| 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_SYSTEM_NSS_H_ | 5 #ifndef CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ |
| 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ | 6 #define CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ |
| 7 | 7 |
| 8 #include <secmodt.h> | 8 #include <secmodt.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 | 14 |
| 15 namespace base { |
| 15 class FilePath; | 16 class FilePath; |
| 17 } |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 struct PasswordForm; | 20 struct PasswordForm; |
| 19 } | 21 } |
| 20 | 22 |
| 21 // A wrapper for Firefox NSS decrypt component. | 23 // A wrapper for Firefox NSS decrypt component. |
| 22 class NSSDecryptor { | 24 class NSSDecryptor { |
| 23 public: | 25 public: |
| 24 NSSDecryptor(); | 26 NSSDecryptor(); |
| 25 ~NSSDecryptor(); | 27 ~NSSDecryptor(); |
| 26 | 28 |
| 27 // Initializes NSS if it hasn't already been initialized. | 29 // Initializes NSS if it hasn't already been initialized. |
| 28 bool Init(const FilePath& dll_path, const FilePath& db_path); | 30 bool Init(const base::FilePath& dll_path, const base::FilePath& db_path); |
| 29 | 31 |
| 30 // Decrypts Firefox stored passwords. Before using this method, | 32 // Decrypts Firefox stored passwords. Before using this method, |
| 31 // make sure Init() returns true. | 33 // make sure Init() returns true. |
| 32 string16 Decrypt(const std::string& crypt) const; | 34 string16 Decrypt(const std::string& crypt) const; |
| 33 | 35 |
| 34 // Parses the Firefox password file content, decrypts the | 36 // Parses the Firefox password file content, decrypts the |
| 35 // username/password and reads other related information. | 37 // username/password and reads other related information. |
| 36 // The result will be stored in |forms|. | 38 // The result will be stored in |forms|. |
| 37 void ParseSignons(const std::string& content, | 39 void ParseSignons(const std::string& content, |
| 38 std::vector<content::PasswordForm>* forms); | 40 std::vector<content::PasswordForm>* forms); |
| 39 | 41 |
| 40 // Reads and parses the Firefox password sqlite db, decrypts the | 42 // Reads and parses the Firefox password sqlite db, decrypts the |
| 41 // username/password and reads other related information. | 43 // username/password and reads other related information. |
| 42 // The result will be stored in |forms|. | 44 // The result will be stored in |forms|. |
| 43 bool ReadAndParseSignons(const FilePath& sqlite_file, | 45 bool ReadAndParseSignons(const base::FilePath& sqlite_file, |
| 44 std::vector<content::PasswordForm>* forms); | 46 std::vector<content::PasswordForm>* forms); |
| 45 private: | 47 private: |
| 46 // Does not actually free the slot, since we'll free it when NSSDecryptor is | 48 // Does not actually free the slot, since we'll free it when NSSDecryptor is |
| 47 // destroyed. | 49 // destroyed. |
| 48 void FreeSlot(PK11SlotInfo* slot) const {} | 50 void FreeSlot(PK11SlotInfo* slot) const {} |
| 49 PK11SlotInfo* GetKeySlotForDB() const { return db_slot_; } | 51 PK11SlotInfo* GetKeySlotForDB() const { return db_slot_; } |
| 50 | 52 |
| 51 SECStatus PK11SDR_DecryptWithSlot( | 53 SECStatus PK11SDR_DecryptWithSlot( |
| 52 PK11SlotInfo* slot, SECItem* data, SECItem* result, void* cx) const; | 54 PK11SlotInfo* slot, SECItem* data, SECItem* result, void* cx) const; |
| 53 | 55 |
| 54 bool is_nss_initialized_; | 56 bool is_nss_initialized_; |
| 55 PK11SlotInfo* db_slot_; | 57 PK11SlotInfo* db_slot_; |
| 56 | 58 |
| 57 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); | 59 DISALLOW_COPY_AND_ASSIGN(NSSDecryptor); |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ | 62 #endif // CHROME_BROWSER_IMPORTER_NSS_DECRYPTOR_SYSTEM_NSS_H_ |
| OLD | NEW |