eax_decrypt.c 806 B

12345678910111213141516171819202122232425262728293031323334
  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_decrypt(eax_state *eax, const unsigned char *ct, unsigned char *pt, unsigned long length)
  15. {
  16. int err;
  17. _ARGCHK(eax != NULL);
  18. _ARGCHK(pt != NULL);
  19. _ARGCHK(ct != NULL);
  20. /* omac ciphertext */
  21. if ((err = omac_process(&eax->ctomac, ct, length)) != CRYPT_OK) {
  22. return err;
  23. }
  24. /* decrypt */
  25. return ctr_decrypt(ct, pt, length, &eax->ctr);
  26. }
  27. #endif