Added blocking support for PKCS 7 with async. Fix for RSA async key gen in wolfCryp test.

This commit is contained in:
David Garske
2018-12-27 11:07:07 -08:00
parent 697c99a9ec
commit 5cb5b510ab
2 changed files with 52 additions and 7 deletions

View File

@@ -1342,9 +1342,19 @@ static int wc_PKCS7_RsaSign(PKCS7* pkcs7, byte* in, word32 inSz, ESD* esd)
} }
} }
if (ret == 0) { if (ret == 0) {
ret = wc_RsaSSL_Sign(in, inSz, esd->encContentDigest, #ifdef WOLFSSL_ASYNC_CRYPT
sizeof(esd->encContentDigest), do {
privKey, pkcs7->rng); ret = wc_AsyncWait(ret, &privKey->asyncDev,
WC_ASYNC_FLAG_CALL_AGAIN);
#endif
if (ret >= 0) {
ret = wc_RsaSSL_Sign(in, inSz, esd->encContentDigest,
sizeof(esd->encContentDigest),
privKey, pkcs7->rng);
}
#ifdef WOLFSSL_ASYNC_CRYPT
} while (ret == WC_PENDING_E);
#endif
} }
wc_FreeRsaKey(privKey); wc_FreeRsaKey(privKey);
@@ -1395,8 +1405,18 @@ static int wc_PKCS7_EcdsaSign(PKCS7* pkcs7, byte* in, word32 inSz, ESD* esd)
} }
if (ret == 0) { if (ret == 0) {
outSz = sizeof(esd->encContentDigest); outSz = sizeof(esd->encContentDigest);
ret = wc_ecc_sign_hash(in, inSz, esd->encContentDigest, #ifdef WOLFSSL_ASYNC_CRYPT
&outSz, pkcs7->rng, privKey); do {
ret = wc_AsyncWait(ret, &privKey->asyncDev,
WC_ASYNC_FLAG_CALL_AGAIN);
#endif
if (ret >= 0) {
ret = wc_ecc_sign_hash(in, inSz, esd->encContentDigest,
&outSz, pkcs7->rng, privKey);
}
#ifdef WOLFSSL_ASYNC_CRYPT
} while (ret == WC_PENDING_E);
#endif
if (ret == 0) if (ret == 0)
ret = (int)outSz; ret = (int)outSz;
} }
@@ -2771,7 +2791,18 @@ static int wc_PKCS7_RsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
continue; continue;
} }
ret = wc_RsaSSL_Verify(sig, sigSz, digest, MAX_PKCS7_DIGEST_SZ, key); #ifdef WOLFSSL_ASYNC_CRYPT
do {
ret = wc_AsyncWait(ret, &key->asyncDev,
WC_ASYNC_FLAG_CALL_AGAIN);
#endif
if (ret >= 0) {
ret = wc_RsaSSL_Verify(sig, sigSz, digest, MAX_PKCS7_DIGEST_SZ,
key);
}
#ifdef WOLFSSL_ASYNC_CRYPT
} while (ret == WC_PENDING_E);
#endif
FreeDecodedCert(dCert); FreeDecodedCert(dCert);
wc_FreeRsaKey(key); wc_FreeRsaKey(key);
@@ -2884,7 +2915,17 @@ static int wc_PKCS7_EcdsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
continue; continue;
} }
ret = wc_ecc_verify_hash(sig, sigSz, hash, hashSz, &res, key); #ifdef WOLFSSL_ASYNC_CRYPT
do {
ret = wc_AsyncWait(ret, &key->asyncDev,
WC_ASYNC_FLAG_CALL_AGAIN);
#endif
if (ret >= 0) {
ret = wc_ecc_verify_hash(sig, sigSz, hash, hashSz, &res, key);
}
#ifdef WOLFSSL_ASYNC_CRYPT
} while (ret == WC_PENDING_E);
#endif
FreeDecodedCert(dCert); FreeDecodedCert(dCert);
wc_ecc_free(key); wc_ecc_free(key);

View File

@@ -10738,7 +10738,11 @@ static int rsa_keygen_test(WC_RNG* rng)
if (ret != 0) { if (ret != 0) {
ERROR_OUT(-6962, exit_rsa); ERROR_OUT(-6962, exit_rsa);
} }
ret = wc_MakeRsaKey(&genKey, keySz, WC_RSA_EXPONENT, rng); ret = wc_MakeRsaKey(&genKey, keySz, WC_RSA_EXPONENT, rng);
#if defined(WOLFSSL_ASYNC_CRYPT)
ret = wc_AsyncWait(ret, &genKey.asyncDev, WC_ASYNC_FLAG_NONE);
#endif
if (ret != 0) { if (ret != 0) {
ERROR_OUT(-6963, exit_rsa); ERROR_OUT(-6963, exit_rsa);
} }