Chromium Code Reviews| 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 #include "chrome/utility/importer/nss_decryptor_win.h" | 5 #include "chrome/utility/importer/nss_decryptor_win.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 softokn3_dll_ = LoadLibraryEx(path.value().c_str(), NULL, | 80 softokn3_dll_ = LoadLibraryEx(path.value().c_str(), NULL, |
| 81 LOAD_WITH_ALTERED_SEARCH_PATH); | 81 LOAD_WITH_ALTERED_SEARCH_PATH); |
| 82 if (softokn3_dll_ == NULL) { | 82 if (softokn3_dll_ == NULL) { |
| 83 Free(); | 83 Free(); |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 HMODULE plds4_dll = GetModuleHandle(kPLDS4Library); | 87 HMODULE plds4_dll = GetModuleHandle(kPLDS4Library); |
| 88 HMODULE nspr4_dll = GetModuleHandle(kNSPR4Library); | 88 HMODULE nspr4_dll = GetModuleHandle(kNSPR4Library); |
| 89 | 89 |
| 90 // On Firefox 22 and higher, NSPR is part of nss3.dll rather than separate | |
| 91 // DLLs. | |
|
wtc
2013/09/18 18:29:05
For future reference:
In Firefox 22, the NSPR and
| |
| 92 if (plds4_dll == NULL) { | |
| 93 plds4_dll = nss3_dll_; | |
| 94 nspr4_dll = nss3_dll_; | |
| 95 } | |
| 90 return InitNSS(db_path, plds4_dll, nspr4_dll); | 96 return InitNSS(db_path, plds4_dll, nspr4_dll); |
| 91 } | 97 } |
| 92 | 98 |
| 93 NSSDecryptor::NSSDecryptor() | 99 NSSDecryptor::NSSDecryptor() |
| 94 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL), | 100 : NSS_Init(NULL), NSS_Shutdown(NULL), PK11_GetInternalKeySlot(NULL), |
| 95 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL), | 101 PK11_CheckUserPassword(NULL), PK11_FreeSlot(NULL), |
| 96 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL), | 102 PK11_Authenticate(NULL), PK11SDR_Decrypt(NULL), SECITEM_FreeItem(NULL), |
| 97 PL_ArenaFinish(NULL), PR_Cleanup(NULL), | 103 PL_ArenaFinish(NULL), PR_Cleanup(NULL), |
| 98 nss3_dll_(NULL), softokn3_dll_(NULL), | 104 nss3_dll_(NULL), softokn3_dll_(NULL), |
| 99 is_nss_initialized_(false) { | 105 is_nss_initialized_(false) { |
| 100 } | 106 } |
| 101 | 107 |
| 102 NSSDecryptor::~NSSDecryptor() { | 108 NSSDecryptor::~NSSDecryptor() { |
| 103 Free(); | 109 Free(); |
| 104 } | 110 } |
| 105 | 111 |
| 106 bool NSSDecryptor::InitNSS(const base::FilePath& db_path, | 112 bool NSSDecryptor::InitNSS(const base::FilePath& db_path, |
| 107 base::NativeLibrary plds4_dll, | 113 base::NativeLibrary plds4_dll, |
| 108 base::NativeLibrary nspr4_dll) { | 114 base::NativeLibrary nspr4_dll) { |
| 109 // NSPR DLLs are already loaded now. | |
| 110 if (plds4_dll == NULL || nspr4_dll == NULL) { | |
| 111 Free(); | |
| 112 return false; | |
| 113 } | |
|
Ilya Sherman
2013/09/17 06:14:36
nit: Are you sure that this code is no longer nece
wtc
2013/09/18 00:03:47
Yes. This function (InitNSS) is only called on lin
| |
| 114 | |
| 115 // Gets the function address. | 115 // Gets the function address. |
| 116 NSS_Init = (NSSInitFunc) | 116 NSS_Init = (NSSInitFunc) |
| 117 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Init"); | 117 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Init"); |
| 118 NSS_Shutdown = (NSSShutdownFunc) | 118 NSS_Shutdown = (NSSShutdownFunc) |
| 119 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Shutdown"); | 119 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Shutdown"); |
| 120 PK11_GetInternalKeySlot = (PK11GetInternalKeySlotFunc) | 120 PK11_GetInternalKeySlot = (PK11GetInternalKeySlotFunc) |
| 121 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, | 121 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, |
| 122 "PK11_GetInternalKeySlot"); | 122 "PK11_GetInternalKeySlot"); |
| 123 PK11_FreeSlot = (PK11FreeSlotFunc) | 123 PK11_FreeSlot = (PK11FreeSlotFunc) |
| 124 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_FreeSlot"); | 124 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_FreeSlot"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 PK11_GetInternalKeySlot = NULL; | 168 PK11_GetInternalKeySlot = NULL; |
| 169 PK11_FreeSlot = NULL; | 169 PK11_FreeSlot = NULL; |
| 170 PK11_Authenticate = NULL; | 170 PK11_Authenticate = NULL; |
| 171 PK11SDR_Decrypt = NULL; | 171 PK11SDR_Decrypt = NULL; |
| 172 SECITEM_FreeItem = NULL; | 172 SECITEM_FreeItem = NULL; |
| 173 PL_ArenaFinish = NULL; | 173 PL_ArenaFinish = NULL; |
| 174 PR_Cleanup = NULL; | 174 PR_Cleanup = NULL; |
| 175 nss3_dll_ = NULL; | 175 nss3_dll_ = NULL; |
| 176 softokn3_dll_ = NULL; | 176 softokn3_dll_ = NULL; |
| 177 } | 177 } |
| OLD | NEW |