Merge pull request #792 from SparkiDev/valgrind

Fix valgrind issues
pull/793/head
toddouska 2017-03-14 13:50:26 -07:00 committed by GitHub
commit 7bef7aaa81
2 changed files with 35 additions and 2 deletions

View File

@ -2220,8 +2220,10 @@ int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
}
#endif /* OPENSSL_EXTRA */
if (GetInt(&key->n, input, inOutIdx, inSz) < 0 ||
GetInt(&key->e, input, inOutIdx, inSz) < 0) {
if (GetInt(&key->n, input, inOutIdx, inSz) < 0)
return ASN_RSA_KEY_E;
if (GetInt(&key->e, input, inOutIdx, inSz) < 0) {
mp_clear(&key->n);
return ASN_RSA_KEY_E;
}

View File

@ -5869,11 +5869,19 @@ static int rsa_decode_test(void)
ret = -525;
goto done;
}
wc_FreeRsaKey(&keyPub);
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
return -520;
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, -1, &keyPub);
if (ret != 0) {
ret = -526;
goto done;
}
wc_FreeRsaKey(&keyPub);
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
return -520;
/* Use API. */
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, sizeof(e), &keyPub);
@ -5881,6 +5889,10 @@ static int rsa_decode_test(void)
ret = -527;
goto done;
}
wc_FreeRsaKey(&keyPub);
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
return -520;
/* Parameter Validation testing. */
inSz = sizeof(good);
@ -5974,6 +5986,10 @@ static int rsa_decode_test(void)
goto done;
}
/* TODO: Shouldn't ignore object id's data. */
wc_FreeRsaKey(&keyPub);
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
return -520;
/* Valid data cases. */
inSz = sizeof(good);
@ -5987,6 +6003,10 @@ static int rsa_decode_test(void)
ret = -551;
goto done;
}
wc_FreeRsaKey(&keyPub);
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
return -520;
inSz = sizeof(goodAlgId);
inOutIdx = 0;
@ -5999,6 +6019,10 @@ static int rsa_decode_test(void)
ret = -553;
goto done;
}
wc_FreeRsaKey(&keyPub);
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
return -520;
inSz = sizeof(goodAlgIdNull);
inOutIdx = 0;
@ -6011,6 +6035,10 @@ static int rsa_decode_test(void)
ret = -555;
goto done;
}
wc_FreeRsaKey(&keyPub);
ret = wc_InitRsaKey(&keyPub, NULL);
if (ret != 0)
return -520;
inSz = sizeof(goodBitStrNoZero);
inOutIdx = 0;
@ -10260,6 +10288,9 @@ static int ecc_exp_imp_test(ecc_key* key)
goto done;
}
wc_ecc_free(&keyImp);
wc_ecc_init(&keyImp);
ret = wc_ecc_import_raw_ex(&keyImp, qx, qy, d, ECC_SECP256R1);
if (ret != 0) {
ret = -1073;