Skip to content

Commit 96c72ec

Browse files
sjaeckelkarel-m
authored andcommitted
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.
1 parent 077f4d6 commit 96c72ec

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/pk/dsa/dsa_generate_pqg.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,24 @@ static int s_dsa_make_params(prng_state *prng, int wprng, int group_size, int mo
8787
else { mr_tests_q = 64; }
8888
#endif
8989

90+
hash = -1;
91+
#ifdef LTC_SHA256
9092
if (N <= 256) {
9193
hash = register_hash(&sha256_desc);
9294
}
93-
else if (N <= 384) {
95+
#endif
96+
#ifdef LTC_SHA384
97+
if ((N <= 384) && (hash == -1)) {
9498
hash = register_hash(&sha384_desc);
9599
}
96-
else if (N <= 512) {
100+
#endif
101+
#ifdef LTC_SHA512
102+
if ((N <= 512) && (hash == -1)) {
97103
hash = register_hash(&sha512_desc);
98104
}
99-
else {
100-
return CRYPT_INVALID_ARG; /* group_size too big */
105+
#endif
106+
if (hash == -1) {
107+
return CRYPT_INVALID_ARG; /* group_size too big or no appropriate hash function found */
101108
}
102109

103110
if ((err = hash_is_valid(hash)) != CRYPT_OK) { return err; }

0 commit comments

Comments
 (0)