| OLD | NEW |
| 1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
| 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 3 * | 3 * |
| 4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
| 5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
| 6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
| 7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
| 8 * | 8 * |
| 9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
| 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "prenv.h" | 45 #include "prenv.h" |
| 46 | 46 |
| 47 /* | 47 /* |
| 48 * this file contains routines for parsing PKCS #11 module spec | 48 * this file contains routines for parsing PKCS #11 module spec |
| 49 * strings. | 49 * strings. |
| 50 */ | 50 */ |
| 51 | 51 |
| 52 #define SFTK_HANDLE_STRING_ARG(param,target,value,command) \ | 52 #define SFTK_HANDLE_STRING_ARG(param,target,value,command) \ |
| 53 if (PORT_Strncasecmp(param,value,sizeof(value)-1) == 0) { \ | 53 if (PORT_Strncasecmp(param,value,sizeof(value)-1) == 0) { \ |
| 54 param += sizeof(value)-1; \ | 54 param += sizeof(value)-1; \ |
| 55 if (target) \ |
| 56 PORT_Free(target); \ |
| 55 target = sftk_argFetchValue(param,&next); \ | 57 target = sftk_argFetchValue(param,&next); \ |
| 56 param += next; \ | 58 param += next; \ |
| 57 command ;\ | 59 command ;\ |
| 58 } else | 60 } else |
| 59 | 61 |
| 60 #define SFTK_HANDLE_FINAL_ARG(param) \ | 62 #define SFTK_HANDLE_FINAL_ARG(param) \ |
| 61 { param = sftk_argSkipParameter(param); } param = sftk_argStrip(param); | 63 { param = sftk_argSkipParameter(param); } param = sftk_argStrip(param); |
| 62 | 64 |
| 63 static PRBool sftk_argGetPair(char c) { | 65 static PRBool sftk_argGetPair(char c) { |
| 64 switch (c) { | 66 switch (c) { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 parsed->forceOpen = sftk_argHasFlag("flags","forceOpen",tmp); | 333 parsed->forceOpen = sftk_argHasFlag("flags","forceOpen",tmp); |
| 332 parsed->pwRequired = sftk_argHasFlag("flags","passwordRequired",tmp); | 334 parsed->pwRequired = sftk_argHasFlag("flags","passwordRequired",tmp); |
| 333 parsed->optimizeSpace = sftk_argHasFlag("flags","optimizeSpace",tmp); | 335 parsed->optimizeSpace = sftk_argHasFlag("flags","optimizeSpace",tmp); |
| 334 return; | 336 return; |
| 335 } | 337 } |
| 336 | 338 |
| 337 static CK_RV | 339 static CK_RV |
| 338 sftk_parseTokenParameters(char *param, sftk_token_parameters *parsed) | 340 sftk_parseTokenParameters(char *param, sftk_token_parameters *parsed) |
| 339 { | 341 { |
| 340 int next; | 342 int next; |
| 341 char *tmp; | 343 char *tmp = NULL; |
| 342 char *index; | 344 char *index; |
| 343 index = sftk_argStrip(param); | 345 index = sftk_argStrip(param); |
| 344 | 346 |
| 345 while (*index) { | 347 while (*index) { |
| 346 SFTK_HANDLE_STRING_ARG(index,parsed->configdir,"configDir=",;) | 348 SFTK_HANDLE_STRING_ARG(index,parsed->configdir,"configDir=",;) |
| 347 SFTK_HANDLE_STRING_ARG(index,parsed->updatedir,"updateDir=",;) | 349 SFTK_HANDLE_STRING_ARG(index,parsed->updatedir,"updateDir=",;) |
| 348 SFTK_HANDLE_STRING_ARG(index,parsed->updCertPrefix,"updateCertPrefix=",;
) | 350 SFTK_HANDLE_STRING_ARG(index,parsed->updCertPrefix,"updateCertPrefix=",;
) |
| 349 SFTK_HANDLE_STRING_ARG(index,parsed->updKeyPrefix,"updateKeyPrefix=",;) | 351 SFTK_HANDLE_STRING_ARG(index,parsed->updKeyPrefix,"updateKeyPrefix=",;) |
| 350 SFTK_HANDLE_STRING_ARG(index,parsed->updateID,"updateID=",;) | 352 SFTK_HANDLE_STRING_ARG(index,parsed->updateID,"updateID=",;) |
| 351 SFTK_HANDLE_STRING_ARG(index,parsed->certPrefix,"certPrefix=",;) | 353 SFTK_HANDLE_STRING_ARG(index,parsed->certPrefix,"certPrefix=",;) |
| 352 SFTK_HANDLE_STRING_ARG(index,parsed->keyPrefix,"keyPrefix=",;) | 354 SFTK_HANDLE_STRING_ARG(index,parsed->keyPrefix,"keyPrefix=",;) |
| 353 SFTK_HANDLE_STRING_ARG(index,parsed->tokdes,"tokenDescription=",;) | 355 SFTK_HANDLE_STRING_ARG(index,parsed->tokdes,"tokenDescription=",;) |
| 354 SFTK_HANDLE_STRING_ARG(index,parsed->updtokdes, | 356 SFTK_HANDLE_STRING_ARG(index,parsed->updtokdes, |
| 355 "updateTokenDescription=",;) | 357 "updateTokenDescription=",;) |
| 356 SFTK_HANDLE_STRING_ARG(index,parsed->slotdes,"slotDescription=",;) | 358 SFTK_HANDLE_STRING_ARG(index,parsed->slotdes,"slotDescription=",;) |
| 357 SFTK_HANDLE_STRING_ARG(index,tmp,"minPWLen=", | 359 SFTK_HANDLE_STRING_ARG(index,tmp,"minPWLen=", |
| 358 » » » if(tmp) { parsed->minPW=atoi(tmp); PORT_Free(tmp); }) | 360 » if(tmp) { parsed->minPW=atoi(tmp); PORT_Free(tmp); tmp = NULL; }) |
| 359 SFTK_HANDLE_STRING_ARG(index,tmp,"flags=", | 361 SFTK_HANDLE_STRING_ARG(index,tmp,"flags=", |
| 360 » if(tmp) { sftk_parseTokenFlags(param,parsed); PORT_Free(tmp); }) | 362 » if(tmp) { sftk_parseTokenFlags(param,parsed); PORT_Free(tmp); tmp = N
ULL; }) |
| 361 SFTK_HANDLE_FINAL_ARG(index) | 363 SFTK_HANDLE_FINAL_ARG(index) |
| 362 } | 364 } |
| 363 return CKR_OK; | 365 return CKR_OK; |
| 364 } | 366 } |
| 365 | 367 |
| 366 static void | 368 static void |
| 367 sftk_parseTokens(char *tokenParams, sftk_parameters *parsed) | 369 sftk_parseTokens(char *tokenParams, sftk_parameters *parsed) |
| 368 { | 370 { |
| 369 char *tokenIndex; | 371 char *tokenIndex; |
| 370 sftk_token_parameters *tokens = NULL; | 372 sftk_token_parameters *tokens = NULL; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 408 } |
| 407 parsed->token_count = i; | 409 parsed->token_count = i; |
| 408 parsed->tokens = tokens; | 410 parsed->tokens = tokens; |
| 409 return; | 411 return; |
| 410 } | 412 } |
| 411 | 413 |
| 412 CK_RV | 414 CK_RV |
| 413 sftk_parseParameters(char *param, sftk_parameters *parsed, PRBool isFIPS) | 415 sftk_parseParameters(char *param, sftk_parameters *parsed, PRBool isFIPS) |
| 414 { | 416 { |
| 415 int next; | 417 int next; |
| 416 char *tmp; | 418 char *tmp = NULL; |
| 417 char *index; | 419 char *index; |
| 418 char *certPrefix = NULL, *keyPrefix = NULL; | 420 char *certPrefix = NULL, *keyPrefix = NULL; |
| 419 char *tokdes = NULL, *ptokdes = NULL, *pupdtokdes = NULL; | 421 char *tokdes = NULL, *ptokdes = NULL, *pupdtokdes = NULL; |
| 420 char *slotdes = NULL, *pslotdes = NULL; | 422 char *slotdes = NULL, *pslotdes = NULL; |
| 421 char *fslotdes = NULL, *ftokdes = NULL; | 423 char *fslotdes = NULL, *ftokdes = NULL; |
| 422 char *minPW = NULL; | 424 char *minPW = NULL; |
| 423 index = sftk_argStrip(param); | 425 index = sftk_argStrip(param); |
| 424 | 426 |
| 425 PORT_Memset(parsed, 0, sizeof(sftk_parameters)); | 427 PORT_Memset(parsed, 0, sizeof(sftk_parameters)); |
| 426 | 428 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 437 SFTK_HANDLE_STRING_ARG(index,tokdes,"cryptoTokenDescription=",;) | 439 SFTK_HANDLE_STRING_ARG(index,tokdes,"cryptoTokenDescription=",;) |
| 438 SFTK_HANDLE_STRING_ARG(index,ptokdes,"dbTokenDescription=",;) | 440 SFTK_HANDLE_STRING_ARG(index,ptokdes,"dbTokenDescription=",;) |
| 439 SFTK_HANDLE_STRING_ARG(index,slotdes,"cryptoSlotDescription=",;) | 441 SFTK_HANDLE_STRING_ARG(index,slotdes,"cryptoSlotDescription=",;) |
| 440 SFTK_HANDLE_STRING_ARG(index,pslotdes,"dbSlotDescription=",;) | 442 SFTK_HANDLE_STRING_ARG(index,pslotdes,"dbSlotDescription=",;) |
| 441 SFTK_HANDLE_STRING_ARG(index,fslotdes,"FIPSSlotDescription=",;) | 443 SFTK_HANDLE_STRING_ARG(index,fslotdes,"FIPSSlotDescription=",;) |
| 442 SFTK_HANDLE_STRING_ARG(index,ftokdes,"FIPSTokenDescription=",;) | 444 SFTK_HANDLE_STRING_ARG(index,ftokdes,"FIPSTokenDescription=",;) |
| 443 SFTK_HANDLE_STRING_ARG(index,pupdtokdes, "updateTokenDescription=",;) | 445 SFTK_HANDLE_STRING_ARG(index,pupdtokdes, "updateTokenDescription=",;) |
| 444 SFTK_HANDLE_STRING_ARG(index,minPW,"minPWLen=",;) | 446 SFTK_HANDLE_STRING_ARG(index,minPW,"minPWLen=",;) |
| 445 | 447 |
| 446 SFTK_HANDLE_STRING_ARG(index,tmp,"flags=", | 448 SFTK_HANDLE_STRING_ARG(index,tmp,"flags=", |
| 447 » » if(tmp) { sftk_parseFlags(param,parsed); PORT_Free(tmp); }) | 449 » » if(tmp) { sftk_parseFlags(param,parsed); PORT_Free(tmp); tmp = N
ULL; }) |
| 448 SFTK_HANDLE_STRING_ARG(index,tmp,"tokens=", | 450 SFTK_HANDLE_STRING_ARG(index,tmp,"tokens=", |
| 449 » » if(tmp) { sftk_parseTokens(tmp,parsed); PORT_Free(tmp); }) | 451 » » if(tmp) { sftk_parseTokens(tmp,parsed); PORT_Free(tmp); tmp = NU
LL; }) |
| 450 SFTK_HANDLE_FINAL_ARG(index) | 452 SFTK_HANDLE_FINAL_ARG(index) |
| 451 } | 453 } |
| 452 if (parsed->tokens == NULL) { | 454 if (parsed->tokens == NULL) { |
| 453 int count = isFIPS ? 1 : 2; | 455 int count = isFIPS ? 1 : 2; |
| 454 int index = count-1; | 456 int index = count-1; |
| 455 sftk_token_parameters *tokens = NULL; | 457 sftk_token_parameters *tokens = NULL; |
| 456 | 458 |
| 457 tokens = (sftk_token_parameters *) | 459 tokens = (sftk_token_parameters *) |
| 458 PORT_ZAlloc(count*sizeof(sftk_token_parameters)); | 460 PORT_ZAlloc(count*sizeof(sftk_token_parameters)); |
| 459 if (tokens == NULL) { | 461 if (tokens == NULL) { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 } | 641 } |
| 640 | 642 |
| 641 if (lconfigdir) { | 643 if (lconfigdir) { |
| 642 value = PR_smprintf("%s" PATH_SEPARATOR "%s",lconfigdir,secmodName); | 644 value = PR_smprintf("%s" PATH_SEPARATOR "%s",lconfigdir,secmodName); |
| 643 } else { | 645 } else { |
| 644 value = PR_smprintf("%s",secmodName); | 646 value = PR_smprintf("%s",secmodName); |
| 645 } | 647 } |
| 646 if (configdir) PORT_Free(configdir); | 648 if (configdir) PORT_Free(configdir); |
| 647 return value; | 649 return value; |
| 648 } | 650 } |
| OLD | NEW |