OLD | NEW |
1 // Copyright (c) 2009 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 #include "chrome/browser/importer/nss_decryptor_system_nss.h" | 5 #include "chrome/browser/importer/nss_decryptor_system_nss.h" |
6 | 6 |
7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
8 #include <pk11sdr.h> | 8 #include <pk11sdr.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/nss_util.h" | |
13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
14 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 #include "crypto/nss_util.h" |
15 | 15 |
16 NSSDecryptor::NSSDecryptor() : is_nss_initialized_(false), db_slot_(NULL) {} | 16 NSSDecryptor::NSSDecryptor() : is_nss_initialized_(false), db_slot_(NULL) {} |
17 NSSDecryptor::~NSSDecryptor() { | 17 NSSDecryptor::~NSSDecryptor() { |
18 if (db_slot_) { | 18 if (db_slot_) { |
19 // Deliberately leave the user db open, just in case we need to open more | 19 // Deliberately leave the user db open, just in case we need to open more |
20 // than one, because there's an NSS bug with reopening user dbs. | 20 // than one, because there's an NSS bug with reopening user dbs. |
21 // https://bugzilla.mozilla.org/show_bug.cgi?id=506140 | 21 // https://bugzilla.mozilla.org/show_bug.cgi?id=506140 |
22 // SECMOD_CloseUserDB(db_slot_); | 22 // SECMOD_CloseUserDB(db_slot_); |
23 PK11_FreeSlot(db_slot_); | 23 PK11_FreeSlot(db_slot_); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { | 27 bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { |
28 base::EnsureNSSInit(); | 28 crypto::EnsureNSSInit(); |
29 is_nss_initialized_ = true; | 29 is_nss_initialized_ = true; |
30 const std::string modspec = | 30 const std::string modspec = |
31 StringPrintf("configDir='%s' tokenDescription='Firefox NSS database' " | 31 StringPrintf("configDir='%s' tokenDescription='Firefox NSS database' " |
32 "flags=readOnly", db_path.value().c_str()); | 32 "flags=readOnly", db_path.value().c_str()); |
33 db_slot_ = SECMOD_OpenUserDB(modspec.c_str()); | 33 db_slot_ = SECMOD_OpenUserDB(modspec.c_str()); |
34 return db_slot_ != NULL; | 34 return db_slot_ != NULL; |
35 } | 35 } |
36 | 36 |
37 // This method is based on some NSS code in | 37 // This method is based on some NSS code in |
38 // security/nss/lib/pk11wrap/pk11sdr.c, CVS revision 1.22 | 38 // security/nss/lib/pk11wrap/pk11sdr.c, CVS revision 1.22 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 260 } |
261 | 261 |
262 loser: | 262 loser: |
263 if (arena) PORT_FreeArena(arena, PR_TRUE); | 263 if (arena) PORT_FreeArena(arena, PR_TRUE); |
264 if (key) PK11_FreeSymKey(key); | 264 if (key) PK11_FreeSymKey(key); |
265 if (params) SECITEM_ZfreeItem(params, PR_TRUE); | 265 if (params) SECITEM_ZfreeItem(params, PR_TRUE); |
266 if (possibleResult.data) SECITEM_ZfreeItem(&possibleResult, PR_FALSE); | 266 if (possibleResult.data) SECITEM_ZfreeItem(&possibleResult, PR_FALSE); |
267 | 267 |
268 return rv; | 268 return rv; |
269 } | 269 } |
OLD | NEW |