comparison libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.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 pkcs_1_mgf1.c 12 @file pkcs_1_mgf1.c
15 The Mask Generation Function (MGF1) for LTC_PKCS #1, Tom St Denis 13 The Mask Generation Function (MGF1) for PKCS #1, Tom St Denis
16 */ 14 */
17 15
18 #ifdef LTC_PKCS_1 16 #ifdef LTC_PKCS_1
19 17
20 /** 18 /**
21 Perform LTC_PKCS #1 MGF1 (internal) 19 Perform PKCS #1 MGF1 (internal)
20 @param hash_idx The index of the hash desired
22 @param seed The seed for MGF1 21 @param seed The seed for MGF1
23 @param seedlen The length of the seed 22 @param seedlen The length of the seed
24 @param hash_idx The index of the hash desired
25 @param mask [out] The destination 23 @param mask [out] The destination
26 @param masklen The length of the mask desired 24 @param masklen The length of the mask desired
27 @return CRYPT_OK if successful 25 @return CRYPT_OK if successful
28 */ 26 */
29 int pkcs_1_mgf1(int hash_idx, 27 int pkcs_1_mgf1(int hash_idx,
33 unsigned long hLen, x; 31 unsigned long hLen, x;
34 ulong32 counter; 32 ulong32 counter;
35 int err; 33 int err;
36 hash_state *md; 34 hash_state *md;
37 unsigned char *buf; 35 unsigned char *buf;
38 36
39 LTC_ARGCHK(seed != NULL); 37 LTC_ARGCHK(seed != NULL);
40 LTC_ARGCHK(mask != NULL); 38 LTC_ARGCHK(mask != NULL);
41 39
42 /* ensure valid hash */ 40 /* ensure valid hash */
43 if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { 41 if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
44 return err; 42 return err;
45 } 43 }
46 44
47 /* get hash output size */ 45 /* get hash output size */
48 hLen = hash_descriptor[hash_idx].hashsize; 46 hLen = hash_descriptor[hash_idx].hashsize;
101 return err; 99 return err;
102 } 100 }
103 101
104 #endif /* LTC_PKCS_1 */ 102 #endif /* LTC_PKCS_1 */
105 103
106 /* $Source$ */ 104 /* ref: $Format:%D$ */
107 /* $Revision$ */ 105 /* git commit: $Format:%H$ */
108 /* $Date$ */ 106 /* commit time: $Format:%ai$ */