Skip to content

Commit

Permalink
esys: Use default OpenSSL context for session HMAC operations
Browse files Browse the repository at this point in the history
The TPM2 provider may be loaded in the global library context.
As we don't want the TPM to be called for some operations, we have
to initialize own library context with the default provider.

Signed-off-by: Stefan Thöni <stefan.thoeni@gapfruit.com>
  • Loading branch information
throwException committed Nov 29, 2023
1 parent fcff6da commit e643676
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tss2-esys/esys_crypto_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,14 @@ iesys_cryptossl_hmac_start(ESYS_CRYPTO_CONTEXT_BLOB ** context,

#if OPENSSL_VERSION_NUMBER < 0x10101000L
if (!(hkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, key, size))) {
#else
#elif OPENSSL_VERSION_NUMBER < 0x30000000L
/* this is preferred, but available since OpenSSL 1.1.1 only */
if (!(hkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL, key, size))) {
#else
/* this is nessecary from OpenSSL 3.0.0 to avoid using the TPM2 provider using
* OpenSSL in a circular dependency */
if (!(hkey = EVP_PKEY_new_raw_private_key_ex(mycontext->hash.ossl_libctx,
"HMAC", NULL, key, size))) {
#endif
goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE,
"Failed to create HMAC key", cleanup);
Expand Down

0 comments on commit e643676

Please sign in to comment.