comparison libtomcrypt/src/encauth/gcm/gcm_init.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_init.c 13 @file gcm_init.c
14 GCM implementation, initialize state, by Tom St Denis 14 GCM implementation, initialize state, 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 Initialize a GCM state 21 Initialize a GCM state
22 @param gcm The GCM state to initialize 22 @param gcm The GCM state to initialize
23 @param cipher The index of the cipher to use 23 @param cipher The index of the cipher to use
28 int gcm_init(gcm_state *gcm, int cipher, 28 int gcm_init(gcm_state *gcm, int cipher,
29 const unsigned char *key, int keylen) 29 const unsigned char *key, int keylen)
30 { 30 {
31 int err; 31 int err;
32 unsigned char B[16]; 32 unsigned char B[16];
33 #ifdef GCM_TABLES 33 #ifdef LTC_GCM_TABLES
34 int x, y, z, t; 34 int x, y, z, t;
35 #endif 35 #endif
36 36
37 LTC_ARGCHK(gcm != NULL); 37 LTC_ARGCHK(gcm != NULL);
38 LTC_ARGCHK(key != NULL); 38 LTC_ARGCHK(key != NULL);
64 64
65 /* setup state */ 65 /* setup state */
66 zeromem(gcm->buf, sizeof(gcm->buf)); 66 zeromem(gcm->buf, sizeof(gcm->buf));
67 zeromem(gcm->X, sizeof(gcm->X)); 67 zeromem(gcm->X, sizeof(gcm->X));
68 gcm->cipher = cipher; 68 gcm->cipher = cipher;
69 gcm->mode = GCM_MODE_IV; 69 gcm->mode = LTC_GCM_MODE_IV;
70 gcm->ivmode = 0; 70 gcm->ivmode = 0;
71 gcm->buflen = 0; 71 gcm->buflen = 0;
72 gcm->totlen = 0; 72 gcm->totlen = 0;
73 gcm->pttotlen = 0; 73 gcm->pttotlen = 0;
74 74
75 #ifdef GCM_TABLES 75 #ifdef LTC_GCM_TABLES
76 /* setup tables */ 76 /* setup tables */
77 77
78 /* generate the first table as it has no shifting (from which we make the other tables) */ 78 /* generate the first table as it has no shifting (from which we make the other tables) */
79 zeromem(B, 16); 79 zeromem(B, 16);
80 for (y = 0; y < 256; y++) { 80 for (y = 0; y < 256; y++) {
100 return CRYPT_OK; 100 return CRYPT_OK;
101 } 101 }
102 102
103 #endif 103 #endif
104 104
105 /* $Source: /cvs/libtom/libtomcrypt/src/encauth/gcm/gcm_init.c,v $ */ 105 /* $Source$ */
106 /* $Revision: 1.18 $ */ 106 /* $Revision$ */
107 /* $Date: 2006/03/31 14:15:35 $ */ 107 /* $Date$ */