comparison libtomcrypt/src/mac/pelican/pelican_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 pelican_memory.c 12 @file pelican_memory.c
15 Pelican MAC, MAC a block of memory, by Tom St Denis 13 Pelican MAC, MAC a block of memory, by Tom St Denis
16 */ 14 */
17 15
18 #ifdef LTC_PELICAN 16 #ifdef LTC_PELICAN
19 17
20 /** 18 /**
21 Pelican block of memory 19 Pelican block of memory
22 @param key The key for the MAC 20 @param key The key for the MAC
23 @param keylen The length of the key (octets) 21 @param keylen The length of the key (octets)
24 @param in The input to MAC 22 @param in The input to MAC
25 @param inlen The length of the input (octets) 23 @param inlen The length of the input (octets)
26 @param out [out] The output TAG 24 @param out [out] The output TAG
27 @return CRYPT_OK on success 25 @return CRYPT_OK on success
28 */ 26 */
29 int pelican_memory(const unsigned char *key, unsigned long keylen, 27 int pelican_memory(const unsigned char *key, unsigned long keylen,
30 const unsigned char *in, unsigned long inlen, 28 const unsigned char *in, unsigned long inlen,
31 unsigned char *out) 29 unsigned char *out)
32 { 30 {
33 pelican_state *pel; 31 pelican_state *pel;
34 int err; 32 int err;
35 33
36 pel = XMALLOC(sizeof(*pel)); 34 pel = XMALLOC(sizeof(*pel));
37 if (pel == NULL) { 35 if (pel == NULL) {
38 return CRYPT_MEM; 36 return CRYPT_MEM;
39 } 37 }
40 38
41 if ((err = pelican_init(pel, key, keylen)) != CRYPT_OK) { 39 if ((err = pelican_init(pel, key, keylen)) != CRYPT_OK) {
42 XFREE(pel); 40 XFREE(pel);
45 if ((err = pelican_process(pel, in ,inlen)) != CRYPT_OK) { 43 if ((err = pelican_process(pel, in ,inlen)) != CRYPT_OK) {
46 XFREE(pel); 44 XFREE(pel);
47 return err; 45 return err;
48 } 46 }
49 err = pelican_done(pel, out); 47 err = pelican_done(pel, out);
50 XFREE(pel); 48 XFREE(pel);
51 return err; 49 return err;
52 } 50 }
53 51
54 52
55 #endif 53 #endif
56 54
57 /* $Source$ */ 55 /* ref: $Format:%D$ */
58 /* $Revision$ */ 56 /* git commit: $Format:%H$ */
59 /* $Date$ */ 57 /* commit time: $Format:%ai$ */