comparison libtomcrypt/src/encauth/gcm/gcm_add_aad.c @ 1435:f849a5ca2efc

update to libtomcrypt 1.17 (with Dropbear changes)
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 17:50:50 +0800
parents 0cbe8f6dbf9e
children 6dba84798cd5
comparison
equal deleted inserted replaced
1434:27b9ddb06b09 1435:f849a5ca2efc
4 * algorithms in a highly modular and flexible manner. 4 * algorithms in a highly modular and flexible manner.
5 * 5 *
6 * The library is free for all purposes without any express 6 * The library is free for all purposes without any express
7 * guarantee it works. 7 * guarantee it works.
8 * 8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.com 9 * Tom St Denis, [email protected], http://libtom.org
10 */ 10 */
11 11
12 /** 12 /**
13 @file gcm_add_aad.c 13 @file gcm_add_aad.c
14 GCM implementation, Add AAD data to the stream, by Tom St Denis 14 GCM implementation, Add AAD data to the stream, by Tom St Denis
15 */ 15 */
16 #include "tomcrypt.h" 16 #include "tomcrypt.h"
17 17
18 #ifdef GCM_MODE 18 #ifdef LTC_GCM_MODE
19 19
20 /** 20 /**
21 Add AAD to the GCM state 21 Add AAD to the GCM state
22 @param gcm The GCM state 22 @param gcm The GCM state
23 @param adata The additional authentication data to add to the GCM state 23 @param adata The additional authentication data to add to the GCM state
45 if ((err = cipher_is_valid(gcm->cipher)) != CRYPT_OK) { 45 if ((err = cipher_is_valid(gcm->cipher)) != CRYPT_OK) {
46 return err; 46 return err;
47 } 47 }
48 48
49 /* in IV mode? */ 49 /* in IV mode? */
50 if (gcm->mode == GCM_MODE_IV) { 50 if (gcm->mode == LTC_GCM_MODE_IV) {
51 /* let's process the IV */ 51 /* let's process the IV */
52 if (gcm->ivmode || gcm->buflen != 12) { 52 if (gcm->ivmode || gcm->buflen != 12) {
53 for (x = 0; x < (unsigned long)gcm->buflen; x++) { 53 for (x = 0; x < (unsigned long)gcm->buflen; x++) {
54 gcm->X[x] ^= gcm->buf[x]; 54 gcm->X[x] ^= gcm->buf[x];
55 } 55 }
78 } 78 }
79 XMEMCPY(gcm->Y_0, gcm->Y, 16); 79 XMEMCPY(gcm->Y_0, gcm->Y, 16);
80 zeromem(gcm->buf, 16); 80 zeromem(gcm->buf, 16);
81 gcm->buflen = 0; 81 gcm->buflen = 0;
82 gcm->totlen = 0; 82 gcm->totlen = 0;
83 gcm->mode = GCM_MODE_AAD; 83 gcm->mode = LTC_GCM_MODE_AAD;
84 } 84 }
85 85
86 if (gcm->mode != GCM_MODE_AAD || gcm->buflen >= 16) { 86 if (gcm->mode != LTC_GCM_MODE_AAD || gcm->buflen >= 16) {
87 return CRYPT_INVALID_ARG; 87 return CRYPT_INVALID_ARG;
88 } 88 }
89 89
90 x = 0; 90 x = 0;
91 #ifdef LTC_FAST 91 #ifdef LTC_FAST
117 return CRYPT_OK; 117 return CRYPT_OK;
118 } 118 }
119 #endif 119 #endif
120 120
121 121
122 /* $Source: /cvs/libtom/libtomcrypt/src/encauth/gcm/gcm_add_aad.c,v $ */ 122 /* $Source$ */
123 /* $Revision: 1.16 $ */ 123 /* $Revision$ */
124 /* $Date: 2006/09/23 19:24:21 $ */ 124 /* $Date$ */