comparison libtomcrypt/src/ciphers/kasumi.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 kasumi.c 11 @file kasumi.c
14 Implementation of the 3GPP Kasumi block cipher 12 Implementation of the 3GPP Kasumi block cipher
31 &kasumi_ecb_encrypt, 29 &kasumi_ecb_encrypt,
32 &kasumi_ecb_decrypt, 30 &kasumi_ecb_decrypt,
33 &kasumi_test, 31 &kasumi_test,
34 &kasumi_done, 32 &kasumi_done,
35 &kasumi_keysize, 33 &kasumi_keysize,
36 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL 34 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
37 }; 35 };
38 36
39 static u16 FI( u16 in, u16 subkey ) 37 static u16 FI( u16 in, u16 subkey )
40 { 38 {
41 u16 nine, seven; 39 u16 nine, seven;
148 LTC_ARGCHK(skey != NULL); 146 LTC_ARGCHK(skey != NULL);
149 147
150 LOAD32H(left, pt); 148 LOAD32H(left, pt);
151 LOAD32H(right, pt+4); 149 LOAD32H(right, pt+4);
152 150
153 for (n = 0; n <= 7; ) { 151 for (n = 0; n <= 7; ) {
154 temp = FL(left, n, skey); 152 temp = FL(left, n, skey);
155 temp = FO(temp, n++, skey); 153 temp = FO(temp, n++, skey);
156 right ^= temp; 154 right ^= temp;
157 temp = FO(right, n, skey); 155 temp = FO(right, n, skey);
158 temp = FL(temp, n++, skey); 156 temp = FL(temp, n++, skey);
234 return CRYPT_OK; 232 return CRYPT_OK;
235 } 233 }
236 234
237 void kasumi_done(symmetric_key *skey) 235 void kasumi_done(symmetric_key *skey)
238 { 236 {
237 LTC_UNUSED_PARAM(skey);
239 } 238 }
240 239
241 int kasumi_keysize(int *keysize) 240 int kasumi_keysize(int *keysize)
242 { 241 {
243 LTC_ARGCHK(keysize != NULL); 242 LTC_ARGCHK(keysize != NULL);
301 return err; 300 return err;
302 } 301 }
303 if ((err = kasumi_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) { 302 if ((err = kasumi_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) {
304 return err; 303 return err;
305 } 304 }
306 if (XMEMCMP(tests[x].pt, buf[1], 8) || XMEMCMP(tests[x].ct, buf[0], 8)) { 305 if (compare_testvector(buf[1], 8, tests[x].pt, 8, "Kasumi Decrypt", x) ||
306 compare_testvector(buf[0], 8, tests[x].ct, 8, "Kasumi Encrypt", x)) {
307 return CRYPT_FAIL_TESTVECTOR; 307 return CRYPT_FAIL_TESTVECTOR;
308 } 308 }
309 } 309 }
310 return CRYPT_OK; 310 return CRYPT_OK;
311 #endif 311 #endif
312 } 312 }
313 313
314 #endif 314 #endif
315 315
316 /* $Source$ */ 316 /* ref: $Format:%D$ */
317 /* $Revision$ */ 317 /* git commit: $Format:%H$ */
318 /* $Date$ */ 318 /* commit time: $Format:%ai$ */