Merge pull request #4587 from SparkiDev/dis_algs_fix_1

Disable algorithms: fixes
This commit is contained in:
David Garske
2021-12-19 20:12:30 -08:00
committed by GitHub
6 changed files with 76 additions and 8 deletions

View File

@ -5944,6 +5944,14 @@ if test "$ENABLED_SP_NONBLOCK" = "yes"; then
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_SP_NONBLOCK"
fi
# Check that we enable SP with RSA, DH or ECC.
if test "$ENABLED_SP" = "no"; then
# Didn't need SP, don't need SP_MATH.
if test "$ENABLED_SP_MATH" = "yes"; then
ENABLED_SP_MATH=no
fi
fi
if test "$ENABLED_SP_MATH" = "yes"; then
if test "$ENABLED_SP" = "no"; then
AC_MSG_ERROR([Must have SP enabled: --enable-sp])

View File

@ -20291,7 +20291,7 @@ static int test_wc_DsaSignVerify (void)
mp_init(&key.q);
AssertIntEQ(wc_DsaSign(hash, signature, &key, &rng), BAD_FUNC_ARG);
mp_set_int(&key.q, 1);
mp_set(&key.q, 1);
AssertIntEQ(wc_DsaSign(hash, signature, &key, &rng), BAD_FUNC_ARG);
#endif
@ -47962,7 +47962,8 @@ static int test_get_digit_count (void)
static int test_mp_cond_copy (void)
{
int ret = 0;
#if defined(WOLFSSL_PUBLIC_MP)
#if (defined(HAVE_ECC) || defined(WOLFSSL_MP_COND_COPY)) && \
defined(WOLFSSL_PUBLIC_MP)
mp_int a;
mp_int b;
int copy = 0;
@ -48102,7 +48103,8 @@ static int test_get_digit (void)
static int test_wc_export_int(void)
{
int ret = 0;
#if defined(WOLFSSL_PUBLIC_MP)
#if (defined(HAVE_ECC) || defined(WOLFSSL_EXPORT_INT)) && \
defined(WOLFSSL_PUBLIC_MP)
mp_int mp;
byte buf[32];
word32 keySz = (word32)sizeof(buf);
@ -48114,7 +48116,7 @@ static int test_wc_export_int(void)
ret = -1;
}
if (ret == 0) {
ret = mp_set_int(&mp, 1234);
ret = mp_set(&mp, 1234);
}
if (ret == 0) {
ret = wc_export_int(NULL, buf, &len, keySz, WC_TYPE_UNSIGNED_BIN);

View File

@ -4500,7 +4500,7 @@ int mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
#if defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) || defined(HAVE_ECC) || \
defined(DEBUG_WOLFSSL) || !defined(NO_RSA) || !defined(NO_DSA) || \
!defined(NO_DH)
!defined(NO_DH) || defined(WC_MP_TO_RADIX)
static const int lnz[16] = {
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
@ -5208,7 +5208,7 @@ LBL_U:mp_clear (&u);
#if !defined(NO_DSA) || defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || \
defined(HAVE_COMP_KEY) || defined(WOLFSSL_DEBUG_MATH) || \
defined(DEBUG_WOLFSSL) || defined(OPENSSL_EXTRA)
defined(DEBUG_WOLFSSL) || defined(OPENSSL_EXTRA) || defined(WC_MP_TO_RADIX)
/* chars used in radix conversions */
const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

View File

@ -2633,7 +2633,7 @@ int sp_cmp_mag(sp_int* a, sp_int* b)
#endif
#if defined(WOLFSSL_SP_MATH_ALL) || defined(HAVE_ECC) || !defined(NO_DSA) || \
defined(OPENSSL_EXTRA) || \
defined(OPENSSL_EXTRA) || !defined(NO_DH) || \
(!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY))
/* Compare two multi-precision numbers.
*
@ -2674,7 +2674,8 @@ static int _sp_cmp(sp_int* a, sp_int* b)
}
#endif
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) || defined(HAVE_ECC)
#if (!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY)) || \
!defined(NO_DSA) || defined(HAVE_ECC) || !defined(NO_DH)
/* Compare two multi-precision numbers.
*
* Pointers are compared such that NULL is less than not NULL.

View File

@ -16681,6 +16681,7 @@ WOLFSSL_TEST_SUBROUTINE int dh_test(void)
}
#ifdef NO_ASN
#ifndef WOLFSSL_SP_MATH
ret = wc_DhSetKey(key, dh_p, sizeof(dh_p), dh_g, sizeof(dh_g));
if (ret != 0) {
ERROR_OUT(-8106, done);
@ -16690,6 +16691,19 @@ WOLFSSL_TEST_SUBROUTINE int dh_test(void)
if (ret != 0) {
ERROR_OUT(-8107, done);
}
#else
ret = wc_DhSetKey(key, dh2048_p, sizeof(dh2048_p), dh2048_g,
sizeof(dh2048_g));
if (ret != 0) {
ERROR_OUT(-8106, done);
}
ret = wc_DhSetKey(key2, dh2048_p, sizeof(dh2048_p), dh2048_g,
sizeof(dh2048_g));
if (ret != 0) {
ERROR_OUT(-8107, done);
}
#endif
#else
ret = wc_DhKeyDecode(tmp, &idx, key, bytes);
if (ret != 0) {

View File

@ -4640,6 +4640,49 @@ static const unsigned char dh_g[] =
0x02,
};
/* dh2048 p */
static const unsigned char dh2048_p[] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xAD, 0xF8, 0x54, 0x58, 0xA2, 0xBB, 0x4A, 0x9A,
0xAF, 0xDC, 0x56, 0x20, 0x27, 0x3D, 0x3C, 0xF1,
0xD8, 0xB9, 0xC5, 0x83, 0xCE, 0x2D, 0x36, 0x95,
0xA9, 0xE1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xFB,
0xCC, 0x93, 0x9D, 0xCE, 0x24, 0x9B, 0x3E, 0xF9,
0x7D, 0x2F, 0xE3, 0x63, 0x63, 0x0C, 0x75, 0xD8,
0xF6, 0x81, 0xB2, 0x02, 0xAE, 0xC4, 0x61, 0x7A,
0xD3, 0xDF, 0x1E, 0xD5, 0xD5, 0xFD, 0x65, 0x61,
0x24, 0x33, 0xF5, 0x1F, 0x5F, 0x06, 0x6E, 0xD0,
0x85, 0x63, 0x65, 0x55, 0x3D, 0xED, 0x1A, 0xF3,
0xB5, 0x57, 0x13, 0x5E, 0x7F, 0x57, 0xC9, 0x35,
0x98, 0x4F, 0x0C, 0x70, 0xE0, 0xE6, 0x8B, 0x77,
0xE2, 0xA6, 0x89, 0xDA, 0xF3, 0xEF, 0xE8, 0x72,
0x1D, 0xF1, 0x58, 0xA1, 0x36, 0xAD, 0xE7, 0x35,
0x30, 0xAC, 0xCA, 0x4F, 0x48, 0x3A, 0x79, 0x7A,
0xBC, 0x0A, 0xB1, 0x82, 0xB3, 0x24, 0xFB, 0x61,
0xD1, 0x08, 0xA9, 0x4B, 0xB2, 0xC8, 0xE3, 0xFB,
0xB9, 0x6A, 0xDA, 0xB7, 0x60, 0xD7, 0xF4, 0x68,
0x1D, 0x4F, 0x42, 0xA3, 0xDE, 0x39, 0x4D, 0xF4,
0xAE, 0x56, 0xED, 0xE7, 0x63, 0x72, 0xBB, 0x19,
0x0B, 0x07, 0xA7, 0xC8, 0xEE, 0x0A, 0x6D, 0x70,
0x9E, 0x02, 0xFC, 0xE1, 0xCD, 0xF7, 0xE2, 0xEC,
0xC0, 0x34, 0x04, 0xCD, 0x28, 0x34, 0x2F, 0x61,
0x91, 0x72, 0xFE, 0x9C, 0xE9, 0x85, 0x83, 0xFF,
0x8E, 0x4F, 0x12, 0x32, 0xEE, 0xF2, 0x81, 0x83,
0xC3, 0xFE, 0x3B, 0x1B, 0x4C, 0x6F, 0xAD, 0x73,
0x3B, 0xB5, 0xFC, 0xBC, 0x2E, 0xC2, 0x20, 0x05,
0xC5, 0x8E, 0xF1, 0x83, 0x7D, 0x16, 0x83, 0xB2,
0xC6, 0xF3, 0x4A, 0x26, 0xC1, 0xB2, 0xEF, 0xFA,
0x88, 0x6B, 0x42, 0x38, 0x61, 0x28, 0x5C, 0x97,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
/* dh2048 g */
static const unsigned char dh2048_g[] =
{
0x02,
};
#if defined(HAVE_ED25519)
/* ./certs/ed25519/server-ed25519.der, ED25519 */