Skip to content

Commit 91e411b

Browse files
committed
Set RSA_MIN_SIZE default to 2048 bits
1 parent d4f6b5b commit 91e411b

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))
@@ -20294,7 +20297,8 @@ static int test_wc_MakeRsaKey(void)
2029420297
RsaKey genKey;
2029520298
WC_RNG rng;
2029620299
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
20297-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
20300+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
20301+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2029820302
int bits = 1024;
2029920303
#else
2030020304
int bits = 2048;
@@ -20695,7 +20699,8 @@ static int test_wc_RsaKeyToDer(void)
2069520699
WC_RNG rng;
2069620700
byte* der = NULL;
2069720701
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
20698-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
20702+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
20703+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2069920704
int bits = 1024;
2070020705
word32 derSz = 611;
2070120706
/* (2 x 128) + 2 (possible leading 00) + (5 x 64) + 5 (possible leading 00)
@@ -20749,7 +20754,8 @@ static int test_wc_RsaKeyToPublicDer(void)
2074920754
WC_RNG rng;
2075020755
byte* der = NULL;
2075120756
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
20752-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
20757+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
20758+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2075320759
int bits = 1024;
2075420760
word32 derLen = 162;
2075520761
#else
@@ -21013,7 +21019,8 @@ static int test_wc_RsaEncryptSize(void)
2101321019
ExpectIntEQ(wc_InitRng(&rng), 0);
2101421020

2101521021
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
21016-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
21022+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
21023+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2101721024
ExpectIntEQ(MAKE_RSA_KEY(&key, 1024, WC_RSA_EXPONENT, &rng), 0);
2101821025

2101921026
ExpectIntEQ(wc_RsaEncryptSize(&key), 128);
@@ -21047,7 +21054,8 @@ static int test_wc_RsaFlattenPublicKey(void)
2104721054
word32 eSz = sizeof(e);
2104821055
word32 nSz = sizeof(n);
2104921056
#if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
21050-
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4))
21057+
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \
21058+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2105121059
int bits = 1024;
2105221060
#else
2105321061
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
@@ -20891,7 +20891,8 @@ static wc_test_ret_t rsa_keygen_test(WC_RNG* rng)
2089120891
word32 idx = 0;
2089220892
#endif
2089320893
int derSz = 0;
20894-
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FIPS)
20894+
#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FIPS) && \
20895+
(defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024))
2089520896
int keySz = 1024;
2089620897
#else
2089720898
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)