Merge pull request #1054 from jrblixt/fix-RsaSetRng

Fix rsa set rng
This commit is contained in:
Chris Conlon
2017-07-25 09:16:14 -06:00
committed by GitHub

View File

@@ -7167,7 +7167,7 @@ static int test_wc_RsaPublicKeyDecode (void)
*/ */
static int test_wc_RsaPublicKeyDecodeRaw (void) static int test_wc_RsaPublicKeyDecodeRaw (void)
{ {
#if !defined(NO_RSA) && !defined(HAVE_FIPS) #if !defined(NO_RSA)
RsaKey key; RsaKey key;
int ret; int ret;
const byte n = 0x23; const byte n = 0x23;
@@ -7365,7 +7365,7 @@ static int test_wc_SetKeyUsage (void)
*/ */
static int test_wc_RsaKeyToDer (void) static int test_wc_RsaKeyToDer (void)
{ {
#if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_FIPS) #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
RsaKey genKey; RsaKey genKey;
WC_RNG rng; WC_RNG rng;
byte* der; byte* der;
@@ -7459,7 +7459,7 @@ static int test_wc_RsaKeyToDer (void)
*/ */
static int test_wc_RsaKeyToPublicDer (void) static int test_wc_RsaKeyToPublicDer (void)
{ {
#if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_FIPS) #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
RsaKey key; RsaKey key;
WC_RNG rng; WC_RNG rng;
byte* der; byte* der;
@@ -7547,8 +7547,7 @@ static int test_wc_RsaKeyToPublicDer (void)
*/ */
static int test_wc_RsaPublicEncryptDecrypt (void) static int test_wc_RsaPublicEncryptDecrypt (void)
{ {
#if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)\ #if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
&& !defined(HAVE_FIPS)
RsaKey key; RsaKey key;
WC_RNG rng; WC_RNG rng;
const char* inStr = "Everyone gets Friday off."; const char* inStr = "Everyone gets Friday off.";
@@ -7587,10 +7586,12 @@ static int test_wc_RsaPublicEncryptDecrypt (void)
/* Decrypt */ /* Decrypt */
printf(testingFmt, "wc_RsaPrivateDecrypt()"); printf(testingFmt, "wc_RsaPrivateDecrypt()");
#if defined(WC_RSA_BLINDING)
/* Bind rng */ /* Bind rng */
if (ret == 0) { if (ret == 0) {
ret = wc_RsaSetRNG(&key, &rng); ret = wc_RsaSetRNG(&key, &rng);
} }
#endif
if (ret == 0) { if (ret == 0) {
ret = wc_RsaPrivateDecrypt(cipher, cipherLen, plain, plainLen, &key); ret = wc_RsaPrivateDecrypt(cipher, cipherLen, plain, plainLen, &key);
} }
@@ -7669,8 +7670,11 @@ static int test_wc_RsaPublicEncryptDecrypt_ex (void)
/* Decrypt */ /* Decrypt */
printf(testingFmt, "wc_RsaPrivateDecrypt_ex()"); printf(testingFmt, "wc_RsaPrivateDecrypt_ex()");
#if defined(WC_RSA_BLINDING)
if (ret == 0) { if (ret == 0) {
ret = wc_RsaSetRNG(&key, &rng); ret = wc_RsaSetRNG(&key, &rng);
}
#endif
if (ret == 0) { if (ret == 0) {
ret = wc_RsaPrivateDecrypt_ex(cipher, (word32)idx, ret = wc_RsaPrivateDecrypt_ex(cipher, (word32)idx,
plain, plainSz, &key, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, plain, plainSz, &key, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA,
@@ -7683,7 +7687,6 @@ static int test_wc_RsaPublicEncryptDecrypt_ex (void)
ret = SSL_FATAL_ERROR; ret = SSL_FATAL_ERROR;
} }
} }
}
/*Pass bad args.*/ /*Pass bad args.*/
/* Tests RsaPrivateDecryptEx() again. No need duplicate. */ /* Tests RsaPrivateDecryptEx() again. No need duplicate. */