comparison libtomcrypt/src/mac/pmac/pmac_memory.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 10
13 /** 11 /**
14 @file pmac_memory.c 12 @file pmac_memory.c
15 PMAC implementation, process a block of memory, by Tom St Denis 13 PMAC implementation, process a block of memory, by Tom St Denis
16 */ 14 */
17 15
18 #ifdef LTC_PMAC 16 #ifdef LTC_PMAC
19 17
20 /** 18 /**
26 @param inlen The length of data you wish to send through PMAC (octets) 24 @param inlen The length of data you wish to send through PMAC (octets)
27 @param out [out] Destination for the authentication tag 25 @param out [out] Destination for the authentication tag
28 @param outlen [in/out] The max size and resulting size of the authentication tag 26 @param outlen [in/out] The max size and resulting size of the authentication tag
29 @return CRYPT_OK if successful 27 @return CRYPT_OK if successful
30 */ 28 */
31 int pmac_memory(int cipher, 29 int pmac_memory(int cipher,
32 const unsigned char *key, unsigned long keylen, 30 const unsigned char *key, unsigned long keylen,
33 const unsigned char *in, unsigned long inlen, 31 const unsigned char *in, unsigned long inlen,
34 unsigned char *out, unsigned long *outlen) 32 unsigned char *out, unsigned long *outlen)
35 { 33 {
36 int err; 34 int err;
44 /* allocate ram for pmac state */ 42 /* allocate ram for pmac state */
45 pmac = XMALLOC(sizeof(pmac_state)); 43 pmac = XMALLOC(sizeof(pmac_state));
46 if (pmac == NULL) { 44 if (pmac == NULL) {
47 return CRYPT_MEM; 45 return CRYPT_MEM;
48 } 46 }
49 47
50 if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) { 48 if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) {
51 goto LBL_ERR; 49 goto LBL_ERR;
52 } 50 }
53 if ((err = pmac_process(pmac, in, inlen)) != CRYPT_OK) { 51 if ((err = pmac_process(pmac, in, inlen)) != CRYPT_OK) {
54 goto LBL_ERR; 52 goto LBL_ERR;
62 #ifdef LTC_CLEAN_STACK 60 #ifdef LTC_CLEAN_STACK
63 zeromem(pmac, sizeof(pmac_state)); 61 zeromem(pmac, sizeof(pmac_state));
64 #endif 62 #endif
65 63
66 XFREE(pmac); 64 XFREE(pmac);
67 return err; 65 return err;
68 } 66 }
69 67
70 #endif 68 #endif
71 69
72 /* $Source$ */ 70 /* ref: $Format:%D$ */
73 /* $Revision$ */ 71 /* git commit: $Format:%H$ */
74 /* $Date$ */ 72 /* commit time: $Format:%ai$ */