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:
David Garske
2016-06-21 14:06:02 -07:00
parent 5fa80a2667
commit aa1a405dd1
6 changed files with 46 additions and 31 deletions
+5 -14
View File
@@ -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;