Skip to content

Commit 7737085

Browse files
Merge branch 'feat/support_for_the_ecdsa_signing' into 'master'
Added the support for the ECDSA signing See merge request espressif/esp-mqtt!238
2 parents 706e09f + b35a691 commit 7737085

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

include/mqtt_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ typedef struct esp_mqtt_client_config_t {
308308
bool use_secure_element; /*!< Enable secure element, available in ESP32-ROOM-32SE, for SSL connection */
309309
void *ds_data; /*!< Carrier of handle for digital signature parameters, digital signature peripheral is
310310
available in some Espressif devices. It's not copied nor freed by the client, user needs to clean up.*/
311+
bool use_ecdsa_peripheral; /*!< Enable ECDSA peripheral, available in some Espressif devices. */
312+
uint8_t ecdsa_key_efuse_blk; /*!< ECDSA key block number from efuse, available in some Espressif devices. */
311313
} authentication; /*!< Client authentication */
312314
} credentials; /*!< User credentials for broker */
313315
/**

include/mqtt_supported_features.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
#define MQTT_SUPPORTED_FEATURE_CRT_CMN_NAME
7070
#endif
7171

72+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
73+
// Features supported in 5.3.0
74+
#define MQTT_SUPPORTED_FEATURE_ECDSA_PERIPHERAL
75+
#endif
76+
7277

7378
#endif /* ESP_IDF_VERSION */
7479
#endif // _MQTT_SUPPORTED_FEATURES_H_

lib/include/mqtt_client_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ typedef struct {
9696
const char *common_name;
9797
bool use_secure_element;
9898
void *ds_data;
99+
bool use_ecdsa_peripheral;
100+
uint8_t ecdsa_key_efuse_blk;
99101
int message_retransmit_timeout;
100102
uint64_t outbox_limit;
101103
esp_transport_handle_t transport;

mqtt_client.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,21 @@ static esp_err_t esp_mqtt_set_ssl_transport_properties(esp_transport_list_handle
231231
goto esp_mqtt_set_transport_failed;
232232
#endif
233233
}
234+
235+
if (cfg->use_ecdsa_peripheral) {
236+
#ifdef MQTT_SUPPORTED_FEATURE_ECDSA_PERIPHERAL
237+
#ifdef CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN
238+
esp_transport_ssl_set_client_key_ecdsa_peripheral(ssl, cfg->ecdsa_key_efuse_blk);
239+
#else
240+
ESP_LOGE(TAG, "ECDSA peripheral not enabled for esp-tls in menuconfig");
241+
goto esp_mqtt_set_transport_failed;
242+
#endif /* CONFIG_MBEDTLS_HARDWARE_ECDSA_SIGN */
243+
#else
244+
ESP_LOGE(TAG, "ECDSA peripheral feature is not available in IDF version %s", IDF_VER);
245+
goto esp_mqtt_set_transport_failed;
246+
#endif /* MQTT_SUPPORTED_FEATURE_ECDSA_PERIPHERAL */
247+
}
248+
234249
ESP_OK_CHECK(TAG, esp_mqtt_set_cert_key_data(ssl, MQTT_SSL_DATA_API_CLIENT_CERT, cfg->clientcert_buf, cfg->clientcert_bytes),
235250
goto esp_mqtt_set_transport_failed);
236251
ESP_OK_CHECK(TAG, esp_mqtt_set_cert_key_data(ssl, MQTT_SSL_DATA_API_CLIENT_KEY, cfg->clientkey_buf, cfg->clientkey_bytes),
@@ -570,6 +585,8 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
570585
client->config->common_name = config->broker.verification.common_name;
571586
client->config->use_secure_element = config->credentials.authentication.use_secure_element;
572587
client->config->ds_data = config->credentials.authentication.ds_data;
588+
client->config->use_ecdsa_peripheral = config->credentials.authentication.use_ecdsa_peripheral;
589+
client->config->ecdsa_key_efuse_blk = config->credentials.authentication.ecdsa_key_efuse_blk;
573590

574591
if (config->credentials.authentication.key_password && config->credentials.authentication.key_password_len) {
575592
client->config->clientkey_password_len = config->credentials.authentication.key_password_len;

0 commit comments

Comments
 (0)