mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-05-04 19:34:13 +02:00
Fixes for compressed keys. Fix to fast math "mp_cnt_lsb" to return proper value, which fixes "mp_jacobi", which fixes "mp_sqrtmod_prime", which fixes compressed keys for 224-bit key. Removed workarounds for compressed keys. Added new configure option "--enable-compkey". Fixed issue with normal math and custom curves where "t2" could be free'd and used. Fixed issue with mp_dump in integer.c, with not allocating correctly sized buffer for toradix.
This commit is contained in:
+5
-14
@@ -6675,7 +6675,7 @@ static int ecc_test_key_gen(WC_RNG* rng, int keySize)
|
||||
}
|
||||
#endif /* WOLFSSL_KEY_GEN */
|
||||
static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
int testCompressedKey, const ecc_set_type* dp)
|
||||
const ecc_set_type* dp)
|
||||
{
|
||||
#ifdef BENCH_EMBEDDED
|
||||
byte sharedA[128]; /* Needs to be at least keySize */
|
||||
@@ -6735,7 +6735,6 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
|
||||
#ifdef HAVE_ECC_KEY_EXPORT
|
||||
x = sizeof(exportBuf);
|
||||
|
||||
ret = wc_ecc_export_x963(&userA, exportBuf, &x);
|
||||
if (ret != 0)
|
||||
ERROR_OUT(-1006, done);
|
||||
@@ -6755,11 +6754,9 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
ERROR_OUT(-1009, done);
|
||||
#endif /* HAVE_ECC_DHE */
|
||||
|
||||
if (testCompressedKey) {
|
||||
#ifdef HAVE_COMP_KEY
|
||||
/* try compressed export / import too */
|
||||
x = sizeof(exportBuf);
|
||||
|
||||
ret = wc_ecc_export_x963_ex(&userA, exportBuf, &x, 1);
|
||||
if (ret != 0)
|
||||
ERROR_OUT(-1010, done);
|
||||
@@ -6780,7 +6777,7 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount,
|
||||
ERROR_OUT(-1013, done);
|
||||
#endif /* HAVE_ECC_DHE */
|
||||
#endif /* HAVE_COMP_KEY */
|
||||
}
|
||||
|
||||
#endif /* HAVE_ECC_KEY_IMPORT */
|
||||
#endif /* HAVE_ECC_KEY_EXPORT */
|
||||
|
||||
@@ -6850,15 +6847,9 @@ done:
|
||||
#define ECC_TEST_VERIFY_COUNT 2
|
||||
static int ecc_test_curve(WC_RNG* rng, int keySize)
|
||||
{
|
||||
int ret, testCompressedKey = 1;
|
||||
int ret;
|
||||
|
||||
/* At this time, ECC 224-bit does not work with compressed key */
|
||||
if (keySize == 28) {
|
||||
testCompressedKey = 0;
|
||||
}
|
||||
|
||||
ret = ecc_test_curve_size(rng, keySize, ECC_TEST_VERIFY_COUNT,
|
||||
testCompressedKey, NULL);
|
||||
ret = ecc_test_curve_size(rng, keySize, ECC_TEST_VERIFY_COUNT, NULL);
|
||||
if (ret < 0) {
|
||||
printf("ecc_test_curve_size %d failed!: %d\n", keySize, ret);
|
||||
return ret;
|
||||
@@ -6936,7 +6927,7 @@ int ecc_test(void)
|
||||
"8BD2AEB9CB7E57CB2C4B482FFC81B7AFB9DE27E1E3BD23C23A4453BD9ACE3262", /* Gx */
|
||||
"547EF835C3DAC4FD97F8461A14611DC9C27745132DED8E545C1D54C72F046997", /* Gy */
|
||||
};
|
||||
ret = ecc_test_curve_size(&rng, -1, ECC_TEST_VERIFY_COUNT, 0, &ecc_cust_dp);
|
||||
ret = ecc_test_curve_size(&rng, -1, ECC_TEST_VERIFY_COUNT, &ecc_cust_dp);
|
||||
if (ret < 0) {
|
||||
printf("ecc_test_curve_size custom failed!: %d\n", ret);
|
||||
goto done;
|
||||
|
||||
Reference in New Issue
Block a user