comparison libtomcrypt/src/encauth/gcm/gcm_process.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_process.c 13 @file gcm_process.c
14 GCM implementation, process message data, by Tom St Denis 14 GCM implementation, process message data, 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 Process plaintext/ciphertext through GCM 21 Process plaintext/ciphertext through GCM
22 @param gcm The GCM state 22 @param gcm The GCM state
23 @param pt The plaintext 23 @param pt The plaintext
48 if ((err = cipher_is_valid(gcm->cipher)) != CRYPT_OK) { 48 if ((err = cipher_is_valid(gcm->cipher)) != CRYPT_OK) {
49 return err; 49 return err;
50 } 50 }
51 51
52 /* in AAD mode? */ 52 /* in AAD mode? */
53 if (gcm->mode == GCM_MODE_AAD) { 53 if (gcm->mode == LTC_GCM_MODE_AAD) {
54 /* let's process the AAD */ 54 /* let's process the AAD */
55 if (gcm->buflen) { 55 if (gcm->buflen) {
56 gcm->totlen += gcm->buflen * CONST64(8); 56 gcm->totlen += gcm->buflen * CONST64(8);
57 gcm_mult_h(gcm, gcm->X); 57 gcm_mult_h(gcm, gcm->X);
58 } 58 }
65 if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) { 65 if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) {
66 return err; 66 return err;
67 } 67 }
68 68
69 gcm->buflen = 0; 69 gcm->buflen = 0;
70 gcm->mode = GCM_MODE_TEXT; 70 gcm->mode = LTC_GCM_MODE_TEXT;
71 } 71 }
72 72
73 if (gcm->mode != GCM_MODE_TEXT) { 73 if (gcm->mode != LTC_GCM_MODE_TEXT) {
74 return CRYPT_INVALID_ARG; 74 return CRYPT_INVALID_ARG;
75 } 75 }
76 76
77 x = 0; 77 x = 0;
78 #ifdef LTC_FAST 78 #ifdef LTC_FAST
145 return CRYPT_OK; 145 return CRYPT_OK;
146 } 146 }
147 147
148 #endif 148 #endif
149 149
150 /* $Source: /cvs/libtom/libtomcrypt/src/encauth/gcm/gcm_process.c,v $ */ 150 /* $Source$ */
151 /* $Revision: 1.14 $ */ 151 /* $Revision$ */
152 /* $Date: 2006/11/19 19:33:36 $ */ 152 /* $Date$ */