comparison libtomcrypt/src/hashes/helper/hash_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>
11
12 #ifdef LTC_HASH_HELPERS
13 /** 13 /**
14 @file hash_memory_multi.c 14 @file hash_memory_multi.c
15 Hash (multiple buffers) memory helper, Tom St Denis 15 Hash (multiple buffers) memory helper, Tom St Denis
16 */ 16 */
17 17
18 /** 18 /**
19 Hash multiple (non-adjacent) blocks of memory at once. 19 Hash multiple (non-adjacent) blocks of memory at once.
20 @param hash The index of the hash you wish to use 20 @param hash The index of the hash you wish to use
21 @param out [out] Where to store the digest 21 @param out [out] Where to store the digest
22 @param outlen [in/out] Max size and resulting size of the digest 22 @param outlen [in/out] Max size and resulting size of the digest
23 @param in The data you wish to hash 23 @param in The data you wish to hash
24 @param inlen The length of the data to hash (octets) 24 @param inlen The length of the data to hash (octets)
25 @param ... tuples of (data,len) pairs to hash, terminated with a (NULL,x) (x=don't care) 25 @param ... tuples of (data,len) pairs to hash, terminated with a (NULL,x) (x=don't care)
26 @return CRYPT_OK if successful 26 @return CRYPT_OK if successful
27 */ 27 */
28 int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, 28 int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
29 const unsigned char *in, unsigned long inlen, ...) 29 const unsigned char *in, unsigned long inlen, ...)
30 { 30 {
31 hash_state *md; 31 hash_state *md;
32 int err; 32 int err;
55 if ((err = hash_descriptor[hash].init(md)) != CRYPT_OK) { 55 if ((err = hash_descriptor[hash].init(md)) != CRYPT_OK) {
56 goto LBL_ERR; 56 goto LBL_ERR;
57 } 57 }
58 58
59 va_start(args, inlen); 59 va_start(args, inlen);
60 curptr = in; 60 curptr = in;
61 curlen = inlen; 61 curlen = inlen;
62 for (;;) { 62 for (;;) {
63 /* process buf */ 63 /* process buf */
64 if ((err = hash_descriptor[hash].process(md, curptr, curlen)) != CRYPT_OK) { 64 if ((err = hash_descriptor[hash].process(md, curptr, curlen)) != CRYPT_OK) {
65 goto LBL_ERR; 65 goto LBL_ERR;
79 #endif 79 #endif
80 XFREE(md); 80 XFREE(md);
81 va_end(args); 81 va_end(args);
82 return err; 82 return err;
83 } 83 }
84 #endif /* #ifdef LTC_HASH_HELPERS */
84 85
85 /* $Source$ */ 86 /* ref: $Format:%D$ */
86 /* $Revision$ */ 87 /* git commit: $Format:%H$ */
87 /* $Date$ */ 88 /* commit time: $Format:%ai$ */