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 omac_memory_multi.c
14 OMAC1 support, process multiple blocks of memory, Tom St Denis
20 OMAC multiple blocks of memory
21 @param cipher The index of the desired cipher
22 @param key The secret key
23 @param keylen The length of the secret key (octets)
24 @param out [out] The destination of the authentication tag
25 @param outlen [in/out] The max size and resulting size of the authentication tag (octets)
26 @param in The data to send through OMAC
27 @param inlen The length of the data to send through OMAC (octets)
28 @param ... tuples of (data,len) pairs to OMAC, terminated with a (NULL,x) (x=don't care)
29 @return CRYPT_OK if successful
31 int omac_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 omac state */
48 omac = XMALLOC(sizeof(omac_state));
53 /* omac process the message */
54 if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) {
57 va_start(args, inlen);
62 if ((err = omac_process(omac, curptr, curlen)) != CRYPT_OK) {
66 curptr = va_arg(args, const unsigned char*);
70 curlen = va_arg(args, unsigned long);
72 if ((err = omac_done(omac, out, outlen)) != CRYPT_OK) {
76 #ifdef LTC_CLEAN_STACK
77 zeromem(omac, sizeof(omac_state));
86 /* ref: $Format:%D$ */
87 /* git commit: $Format:%H$ */
88 /* commit time: $Format:%ai$ */