OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 5 #ifndef CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
6 #define CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 6 #define CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); | 97 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); |
98 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); | 98 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); |
99 typedef SECStatus | 99 typedef SECStatus |
100 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); | 100 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); |
101 typedef SECStatus | 101 typedef SECStatus |
102 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); | 102 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); |
103 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); | 103 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); |
104 typedef void (*PLArenaFinishFunc)(void); | 104 typedef void (*PLArenaFinishFunc)(void); |
105 typedef PRStatus (*PRCleanupFunc)(void); | 105 typedef PRStatus (*PRCleanupFunc)(void); |
106 | 106 |
107 namespace content { | 107 namespace autofill { |
108 struct PasswordForm; | 108 struct PasswordForm; |
109 } | 109 } |
110 | 110 |
111 // A wrapper for Firefox NSS decrypt component. | 111 // A wrapper for Firefox NSS decrypt component. |
112 class NSSDecryptor { | 112 class NSSDecryptor { |
113 public: | 113 public: |
114 NSSDecryptor(); | 114 NSSDecryptor(); |
115 ~NSSDecryptor(); | 115 ~NSSDecryptor(); |
116 | 116 |
117 // Loads NSS3 library and returns true if successful. | 117 // Loads NSS3 library and returns true if successful. |
118 // |dll_path| indicates the location of NSS3 DLL files, and |db_path| | 118 // |dll_path| indicates the location of NSS3 DLL files, and |db_path| |
119 // is the location of the database file that stores the keys. | 119 // is the location of the database file that stores the keys. |
120 bool Init(const base::FilePath& dll_path, const base::FilePath& db_path); | 120 bool Init(const base::FilePath& dll_path, const base::FilePath& db_path); |
121 | 121 |
122 // Frees the libraries. | 122 // Frees the libraries. |
123 void Free(); | 123 void Free(); |
124 | 124 |
125 // Decrypts Firefox stored passwords. Before using this method, | 125 // Decrypts Firefox stored passwords. Before using this method, |
126 // make sure Init() returns true. | 126 // make sure Init() returns true. |
127 string16 Decrypt(const std::string& crypt) const; | 127 string16 Decrypt(const std::string& crypt) const; |
128 | 128 |
129 // Parses the Firefox password file content, decrypts the | 129 // Parses the Firefox password file content, decrypts the |
130 // username/password and reads other related information. | 130 // username/password and reads other related information. |
131 // The result will be stored in |forms|. | 131 // The result will be stored in |forms|. |
132 void ParseSignons(const std::string& content, | 132 void ParseSignons(const std::string& content, |
133 std::vector<content::PasswordForm>* forms); | 133 std::vector<autofill::PasswordForm>* forms); |
134 | 134 |
135 // Reads and parses the Firefox password sqlite db, decrypts the | 135 // Reads and parses the Firefox password sqlite db, decrypts the |
136 // username/password and reads other related information. | 136 // username/password and reads other related information. |
137 // The result will be stored in |forms|. | 137 // The result will be stored in |forms|. |
138 bool ReadAndParseSignons(const base::FilePath& sqlite_file, | 138 bool ReadAndParseSignons(const base::FilePath& sqlite_file, |
139 std::vector<content::PasswordForm>* forms); | 139 std::vector<autofill::PasswordForm>* forms); |
140 | 140 |
141 private: | 141 private: |
142 // Call NSS initialization funcs. | 142 // Call NSS initialization funcs. |
143 bool InitNSS(const base::FilePath& db_path, | 143 bool InitNSS(const base::FilePath& db_path, |
144 base::NativeLibrary plds4_dll, | 144 base::NativeLibrary plds4_dll, |
145 base::NativeLibrary nspr4_dll); | 145 base::NativeLibrary nspr4_dll); |
146 | 146 |
147 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } | 147 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } |
148 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } | 148 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } |
149 | 149 |
(...skipping 19 matching lines...) Expand all Loading... |
169 base::NativeLibrary nss3_dll_; | 169 base::NativeLibrary nss3_dll_; |
170 base::NativeLibrary softokn3_dll_; | 170 base::NativeLibrary softokn3_dll_; |
171 | 171 |
172 // True if NSS_Init() has been called | 172 // True if NSS_Init() has been called |
173 bool is_nss_initialized_; | 173 bool is_nss_initialized_; |
174 | 174 |
175 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 175 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
176 }; | 176 }; |
177 | 177 |
178 #endif // CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 178 #endif // CHROME_UTILITY_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
OLD | NEW |