Skip to content

Commit 9a07c42

Browse files
committed
DSA gen params: fixed check group_size vs LTC_MDSA_MAX_GROUP, updated LTC_MDSA_DELTA, new LTC_MDSA_MAX_MODULUS
1 parent 4bcb2c1 commit 9a07c42

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/headers/tomcrypt_pk.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,14 @@ int x25519_shared_secret(const curve25519_key *private_key,
384384

385385
#ifdef LTC_MDSA
386386

387-
/* Max diff between group and modulus size in bytes */
388-
#define LTC_MDSA_DELTA 512
387+
/* Max diff between group and modulus size in bytes (max case: L=8192bits, N=256bits) */
388+
#define LTC_MDSA_DELTA 992
389389

390-
/* Max DSA group size in bytes (default allows 4k-bit groups) */
391-
#define LTC_MDSA_MAX_GROUP 512
390+
/* Max DSA group size in bytes */
391+
#define LTC_MDSA_MAX_GROUP 64
392+
393+
/* Max DSA modulus size in bytes (the actual DSA size, max 8192 bits) */
394+
#define LTC_MDSA_MAX_MODULUS 1024
392395

393396
/** DSA key structure */
394397
typedef struct {

src/misc/crypt/crypt_constants.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ static const crypt_constant s_crypt_constants[] = {
102102
{"LTC_MDSA", 1},
103103
C_STRINGIFY(LTC_MDSA_DELTA),
104104
C_STRINGIFY(LTC_MDSA_MAX_GROUP),
105+
C_STRINGIFY(LTC_MDSA_MAX_MODULUS),
105106
#else
106107
{"LTC_MDSA", 0},
107108
#endif

src/pk/dsa/dsa_generate_pqg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int s_dsa_make_params(prng_state *prng, int wprng, int group_size, int mo
2929
const char *accepted_hashes[] = { "sha3-512", "sha512", "sha3-384", "sha384", "sha3-256", "sha256" };
3030

3131
/* check size */
32-
if (group_size >= LTC_MDSA_MAX_GROUP || group_size < 1 || group_size >= modulus_size) {
32+
if (group_size > LTC_MDSA_MAX_GROUP || group_size < 1 || group_size >= modulus_size || modulus_size > LTC_MDSA_MAX_MODULUS) {
3333
return CRYPT_INVALID_ARG;
3434
}
3535

0 commit comments

Comments
 (0)