]> pd.if.org Git - zpackage/blob - libtomcrypt/src/encauth/eax/eax_encrypt.c
initial cleanup of unused parts of ltc
[zpackage] / libtomcrypt / src / encauth / eax / eax_encrypt.c
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2  *
3  * LibTomCrypt is a library that provides various cryptographic
4  * algorithms in a highly modular and flexible manner.
5  *
6  * The library is free for all purposes without any express
7  * guarantee it works.
8  */
9
10 /**
11    @file eax_encrypt.c
12    EAX implementation, encrypt block by Tom St Denis
13 */
14 #include "tomcrypt.h"
15
16 #ifdef LTC_EAX_MODE
17
18 /**
19    Encrypt with EAX a block of data.
20    @param eax        The EAX state
21    @param pt         The plaintext to encrypt
22    @param ct         [out] The ciphertext as encrypted
23    @param length     The length of the plaintext (octets)
24    @return CRYPT_OK if successful
25 */
26 int eax_encrypt(eax_state *eax, const unsigned char *pt, unsigned char *ct,
27                 unsigned long length)
28 {
29    int err;
30
31    LTC_ARGCHK(eax != NULL);
32    LTC_ARGCHK(pt  != NULL);
33    LTC_ARGCHK(ct  != NULL);
34
35    /* encrypt */
36    if ((err = ctr_encrypt(pt, ct, length, &eax->ctr)) != CRYPT_OK) {
37       return err;
38    }
39
40    /* omac ciphertext */
41    return omac_process(&eax->ctomac, ct, length);
42 }
43
44 #endif
45
46
47 /* ref:         $Format:%D$ */
48 /* git commit:  $Format:%H$ */
49 /* commit time: $Format:%ai$ */