comparison libtomcrypt/src/encauth/gcm/gcm_init.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
comparison
equal deleted inserted replaced
1470:8bba51a55704 1471:6dba84798cd5
3 * LibTomCrypt is a library that provides various cryptographic 3 * LibTomCrypt is a library that provides various cryptographic
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 *
9 * Tom St Denis, [email protected], http://libtom.org
10 */ 8 */
11 9
12 /** 10 /**
13 @file gcm_init.c 11 @file gcm_init.c
14 GCM implementation, initialize state, by Tom St Denis 12 GCM implementation, initialize state, by Tom St Denis
23 @param cipher The index of the cipher to use 21 @param cipher The index of the cipher to use
24 @param key The secret key 22 @param key The secret key
25 @param keylen The length of the secret key 23 @param keylen The length of the secret key
26 @return CRYPT_OK on success 24 @return CRYPT_OK on success
27 */ 25 */
28 int gcm_init(gcm_state *gcm, int cipher, 26 int gcm_init(gcm_state *gcm, int cipher,
29 const unsigned char *key, int keylen) 27 const unsigned char *key, int keylen)
30 { 28 {
31 int err; 29 int err;
32 unsigned char B[16]; 30 unsigned char B[16];
33 #ifdef LTC_GCM_TABLES 31 #ifdef LTC_GCM_TABLES
90 for (z = 15; z > 0; z--) { 88 for (z = 15; z > 0; z--) {
91 gcm->PC[x][y][z] = gcm->PC[x-1][y][z-1]; 89 gcm->PC[x][y][z] = gcm->PC[x-1][y][z-1];
92 } 90 }
93 gcm->PC[x][y][0] = gcm_shift_table[t<<1]; 91 gcm->PC[x][y][0] = gcm_shift_table[t<<1];
94 gcm->PC[x][y][1] ^= gcm_shift_table[(t<<1)+1]; 92 gcm->PC[x][y][1] ^= gcm_shift_table[(t<<1)+1];
95 } 93 }
96 } 94 }
97 95
98 #endif 96 #endif
99 97
100 return CRYPT_OK; 98 return CRYPT_OK;
101 } 99 }
102 100
103 #endif 101 #endif
104 102
105 /* $Source$ */ 103 /* ref: $Format:%D$ */
106 /* $Revision$ */ 104 /* git commit: $Format:%H$ */
107 /* $Date$ */ 105 /* commit time: $Format:%ai$ */