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 xcbc_memory_multi.c
14 XCBC support, process multiple blocks of memory, Tom St Denis
20 XCBC 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 XCBC
27 @param inlen The length of the data to send through XCBC (octets)
28 @param ... tuples of (data,len) pairs to XCBC, terminated with a (NULL,x) (x=don't care)
29 @return CRYPT_OK if successful
31 int xcbc_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 xcbc state */
48 xcbc = XMALLOC(sizeof(xcbc_state));
53 /* xcbc process the message */
54 if ((err = xcbc_init(xcbc, cipher, key, keylen)) != CRYPT_OK) {
57 va_start(args, inlen);
62 if ((err = xcbc_process(xcbc, curptr, curlen)) != CRYPT_OK) {
66 curptr = va_arg(args, const unsigned char*);
70 curlen = va_arg(args, unsigned long);
72 if ((err = xcbc_done(xcbc, out, outlen)) != CRYPT_OK) {
76 #ifdef LTC_CLEAN_STACK
77 zeromem(xcbc, sizeof(xcbc_state));
86 /* ref: $Format:%D$ */
87 /* git commit: $Format:%H$ */
88 /* commit time: $Format:%ai$ */