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 XCBC Support, XCBC-MAC a block of memory
18 /** XCBC-MAC a block of memory
19 @param cipher Index of cipher to use
20 @param key [in] Secret key
21 @param keylen Length of key in octets
22 @param in [in] Message to MAC
23 @param inlen Length of input in octets
24 @param out [out] Destination for the MAC tag
25 @param outlen [in/out] Output size and final tag size
26 Return CRYPT_OK on success.
28 int xcbc_memory(int cipher,
29 const unsigned char *key, unsigned long keylen,
30 const unsigned char *in, unsigned long inlen,
31 unsigned char *out, unsigned long *outlen)
36 /* is the cipher valid? */
37 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
41 /* Use accelerator if found */
42 if (cipher_descriptor[cipher].xcbc_memory != NULL) {
43 return cipher_descriptor[cipher].xcbc_memory(key, keylen, in, inlen, out, outlen);
46 xcbc = XCALLOC(1, sizeof(*xcbc));
51 if ((err = xcbc_init(xcbc, cipher, key, keylen)) != CRYPT_OK) {
55 if ((err = xcbc_process(xcbc, in, inlen)) != CRYPT_OK) {
59 err = xcbc_done(xcbc, out, outlen);
67 /* ref: $Format:%D$ */
68 /* git commit: $Format:%H$ */
69 /* commit time: $Format:%ai$ */