Mercurial > dropbear
comparison libtomcrypt/src/mac/f9/f9_memory_multi.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 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 #include <stdarg.h> | 10 #include <stdarg.h> |
13 | 11 |
14 /** | 12 /** |
15 @file f9_memory_multi.c | 13 @file f9_memory_multi.c |
16 f9 support, process multiple blocks of memory, Tom St Denis | 14 f9 support, process multiple blocks of memory, Tom St Denis |
17 */ | 15 */ |
18 | 16 |
19 #ifdef LTC_F9_MODE | 17 #ifdef LTC_F9_MODE |
20 | 18 |
21 /** | 19 /** |
22 f9 multiple blocks of memory | 20 f9 multiple blocks of memory |
23 @param cipher The index of the desired cipher | 21 @param cipher The index of the desired cipher |
24 @param key The secret key | 22 @param key The secret key |
25 @param keylen The length of the secret key (octets) | 23 @param keylen The length of the secret key (octets) |
26 @param out [out] The destination of the authentication tag | 24 @param out [out] The destination of the authentication tag |
27 @param outlen [in/out] The max size and resulting size of the authentication tag (octets) | 25 @param outlen [in/out] The max size and resulting size of the authentication tag (octets) |
28 @param in The data to send through f9 | 26 @param in The data to send through f9 |
29 @param inlen The length of the data to send through f9 (octets) | 27 @param inlen The length of the data to send through f9 (octets) |
30 @param ... tuples of (data,len) pairs to f9, terminated with a (NULL,x) (x=don't care) | 28 @param ... tuples of (data,len) pairs to f9, terminated with a (NULL,x) (x=don't care) |
31 @return CRYPT_OK if successful | 29 @return CRYPT_OK if successful |
32 */ | 30 */ |
33 int f9_memory_multi(int cipher, | 31 int f9_memory_multi(int cipher, |
34 const unsigned char *key, unsigned long keylen, | 32 const unsigned char *key, unsigned long keylen, |
35 unsigned char *out, unsigned long *outlen, | 33 unsigned char *out, unsigned long *outlen, |
36 const unsigned char *in, unsigned long inlen, ...) | 34 const unsigned char *in, unsigned long inlen, ...) |
37 { | 35 { |
38 int err; | 36 int err; |
55 /* f9 process the message */ | 53 /* f9 process the message */ |
56 if ((err = f9_init(f9, cipher, key, keylen)) != CRYPT_OK) { | 54 if ((err = f9_init(f9, cipher, key, keylen)) != CRYPT_OK) { |
57 goto LBL_ERR; | 55 goto LBL_ERR; |
58 } | 56 } |
59 va_start(args, inlen); | 57 va_start(args, inlen); |
60 curptr = in; | 58 curptr = in; |
61 curlen = inlen; | 59 curlen = inlen; |
62 for (;;) { | 60 for (;;) { |
63 /* process buf */ | 61 /* process buf */ |
64 if ((err = f9_process(f9, curptr, curlen)) != CRYPT_OK) { | 62 if ((err = f9_process(f9, curptr, curlen)) != CRYPT_OK) { |
65 goto LBL_ERR; | 63 goto LBL_ERR; |
78 #ifdef LTC_CLEAN_STACK | 76 #ifdef LTC_CLEAN_STACK |
79 zeromem(f9, sizeof(f9_state)); | 77 zeromem(f9, sizeof(f9_state)); |
80 #endif | 78 #endif |
81 XFREE(f9); | 79 XFREE(f9); |
82 va_end(args); | 80 va_end(args); |
83 return err; | 81 return err; |
84 } | 82 } |
85 | 83 |
86 #endif | 84 #endif |
87 | 85 |
88 /* $Source$ */ | 86 /* ref: $Format:%D$ */ |
89 /* $Revision$ */ | 87 /* git commit: $Format:%H$ */ |
90 /* $Date$ */ | 88 /* commit time: $Format:%ai$ */ |