Mercurial > dropbear
comparison libtomcrypt/src/pk/katja/katja_decrypt_key.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file katja_decrypt_key.c | 12 @file katja_decrypt_key.c |
15 Katja LTC_PKCS #1 OAEP Decryption, Tom St Denis | 13 Katja PKCS #1 OAEP Decryption, Tom St Denis |
16 */ | 14 */ |
17 | 15 |
18 #ifdef MKAT | 16 #ifdef LTC_MKAT |
19 | 17 |
20 /** | 18 /** |
21 (LTC_PKCS #1 v2.0) decrypt then OAEP depad | 19 (PKCS #1 v2.0) decrypt then OAEP depad |
22 @param in The ciphertext | 20 @param in The ciphertext |
23 @param inlen The length of the ciphertext (octets) | 21 @param inlen The length of the ciphertext (octets) |
24 @param out [out] The plaintext | 22 @param out [out] The plaintext |
25 @param outlen [in/out] The max size and resulting size of the plaintext (octets) | 23 @param outlen [in/out] The max size and resulting size of the plaintext (octets) |
26 @param lparam The system "lparam" value | 24 @param lparam The system "lparam" value |
29 @param stat [out] Result of the decryption, 1==valid, 0==invalid | 27 @param stat [out] Result of the decryption, 1==valid, 0==invalid |
30 @param key The corresponding private Katja key | 28 @param key The corresponding private Katja key |
31 @return CRYPT_OK if succcessul (even if invalid) | 29 @return CRYPT_OK if succcessul (even if invalid) |
32 */ | 30 */ |
33 int katja_decrypt_key(const unsigned char *in, unsigned long inlen, | 31 int katja_decrypt_key(const unsigned char *in, unsigned long inlen, |
34 unsigned char *out, unsigned long *outlen, | 32 unsigned char *out, unsigned long *outlen, |
35 const unsigned char *lparam, unsigned long lparamlen, | 33 const unsigned char *lparam, unsigned long lparamlen, |
36 int hash_idx, int *stat, | 34 int hash_idx, int *stat, |
37 katja_key *key) | 35 katja_key *key) |
38 { | 36 { |
39 unsigned long modulus_bitlen, modulus_bytelen, x; | 37 unsigned long modulus_bitlen, modulus_bytelen, x; |
40 int err; | 38 int err; |
41 unsigned char *tmp; | 39 unsigned char *tmp; |
42 | 40 |
43 LTC_ARGCHK(out != NULL); | 41 LTC_ARGCHK(out != NULL); |
44 LTC_ARGCHK(outlen != NULL); | 42 LTC_ARGCHK(outlen != NULL); |
45 LTC_ARGCHK(key != NULL); | 43 LTC_ARGCHK(key != NULL); |
46 LTC_ARGCHK(stat != NULL); | 44 LTC_ARGCHK(stat != NULL); |
47 | 45 |
50 | 48 |
51 /* valid hash ? */ | 49 /* valid hash ? */ |
52 if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { | 50 if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { |
53 return err; | 51 return err; |
54 } | 52 } |
55 | 53 |
56 /* get modulus len in bits */ | 54 /* get modulus len in bits */ |
57 modulus_bitlen = mp_count_bits( (key->N)); | 55 modulus_bitlen = mp_count_bits( (key->N)); |
58 | 56 |
59 /* payload is upto pq, so we know q is 1/3rd the size of N and therefore pq is 2/3th the size */ | 57 /* payload is upto pq, so we know q is 1/3rd the size of N and therefore pq is 2/3th the size */ |
60 modulus_bitlen = ((modulus_bitlen << 1) / 3); | 58 modulus_bitlen = ((modulus_bitlen << 1) / 3); |
98 | 96 |
99 | 97 |
100 | 98 |
101 | 99 |
102 | 100 |
103 /* $Source$ */ | 101 /* ref: $Format:%D$ */ |
104 /* $Revision$ */ | 102 /* git commit: $Format:%H$ */ |
105 /* $Date$ */ | 103 /* commit time: $Format:%ai$ */ |