| 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_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 6 #define CHROME_BROWSER_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 webkit { | 107 namespace content { |
| 108 namespace forms { | |
| 109 struct PasswordForm; | 108 struct PasswordForm; |
| 110 } | 109 } |
| 111 } | |
| 112 | 110 |
| 113 // A wrapper for Firefox NSS decrypt component. | 111 // A wrapper for Firefox NSS decrypt component. |
| 114 class NSSDecryptor { | 112 class NSSDecryptor { |
| 115 public: | 113 public: |
| 116 NSSDecryptor(); | 114 NSSDecryptor(); |
| 117 ~NSSDecryptor(); | 115 ~NSSDecryptor(); |
| 118 | 116 |
| 119 // Loads NSS3 library and returns true if successful. | 117 // Loads NSS3 library and returns true if successful. |
| 120 // |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| |
| 121 // is the location of the database file that stores the keys. | 119 // is the location of the database file that stores the keys. |
| 122 bool Init(const FilePath& dll_path, const FilePath& db_path); | 120 bool Init(const FilePath& dll_path, const FilePath& db_path); |
| 123 | 121 |
| 124 // Frees the libraries. | 122 // Frees the libraries. |
| 125 void Free(); | 123 void Free(); |
| 126 | 124 |
| 127 // Decrypts Firefox stored passwords. Before using this method, | 125 // Decrypts Firefox stored passwords. Before using this method, |
| 128 // make sure Init() returns true. | 126 // make sure Init() returns true. |
| 129 string16 Decrypt(const std::string& crypt) const; | 127 string16 Decrypt(const std::string& crypt) const; |
| 130 | 128 |
| 131 // Parses the Firefox password file content, decrypts the | 129 // Parses the Firefox password file content, decrypts the |
| 132 // username/password and reads other related information. | 130 // username/password and reads other related information. |
| 133 // The result will be stored in |forms|. | 131 // The result will be stored in |forms|. |
| 134 void ParseSignons(const std::string& content, | 132 void ParseSignons(const std::string& content, |
| 135 std::vector<webkit::forms::PasswordForm>* forms); | 133 std::vector<content::PasswordForm>* forms); |
| 136 | 134 |
| 137 // Reads and parses the Firefox password sqlite db, decrypts the | 135 // Reads and parses the Firefox password sqlite db, decrypts the |
| 138 // username/password and reads other related information. | 136 // username/password and reads other related information. |
| 139 // The result will be stored in |forms|. | 137 // The result will be stored in |forms|. |
| 140 bool ReadAndParseSignons(const FilePath& sqlite_file, | 138 bool ReadAndParseSignons(const FilePath& sqlite_file, |
| 141 std::vector<webkit::forms::PasswordForm>* forms); | 139 std::vector<content::PasswordForm>* forms); |
| 142 | 140 |
| 143 private: | 141 private: |
| 144 // Call NSS initialization funcs. | 142 // Call NSS initialization funcs. |
| 145 bool InitNSS(const FilePath& db_path, | 143 bool InitNSS(const FilePath& db_path, |
| 146 base::NativeLibrary plds4_dll, | 144 base::NativeLibrary plds4_dll, |
| 147 base::NativeLibrary nspr4_dll); | 145 base::NativeLibrary nspr4_dll); |
| 148 | 146 |
| 149 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } | 147 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } |
| 150 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } | 148 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } |
| 151 | 149 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 171 base::NativeLibrary nss3_dll_; | 169 base::NativeLibrary nss3_dll_; |
| 172 base::NativeLibrary softokn3_dll_; | 170 base::NativeLibrary softokn3_dll_; |
| 173 | 171 |
| 174 // True if NSS_Init() has been called | 172 // True if NSS_Init() has been called |
| 175 bool is_nss_initialized_; | 173 bool is_nss_initialized_; |
| 176 | 174 |
| 177 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 175 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
| 178 }; | 176 }; |
| 179 | 177 |
| 180 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ | 178 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_WIN_H_ |
| OLD | NEW |