mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
Added blocking support for PKCS 7 with async. Fix for RSA async key gen in wolfCryp test.
This commit is contained in:
@@ -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);
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user