| 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 * PKCS7 implementation -- the exported parts that are used whether | 6 * PKCS7 implementation -- the exported parts that are used whether |
| 7 * creating or decoding. | 7 * creating or decoding. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #include "p7local.h" | 10 #include "p7local.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 * in the event of an error, SECFailure is returned. SECSuccess | 401 * in the event of an error, SECFailure is returned. SECSuccess |
| 402 * indicates a success. | 402 * indicates a success. |
| 403 */ | 403 */ |
| 404 SECStatus | 404 SECStatus |
| 405 SEC_PKCS7EncryptContents(PLArenaPool *poolp, | 405 SEC_PKCS7EncryptContents(PLArenaPool *poolp, |
| 406 SEC_PKCS7ContentInfo *cinfo, | 406 SEC_PKCS7ContentInfo *cinfo, |
| 407 SECItem *key, | 407 SECItem *key, |
| 408 void *wincx) | 408 void *wincx) |
| 409 { | 409 { |
| 410 SECAlgorithmID *algid = NULL; | 410 SECAlgorithmID *algid = NULL; |
| 411 SECItem * result = NULL; | |
| 412 SECItem * src; | 411 SECItem * src; |
| 413 SECItem * dest; | 412 SECItem * dest; |
| 414 SECItem * blocked_data = NULL; | 413 SECItem * blocked_data = NULL; |
| 415 void * mark; | 414 void * mark; |
| 416 void * cx; | 415 void * cx; |
| 417 PK11SymKey * eKey = NULL; | 416 PK11SymKey * eKey = NULL; |
| 418 PK11SlotInfo * slot = NULL; | 417 PK11SlotInfo * slot = NULL; |
| 419 | 418 |
| 420 CK_MECHANISM_TYPE cryptoMechType; | 419 CK_MECHANISM_TYPE cryptoMechType; |
| 421 int bs; | 420 int bs; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 rv = PK11_CipherOp((PK11Context*)cx, dest->data, (int *)(&dest->len), | 516 rv = PK11_CipherOp((PK11Context*)cx, dest->data, (int *)(&dest->len), |
| 518 (int)(src->len + 64), blocked_data->data, | 517 (int)(src->len + 64), blocked_data->data, |
| 519 (int)blocked_data->len); | 518 (int)blocked_data->len); |
| 520 PK11_DestroyContext((PK11Context*)cx, PR_TRUE); | 519 PK11_DestroyContext((PK11Context*)cx, PR_TRUE); |
| 521 | 520 |
| 522 loser: | 521 loser: |
| 523 /* let success fall through */ | 522 /* let success fall through */ |
| 524 if(blocked_data != NULL) | 523 if(blocked_data != NULL) |
| 525 SECITEM_ZfreeItem(blocked_data, PR_TRUE); | 524 SECITEM_ZfreeItem(blocked_data, PR_TRUE); |
| 526 | 525 |
| 527 if(result != NULL) | |
| 528 SECITEM_ZfreeItem(result, PR_TRUE); | |
| 529 | |
| 530 if(rv == SECFailure) | 526 if(rv == SECFailure) |
| 531 PORT_ArenaRelease(poolp, mark); | 527 PORT_ArenaRelease(poolp, mark); |
| 532 else | 528 else |
| 533 PORT_ArenaUnmark(poolp, mark); | 529 PORT_ArenaUnmark(poolp, mark); |
| 534 | 530 |
| 535 if(eKey != NULL) | 531 if(eKey != NULL) |
| 536 PK11_FreeSymKey(eKey); | 532 PK11_FreeSymKey(eKey); |
| 537 | 533 |
| 538 if(slot != NULL) | 534 if(slot != NULL) |
| 539 PK11_FreeSlot(slot); | 535 PK11_FreeSlot(slot); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 559 * indicates a success. | 555 * indicates a success. |
| 560 */ | 556 */ |
| 561 SECStatus | 557 SECStatus |
| 562 SEC_PKCS7DecryptContents(PLArenaPool *poolp, | 558 SEC_PKCS7DecryptContents(PLArenaPool *poolp, |
| 563 SEC_PKCS7ContentInfo *cinfo, | 559 SEC_PKCS7ContentInfo *cinfo, |
| 564 SECItem *key, | 560 SECItem *key, |
| 565 void *wincx) | 561 void *wincx) |
| 566 { | 562 { |
| 567 SECAlgorithmID *algid = NULL; | 563 SECAlgorithmID *algid = NULL; |
| 568 SECStatus rv = SECFailure; | 564 SECStatus rv = SECFailure; |
| 569 SECItem *result = NULL, *dest, *src; | 565 SECItem *dest, *src; |
| 570 void *mark; | 566 void *mark; |
| 571 | 567 |
| 572 PK11SymKey *eKey = NULL; | 568 PK11SymKey *eKey = NULL; |
| 573 PK11SlotInfo *slot = NULL; | 569 PK11SlotInfo *slot = NULL; |
| 574 CK_MECHANISM_TYPE cryptoMechType; | 570 CK_MECHANISM_TYPE cryptoMechType; |
| 575 void *cx; | 571 void *cx; |
| 576 SECItem *c_param = NULL; | 572 SECItem *c_param = NULL; |
| 577 int bs; | 573 int bs; |
| 578 | 574 |
| 579 if((cinfo == NULL) || (key == NULL)) | 575 if((cinfo == NULL) || (key == NULL)) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 ((int)dest->data[dest->len-1] > 0)) { | 634 ((int)dest->data[dest->len-1] > 0)) { |
| 639 dest->len -= (int)dest->data[dest->len-1]; | 635 dest->len -= (int)dest->data[dest->len-1]; |
| 640 } else { | 636 } else { |
| 641 rv = SECFailure; | 637 rv = SECFailure; |
| 642 /* set an error ? */ | 638 /* set an error ? */ |
| 643 } | 639 } |
| 644 } | 640 } |
| 645 | 641 |
| 646 loser: | 642 loser: |
| 647 /* let success fall through */ | 643 /* let success fall through */ |
| 648 if(result != NULL) | |
| 649 SECITEM_ZfreeItem(result, PR_TRUE); | |
| 650 | |
| 651 if(rv == SECFailure) | 644 if(rv == SECFailure) |
| 652 PORT_ArenaRelease(poolp, mark); | 645 PORT_ArenaRelease(poolp, mark); |
| 653 else | 646 else |
| 654 PORT_ArenaUnmark(poolp, mark); | 647 PORT_ArenaUnmark(poolp, mark); |
| 655 | 648 |
| 656 if(eKey != NULL) | 649 if(eKey != NULL) |
| 657 PK11_FreeSymKey(eKey); | 650 PK11_FreeSymKey(eKey); |
| 658 | 651 |
| 659 if(slot != NULL) | 652 if(slot != NULL) |
| 660 PK11_FreeSlot(slot); | 653 PK11_FreeSlot(slot); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 682 | 675 |
| 683 int | 676 int |
| 684 SEC_PKCS7GetKeyLength(SEC_PKCS7ContentInfo *cinfo) | 677 SEC_PKCS7GetKeyLength(SEC_PKCS7ContentInfo *cinfo) |
| 685 { | 678 { |
| 686 if (cinfo->contentTypeTag->offset == SEC_OID_PKCS7_ENVELOPED_DATA) | 679 if (cinfo->contentTypeTag->offset == SEC_OID_PKCS7_ENVELOPED_DATA) |
| 687 return cinfo->content.envelopedData->encContentInfo.keysize; | 680 return cinfo->content.envelopedData->encContentInfo.keysize; |
| 688 else | 681 else |
| 689 return 0; | 682 return 0; |
| 690 } | 683 } |
| 691 | 684 |
| OLD | NEW |