Path: blob/master/libs/tomcrypt/src/encauth/eax/eax_encrypt.c
5972 views
/* LibTomCrypt, modular cryptographic library -- Tom St Denis1*2* LibTomCrypt is a library that provides various cryptographic3* algorithms in a highly modular and flexible manner.4*5* The library is free for all purposes without any express6* guarantee it works.7*/89/**10@file eax_encrypt.c11EAX implementation, encrypt block by Tom St Denis12*/13#include "tomcrypt.h"1415#ifdef LTC_EAX_MODE1617/**18Encrypt with EAX a block of data.19@param eax The EAX state20@param pt The plaintext to encrypt21@param ct [out] The ciphertext as encrypted22@param length The length of the plaintext (octets)23@return CRYPT_OK if successful24*/25int eax_encrypt(eax_state *eax, const unsigned char *pt, unsigned char *ct,26unsigned long length)27{28int err;2930LTC_ARGCHK(eax != NULL);31LTC_ARGCHK(pt != NULL);32LTC_ARGCHK(ct != NULL);3334/* encrypt */35if ((err = ctr_encrypt(pt, ct, length, &eax->ctr)) != CRYPT_OK) {36return err;37}3839/* omac ciphertext */40return omac_process(&eax->ctomac, ct, length);41}4243#endif444546