1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4
5 /**
6 @file lrw_encrypt.c
7 LRW_MODE implementation, Encrypt blocks, Tom St Denis
8 */
9
10 #ifdef LTC_LRW_MODE
11
12 /**
13 LRW encrypt blocks
14 @param pt The plaintext
15 @param ct [out] The ciphertext
16 @param len The length in octets, must be a multiple of 16
17 @param lrw The LRW state
18 */
lrw_encrypt(const unsigned char * pt,unsigned char * ct,unsigned long len,symmetric_LRW * lrw)19 int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw)
20 {
21 int err;
22
23 LTC_ARGCHK(pt != NULL);
24 LTC_ARGCHK(ct != NULL);
25 LTC_ARGCHK(lrw != NULL);
26
27 if ((err = cipher_is_valid(lrw->cipher)) != CRYPT_OK) {
28 return err;
29 }
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
35 return lrw_process(pt, ct, len, LRW_ENCRYPT, lrw);
36 }
37
38
39 #endif
40