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 OMAC1 support, process a block of memory, Tom St Denis
19 OMAC a block of memory
20 @param cipher The index of the desired cipher
21 @param key The secret key
22 @param keylen The length of the secret key (octets)
23 @param in The data to send through OMAC
24 @param inlen The length of the data to send through OMAC (octets)
25 @param out [out] The destination of the authentication tag
26 @param outlen [in/out] The max size and resulting size of the authentication tag (octets)
27 @return CRYPT_OK if successful
29 int omac_memory(int cipher,
30 const unsigned char *key, unsigned long keylen,
31 const unsigned char *in, unsigned long inlen,
32 unsigned char *out, unsigned long *outlen)
37 LTC_ARGCHK(key != NULL);
38 LTC_ARGCHK(in != NULL);
39 LTC_ARGCHK(out != NULL);
40 LTC_ARGCHK(outlen != NULL);
42 /* is the cipher valid? */
43 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
47 /* Use accelerator if found */
48 if (cipher_descriptor[cipher].omac_memory != NULL) {
49 return cipher_descriptor[cipher].omac_memory(key, keylen, in, inlen, out, outlen);
52 /* allocate ram for omac state */
53 omac = XMALLOC(sizeof(omac_state));
58 /* omac process the message */
59 if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) {
62 if ((err = omac_process(omac, in, inlen)) != CRYPT_OK) {
65 if ((err = omac_done(omac, out, outlen)) != CRYPT_OK) {
71 #ifdef LTC_CLEAN_STACK
72 zeromem(omac, sizeof(omac_state));
81 /* ref: $Format:%D$ */
82 /* git commit: $Format:%H$ */
83 /* commit time: $Format:%ai$ */