1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3
4 /**
5 @file eax_decrypt.c
6 EAX implementation, decrypt block, by Tom St Denis
7 */
8 #include "tomcrypt_private.h"
9
10 #ifdef LTC_EAX_MODE
11
12 /**
13 Decrypt data with the EAX protocol
14 @param eax The EAX state
15 @param ct The ciphertext
16 @param pt [out] The plaintext
17 @param length The length (octets) of the ciphertext
18 @return CRYPT_OK if successful
19 */
eax_decrypt(eax_state * eax,const unsigned char * ct,unsigned char * pt,unsigned long length)20 int eax_decrypt(eax_state *eax, const unsigned char *ct, unsigned char *pt,
21 unsigned long length)
22 {
23 int err;
24
25 LTC_ARGCHK(eax != NULL);
26 LTC_ARGCHK(pt != NULL);
27 LTC_ARGCHK(ct != NULL);
28
29 /* omac ciphertext */
30 if ((err = omac_process(&eax->ctomac, ct, length)) != CRYPT_OK) {
31 return err;
32 }
33
34 /* decrypt */
35 return ctr_decrypt(ct, pt, length, &eax->ctr);
36 }
37
38 #endif
39