@@ -26,6 +26,7 @@ static int s_dsa_make_params(prng_state *prng, int wprng, int group_size, int mo
26
26
int err , res , mr_tests_q , mr_tests_p , found_p , found_q , hash ;
27
27
unsigned char * wbuf , * sbuf , digest [MAXBLOCKSIZE ];
28
28
void * t2L1 , * t2N1 , * t2q , * t2seedlen , * U , * W , * X , * c , * h , * e , * seedinc ;
29
+ const char * accepted_hashes [] = { "sha3-512" , "sha512" , "sha3-384" , "sha384" , "sha3-256" , "sha256" };
29
30
30
31
/* check size */
31
32
if (group_size >= LTC_MDSA_MAX_GROUP || group_size < 1 || group_size >= modulus_size ) {
@@ -88,15 +89,10 @@ static int s_dsa_make_params(prng_state *prng, int wprng, int group_size, int mo
88
89
#endif
89
90
90
91
hash = -1 ;
91
- #if defined(LTC_SHA3 )
92
- hash = register_hash (& sha3_512_desc );
93
- #elif defined(LTC_SHA512 )
94
- hash = register_hash (& sha512_desc );
95
- #elif defined(LTC_SHA384 )
96
- hash = register_hash (& sha384_desc );
97
- #elif defined(LTC_SHA256 )
98
- hash = register_hash (& sha256_desc );
99
- #endif
92
+ for (i = 0 ; i < sizeof (accepted_hashes )/sizeof (accepted_hashes [0 ]); ++ i ) {
93
+ hash = find_hash (accepted_hashes [i ]);
94
+ if (hash != -1 ) break ;
95
+ }
100
96
if (hash == -1 ) {
101
97
return CRYPT_INVALID_ARG ; /* no appropriate hash function found */
102
98
}
0 commit comments