mirror of https://github.com/wolfSSL/wolfTPM.git
Merge pull request #421 from dgarske/cryptocb_nokey
Fix for crypto callback with no TPM key and update for WC_RNG getpidmaster
commit
21d8604db9
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue