Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/tpm2_cryptocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down