Mercurial > dropbear
comparison libtomcrypt/src/mac/pmac/pmac_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 pmac_memory_multi.c | 13 @file pmac_memory_multi.c |
16 PMAC implementation, process multiple blocks of memory, by Tom St Denis | 14 PMAC implementation, process multiple blocks of memory, by Tom St Denis |
17 */ | 15 */ |
18 | 16 |
19 #ifdef LTC_PMAC | 17 #ifdef LTC_PMAC |
20 | 18 |
21 /** | 19 /** |
28 @param in The data you wish to send through PMAC | 26 @param in The data you wish to send through PMAC |
29 @param inlen The length of data you wish to send through PMAC (octets) | 27 @param inlen The length of data you wish to send through PMAC (octets) |
30 @param ... tuples of (data,len) pairs to PMAC, terminated with a (NULL,x) (x=don't care) | 28 @param ... tuples of (data,len) pairs to PMAC, 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 pmac_memory_multi(int cipher, | 31 int pmac_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; |
49 /* allocate ram for pmac state */ | 47 /* allocate ram for pmac state */ |
50 pmac = XMALLOC(sizeof(pmac_state)); | 48 pmac = XMALLOC(sizeof(pmac_state)); |
51 if (pmac == NULL) { | 49 if (pmac == NULL) { |
52 return CRYPT_MEM; | 50 return CRYPT_MEM; |
53 } | 51 } |
54 | 52 |
55 if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) { | 53 if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) { |
56 goto LBL_ERR; | 54 goto LBL_ERR; |
57 } | 55 } |
58 va_start(args, inlen); | 56 va_start(args, inlen); |
59 curptr = in; | 57 curptr = in; |
60 curlen = inlen; | 58 curlen = inlen; |
61 for (;;) { | 59 for (;;) { |
62 /* process buf */ | 60 /* process buf */ |
63 if ((err = pmac_process(pmac, curptr, curlen)) != CRYPT_OK) { | 61 if ((err = pmac_process(pmac, curptr, curlen)) != CRYPT_OK) { |
64 goto LBL_ERR; | 62 goto LBL_ERR; |
77 #ifdef LTC_CLEAN_STACK | 75 #ifdef LTC_CLEAN_STACK |
78 zeromem(pmac, sizeof(pmac_state)); | 76 zeromem(pmac, sizeof(pmac_state)); |
79 #endif | 77 #endif |
80 XFREE(pmac); | 78 XFREE(pmac); |
81 va_end(args); | 79 va_end(args); |
82 return err; | 80 return err; |
83 } | 81 } |
84 | 82 |
85 #endif | 83 #endif |
86 | 84 |
87 /* $Source$ */ | 85 /* ref: $Format:%D$ */ |
88 /* $Revision$ */ | 86 /* git commit: $Format:%H$ */ |
89 /* $Date$ */ | 87 /* commit time: $Format:%ai$ */ |