diff --git a/crypto/cipher/aes_gcm_mbedtls.c b/crypto/cipher/aes_gcm_mbedtls.c index 13465f1da..04ff98b6a 100644 --- a/crypto/cipher/aes_gcm_mbedtls.c +++ b/crypto/cipher/aes_gcm_mbedtls.c @@ -293,6 +293,12 @@ static srtp_err_status_t srtp_aes_gcm_mbedtls_context_init(void *cv, break; } + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + debug_print(srtp_mod_aes_gcm, "psa_crypto_init failed: %d", status); + return srtp_err_status_cipher_fail; + } + psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT; psa_set_key_usage_flags(&attr, diff --git a/crypto/hash/hmac_mbedtls.c b/crypto/hash/hmac_mbedtls.c index b7733b2ff..af4db2cf1 100644 --- a/crypto/hash/hmac_mbedtls.c +++ b/crypto/hash/hmac_mbedtls.c @@ -148,6 +148,12 @@ static srtp_err_status_t srtp_hmac_mbedtls_init(void *statev, psa_status_t status = PSA_SUCCESS; psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT; + status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + debug_print(srtp_mod_hmac, "psa_crypto_init failed: %d", status); + return srtp_err_status_auth_fail; + } + psa_set_key_type(&attr, PSA_KEY_TYPE_HMAC); psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_SIGN_MESSAGE); psa_set_key_algorithm(&attr, PSA_ALG_HMAC(PSA_ALG_SHA_1));