Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: nss/lib/pk11wrap/pk11load.c

Issue 319593003: Update to NSS 3.16.2 Beta 3. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Remove unused function SEC_NumberOrNameStringToOIDTag Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 /* 4 /*
5 * The following handles the loading, unloading and management of 5 * The following handles the loading, unloading and management of
6 * various PCKS #11 modules 6 * various PCKS #11 modules
7 */ 7 */
8 #define FORCE_PR_LOG 1 8 #define FORCE_PR_LOG 1
9 #include "seccomon.h" 9 #include "seccomon.h"
10 #include "pkcs11.h" 10 #include "pkcs11.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return CKR_OK; 48 return CKR_OK;
49 } 49 }
50 50
51 static SECMODModuleID nextModuleID = 1; 51 static SECMODModuleID nextModuleID = 1;
52 static const CK_C_INITIALIZE_ARGS secmodLockFunctions = { 52 static const CK_C_INITIALIZE_ARGS secmodLockFunctions = {
53 secmodCreateMutext, secmodDestroyMutext, secmodLockMutext, 53 secmodCreateMutext, secmodDestroyMutext, secmodLockMutext,
54 secmodUnlockMutext, CKF_LIBRARY_CANT_CREATE_OS_THREADS| 54 secmodUnlockMutext, CKF_LIBRARY_CANT_CREATE_OS_THREADS|
55 CKF_OS_LOCKING_OK 55 CKF_OS_LOCKING_OK
56 ,NULL 56 ,NULL
57 }; 57 };
58 static const CK_C_INITIALIZE_ARGS secmodNoLockArgs = {
59 NULL, NULL, NULL, NULL,
60 CKF_LIBRARY_CANT_CREATE_OS_THREADS
61 ,NULL
62 };
58 63
59 static PRBool loadSingleThreadedModules = PR_TRUE; 64 static PRBool loadSingleThreadedModules = PR_TRUE;
60 static PRBool enforceAlreadyInitializedError = PR_TRUE; 65 static PRBool enforceAlreadyInitializedError = PR_TRUE;
61 static PRBool finalizeModules = PR_TRUE; 66 static PRBool finalizeModules = PR_TRUE;
62 67
63 /* set global options for NSS PKCS#11 module loader */ 68 /* set global options for NSS PKCS#11 module loader */
64 SECStatus pk11_setGlobalOptions(PRBool noSingleThreadedModules, 69 SECStatus pk11_setGlobalOptions(PRBool noSingleThreadedModules,
65 PRBool allowAlreadyInitializedModules, 70 PRBool allowAlreadyInitializedModules,
66 PRBool dontFinalizeModules) 71 PRBool dontFinalizeModules)
67 { 72 {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 207
203 if (reload) { 208 if (reload) {
204 *reload = NULL; 209 *reload = NULL;
205 } 210 }
206 211
207 if (!mod || !alreadyLoaded) { 212 if (!mod || !alreadyLoaded) {
208 PORT_SetError(SEC_ERROR_INVALID_ARGS); 213 PORT_SetError(SEC_ERROR_INVALID_ARGS);
209 return SECFailure; 214 return SECFailure;
210 } 215 }
211 216
212 if (mod->isThreadSafe == PR_FALSE) { 217 if (mod->libraryParams == NULL) {
213 » pInitArgs = NULL; 218 » if (mod->isThreadSafe) {
214 } else if (mod->libraryParams == NULL) { 219 » pInitArgs = (void *) &secmodLockFunctions;
215 » pInitArgs = (void *) &secmodLockFunctions; 220 » } else {
221 » pInitArgs = NULL;
222 » }
216 } else { 223 } else {
217 » moduleArgs = secmodLockFunctions; 224 » if (mod->isThreadSafe) {
225 » moduleArgs = secmodLockFunctions;
226 » } else {
227 » moduleArgs = secmodNoLockArgs;
228 » }
218 moduleArgs.LibraryParameters = (void *) mod->libraryParams; 229 moduleArgs.LibraryParameters = (void *) mod->libraryParams;
219 pInitArgs = &moduleArgs; 230 pInitArgs = &moduleArgs;
220 } 231 }
221 crv = PK11_GETTAB(mod)->C_Initialize(pInitArgs); 232 crv = PK11_GETTAB(mod)->C_Initialize(pInitArgs);
222 if (CKR_CRYPTOKI_ALREADY_INITIALIZED == crv) { 233 if (CKR_CRYPTOKI_ALREADY_INITIALIZED == crv) {
223 SECMODModule *oldModule = NULL; 234 SECMODModule *oldModule = NULL;
224 235
225 /* Library has already been loaded once, if caller expects it, and it 236 /* Library has already been loaded once, if caller expects it, and it
226 * has additional configuration, try reloading it as well. */ 237 * has additional configuration, try reloading it as well. */
227 if (reload != NULL && mod->libraryParams) { 238 if (reload != NULL && mod->libraryParams) {
(...skipping 16 matching lines...) Expand all
244 } 255 }
245 SECMOD_DestroyModule(oldModule); 256 SECMOD_DestroyModule(oldModule);
246 } 257 }
247 /* reload not possible, fall back to old semantics */ 258 /* reload not possible, fall back to old semantics */
248 if (!enforceAlreadyInitializedError) { 259 if (!enforceAlreadyInitializedError) {
249 *alreadyLoaded = PR_TRUE; 260 *alreadyLoaded = PR_TRUE;
250 return SECSuccess; 261 return SECSuccess;
251 } 262 }
252 } 263 }
253 if (crv != CKR_OK) { 264 if (crv != CKR_OK) {
254 » if (pInitArgs == NULL || 265 » if (!mod->isThreadSafe ||
255 crv == CKR_NETSCAPE_CERTDB_FAILED || 266 crv == CKR_NETSCAPE_CERTDB_FAILED ||
256 crv == CKR_NETSCAPE_KEYDB_FAILED) { 267 crv == CKR_NETSCAPE_KEYDB_FAILED) {
257 PORT_SetError(PK11_MapError(crv)); 268 PORT_SetError(PK11_MapError(crv));
258 return SECFailure; 269 return SECFailure;
259 } 270 }
271 /* If we had attempted to init a single threaded module "with"
272 * parameters and it failed, should we retry "without" parameters?
273 * (currently we don't retry in this scenario) */
274
260 if (!loadSingleThreadedModules) { 275 if (!loadSingleThreadedModules) {
261 PORT_SetError(SEC_ERROR_INCOMPATIBLE_PKCS11); 276 PORT_SetError(SEC_ERROR_INCOMPATIBLE_PKCS11);
262 return SECFailure; 277 return SECFailure;
263 } 278 }
279 /* If we arrive here, the module failed a ThreadSafe init. */
264 mod->isThreadSafe = PR_FALSE; 280 mod->isThreadSafe = PR_FALSE;
265 » crv = PK11_GETTAB(mod)->C_Initialize(NULL); 281 » if (!mod->libraryParams) {
282 » pInitArgs = NULL;
283 » } else {
284 » moduleArgs = secmodNoLockArgs;
285 » moduleArgs.LibraryParameters = (void *) mod->libraryParams;
286 » pInitArgs = &moduleArgs;
287 » }
288 » crv = PK11_GETTAB(mod)->C_Initialize(pInitArgs);
266 if ((CKR_CRYPTOKI_ALREADY_INITIALIZED == crv) && 289 if ((CKR_CRYPTOKI_ALREADY_INITIALIZED == crv) &&
267 (!enforceAlreadyInitializedError)) { 290 (!enforceAlreadyInitializedError)) {
268 *alreadyLoaded = PR_TRUE; 291 *alreadyLoaded = PR_TRUE;
269 return SECSuccess; 292 return SECSuccess;
270 } 293 }
271 if (crv != CKR_OK) { 294 if (crv != CKR_OK) {
272 PORT_SetError(PK11_MapError(crv)); 295 PORT_SetError(PK11_MapError(crv));
273 return SECFailure; 296 return SECFailure;
274 } 297 }
275 } 298 }
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 653
631 void 654 void
632 nss_DumpModuleLog(void) 655 nss_DumpModuleLog(void)
633 { 656 {
634 #ifdef DEBUG_MODULE 657 #ifdef DEBUG_MODULE
635 if (modToDBG) { 658 if (modToDBG) {
636 print_final_statistics(); 659 print_final_statistics();
637 } 660 }
638 #endif 661 #endif
639 } 662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698