From 342a10cc14c9689929f39ab89cbad3385178923e Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 21 Sep 2017 13:52:17 +0200 Subject: [PATCH] make PK_MAX_RETRIES a config option --- src/headers/tomcrypt_custom.h | 5 +++++ src/headers/tomcrypt_pk.h | 3 --- src/misc/crypt/crypt.c | 5 ++++- src/pk/dh/dh_generate_key.c | 2 +- src/pk/ecc/ecc_sign_hash.c | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/headers/tomcrypt_custom.h b/src/headers/tomcrypt_custom.h index c657553..e1de248 100644 --- a/src/headers/tomcrypt_custom.h +++ b/src/headers/tomcrypt_custom.h @@ -500,6 +500,11 @@ #if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(LTC_MKAT) /* Include the MPI functionality? (required by the PK algorithms) */ #define LTC_MPI + + #ifndef LTC_PK_MAX_RETRIES + /* iterations limit for retry-loops */ + #define LTC_PK_MAX_RETRIES 20 + #endif #endif #ifdef LTC_MRSA diff --git a/src/headers/tomcrypt_pk.h b/src/headers/tomcrypt_pk.h index 802c244..9f04f38 100644 --- a/src/headers/tomcrypt_pk.h +++ b/src/headers/tomcrypt_pk.h @@ -17,9 +17,6 @@ enum { /* Indicates standard output formats that can be read e.g. by OpenSSL or GnuTLS */ #define PK_STD 0x1000 -/* iterations limit for retry-loops */ -#define PK_MAX_RETRIES 20 - int rand_prime(void *N, long len, prng_state *prng, int wprng); #ifdef LTC_SOURCE diff --git a/src/misc/crypt/crypt.c b/src/misc/crypt/crypt.c index dd41df8..4ab6275 100644 --- a/src/misc/crypt/crypt.c +++ b/src/misc/crypt/crypt.c @@ -301,7 +301,7 @@ const char *crypt_build_settings = " SOBER128\n" #endif - "\nPK Algs:\n" + "\nPK Crypto:\n" #if defined(LTC_MRSA) " RSA" #if defined(LTC_RSA_BLINDING) && defined(LTC_RSA_CRT_HARDENING) @@ -329,6 +329,9 @@ const char *crypt_build_settings = #if defined(LTC_MKAT) " Katja\n" #endif +#if defined(LTC_PK_MAX_RETRIES) + " "NAME_VALUE(LTC_PK_MAX_RETRIES)"\n" +#endif "\nMPI (Math):\n" #if defined(LTC_MPI) diff --git a/src/pk/dh/dh_generate_key.c b/src/pk/dh/dh_generate_key.c index f128fd8..69fb6f9 100644 --- a/src/pk/dh/dh_generate_key.c +++ b/src/pk/dh/dh_generate_key.c @@ -46,7 +46,7 @@ int dh_generate_key(prng_state *prng, int wprng, dh_key *key) { unsigned char *buf; unsigned long keysize; - int err, max_iterations = PK_MAX_RETRIES; + int err, max_iterations = LTC_PK_MAX_RETRIES; LTC_ARGCHK(key != NULL); LTC_ARGCHK(ltc_mp.name != NULL); diff --git a/src/pk/ecc/ecc_sign_hash.c b/src/pk/ecc/ecc_sign_hash.c index e97dcf4..46cdfa3 100644 --- a/src/pk/ecc/ecc_sign_hash.c +++ b/src/pk/ecc/ecc_sign_hash.c @@ -22,7 +22,7 @@ static int _ecc_sign_hash(const unsigned char *in, unsigned long inlen, { ecc_key pubkey; void *r, *s, *e, *p; - int err, max_iterations = PK_MAX_RETRIES; + int err, max_iterations = LTC_PK_MAX_RETRIES; unsigned long pbits, pbytes, i, shift_right; unsigned char ch, buf[MAXBLOCKSIZE];