Mercurial > dropbear
comparison libtomcrypt/src/encauth/eax/eax_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 eax_init.c | 13 @file eax_init.c |
14 EAX implementation, initialized EAX state, by Tom St Denis | 14 EAX implementation, initialized EAX state, by Tom St Denis |
15 */ | 15 */ |
16 #include "tomcrypt.h" | 16 #include "tomcrypt.h" |
17 | 17 |
18 #ifdef EAX_MODE | 18 #ifdef LTC_EAX_MODE |
19 | 19 |
20 /** | 20 /** |
21 Initialized an EAX state | 21 Initialized an EAX state |
22 @param eax [out] The EAX state to initialize | 22 @param eax [out] The EAX state to initialize |
23 @param cipher The index of the desired cipher | 23 @param cipher The index of the desired cipher |
64 XFREE(omac); | 64 XFREE(omac); |
65 } | 65 } |
66 return CRYPT_MEM; | 66 return CRYPT_MEM; |
67 } | 67 } |
68 | 68 |
69 /* N = OMAC_0K(nonce) */ | 69 /* N = LTC_OMAC_0K(nonce) */ |
70 zeromem(buf, MAXBLOCKSIZE); | 70 zeromem(buf, MAXBLOCKSIZE); |
71 if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) { | 71 if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) { |
72 goto LBL_ERR; | 72 goto LBL_ERR; |
73 } | 73 } |
74 | 74 |
84 len = sizeof(eax->N); | 84 len = sizeof(eax->N); |
85 if ((err = omac_done(omac, eax->N, &len)) != CRYPT_OK) { | 85 if ((err = omac_done(omac, eax->N, &len)) != CRYPT_OK) { |
86 goto LBL_ERR; | 86 goto LBL_ERR; |
87 } | 87 } |
88 | 88 |
89 /* H = OMAC_1K(header) */ | 89 /* H = LTC_OMAC_1K(header) */ |
90 zeromem(buf, MAXBLOCKSIZE); | 90 zeromem(buf, MAXBLOCKSIZE); |
91 buf[blklen - 1] = 1; | 91 buf[blklen - 1] = 1; |
92 | 92 |
93 if ((err = omac_init(&eax->headeromac, cipher, key, keylen)) != CRYPT_OK) { | 93 if ((err = omac_init(&eax->headeromac, cipher, key, keylen)) != CRYPT_OK) { |
94 goto LBL_ERR; | 94 goto LBL_ERR; |
110 /* setup the CTR mode */ | 110 /* setup the CTR mode */ |
111 if ((err = ctr_start(cipher, eax->N, key, keylen, 0, CTR_COUNTER_BIG_ENDIAN, &eax->ctr)) != CRYPT_OK) { | 111 if ((err = ctr_start(cipher, eax->N, key, keylen, 0, CTR_COUNTER_BIG_ENDIAN, &eax->ctr)) != CRYPT_OK) { |
112 goto LBL_ERR; | 112 goto LBL_ERR; |
113 } | 113 } |
114 | 114 |
115 /* setup the OMAC for the ciphertext */ | 115 /* setup the LTC_OMAC for the ciphertext */ |
116 if ((err = omac_init(&eax->ctomac, cipher, key, keylen)) != CRYPT_OK) { | 116 if ((err = omac_init(&eax->ctomac, cipher, key, keylen)) != CRYPT_OK) { |
117 goto LBL_ERR; | 117 goto LBL_ERR; |
118 } | 118 } |
119 | 119 |
120 /* omac [2]_n */ | 120 /* omac [2]_n */ |
137 return err; | 137 return err; |
138 } | 138 } |
139 | 139 |
140 #endif | 140 #endif |
141 | 141 |
142 /* $Source: /cvs/libtom/libtomcrypt/src/encauth/eax/eax_init.c,v $ */ | 142 /* $Source$ */ |
143 /* $Revision: 1.5 $ */ | 143 /* $Revision$ */ |
144 /* $Date: 2006/03/31 14:15:35 $ */ | 144 /* $Date$ */ |