Mercurial > dropbear
comparison libtomcrypt/src/mac/omac/omac_process.c @ 1437:871b18fd7065 fuzz
merge from main (libtommath/libtomcrypt/curve25510-donna updates)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 24 Jun 2017 22:51:45 +0800 |
parents | f849a5ca2efc |
children | 6dba84798cd5 |
comparison
equal
deleted
inserted
replaced
1432:41dca1e5ea34 | 1437:871b18fd7065 |
---|---|
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 #include "tomcrypt.h" | 11 #include "tomcrypt.h" |
12 | 12 |
13 /** | 13 /** |
14 @file omac_process.c | 14 @file omac_process.c |
15 OMAC1 support, process data, Tom St Denis | 15 LTC_OMAC1 support, process data, Tom St Denis |
16 */ | 16 */ |
17 | 17 |
18 | 18 |
19 #ifdef LTC_OMAC | 19 #ifdef LTC_OMAC |
20 | 20 |
21 /** | 21 /** |
22 Process data through OMAC | 22 Process data through LTC_OMAC |
23 @param omac The OMAC state | 23 @param omac The LTC_OMAC state |
24 @param in The input data to send through OMAC | 24 @param in The input data to send through LTC_OMAC |
25 @param inlen The length of the input (octets) | 25 @param inlen The length of the input (octets) |
26 @return CRYPT_OK if successful | 26 @return CRYPT_OK if successful |
27 */ | 27 */ |
28 int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen) | 28 int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen) |
29 { | 29 { |
30 unsigned long n, x; | 30 unsigned long n, x, blklen; |
31 int err; | 31 int err; |
32 | 32 |
33 LTC_ARGCHK(omac != NULL); | 33 LTC_ARGCHK(omac != NULL); |
34 LTC_ARGCHK(in != NULL); | 34 LTC_ARGCHK(in != NULL); |
35 if ((err = cipher_is_valid(omac->cipher_idx)) != CRYPT_OK) { | 35 if ((err = cipher_is_valid(omac->cipher_idx)) != CRYPT_OK) { |
40 (omac->blklen > (int)sizeof(omac->block)) || (omac->buflen > omac->blklen)) { | 40 (omac->blklen > (int)sizeof(omac->block)) || (omac->buflen > omac->blklen)) { |
41 return CRYPT_INVALID_ARG; | 41 return CRYPT_INVALID_ARG; |
42 } | 42 } |
43 | 43 |
44 #ifdef LTC_FAST | 44 #ifdef LTC_FAST |
45 if (omac->buflen == 0 && inlen > 16) { | 45 blklen = cipher_descriptor[omac->cipher_idx].block_length; |
46 int y; | 46 if (omac->buflen == 0 && inlen > blklen) { |
47 for (x = 0; x < (inlen - 16); x += 16) { | 47 unsigned long y; |
48 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) { | 48 for (x = 0; x < (inlen - blklen); x += blklen) { |
49 for (y = 0; y < blklen; y += sizeof(LTC_FAST_TYPE)) { | |
49 *((LTC_FAST_TYPE*)(&omac->prev[y])) ^= *((LTC_FAST_TYPE*)(&in[y])); | 50 *((LTC_FAST_TYPE*)(&omac->prev[y])) ^= *((LTC_FAST_TYPE*)(&in[y])); |
50 } | 51 } |
51 in += 16; | 52 in += blklen; |
52 if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) { | 53 if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) { |
53 return err; | 54 return err; |
54 } | 55 } |
55 } | 56 } |
56 inlen -= x; | 57 inlen -= x; |
81 } | 82 } |
82 | 83 |
83 #endif | 84 #endif |
84 | 85 |
85 | 86 |
86 /* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_process.c,v $ */ | 87 /* $Source$ */ |
87 /* $Revision: 1.9 $ */ | 88 /* $Revision$ */ |
88 /* $Date: 2006/11/03 00:39:49 $ */ | 89 /* $Date$ */ |