@@ -26,6 +26,7 @@ static int s_dsa_make_params(prng_state *prng, int wprng, int group_size, int mo
2626 int err , res , mr_tests_q , mr_tests_p , found_p , found_q , hash ;
2727 unsigned char * wbuf , * sbuf , digest [MAXBLOCKSIZE ];
2828 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" };
2930
3031 /* check size */
3132 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
8889#endif
8990
9091 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+ }
10096 if (hash == -1 ) {
10197 return CRYPT_INVALID_ARG ; /* no appropriate hash function found */
10298 }
0 commit comments