fix(mbedtls): revert struct member name change esp_rsa_ds_data to esp_ds_data

This commit is contained in:
Ashish Sharma
2026-02-06 17:37:42 +08:00
parent 7418a91d3e
commit 762c4e9e65
4 changed files with 19 additions and 19 deletions
@@ -70,7 +70,7 @@ static int esp_rsa_ds_validate_opaque_key(const esp_ds_data_ctx_t *opaque_key)
if (opaque_key == NULL) {
return PSA_ERROR_INVALID_ARGUMENT;
}
if (opaque_key->esp_rsa_ds_data == NULL) {
if (opaque_key->esp_ds_data == NULL) {
return PSA_ERROR_INVALID_ARGUMENT;
}
@@ -87,7 +87,7 @@ static int esp_rsa_ds_validate_opaque_key(const esp_ds_data_ctx_t *opaque_key)
}
/* DS data rsa_length must match rsa_length_bits so we can use the key's data directly in sign operations */
if (opaque_key->esp_rsa_ds_data->rsa_length != (opaque_key->rsa_length_bits / 32) - 1) {
if (opaque_key->esp_ds_data->rsa_length != (opaque_key->rsa_length_bits / 32) - 1) {
return PSA_ERROR_INVALID_ARGUMENT;
}
@@ -171,7 +171,7 @@ psa_status_t esp_rsa_ds_opaque_sign_hash_start(
}
esp_err_t err = esp_ds_start_sign((const void *)operation->sig_buffer,
opaque_key->esp_rsa_ds_data,
opaque_key->esp_ds_data,
(hmac_key_id_t) opaque_key->efuse_key_id,
&operation->esp_rsa_ds_ctx);
if (err != ESP_OK) {
@@ -319,7 +319,7 @@ psa_status_t esp_rsa_ds_opaque_import_key(
return ret;
}
/* Shallow copy: key buffer holds the context; esp_rsa_ds_data points to the caller's data.
/* Shallow copy: key buffer holds the context; esp_ds_data points to the caller's data.
* The key material (esp_ds_data_ctx_t and the esp_ds_data_t it points to) must remain
* valid until psa_destroy_key() is called on this key. */
memcpy(key_buffer, opaque_key, sizeof(esp_ds_data_ctx_t));
@@ -409,7 +409,7 @@ psa_status_t esp_rsa_ds_opaque_asymmetric_decrypt(
operation.sig_buffer = em_words;
esp_err_t err = esp_ds_start_sign((const void *)em_words,
opaque_key->esp_rsa_ds_data,
opaque_key->esp_ds_data,
(hmac_key_id_t) opaque_key->efuse_key_id,
&operation.esp_rsa_ds_ctx);
if (err != ESP_OK) {
@@ -30,11 +30,11 @@ typedef enum {
* This context is used to store the ESP DS data.
*
* When passed to psa_import_key() for PSA_KEY_LIFETIME_ESP_RSA_DS, the key material
* (this struct and the esp_ds_data_t pointed to by esp_rsa_ds_data) must remain valid
* (this struct and the esp_ds_data_t pointed to by esp_ds_data) must remain valid
* until psa_destroy_key() is called on the imported key.
*/
typedef struct {
esp_ds_data_t *esp_rsa_ds_data; /**< Pointer to the esp ds data */
esp_ds_data_t *esp_ds_data; /**< Pointer to the esp ds data */
uint8_t efuse_key_id; /**< efuse block id in which DS_KEY is stored e.g. 0,1*/
uint16_t rsa_length_bits; /**< length of RSA private key in bits e.g. 2048 */
} esp_ds_data_ctx_t;
@@ -30,10 +30,10 @@ esp_ds_data_ctx_t *esp_secure_cert_get_ds_ctx(void)
// Mock RSA key parameters
ds_key->rsa_length_bits = 2048;
ds_key->efuse_key_id = 0;
ds_key->esp_rsa_ds_data = calloc(1, sizeof(esp_ds_data_t));
if (ds_key->esp_rsa_ds_data != NULL) {
ds_key->esp_ds_data = calloc(1, sizeof(esp_ds_data_t));
if (ds_key->esp_ds_data != NULL) {
/* rsa_length must match rsa_length_bits for driver validation */
ds_key->esp_rsa_ds_data->rsa_length = (ds_key->rsa_length_bits / 32) - 1;
ds_key->esp_ds_data->rsa_length = (ds_key->rsa_length_bits / 32) - 1;
}
// Fill in other necessary fields as per esp_ds_data_ctx_t definition
// For simplicity, we will leave them zeroed out
@@ -44,8 +44,8 @@ esp_ds_data_ctx_t *esp_secure_cert_get_ds_ctx(void)
void esp_secure_cert_free_ds_ctx(esp_ds_data_ctx_t *ds_key)
{
if (ds_key != NULL) {
if (ds_key->esp_rsa_ds_data != NULL) {
free(ds_key->esp_rsa_ds_data);
if (ds_key->esp_ds_data != NULL) {
free(ds_key->esp_ds_data);
}
free(ds_key);
}
@@ -83,15 +83,15 @@ TEST_CASE("ds sign test pkcs1_v15 PSA validation", "[ds_rsa_psa]")
TEST_ASSERT_EQUAL(PSA_ERROR_INVALID_ARGUMENT, status);
ds_key->rsa_length_bits = 2048; // Reset to valid RSA length
esp_ds_data_t *ds_data_backup = ds_key->esp_rsa_ds_data;
ds_key->esp_rsa_ds_data = NULL; // NULL esp_rsa_ds_data to trigger validation failure
esp_ds_data_t *ds_data_backup = ds_key->esp_ds_data;
ds_key->esp_ds_data = NULL; // NULL esp_ds_data to trigger validation failure
status = psa_import_key(&attributes,
(const uint8_t *)ds_key,
sizeof(*ds_key),
&keyt_id);
TEST_ASSERT_EQUAL(PSA_ERROR_INVALID_ARGUMENT, status);
ds_key->esp_rsa_ds_data = ds_data_backup; // Restore esp_rsa_ds_data
ds_key->esp_ds_data = ds_data_backup; // Restore esp_ds_data
esp_secure_cert_free_ds_ctx(ds_key);
}