comparison libtomcrypt/src/mac/xcbc/xcbc_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 xcbc_memory_multi.c 13 @file xcbc_memory_multi.c
16 XCBC support, process multiple blocks of memory, Tom St Denis 14 XCBC support, process multiple blocks of memory, Tom St Denis
17 */ 15 */
18 16
19 #ifdef LTC_XCBC 17 #ifdef LTC_XCBC
20 18
21 /** 19 /**
22 XCBC multiple blocks of memory 20 XCBC 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 XCBC 26 @param in The data to send through XCBC
29 @param inlen The length of the data to send through XCBC (octets) 27 @param inlen The length of the data to send through XCBC (octets)
30 @param ... tuples of (data,len) pairs to XCBC, terminated with a (NULL,x) (x=don't care) 28 @param ... tuples of (data,len) pairs to XCBC, 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 xcbc_memory_multi(int cipher, 31 int xcbc_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 /* xcbc process the message */ 53 /* xcbc process the message */
56 if ((err = xcbc_init(xcbc, cipher, key, keylen)) != CRYPT_OK) { 54 if ((err = xcbc_init(xcbc, 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 = xcbc_process(xcbc, curptr, curlen)) != CRYPT_OK) { 62 if ((err = xcbc_process(xcbc, curptr, curlen)) != CRYPT_OK) {
65 goto LBL_ERR; 63 goto LBL_ERR;
78 #ifdef LTC_CLEAN_STACK 76 #ifdef LTC_CLEAN_STACK
79 zeromem(xcbc, sizeof(xcbc_state)); 77 zeromem(xcbc, sizeof(xcbc_state));
80 #endif 78 #endif
81 XFREE(xcbc); 79 XFREE(xcbc);
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$ */