Merge pull request #421 from dgarske/cryptocb_nokey

Fix for crypto callback with no TPM key and update for WC_RNG getpid
master
Andrew Hutchings 2025-06-19 13:33:02 +01:00 committed by GitHub
commit 21d8604db9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 1 deletions

View File

@ -67,6 +67,7 @@ include(CheckFunctionExists)
check_function_exists("gethostbyname" HAVE_GETHOSTBYNAME)
check_function_exists("getaddrinfo" HAVE_GETADDRINFO)
check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
check_function_exists("getpid" HAVE_GETPID)

View File

@ -60,7 +60,7 @@ AC_CHECK_SIZEOF([long], 4)
# Check headers/libs
AC_CHECK_HEADERS([netdb.h])
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday inet_ntoa memset socket])
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday inet_ntoa memset socket getpid])
AC_CHECK_LIB([network],[socket])
# Thread local storage

View File

@ -120,6 +120,14 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
#endif
rc = exit_rc;
}
else if (info->pk.type == WC_PK_TYPE_RSA_GET_SIZE) {
if (tlsCtx->rsaKey != NULL) {
*info->pk.rsa_get_size.keySize =
tlsCtx->rsaKey->pub.publicArea.parameters.rsaDetail.keyBits
/ 8;
rc = 0;
}
}
else if (info->pk.type == WC_PK_TYPE_RSA) {
switch (info->pk.rsa.type) {
case RSA_PUBLIC_ENCRYPT:
@ -153,6 +161,11 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
case RSA_PRIVATE_DECRYPT:
{
/* private operations */
if (tlsCtx->rsaKey == NULL) {
/* TPM key not setup, fallback to software */
rc = exit_rc;
break;
}
rc = wolfTPM2_RsaDecrypt(tlsCtx->dev, tlsCtx->rsaKey,
TPM_ALG_NULL, /* no padding */
info->pk.rsa.in, info->pk.rsa.inLen,
@ -237,6 +250,11 @@ int wolfTPM2_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
word32 rsLen = sizeof(sigRS), keySz;
word32 inlen = info->pk.eccsign.inlen;
if (tlsCtx->eccKey == NULL) {
/* TPM key not setup, fallback to software */
return exit_rc;
}
/* get key size from wolf signing key */
keySz = wc_ecc_size(info->pk.eccsign.key);
if (keySz == 0) {