1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6    @file pelican_memory.c
7    Pelican MAC, MAC a block of memory, by Tom St Denis
8 */
9 
10 #ifdef LTC_PELICAN
11 
12 /**
13   Pelican block of memory
14   @param key      The key for the MAC
15   @param keylen   The length of the key (octets)
16   @param in       The input to MAC
17   @param inlen    The length of the input (octets)
18   @param out      [out] The output TAG
19   @return CRYPT_OK on success
20 */
pelican_memory(const unsigned char * key,unsigned long keylen,const unsigned char * in,unsigned long inlen,unsigned char * out)21 int pelican_memory(const unsigned char *key, unsigned long keylen,
22                    const unsigned char *in,  unsigned long inlen,
23                          unsigned char *out)
24 {
25    pelican_state *pel;
26    int err;
27 
28    pel = XMALLOC(sizeof(*pel));
29    if (pel == NULL) {
30       return CRYPT_MEM;
31    }
32 
33    if ((err = pelican_init(pel, key, keylen)) != CRYPT_OK) {
34       XFREE(pel);
35       return err;
36    }
37    if ((err = pelican_process(pel, in ,inlen)) != CRYPT_OK) {
38       XFREE(pel);
39       return err;
40    }
41    err = pelican_done(pel, out);
42    XFREE(pel);
43    return err;
44 }
45 
46 
47 #endif
48