| 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_MAC_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_MAC_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_MAC_H_ | 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); | 98 typedef void (*PK11FreeSlotFunc)(PK11SlotInfo *slot); |
| 99 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); | 99 typedef SECStatus (*PK11CheckUserPasswordFunc)(PK11SlotInfo *slot, char *pw); |
| 100 typedef SECStatus | 100 typedef SECStatus |
| 101 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); | 101 (*PK11AuthenticateFunc)(PK11SlotInfo *slot, PRBool loadCerts, void *wincx); |
| 102 typedef SECStatus | 102 typedef SECStatus |
| 103 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); | 103 (*PK11SDRDecryptFunc)(SECItem *data, SECItem *result, void *cx); |
| 104 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); | 104 typedef void (*SECITEMFreeItemFunc)(SECItem *item, PRBool free_it); |
| 105 typedef void (*PLArenaFinishFunc)(void); | 105 typedef void (*PLArenaFinishFunc)(void); |
| 106 typedef PRStatus (*PRCleanupFunc)(void); | 106 typedef PRStatus (*PRCleanupFunc)(void); |
| 107 | 107 |
| 108 namespace webkit { | 108 namespace content { |
| 109 namespace forms { | |
| 110 struct PasswordForm; | 109 struct PasswordForm; |
| 111 } | 110 } |
| 112 } | |
| 113 | 111 |
| 114 // A wrapper for Firefox NSS decrypt component. | 112 // A wrapper for Firefox NSS decrypt component. |
| 115 class NSSDecryptor { | 113 class NSSDecryptor { |
| 116 public: | 114 public: |
| 117 NSSDecryptor() | 115 NSSDecryptor() |
| 118 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL), | 116 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL), |
| 119 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL), | 117 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL), |
| 120 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL), | 118 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL), |
| 121 is_nss_initialized_(false) {} | 119 is_nss_initialized_(false) {} |
| 122 ~NSSDecryptor(); | 120 ~NSSDecryptor(); |
| 123 | 121 |
| 124 // Initializes NSS if it hasn't already been initialized. | 122 // Initializes NSS if it hasn't already been initialized. |
| 125 bool Init(const FilePath& dll_path, const FilePath& db_path); | 123 bool Init(const FilePath& dll_path, const FilePath& db_path); |
| 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 private: | 140 private: |
| 143 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } | 141 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } |
| 144 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } | 142 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } |
| 145 | 143 |
| 146 // Methods in Firefox security components. | 144 // Methods in Firefox security components. |
| 147 NSSInitFunc NSS_Init; | 145 NSSInitFunc NSS_Init; |
| 148 NSSShutdownFunc NSS_Shutdown; | 146 NSSShutdownFunc NSS_Shutdown; |
| 149 PK11GetInternalKeySlotFunc PK11_GetInternalKeySlot; | 147 PK11GetInternalKeySlotFunc PK11_GetInternalKeySlot; |
| 150 PK11CheckUserPasswordFunc PK11_CheckUserPassword; | 148 PK11CheckUserPasswordFunc PK11_CheckUserPassword; |
| 151 PK11FreeSlotFunc PK11_FreeSlot; | 149 PK11FreeSlotFunc PK11_FreeSlot; |
| 152 PK11AuthenticateFunc PK11_Authenticate; | 150 PK11AuthenticateFunc PK11_Authenticate; |
| 153 PK11SDRDecryptFunc PK11SDR_Decrypt; | 151 PK11SDRDecryptFunc PK11SDR_Decrypt; |
| 154 SECITEMFreeItemFunc SECITEM_FreeItem; | 152 SECITEMFreeItemFunc SECITEM_FreeItem; |
| 155 | 153 |
| 156 // True if NSS_Init() has been called | 154 // True if NSS_Init() has been called |
| 157 bool is_nss_initialized_; | 155 bool is_nss_initialized_; |
| 158 | 156 |
| 159 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 157 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
| 160 }; | 158 }; |
| 161 | 159 |
| 162 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_MAC_H_ | 160 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_MAC_H_ |
| OLD | NEW |