| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 | 13 |
| 14 namespace base { |
| 14 class FilePath; | 15 class FilePath; |
| 16 } |
| 15 | 17 |
| 16 // The following declarations of functions and types are from Firefox | 18 // The following declarations of functions and types are from Firefox |
| 17 // NSS library. | 19 // NSS library. |
| 18 // source code: | 20 // source code: |
| 19 // security/nss/lib/util/seccomon.h | 21 // security/nss/lib/util/seccomon.h |
| 20 // security/nss/lib/nss/nss.h | 22 // security/nss/lib/nss/nss.h |
| 21 // The license block is: | 23 // The license block is: |
| 22 | 24 |
| 23 /* ***** BEGIN LICENSE BLOCK ***** | 25 /* ***** BEGIN LICENSE BLOCK ***** |
| 24 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 26 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 class NSSDecryptor { | 115 class NSSDecryptor { |
| 114 public: | 116 public: |
| 115 NSSDecryptor() | 117 NSSDecryptor() |
| 116 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL), | 118 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL), |
| 117 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL), | 119 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL), |
| 118 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL), | 120 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL), |
| 119 is_nss_initialized_(false) {} | 121 is_nss_initialized_(false) {} |
| 120 ~NSSDecryptor(); | 122 ~NSSDecryptor(); |
| 121 | 123 |
| 122 // Initializes NSS if it hasn't already been initialized. | 124 // Initializes NSS if it hasn't already been initialized. |
| 123 bool Init(const FilePath& dll_path, const FilePath& db_path); | 125 bool Init(const base::FilePath& dll_path, const base::FilePath& db_path); |
| 124 | 126 |
| 125 // Decrypts Firefox stored passwords. Before using this method, | 127 // Decrypts Firefox stored passwords. Before using this method, |
| 126 // make sure Init() returns true. | 128 // make sure Init() returns true. |
| 127 string16 Decrypt(const std::string& crypt) const; | 129 string16 Decrypt(const std::string& crypt) const; |
| 128 | 130 |
| 129 // Parses the Firefox password file content, decrypts the | 131 // Parses the Firefox password file content, decrypts the |
| 130 // username/password and reads other related information. | 132 // username/password and reads other related information. |
| 131 // The result will be stored in |forms|. | 133 // The result will be stored in |forms|. |
| 132 void ParseSignons(const std::string& content, | 134 void ParseSignons(const std::string& content, |
| 133 std::vector<content::PasswordForm>* forms); | 135 std::vector<content::PasswordForm>* forms); |
| 134 | 136 |
| 135 // Reads and parses the Firefox password sqlite db, decrypts the | 137 // Reads and parses the Firefox password sqlite db, decrypts the |
| 136 // username/password and reads other related information. | 138 // username/password and reads other related information. |
| 137 // The result will be stored in |forms|. | 139 // The result will be stored in |forms|. |
| 138 bool ReadAndParseSignons(const FilePath& sqlite_file, | 140 bool ReadAndParseSignons(const base::FilePath& sqlite_file, |
| 139 std::vector<content::PasswordForm>* forms); | 141 std::vector<content::PasswordForm>* forms); |
| 140 private: | 142 private: |
| 141 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } | 143 PK11SlotInfo* GetKeySlotForDB() const { return PK11_GetInternalKeySlot(); } |
| 142 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } | 144 void FreeSlot(PK11SlotInfo* slot) const { PK11_FreeSlot(slot); } |
| 143 | 145 |
| 144 // Methods in Firefox security components. | 146 // Methods in Firefox security components. |
| 145 NSSInitFunc NSS_Init; | 147 NSSInitFunc NSS_Init; |
| 146 NSSShutdownFunc NSS_Shutdown; | 148 NSSShutdownFunc NSS_Shutdown; |
| 147 PK11GetInternalKeySlotFunc PK11_GetInternalKeySlot; | 149 PK11GetInternalKeySlotFunc PK11_GetInternalKeySlot; |
| 148 PK11CheckUserPasswordFunc PK11_CheckUserPassword; | 150 PK11CheckUserPasswordFunc PK11_CheckUserPassword; |
| 149 PK11FreeSlotFunc PK11_FreeSlot; | 151 PK11FreeSlotFunc PK11_FreeSlot; |
| 150 PK11AuthenticateFunc PK11_Authenticate; | 152 PK11AuthenticateFunc PK11_Authenticate; |
| 151 PK11SDRDecryptFunc PK11SDR_Decrypt; | 153 PK11SDRDecryptFunc PK11SDR_Decrypt; |
| 152 SECITEMFreeItemFunc SECITEM_FreeItem; | 154 SECITEMFreeItemFunc SECITEM_FreeItem; |
| 153 | 155 |
| 154 // True if NSS_Init() has been called | 156 // True if NSS_Init() has been called |
| 155 bool is_nss_initialized_; | 157 bool is_nss_initialized_; |
| 156 | 158 |
| 157 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 159 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
| 158 }; | 160 }; |
| 159 | 161 |
| 160 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_MAC_H_ | 162 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_MAC_H_ |
| OLD | NEW |