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 #ifdef FREEBL_NO_DEPEND | 5 #ifdef FREEBL_NO_DEPEND |
6 #include "stubs.h" | 6 #include "stubs.h" |
7 #endif | 7 #endif |
8 #include "blapii.h" | 8 #include "blapii.h" |
9 #include "blapit.h" | 9 #include "blapit.h" |
10 #include "gcm.h" | 10 #include "gcm.h" |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 PORT_Memset(ghash->counterBuf, 0, GCM_HASH_LEN_LEN*2); | 570 PORT_Memset(ghash->counterBuf, 0, GCM_HASH_LEN_LEN*2); |
571 ghash->bufLen = 0; | 571 ghash->bufLen = 0; |
572 gcm_zeroX(ghash); | 572 gcm_zeroX(ghash); |
573 | 573 |
574 /* now kick things off by hashing the Additional Authenticated Data */ | 574 /* now kick things off by hashing the Additional Authenticated Data */ |
575 if (AADLen != 0) { | 575 if (AADLen != 0) { |
576 rv = gcmHash_Update(ghash, AAD, AADLen, blocksize); | 576 rv = gcmHash_Update(ghash, AAD, AADLen, blocksize); |
577 if (rv != SECSuccess) { | 577 if (rv != SECSuccess) { |
578 return SECFailure; | 578 return SECFailure; |
579 } | 579 } |
| 580 rv = gcmHash_Sync(ghash, blocksize); |
| 581 if (rv != SECSuccess) { |
| 582 return SECFailure; |
| 583 } |
580 } | 584 } |
581 rv = gcmHash_Sync(ghash, blocksize); | |
582 if (rv != SECSuccess) { | |
583 return SECFailure; | |
584 } | |
585 return SECSuccess; | 585 return SECSuccess; |
586 } | 586 } |
587 | 587 |
588 /************************************************************************** | 588 /************************************************************************** |
589 * Now implement the GCM using gcmHash and CTR * | 589 * Now implement the GCM using gcmHash and CTR * |
590 **************************************************************************/ | 590 **************************************************************************/ |
591 | 591 |
592 /* state to handle the full GCM operation (hash and counter) */ | 592 /* state to handle the full GCM operation (hash and counter) */ |
593 struct GCMContextStr { | 593 struct GCMContextStr { |
594 gcmHashContext ghash_context; | 594 gcmHashContext ghash_context; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 * preserve the masked off missing bits. */ | 837 * preserve the masked off missing bits. */ |
838 if (NSS_SecureMemcmp(tag, intag, tagBytes) != 0) { | 838 if (NSS_SecureMemcmp(tag, intag, tagBytes) != 0) { |
839 /* force a CKR_ENCRYPTED_DATA_INVALID error at in softoken */ | 839 /* force a CKR_ENCRYPTED_DATA_INVALID error at in softoken */ |
840 PORT_SetError(SEC_ERROR_BAD_DATA); | 840 PORT_SetError(SEC_ERROR_BAD_DATA); |
841 return SECFailure; | 841 return SECFailure; |
842 } | 842 } |
843 /* finish the decryption */ | 843 /* finish the decryption */ |
844 return CTR_Update(&gcm->ctr_context, outbuf, outlen, maxout, | 844 return CTR_Update(&gcm->ctr_context, outbuf, outlen, maxout, |
845 inbuf, inlen, blocksize); | 845 inbuf, inlen, blocksize); |
846 } | 846 } |
OLD | NEW |