OLD | NEW |
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 /* | 5 /* |
6 * Merge the source token into the target token. | 6 * Merge the source token into the target token. |
7 */ | 7 */ |
8 | 8 |
9 #include "secmod.h" | 9 #include "secmod.h" |
10 #include "secmodi.h" | 10 #include "secmodi.h" |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 */ | 422 */ |
423 static SECStatus | 423 static SECStatus |
424 pk11_mergeSecretKey(PK11SlotInfo *targetSlot, PK11SlotInfo *sourceSlot, | 424 pk11_mergeSecretKey(PK11SlotInfo *targetSlot, PK11SlotInfo *sourceSlot, |
425 CK_OBJECT_HANDLE id, void *targetPwArg, void *sourcePwArg) | 425 CK_OBJECT_HANDLE id, void *targetPwArg, void *sourcePwArg) |
426 { | 426 { |
427 PK11SymKey *sourceKey = NULL; | 427 PK11SymKey *sourceKey = NULL; |
428 PK11SymKey *targetKey = NULL; | 428 PK11SymKey *targetKey = NULL; |
429 SECItem *sourceOutput = NULL; | 429 SECItem *sourceOutput = NULL; |
430 SECItem *targetOutput = NULL; | 430 SECItem *targetOutput = NULL; |
431 SECItem *param = NULL; | 431 SECItem *param = NULL; |
| 432 int blockSize; |
432 SECItem input; | 433 SECItem input; |
433 CK_OBJECT_HANDLE targetKeyID; | 434 CK_OBJECT_HANDLE targetKeyID; |
434 CK_FLAGS flags; | 435 CK_FLAGS flags; |
435 PRArenaPool *arena = NULL; | 436 PRArenaPool *arena = NULL; |
436 SECStatus rv = SECSuccess; | 437 SECStatus rv = SECSuccess; |
437 CK_MECHANISM_TYPE keyMechType, cryptoMechType; | 438 CK_MECHANISM_TYPE keyMechType, cryptoMechType; |
438 CK_KEY_TYPE sourceKeyType, targetKeyType; | 439 CK_KEY_TYPE sourceKeyType, targetKeyType; |
439 CK_ATTRIBUTE symTemplate[] = { | 440 CK_ATTRIBUTE symTemplate[] = { |
440 { CKA_ID, NULL, 0 }, | 441 { CKA_ID, NULL, 0 }, |
441 { CKA_CLASS, NULL, 0 } | 442 { CKA_CLASS, NULL, 0 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 * really matches. If they don't import the key with a new CKA_ID | 485 * really matches. If they don't import the key with a new CKA_ID |
485 * value. */ | 486 * value. */ |
486 rv = pk11_matchAcrossTokens(arena, targetSlot, sourceSlot, | 487 rv = pk11_matchAcrossTokens(arena, targetSlot, sourceSlot, |
487 symTemplate, symTemplateCount, id, &targetKeyID); | 488 symTemplate, symTemplateCount, id, &targetKeyID); |
488 if (rv != SECSuccess) { | 489 if (rv != SECSuccess) { |
489 goto done; | 490 goto done; |
490 } | 491 } |
491 | 492 |
492 /* set up the input test */ | 493 /* set up the input test */ |
493 input.data = (unsigned char *)testString; | 494 input.data = (unsigned char *)testString; |
494 input.len = PK11_GetBlockSize(cryptoMechType, NULL); | 495 blockSize = PK11_GetBlockSize(cryptoMechType, NULL); |
495 if (input.len < 0) { | 496 if (blockSize < 0) { |
496 rv = SECFailure; | 497 rv = SECFailure; |
497 goto done; | 498 goto done; |
498 } | 499 } |
| 500 input.len = blockSize; |
499 if (input.len == 0) { | 501 if (input.len == 0) { |
500 input.len = sizeof (testString); | 502 input.len = sizeof (testString); |
501 } | 503 } |
502 while (targetKeyID != CK_INVALID_HANDLE) { | 504 while (targetKeyID != CK_INVALID_HANDLE) { |
503 /* test to see if the keys are identical */ | 505 /* test to see if the keys are identical */ |
504 targetKeyType = PK11_ReadULongAttribute(sourceSlot, id, CKA_KEY_TYPE); | 506 targetKeyType = PK11_ReadULongAttribute(sourceSlot, id, CKA_KEY_TYPE); |
505 if (targetKeyType == sourceKeyType) { | 507 if (targetKeyType == sourceKeyType) { |
506 /* same keyType - see if it's the same key */ | 508 /* same keyType - see if it's the same key */ |
507 targetKey = PK11_SymKeyFromHandle(targetSlot, NULL, | 509 targetKey = PK11_SymKeyFromHandle(targetSlot, NULL, |
508 PK11_OriginDerive, keyMechType, targetKeyID, PR_FALSE, | 510 PK11_OriginDerive, keyMechType, targetKeyID, PR_FALSE, |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 return log; | 1410 return log; |
1409 } | 1411 } |
1410 | 1412 |
1411 void | 1413 void |
1412 PK11_DestroyMergeLog(PK11MergeLog *log) | 1414 PK11_DestroyMergeLog(PK11MergeLog *log) |
1413 { | 1415 { |
1414 if (log && log->arena) { | 1416 if (log && log->arena) { |
1415 PORT_FreeArena(log->arena, PR_FALSE); | 1417 PORT_FreeArena(log->arena, PR_FALSE); |
1416 } | 1418 } |
1417 } | 1419 } |
OLD | NEW |