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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 is_nss_initialized_(false) { | 99 is_nss_initialized_(false) { |
100 } | 100 } |
101 | 101 |
102 NSSDecryptor::~NSSDecryptor() { | 102 NSSDecryptor::~NSSDecryptor() { |
103 Free(); | 103 Free(); |
104 } | 104 } |
105 | 105 |
106 bool NSSDecryptor::InitNSS(const base::FilePath& db_path, | 106 bool NSSDecryptor::InitNSS(const base::FilePath& db_path, |
107 base::NativeLibrary plds4_dll, | 107 base::NativeLibrary plds4_dll, |
108 base::NativeLibrary nspr4_dll) { | 108 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 } | |
114 | |
115 // Gets the function address. | 109 // Gets the function address. |
116 NSS_Init = (NSSInitFunc) | 110 NSS_Init = (NSSInitFunc) |
117 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Init"); | 111 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Init"); |
118 NSS_Shutdown = (NSSShutdownFunc) | 112 NSS_Shutdown = (NSSShutdownFunc) |
119 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Shutdown"); | 113 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "NSS_Shutdown"); |
120 PK11_GetInternalKeySlot = (PK11GetInternalKeySlotFunc) | 114 PK11_GetInternalKeySlot = (PK11GetInternalKeySlotFunc) |
121 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, | 115 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, |
122 "PK11_GetInternalKeySlot"); | 116 "PK11_GetInternalKeySlot"); |
123 PK11_FreeSlot = (PK11FreeSlotFunc) | 117 PK11_FreeSlot = (PK11FreeSlotFunc) |
124 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_FreeSlot"); | 118 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_FreeSlot"); |
125 PK11_Authenticate = (PK11AuthenticateFunc) | 119 PK11_Authenticate = (PK11AuthenticateFunc) |
126 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_Authenticate"); | 120 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11_Authenticate"); |
127 PK11SDR_Decrypt = (PK11SDRDecryptFunc) | 121 PK11SDR_Decrypt = (PK11SDRDecryptFunc) |
128 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11SDR_Decrypt"); | 122 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PK11SDR_Decrypt"); |
129 SECITEM_FreeItem = (SECITEMFreeItemFunc) | 123 SECITEM_FreeItem = (SECITEMFreeItemFunc) |
130 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "SECITEM_FreeItem"); | 124 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "SECITEM_FreeItem"); |
131 PL_ArenaFinish = (PLArenaFinishFunc) | 125 // Firefox 22 and higher PL_ArenaFinish and PR_Cleanup moved from plds4.dll |
Peter Kasting
2013/09/11 05:18:44
Nit: Please use complete grammatical sentences:
O
| |
132 base::GetFunctionPointerFromNativeLibrary(plds4_dll, "PL_ArenaFinish"); | 126 // to nss3.dll |
133 PR_Cleanup = (PRCleanupFunc) | 127 if (plds4_dll == NULL) { |
134 base::GetFunctionPointerFromNativeLibrary(nspr4_dll, "PR_Cleanup"); | 128 PL_ArenaFinish = (PLArenaFinishFunc)( |
129 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PL_ArenaFinish")); | |
130 PR_Cleanup = (PRCleanupFunc)( | |
131 base::GetFunctionPointerFromNativeLibrary(nss3_dll_, "PR_Cleanup")); | |
132 } else { | |
133 PL_ArenaFinish = (PLArenaFinishFunc)( | |
134 base::GetFunctionPointerFromNativeLibrary(nspr4_dll, "PL_ArenaFinish")); | |
135 PR_Cleanup = (PRCleanupFunc)( | |
136 base::GetFunctionPointerFromNativeLibrary(nspr4_dll, "PR_Cleanup")); | |
137 } | |
135 | 138 |
136 if (NSS_Init == NULL || NSS_Shutdown == NULL || | 139 if (NSS_Init == NULL || NSS_Shutdown == NULL || |
137 PK11_GetInternalKeySlot == NULL || PK11_FreeSlot == NULL || | 140 PK11_GetInternalKeySlot == NULL || PK11_FreeSlot == NULL || |
138 PK11_Authenticate == NULL || PK11SDR_Decrypt == NULL || | 141 PK11_Authenticate == NULL || PK11SDR_Decrypt == NULL || |
139 SECITEM_FreeItem == NULL || PL_ArenaFinish == NULL || | 142 SECITEM_FreeItem == NULL || PL_ArenaFinish == NULL || |
140 PR_Cleanup == NULL) { | 143 PR_Cleanup == NULL) { |
141 Free(); | 144 Free(); |
142 return false; | 145 return false; |
143 } | 146 } |
144 | 147 |
(...skipping 23 matching lines...) Expand all Loading... | |
168 PK11_GetInternalKeySlot = NULL; | 171 PK11_GetInternalKeySlot = NULL; |
169 PK11_FreeSlot = NULL; | 172 PK11_FreeSlot = NULL; |
170 PK11_Authenticate = NULL; | 173 PK11_Authenticate = NULL; |
171 PK11SDR_Decrypt = NULL; | 174 PK11SDR_Decrypt = NULL; |
172 SECITEM_FreeItem = NULL; | 175 SECITEM_FreeItem = NULL; |
173 PL_ArenaFinish = NULL; | 176 PL_ArenaFinish = NULL; |
174 PR_Cleanup = NULL; | 177 PR_Cleanup = NULL; |
175 nss3_dll_ = NULL; | 178 nss3_dll_ = NULL; |
176 softokn3_dll_ = NULL; | 179 softokn3_dll_ = NULL; |
177 } | 180 } |
OLD | NEW |