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
9
* Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org
12
/* EAX Implementation by Tom St Denis */
17
int eax_decrypt_verify_memory(int cipher,
18
const unsigned char *key, unsigned long keylen,
19
const unsigned char *nonce, unsigned long noncelen,
20
const unsigned char *header, unsigned long headerlen,
21
const unsigned char *ct, unsigned long ctlen,
23
unsigned char *tag, unsigned long taglen,
37
buf = XMALLOC(taglen);
38
eax = XMALLOC(sizeof(eax_state));
39
if (eax == NULL || buf == NULL) {
49
if ((err = eax_init(eax, cipher, key, keylen, nonce, noncelen, header, headerlen)) != CRYPT_OK) {
53
if ((err = eax_decrypt(eax, ct, pt, ctlen)) != CRYPT_OK) {
58
if ((err = eax_done(eax, buf, &buflen)) != CRYPT_OK) {
63
if (buflen >= taglen && memcmp(buf, tag, taglen) == 0) {
71
zeromem(eax, sizeof(eax_state));