lrw_encrypt.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include "tomcrypt_private.h"
  10. /**
  11. @file lrw_encrypt.c
  12. LRW_MODE implementation, Encrypt blocks, Tom St Denis
  13. */
  14. #ifdef LTC_LRW_MODE
  15. /**
  16. LRW encrypt blocks
  17. @param pt The plaintext
  18. @param ct [out] The ciphertext
  19. @param len The length in octets, must be a multiple of 16
  20. @param lrw The LRW state
  21. */
  22. int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw)
  23. {
  24. int err;
  25. LTC_ARGCHK(pt != NULL);
  26. LTC_ARGCHK(ct != NULL);
  27. LTC_ARGCHK(lrw != NULL);
  28. if ((err = cipher_is_valid(lrw->cipher)) != CRYPT_OK) {
  29. return err;
  30. }
  31. if (cipher_descriptor[lrw->cipher].accel_lrw_encrypt != NULL) {
  32. return cipher_descriptor[lrw->cipher].accel_lrw_encrypt(pt, ct, len, lrw->IV, lrw->tweak, &lrw->key);
  33. }
  34. return lrw_process(pt, ct, len, LRW_ENCRYPT, lrw);
  35. }
  36. #endif
  37. /* ref: $Format:%D$ */
  38. /* git commit: $Format:%H$ */
  39. /* commit time: $Format:%ai$ */