mirror of
https://github.com/espressif/mbedtls.git
synced 2026-10-09 10:37:22 +00:00
feat(drivers): ESP-HMAC opaque driver
This commit is contained in:
@@ -41,10 +41,16 @@
|
|||||||
#include "../drivers/p256-m/p256-m_driver_entrypoints.h"
|
#include "../drivers/p256-m/p256-m_driver_entrypoints.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Headers for esp_sha transparent driver */
|
/* Headers for esp_sha transparent driver */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_SHA_DRIVER_ENABLED)
|
||||||
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_sha.h"
|
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_sha.h"
|
||||||
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_hmac.h"
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
|
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_hmac_transparent.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Headers for esp_aes transparent driver */
|
/* Headers for esp_aes transparent driver */
|
||||||
@@ -55,6 +61,12 @@
|
|||||||
|
|
||||||
#if defined(ESP_MD5_DRIVER_ENABLED)
|
#if defined(ESP_MD5_DRIVER_ENABLED)
|
||||||
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_md5.h"
|
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_md5.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_hmac_opaque.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Headers for esp_ecdsa opaque driver */
|
/* Headers for esp_ecdsa opaque driver */
|
||||||
@@ -90,6 +102,7 @@
|
|||||||
#define ESP_RSA_DS_OPAQUE_DRIVER_ID (10)
|
#define ESP_RSA_DS_OPAQUE_DRIVER_ID (10)
|
||||||
#define ESP_CMAC_TRANSPARENT_DRIVER_ID (11)
|
#define ESP_CMAC_TRANSPARENT_DRIVER_ID (11)
|
||||||
#define ESP_HMAC_TRANSPARENT_DRIVER_ID (12)
|
#define ESP_HMAC_TRANSPARENT_DRIVER_ID (12)
|
||||||
|
#define ESP_HMAC_OPAQUE_DRIVER_ID (13)
|
||||||
|
|
||||||
/* END-driver id */
|
/* END-driver id */
|
||||||
|
|
||||||
@@ -881,6 +894,14 @@ static inline psa_status_t psa_driver_wrapper_get_key_buffer_size_from_key_data(
|
|||||||
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
|
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
|
||||||
#endif /* ESP_RSA_DS_DRIVER_ENABLED */
|
#endif /* ESP_RSA_DS_DRIVER_ENABLED */
|
||||||
|
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case PSA_KEY_LOCATION_ESP_HMAC:
|
||||||
|
*key_buffer_size = esp_hmac_opaque_size_function(key_type,
|
||||||
|
PSA_BYTES_TO_BITS( data_length ) );
|
||||||
|
return( ( *key_buffer_size != 0 ) ?
|
||||||
|
PSA_SUCCESS : PSA_ERROR_NOT_SUPPORTED );
|
||||||
|
#endif /* defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED) */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
(void)key_type;
|
(void)key_type;
|
||||||
(void)data;
|
(void)data;
|
||||||
@@ -1059,6 +1080,14 @@ static inline psa_status_t psa_driver_wrapper_import_key(
|
|||||||
key_buffer, key_buffer_size,
|
key_buffer, key_buffer_size,
|
||||||
key_buffer_length, bits ) );
|
key_buffer_length, bits ) );
|
||||||
#endif /* defined(ESP_ECDSA_DRIVER_ENABLED) && defined(ESP_ECDSA_SIGN_DRIVER_ENABLED) */
|
#endif /* defined(ESP_ECDSA_DRIVER_ENABLED) && defined(ESP_ECDSA_SIGN_DRIVER_ENABLED) */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case PSA_KEY_LOCATION_ESP_HMAC:
|
||||||
|
return( esp_hmac_import_key_opaque(
|
||||||
|
attributes,
|
||||||
|
data, data_length,
|
||||||
|
key_buffer, key_buffer_size,
|
||||||
|
key_buffer_length, bits ) );
|
||||||
|
#endif /* defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED) */
|
||||||
|
|
||||||
#if defined(ESP_RSA_DS_DRIVER_ENABLED)
|
#if defined(ESP_RSA_DS_DRIVER_ENABLED)
|
||||||
case PSA_KEY_LOCATION_ESP_RSA_DS:
|
case PSA_KEY_LOCATION_ESP_RSA_DS:
|
||||||
@@ -2610,25 +2639,22 @@ static inline psa_status_t psa_driver_wrapper_mac_compute(
|
|||||||
status = esp_cmac_compute(attributes, key_buffer, key_buffer_size, alg,
|
status = esp_cmac_compute(attributes, key_buffer, key_buffer_size, alg,
|
||||||
input, input_length,
|
input, input_length,
|
||||||
mac, mac_size, mac_length );
|
mac, mac_size, mac_length );
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
if (PSA_ALG_IS_HMAC(alg)) {
|
if (PSA_ALG_IS_HMAC(alg)) {
|
||||||
status = esp_hmac_compute(attributes, key_buffer, key_buffer_size, alg,
|
status = esp_hmac_compute_transparent(
|
||||||
input, input_length,
|
attributes, key_buffer, key_buffer_size, alg,
|
||||||
mac, mac_size, mac_length );
|
input, input_length,
|
||||||
if (status != PSA_SUCCESS) {
|
mac, mac_size, mac_length );
|
||||||
|
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* ESP_SHA_DRIVER_ENABLED */
|
#endif /* ESP_HMAC_TRANSPARENT_DRIVER_ENABLED */
|
||||||
// TODO: Maybe not required? check all soft fallback mechanisms
|
|
||||||
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||||
status = mbedtls_test_transparent_mac_compute(
|
status = mbedtls_test_transparent_mac_compute(
|
||||||
attributes, key_buffer, key_buffer_size, alg,
|
attributes, key_buffer, key_buffer_size, alg,
|
||||||
@@ -2660,6 +2686,18 @@ static inline psa_status_t psa_driver_wrapper_mac_compute(
|
|||||||
mac, mac_size, mac_length );
|
mac, mac_size, mac_length );
|
||||||
return( status );
|
return( status );
|
||||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case PSA_KEY_LOCATION_ESP_HMAC:
|
||||||
|
if (PSA_ALG_IS_HMAC(alg)) {
|
||||||
|
status = esp_hmac_compute_opaque(
|
||||||
|
attributes, key_buffer, key_buffer_size, alg,
|
||||||
|
input, input_length,
|
||||||
|
mac, mac_size, mac_length );
|
||||||
|
return( status );
|
||||||
|
} else {
|
||||||
|
return PSA_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
#endif /* ESP_HMAC_OPAQUE_DRIVER_ENABLED */
|
||||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||||
default:
|
default:
|
||||||
/* Key is declared with a lifetime not known to us */
|
/* Key is declared with a lifetime not known to us */
|
||||||
@@ -2701,21 +2739,24 @@ static inline psa_status_t psa_driver_wrapper_mac_sign_setup(
|
|||||||
alg );
|
alg );
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
operation->id = ESP_CMAC_TRANSPARENT_DRIVER_ID;
|
operation->id = ESP_CMAC_TRANSPARENT_DRIVER_ID;
|
||||||
|
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
if (PSA_ALG_IS_HMAC(alg)) {
|
if (PSA_ALG_IS_HMAC(alg)) {
|
||||||
status = esp_hmac_setup( &operation->ctx.esp_hmac_ctx,
|
status = esp_hmac_setup_transparent( &operation->ctx.esp_hmac_transparent_ctx,
|
||||||
attributes,
|
attributes,
|
||||||
key_buffer, key_buffer_size,
|
key_buffer, key_buffer_size,
|
||||||
alg );
|
alg );
|
||||||
if ( status == PSA_SUCCESS )
|
if ( status == PSA_SUCCESS )
|
||||||
operation->id = ESP_HMAC_TRANSPARENT_DRIVER_ID;
|
operation->id = ESP_HMAC_TRANSPARENT_DRIVER_ID;
|
||||||
|
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* ESP_SHA_DRIVER_ENABLED */
|
#endif /* ESP_HMAC_TRANSPARENT_DRIVER_ENABLED */
|
||||||
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||||
status = mbedtls_test_transparent_mac_sign_setup(
|
status = mbedtls_test_transparent_mac_sign_setup(
|
||||||
&operation->ctx.transparent_test_driver_ctx,
|
&operation->ctx.transparent_test_driver_ctx,
|
||||||
@@ -2759,6 +2800,19 @@ static inline psa_status_t psa_driver_wrapper_mac_sign_setup(
|
|||||||
|
|
||||||
return( status );
|
return( status );
|
||||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case PSA_KEY_LOCATION_ESP_HMAC:
|
||||||
|
if (PSA_ALG_IS_HMAC(alg)) {
|
||||||
|
status = esp_hmac_setup_opaque(
|
||||||
|
&operation->ctx.esp_hmac_opaque_ctx,
|
||||||
|
attributes, key_buffer, key_buffer_size, alg );
|
||||||
|
if ( status == PSA_SUCCESS )
|
||||||
|
operation->id = ESP_HMAC_OPAQUE_DRIVER_ID;
|
||||||
|
return( status );
|
||||||
|
} else {
|
||||||
|
return PSA_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
#endif /* ESP_HMAC_OPAQUE_DRIVER_ENABLED */
|
||||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||||
default:
|
default:
|
||||||
/* Key is declared with a lifetime not known to us */
|
/* Key is declared with a lifetime not known to us */
|
||||||
@@ -2796,21 +2850,24 @@ static inline psa_status_t psa_driver_wrapper_mac_verify_setup(
|
|||||||
alg );
|
alg );
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
operation->id = ESP_CMAC_TRANSPARENT_DRIVER_ID;
|
operation->id = ESP_CMAC_TRANSPARENT_DRIVER_ID;
|
||||||
|
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
if (PSA_ALG_IS_HMAC(alg)) {
|
if (PSA_ALG_IS_HMAC(alg)) {
|
||||||
status = esp_hmac_setup( &operation->ctx.esp_hmac_ctx,
|
status = esp_hmac_setup_transparent( &operation->ctx.esp_hmac_transparent_ctx,
|
||||||
attributes,
|
attributes,
|
||||||
key_buffer, key_buffer_size,
|
key_buffer, key_buffer_size,
|
||||||
alg );
|
alg );
|
||||||
if (status == PSA_SUCCESS)
|
if (status == PSA_SUCCESS)
|
||||||
operation->id = ESP_HMAC_TRANSPARENT_DRIVER_ID;
|
operation->id = ESP_HMAC_TRANSPARENT_DRIVER_ID;
|
||||||
|
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* ESP_SHA_DRIVER_ENABLED */
|
#endif /* ESP_HMAC_TRANSPARENT_DRIVER_ENABLED */
|
||||||
if (status != PSA_ERROR_NOT_SUPPORTED) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||||
status = mbedtls_test_transparent_mac_verify_setup(
|
status = mbedtls_test_transparent_mac_verify_setup(
|
||||||
&operation->ctx.transparent_test_driver_ctx,
|
&operation->ctx.transparent_test_driver_ctx,
|
||||||
@@ -2854,6 +2911,19 @@ static inline psa_status_t psa_driver_wrapper_mac_verify_setup(
|
|||||||
|
|
||||||
return( status );
|
return( status );
|
||||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case PSA_KEY_LOCATION_ESP_HMAC:
|
||||||
|
if (PSA_ALG_IS_HMAC(alg)) {
|
||||||
|
status = esp_hmac_setup_opaque(
|
||||||
|
&operation->ctx.esp_hmac_opaque_ctx,
|
||||||
|
attributes, key_buffer, key_buffer_size, alg );
|
||||||
|
if ( status == PSA_SUCCESS )
|
||||||
|
operation->id = ESP_HMAC_OPAQUE_DRIVER_ID;
|
||||||
|
return( status );
|
||||||
|
} else {
|
||||||
|
return PSA_ERROR_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
#endif /* ESP_HMAC_OPAQUE_DRIVER_ENABLED */
|
||||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||||
default:
|
default:
|
||||||
/* Key is declared with a lifetime not known to us */
|
/* Key is declared with a lifetime not known to us */
|
||||||
@@ -2885,11 +2955,11 @@ static inline psa_status_t psa_driver_wrapper_mac_update(
|
|||||||
return (esp_cmac_update( &operation->ctx.esp_cmac_ctx,
|
return (esp_cmac_update( &operation->ctx.esp_cmac_ctx,
|
||||||
input, input_length ));
|
input, input_length ));
|
||||||
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
||||||
return (esp_hmac_update( &operation->ctx.esp_hmac_ctx,
|
return (esp_hmac_update_transparent( &operation->ctx.esp_hmac_transparent_ctx,
|
||||||
input, input_length ));
|
input, input_length ));
|
||||||
#endif /* ESP_SHA_DRIVER_ENABLED */
|
#endif /* ESP_HMAC_TRANSPARENT_DRIVER_ENABLED */
|
||||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||||
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
||||||
return( mbedtls_test_transparent_mac_update(
|
return( mbedtls_test_transparent_mac_update(
|
||||||
@@ -2901,6 +2971,11 @@ static inline psa_status_t psa_driver_wrapper_mac_update(
|
|||||||
&operation->ctx.opaque_test_driver_ctx,
|
&operation->ctx.opaque_test_driver_ctx,
|
||||||
input, input_length ) );
|
input, input_length ) );
|
||||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case ESP_HMAC_OPAQUE_DRIVER_ID:
|
||||||
|
return (esp_hmac_update_opaque( &operation->ctx.esp_hmac_opaque_ctx,
|
||||||
|
input, input_length ));
|
||||||
|
#endif /* ESP_HMAC_OPAQUE_DRIVER_ENABLED */
|
||||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||||
default:
|
default:
|
||||||
(void) input;
|
(void) input;
|
||||||
@@ -2929,11 +3004,11 @@ static inline psa_status_t psa_driver_wrapper_mac_sign_finish(
|
|||||||
return (esp_cmac_finish( &operation->ctx.esp_cmac_ctx,
|
return (esp_cmac_finish( &operation->ctx.esp_cmac_ctx,
|
||||||
mac, mac_size, mac_length ));
|
mac, mac_size, mac_length ));
|
||||||
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
||||||
return (esp_hmac_finish( &operation->ctx.esp_hmac_ctx,
|
return (esp_hmac_finish_transparent( &operation->ctx.esp_hmac_transparent_ctx,
|
||||||
mac, mac_size, mac_length ));
|
mac, mac_size, mac_length ));
|
||||||
#endif /* ESP_SHA_DRIVER_ENABLED */
|
#endif /* ESP_HMAC_TRANSPARENT_DRIVER_ENABLED */
|
||||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||||
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
||||||
return( mbedtls_test_transparent_mac_sign_finish(
|
return( mbedtls_test_transparent_mac_sign_finish(
|
||||||
@@ -2945,6 +3020,11 @@ static inline psa_status_t psa_driver_wrapper_mac_sign_finish(
|
|||||||
&operation->ctx.opaque_test_driver_ctx,
|
&operation->ctx.opaque_test_driver_ctx,
|
||||||
mac, mac_size, mac_length ) );
|
mac, mac_size, mac_length ) );
|
||||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case ESP_HMAC_OPAQUE_DRIVER_ID:
|
||||||
|
return (esp_hmac_finish_opaque( &operation->ctx.esp_hmac_opaque_ctx,
|
||||||
|
mac, mac_size, mac_length ));
|
||||||
|
#endif /* ESP_HMAC_OPAQUE_DRIVER_ENABLED */
|
||||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||||
default:
|
default:
|
||||||
(void) mac;
|
(void) mac;
|
||||||
@@ -2973,11 +3053,11 @@ static inline psa_status_t psa_driver_wrapper_mac_verify_finish(
|
|||||||
return (esp_cmac_verify_finish( &operation->ctx.esp_cmac_ctx,
|
return (esp_cmac_verify_finish( &operation->ctx.esp_cmac_ctx,
|
||||||
mac, mac_length ));
|
mac, mac_length ));
|
||||||
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
||||||
return (esp_hmac_verify_finish( &operation->ctx.esp_hmac_ctx,
|
return (esp_hmac_verify_finish_transparent( &operation->ctx.esp_hmac_transparent_ctx,
|
||||||
mac, mac_length ));
|
mac, mac_length ));
|
||||||
#endif /* ESP_SHA_DRIVER_ENABLED */
|
#endif /* ESP_HMAC_TRANSPARENT_DRIVER_ENABLED */
|
||||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||||
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
||||||
return( mbedtls_test_transparent_mac_verify_finish(
|
return( mbedtls_test_transparent_mac_verify_finish(
|
||||||
@@ -2989,6 +3069,11 @@ static inline psa_status_t psa_driver_wrapper_mac_verify_finish(
|
|||||||
&operation->ctx.opaque_test_driver_ctx,
|
&operation->ctx.opaque_test_driver_ctx,
|
||||||
mac, mac_length ) );
|
mac, mac_length ) );
|
||||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case ESP_HMAC_OPAQUE_DRIVER_ID:
|
||||||
|
return (esp_hmac_verify_finish_opaque( &operation->ctx.esp_hmac_opaque_ctx,
|
||||||
|
mac, mac_length ));
|
||||||
|
#endif /* ESP_HMAC_OPAQUE_DRIVER_ENABLED */
|
||||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||||
default:
|
default:
|
||||||
(void) mac;
|
(void) mac;
|
||||||
@@ -3012,10 +3097,10 @@ static inline psa_status_t psa_driver_wrapper_mac_abort(
|
|||||||
case ESP_CMAC_TRANSPARENT_DRIVER_ID:
|
case ESP_CMAC_TRANSPARENT_DRIVER_ID:
|
||||||
return (esp_cmac_abort( &operation->ctx.esp_cmac_ctx ));
|
return (esp_cmac_abort( &operation->ctx.esp_cmac_ctx ));
|
||||||
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
#endif /* ESP_CMAC_DRIVER_ENABLED */
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
case ESP_HMAC_TRANSPARENT_DRIVER_ID:
|
||||||
return (esp_hmac_abort( &operation->ctx.esp_hmac_ctx ));
|
return (esp_hmac_abort_transparent( &operation->ctx.esp_hmac_transparent_ctx ));
|
||||||
#endif /* ESP_SHA_DRIVER_ENABLED */
|
#endif /* ESP_HMAC_TRANSPARENT_DRIVER_ENABLED */
|
||||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||||
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
case MBEDTLS_TEST_TRANSPARENT_DRIVER_ID:
|
||||||
return( mbedtls_test_transparent_mac_abort(
|
return( mbedtls_test_transparent_mac_abort(
|
||||||
@@ -3024,6 +3109,10 @@ static inline psa_status_t psa_driver_wrapper_mac_abort(
|
|||||||
return( mbedtls_test_opaque_mac_abort(
|
return( mbedtls_test_opaque_mac_abort(
|
||||||
&operation->ctx.opaque_test_driver_ctx ) );
|
&operation->ctx.opaque_test_driver_ctx ) );
|
||||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
case ESP_HMAC_OPAQUE_DRIVER_ID:
|
||||||
|
return (esp_hmac_abort_opaque( &operation->ctx.esp_hmac_opaque_ctx ));
|
||||||
|
#endif /* ESP_HMAC_OPAQUE_DRIVER_ENABLED */
|
||||||
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
#endif /* PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT */
|
||||||
default:
|
default:
|
||||||
return( PSA_ERROR_INVALID_ARGUMENT );
|
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||||
|
|||||||
@@ -39,17 +39,6 @@
|
|||||||
#if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
|
#if defined(MBEDTLS_PSA_P256M_DRIVER_ENABLED)
|
||||||
#include "../drivers/p256-m/p256-m_driver_entrypoints.h"
|
#include "../drivers/p256-m/p256-m_driver_entrypoints.h"
|
||||||
|
|
||||||
#endif
|
|
||||||
/* Headers for esp_sha transparent driver */
|
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
|
||||||
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_sha.h"
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/* Headers for esp_aes transparent driver */
|
|
||||||
#if defined(ESP_AES_DRIVER_ENABLED)
|
|
||||||
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_aes.h"
|
|
||||||
#include "../../../port/psa_driver/include/psa_crypto_driver_esp_aes_gcm.h"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* Headers for esp_ecdsa opaque driver */
|
/* Headers for esp_ecdsa opaque driver */
|
||||||
#if defined(ESP_ECDSA_DRIVER_ENABLED)
|
#if defined(ESP_ECDSA_DRIVER_ENABLED)
|
||||||
@@ -67,8 +56,6 @@
|
|||||||
#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2)
|
#define MBEDTLS_TEST_OPAQUE_DRIVER_ID (2)
|
||||||
#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3)
|
#define MBEDTLS_TEST_TRANSPARENT_DRIVER_ID (3)
|
||||||
#define P256_TRANSPARENT_DRIVER_ID (4)
|
#define P256_TRANSPARENT_DRIVER_ID (4)
|
||||||
#define ESP_SHA_TRANSPARENT_DRIVER_ID (5)
|
|
||||||
#define ESP_AES_TRANSPARENT_DRIVER_ID (6)
|
|
||||||
|
|
||||||
/* END-driver id */
|
/* END-driver id */
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,12 @@
|
|||||||
#include "psa_crypto_driver_esp_cmac_contexts.h"
|
#include "psa_crypto_driver_esp_cmac_contexts.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
#include "psa_crypto_driver_esp_hmac_contexts.h"
|
#include "psa_crypto_driver_esp_hmac_transparent_contexts.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
#include "psa_crypto_driver_esp_hmac_opaque_contexts.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
|
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
|
||||||
@@ -143,8 +147,11 @@ typedef union {
|
|||||||
#if defined(ESP_CMAC_DRIVER_ENABLED)
|
#if defined(ESP_CMAC_DRIVER_ENABLED)
|
||||||
esp_cmac_operation_t esp_cmac_ctx;
|
esp_cmac_operation_t esp_cmac_ctx;
|
||||||
#endif
|
#endif
|
||||||
#if defined(ESP_SHA_DRIVER_ENABLED)
|
#if defined(ESP_HMAC_TRANSPARENT_DRIVER_ENABLED)
|
||||||
esp_hmac_operation_t esp_hmac_ctx;
|
esp_hmac_transparent_operation_t esp_hmac_transparent_ctx;
|
||||||
|
#endif
|
||||||
|
#if defined(ESP_HMAC_OPAQUE_DRIVER_ENABLED)
|
||||||
|
esp_hmac_opaque_operation_t esp_hmac_opaque_ctx;
|
||||||
#endif
|
#endif
|
||||||
} psa_driver_mac_context_t;
|
} psa_driver_mac_context_t;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user