diff --git a/.github/workflows/no-malloc.yml b/.github/workflows/no-malloc.yml index db9a09d19..d3ba9b2d2 100644 --- a/.github/workflows/no-malloc.yml +++ b/.github/workflows/no-malloc.yml @@ -18,7 +18,7 @@ jobs: matrix: config: [ # Add new configs here - '--enable-rsa --enable-keygen --disable-dh CFLAGS="-DWOLFSSL_NO_MALLOC"', + '--enable-rsa --enable-keygen --disable-dh CFLAGS="-DWOLFSSL_NO_MALLOC -DRSA_MIN_SIZE=1024"', ] name: make check runs-on: ubuntu-latest diff --git a/.github/workflows/openssh.yml b/.github/workflows/openssh.yml index d54cec184..3e717af01 100644 --- a/.github/workflows/openssh.yml +++ b/.github/workflows/openssh.yml @@ -26,7 +26,7 @@ jobs: path: wolfssl configure: >- --enable-openssh --enable-dsa --with-max-rsa-bits=8192 - --enable-intelasm --enable-sp-asm + --enable-intelasm --enable-sp-asm CFLAGS="-DRSA_MIN_SIZE=1024" install: true - name: tar build-dir diff --git a/tests/api.c b/tests/api.c index d647e5fa1..27069e581 100644 --- a/tests/api.c +++ b/tests/api.c @@ -565,13 +565,16 @@ int tmpDirNameSet = 0; #define TEST_STRING "Everyone gets Friday off." #define TEST_STRING_SZ 25 +#ifndef NO_RSA #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \ + (defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024)) #define TEST_RSA_BITS 1024 #else #define TEST_RSA_BITS 2048 #endif #define TEST_RSA_BYTES (TEST_RSA_BITS/8) +#endif /* !NO_RSA */ #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && \ (!defined(NO_WOLFSSL_SERVER) || !defined(NO_WOLFSSL_CLIENT)) @@ -20564,7 +20567,8 @@ static int test_wc_MakeRsaKey(void) RsaKey genKey; WC_RNG rng; #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \ + (defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024)) int bits = 1024; #else int bits = 2048; @@ -20965,7 +20969,8 @@ static int test_wc_RsaKeyToDer(void) WC_RNG rng; byte* der = NULL; #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \ + (defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024)) int bits = 1024; word32 derSz = 611; /* (2 x 128) + 2 (possible leading 00) + (5 x 64) + 5 (possible leading 00) @@ -21019,7 +21024,8 @@ static int test_wc_RsaKeyToPublicDer(void) WC_RNG rng; byte* der = NULL; #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \ + (defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024)) int bits = 1024; word32 derLen = 162; #else @@ -21283,7 +21289,8 @@ static int test_wc_RsaEncryptSize(void) ExpectIntEQ(wc_InitRng(&rng), 0); #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \ + (defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024)) ExpectIntEQ(MAKE_RSA_KEY(&key, 1024, WC_RSA_EXPONENT, &rng), 0); ExpectIntEQ(wc_RsaEncryptSize(&key), 128); @@ -21317,7 +21324,8 @@ static int test_wc_RsaFlattenPublicKey(void) word32 eSz = sizeof(e); word32 nSz = sizeof(n); #if (!defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \ - (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) + (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 4)) && \ + (defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024)) int bits = 1024; #else int bits = 2048; diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index d018e05b2..fd65b89ac 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -8433,7 +8433,8 @@ exit: void bench_rsaKeyGen(int useDeviceID) { int k; -#if !defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL) +#if !defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL) && \ + (RSA_MIN_SIZE <= 1024) static const word32 keySizes[2] = {1024, 2048}; #else static const word32 keySizes[1] = {2048}; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index d79fb2716..d45bbc983 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -21000,7 +21000,8 @@ static wc_test_ret_t rsa_keygen_test(WC_RNG* rng) word32 idx = 0; #endif int derSz = 0; -#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FIPS) +#if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_FIPS) && \ + (defined(RSA_MIN_SIZE) && (RSA_MIN_SIZE <= 1024)) int keySz = 1024; #else int keySz = 2048; diff --git a/wolfssl/wolfcrypt/rsa.h b/wolfssl/wolfcrypt/rsa.h index 1f9f0222a..776533398 100644 --- a/wolfssl/wolfcrypt/rsa.h +++ b/wolfssl/wolfcrypt/rsa.h @@ -103,7 +103,7 @@ RSA keys can be used to encrypt, decrypt, sign and verify data. #endif #ifndef RSA_MIN_SIZE -#define RSA_MIN_SIZE 1024 +#define RSA_MIN_SIZE 2048 #endif #ifndef RSA_MAX_SIZE