Mercurial > dropbear
comparison libtomcrypt/src/mac/omac/omac_init.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
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 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file omac_init.c | 12 @file omac_init.c |
15 LTC_OMAC1 support, initialize state, by Tom St Denis | 13 OMAC1 support, initialize state, by Tom St Denis |
16 */ | 14 */ |
17 | 15 |
18 | 16 |
19 #ifdef LTC_OMAC | 17 #ifdef LTC_OMAC |
20 | 18 |
21 /** | 19 /** |
22 Initialize an LTC_OMAC state | 20 Initialize an OMAC state |
23 @param omac The LTC_OMAC state to initialize | 21 @param omac The OMAC state to initialize |
24 @param cipher The index of the desired cipher | 22 @param cipher The index of the desired cipher |
25 @param key The secret key | 23 @param key The secret key |
26 @param keylen The length of the secret key (octets) | 24 @param keylen The length of the secret key (octets) |
27 @return CRYPT_OK if successful | 25 @return CRYPT_OK if successful |
28 */ | 26 */ |
75 /* shift left */ | 73 /* shift left */ |
76 for (y = 0; y < (len - 1); y++) { | 74 for (y = 0; y < (len - 1); y++) { |
77 omac->Lu[x][y] = ((omac->Lu[x][y] << 1) | (omac->Lu[x][y+1] >> 7)) & 255; | 75 omac->Lu[x][y] = ((omac->Lu[x][y] << 1) | (omac->Lu[x][y+1] >> 7)) & 255; |
78 } | 76 } |
79 omac->Lu[x][len - 1] = ((omac->Lu[x][len - 1] << 1) ^ (msb ? mask : 0)) & 255; | 77 omac->Lu[x][len - 1] = ((omac->Lu[x][len - 1] << 1) ^ (msb ? mask : 0)) & 255; |
80 | 78 |
81 /* copy up as require */ | 79 /* copy up as require */ |
82 if (x == 0) { | 80 if (x == 0) { |
83 XMEMCPY(omac->Lu[1], omac->Lu[0], sizeof(omac->Lu[0])); | 81 XMEMCPY(omac->Lu[1], omac->Lu[0], sizeof(omac->Lu[0])); |
84 } | 82 } |
85 } | 83 } |
94 return CRYPT_OK; | 92 return CRYPT_OK; |
95 } | 93 } |
96 | 94 |
97 #endif | 95 #endif |
98 | 96 |
99 /* $Source$ */ | 97 /* ref: $Format:%D$ */ |
100 /* $Revision$ */ | 98 /* git commit: $Format:%H$ */ |
101 /* $Date$ */ | 99 /* commit time: $Format:%ai$ */ |