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