mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-28 03:23:14 +00:00
fix(mbedtls): revert struct member name change esp_rsa_ds_data to esp_ds_data
This commit is contained in:
@@ -118,7 +118,7 @@ typedef struct esp_tls_pki_t {
|
||||
const unsigned char *privkey_password;
|
||||
unsigned int privkey_password_len;
|
||||
#ifdef CONFIG_ESP_TLS_USE_DS_PERIPHERAL
|
||||
void *esp_rsa_ds_data;
|
||||
void *esp_ds_data;
|
||||
#endif
|
||||
} esp_tls_pki_t;
|
||||
|
||||
@@ -601,7 +601,7 @@ static esp_err_t set_pki_context(esp_tls_t *tls, const esp_tls_pki_t *pki)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESP_TLS_USE_DS_PERIPHERAL
|
||||
if (pki->esp_rsa_ds_data != NULL) {
|
||||
if (pki->esp_ds_data != NULL) {
|
||||
ret = esp_mbedtls_init_pk_ctx_for_ds(pki);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize pk context for esp_rsa_ds");
|
||||
@@ -1074,7 +1074,7 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t
|
||||
.privkey_pem_bytes = 0,
|
||||
.privkey_password = NULL,
|
||||
.privkey_password_len = 0,
|
||||
.esp_rsa_ds_data = cfg->ds_data,
|
||||
.esp_ds_data = cfg->ds_data,
|
||||
};
|
||||
|
||||
esp_err_t esp_ret = set_pki_context(tls, &pki);
|
||||
@@ -1406,7 +1406,7 @@ static esp_err_t esp_set_atecc608a_pki_context(esp_tls_t *tls, const void *pki)
|
||||
#ifdef CONFIG_ESP_TLS_USE_DS_PERIPHERAL
|
||||
static esp_err_t esp_mbedtls_init_pk_ctx_for_ds(const void *pki)
|
||||
{
|
||||
esp_ds_data_ctx_t *ds_data = ((const esp_tls_pki_t*)pki)->esp_rsa_ds_data;
|
||||
esp_ds_data_ctx_t *ds_data = ((const esp_tls_pki_t*)pki)->esp_ds_data;
|
||||
if (ds_data == NULL) {
|
||||
ESP_LOGE(TAG, "DS data context is NULL");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user