]> pd.if.org Git - zpackage/blob - libtomcrypt/src/modes/lrw/lrw_decrypt.c
remove gmp math descriptor
[zpackage] / libtomcrypt / src / modes / lrw / lrw_decrypt.c
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.h"
10
11 /**
12    @file lrw_decrypt.c
13    LRW_MODE implementation, Decrypt blocks, Tom St Denis
14 */
15
16 #ifdef LTC_LRW_MODE
17
18 /**
19   LRW decrypt blocks
20   @param ct     The ciphertext
21   @param pt     [out] The plaintext
22   @param len    The length in octets, must be a multiple of 16
23   @param lrw    The LRW state
24 */
25 int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw)
26 {
27    int err;
28
29    LTC_ARGCHK(pt  != NULL);
30    LTC_ARGCHK(ct  != NULL);
31    LTC_ARGCHK(lrw != NULL);
32
33    if ((err = cipher_is_valid(lrw->cipher)) != CRYPT_OK) {
34       return err;
35    }
36
37    if (cipher_descriptor[lrw->cipher].accel_lrw_decrypt != NULL) {
38       return cipher_descriptor[lrw->cipher].accel_lrw_decrypt(ct, pt, len, lrw->IV, lrw->tweak, &lrw->key);
39    }
40
41    return lrw_process(ct, pt, len, LRW_DECRYPT, lrw);
42 }
43
44
45 #endif
46
47 /* ref:         $Format:%D$ */
48 /* git commit:  $Format:%H$ */
49 /* commit time: $Format:%ai$ */