1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
13 @file pmac_memory_multi.c
14 PMAC implementation, process multiple blocks of memory, by Tom St Denis
20 PMAC multiple blocks of memory
21 @param cipher The index of the cipher desired
22 @param key The secret key
23 @param keylen The length of the secret key (octets)
24 @param out [out] Destination for the authentication tag
25 @param outlen [in/out] The max size and resulting size of the authentication tag
26 @param in The data you wish to send through PMAC
27 @param inlen The length of data you wish to send through PMAC (octets)
28 @param ... tuples of (data,len) pairs to PMAC, terminated with a (NULL,x) (x=don't care)
29 @return CRYPT_OK if successful
31 int pmac_memory_multi(int cipher,
32 const unsigned char *key, unsigned long keylen,
33 unsigned char *out, unsigned long *outlen,
34 const unsigned char *in, unsigned long inlen, ...)
39 const unsigned char *curptr;
42 LTC_ARGCHK(key != NULL);
43 LTC_ARGCHK(in != NULL);
44 LTC_ARGCHK(out != NULL);
45 LTC_ARGCHK(outlen != NULL);
47 /* allocate ram for pmac state */
48 pmac = XMALLOC(sizeof(pmac_state));
53 if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) {
56 va_start(args, inlen);
61 if ((err = pmac_process(pmac, curptr, curlen)) != CRYPT_OK) {
65 curptr = va_arg(args, const unsigned char*);
69 curlen = va_arg(args, unsigned long);
71 if ((err = pmac_done(pmac, out, outlen)) != CRYPT_OK) {
75 #ifdef LTC_CLEAN_STACK
76 zeromem(pmac, sizeof(pmac_state));
85 /* ref: $Format:%D$ */
86 /* git commit: $Format:%H$ */
87 /* commit time: $Format:%ai$ */