Skip to content

Commit e6b466d

Browse files
authored
Merge pull request #7923 from embhorn/rsa2048_min
Set RSA_MIN_SIZE default to 2048 bits
2 parents 52030f1 + 91e411b commit e6b466d

6 files changed

Lines changed: 21 additions & 11 deletions

File tree

.github/workflows/no-malloc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
config: [
2020
# Add new configs here
21-
'--enable-rsa --enable-keygen --disable-dh CFLAGS="-DWOLFSSL_NO_MALLOC"',
21+
'--enable-rsa --enable-keygen --disable-dh CFLAGS="-DWOLFSSL_NO_MALLOC -DRSA_MIN_SIZE=1024"',
2222
]
2323
name: make check
2424
runs-on: ubuntu-latest

.github/workflows/openssh.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
path: wolfssl
2727
configure: >-
2828
--enable-openssh --enable-dsa --with-max-rsa-bits=8192
29-
--enable-intelasm --enable-sp-asm
29+
--enable-intelasm --enable-sp-asm CFLAGS="-DRSA_MIN_SIZE=1024"
3030
install: true
3131

3232
- name: tar build-dir

tests/api.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,16 @@ int tmpDirNameSet = 0;
565565
#define TEST_STRING "Everyone gets Friday off."
566566
#define TEST_STRING_SZ 25
567567

568+
#ifndef NO_RSA
568569
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
569-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
570+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
571+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
570572
#define TEST_RSA_BITS 1024
571573
#else
572574
#define TEST_RSA_BITS 2048
573575
#endif
574576
#define TEST_RSA_BYTES (TEST_RSA_BITS/8)
577+
#endif /* !NO_RSA */
575578

576579
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \
577580
(!defined(NO_WOLFSSL_SERVER) || !defined(NO_WOLFSSL_CLIENT))
@@ -20564,7 +20567,8 @@ static int test_wc_MakeRsaKey(void)
2056420567
RsaKey genKey;
2056520568
WC_RNG rng;
2056620569
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
20567-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
20570+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
20571+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2056820572
int bits = 1024;
2056920573
#else
2057020574
int bits = 2048;
@@ -20965,7 +20969,8 @@ static int test_wc_RsaKeyToDer(void)
2096520969
WC_RNG rng;
2096620970
byte* der = NULL;
2096720971
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
20968-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
20972+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
20973+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2096920974
int bits = 1024;
2097020975
word32 derSz = 611;
2097120976
/* (2 x 128) + 2 (possible leading 00) + (5 x 64) + 5 (possible leading 00)
@@ -21019,7 +21024,8 @@ static int test_wc_RsaKeyToPublicDer(void)
2101921024
WC_RNG rng;
2102021025
byte* der = NULL;
2102121026
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
21022-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
21027+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
21028+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2102321029
int bits = 1024;
2102421030
word32 derLen = 162;
2102521031
#else
@@ -21283,7 +21289,8 @@ static int test_wc_RsaEncryptSize(void)
2128321289
ExpectIntEQ(wc_InitRng(&rng), 0);
2128421290

2128521291
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
21286-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
21292+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
21293+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2128721294
ExpectIntEQ(MAKE_RSA_KEY(&key, 1024, WC_RSA_EXPONENT, &rng), 0);
2128821295

2128921296
ExpectIntEQ(wc_RsaEncryptSize(&key), 128);
@@ -21317,7 +21324,8 @@ static int test_wc_RsaFlattenPublicKey(void)
2131721324
word32 eSz = sizeof(e);
2131821325
word32 nSz = sizeof(n);
2131921326
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
21320-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
21327+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
21328+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2132121329
int bits = 1024;
2132221330
#else
2132321331
int bits = 2048;

wolfcrypt/benchmark/benchmark.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8433,7 +8433,8 @@ static void bench_rsaKeyGen_helper(int useDeviceID, word32 keySz)
84338433
void bench_rsaKeyGen(int useDeviceID)
84348434
{
84358435
int k;
8436-
#if !defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)
8436+
#if !defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL) && \
8437+
(RSA_MIN_SIZE <= 1024)
84378438
static const word32 keySizes[2] = {1024, 2048};
84388439
#else
84398440
static const word32 keySizes[1] = {2048};

wolfcrypt/test/test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21000,7 +21000,8 @@ static wc_test_ret_t rsa_keygen_test(WC_RNG* rng)
2100021000
word32 idx = 0;
2100121001
#endif
2100221002
int derSz = 0;
21003-
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FIPS)
21003+
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FIPS) && \
21004+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2100421005
int keySz = 1024;
2100521006
#else
2100621007
int keySz = 2048;

wolfssl/wolfcrypt/rsa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ RSA keys can be used to encrypt, decrypt, sign and verify data.
103103
#endif
104104

105105
#ifndef RSA_MIN_SIZE
106-
#define RSA_MIN_SIZE 1024
106+
#define RSA_MIN_SIZE 2048
107107
#endif
108108

109109
#ifndef RSA_MAX_SIZE

0 commit comments

Comments
 (0)