eax_encrypt.c 806 B

1234567891011121314151617181920212223242526272829303132333435
  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. * Tom St Denis, [email protected], http://libtomcrypt.org
  10. */
  11. /* EAX Implementation by Tom St Denis */
  12. #include "mycrypt.h"
  13. #ifdef EAX_MODE
  14. int eax_encrypt(eax_state *eax, const unsigned char *pt, unsigned char *ct, unsigned long length)
  15. {
  16. int err;
  17. _ARGCHK(eax != NULL);
  18. _ARGCHK(pt != NULL);
  19. _ARGCHK(ct != NULL);
  20. /* encrypt */
  21. if ((err = ctr_encrypt(pt, ct, length, &eax->ctr)) != CRYPT_OK) {
  22. return err;
  23. }
  24. /* omac ciphertext */
  25. return omac_process(&eax->ctomac, ct, length);
  26. }
  27. #endif