Parcourir la source

fix dependency to sha2

DSA had a hard dependency to the basic sha2 operations.
In case one wanted to compile e.g. only with sha256 this lead to a
compilation error.
Steffen Jaeckel il y a 5 ans
Parent
commit
96c72ec31e
1 fichiers modifiés avec 11 ajouts et 4 suppressions
  1. 11 4
      src/pk/dsa/dsa_generate_pqg.c

+ 11 - 4
src/pk/dsa/dsa_generate_pqg.c

@@ -87,17 +87,24 @@ static int s_dsa_make_params(prng_state *prng, int wprng, int group_size, int mo
   else                { mr_tests_q = 64; }
 #endif
 
+  hash = -1;
+#ifdef LTC_SHA256
   if (N <= 256) {
     hash = register_hash(&sha256_desc);
   }
-  else if (N <= 384) {
+#endif
+#ifdef LTC_SHA384
+  if ((N <= 384) && (hash == -1)) {
     hash = register_hash(&sha384_desc);
   }
-  else if (N <= 512) {
+#endif
+#ifdef LTC_SHA512
+  if ((N <= 512) && (hash == -1)) {
     hash = register_hash(&sha512_desc);
   }
-  else {
-    return CRYPT_INVALID_ARG; /* group_size too big */
+#endif
+  if (hash == -1) {
+    return CRYPT_INVALID_ARG; /* group_size too big or no appropriate hash function found */
   }
 
   if ((err = hash_is_valid(hash)) != CRYPT_OK)                                   { return err; }