mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
Merge branch 'bugfix/use_decrypt_user_ctx' into 'master'
example: use decrypt_user_ctx in decryption callback See merge request espressif/esp-idf!17460
This commit is contained in:
@@ -1,3 +1,2 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
idf: ">=4.4"
|
|
||||||
espressif/esp_encrypted_img: "^2.0.1"
|
espressif/esp_encrypted_img: "^2.0.1"
|
||||||
|
@@ -39,15 +39,17 @@ extern const char rsa_private_pem_end[] asm("_binary_private_pem_end");
|
|||||||
|
|
||||||
#define OTA_URL_SIZE 256
|
#define OTA_URL_SIZE 256
|
||||||
|
|
||||||
static esp_decrypt_handle_t decrypt_handle;
|
|
||||||
|
|
||||||
static esp_err_t _decrypt_cb(decrypt_cb_arg_t *args, void *user_ctx)
|
static esp_err_t _decrypt_cb(decrypt_cb_arg_t *args, void *user_ctx)
|
||||||
{
|
{
|
||||||
|
if (args == NULL || user_ctx == NULL) {
|
||||||
|
ESP_LOGE(TAG, "_decrypt_cb: Invalid argument");
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
pre_enc_decrypt_arg_t pargs = {};
|
pre_enc_decrypt_arg_t pargs = {};
|
||||||
pargs.data_in = (char *) args->data_in;
|
pargs.data_in = args->data_in;
|
||||||
pargs.data_in_len = args->data_in_len;
|
pargs.data_in_len = args->data_in_len;
|
||||||
err = esp_encrypted_img_decrypt_data(decrypt_handle, &pargs);
|
err = esp_encrypted_img_decrypt_data((esp_decrypt_handle_t *)user_ctx, &pargs);
|
||||||
if (err != ESP_OK && err != ESP_ERR_NOT_FINISHED) {
|
if (err != ESP_OK && err != ESP_ERR_NOT_FINISHED) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -75,7 +77,7 @@ void pre_encrypted_ota_task(void *pvParameter)
|
|||||||
esp_decrypt_cfg_t cfg = {};
|
esp_decrypt_cfg_t cfg = {};
|
||||||
cfg.rsa_pub_key = rsa_private_pem_start;
|
cfg.rsa_pub_key = rsa_private_pem_start;
|
||||||
cfg.rsa_pub_key_len = rsa_private_pem_end - rsa_private_pem_start;
|
cfg.rsa_pub_key_len = rsa_private_pem_end - rsa_private_pem_start;
|
||||||
decrypt_handle = esp_encrypted_img_decrypt_start(&cfg);
|
esp_decrypt_handle_t decrypt_handle = esp_encrypted_img_decrypt_start(&cfg);
|
||||||
if (!decrypt_handle) {
|
if (!decrypt_handle) {
|
||||||
ESP_LOGE(TAG, "OTA upgrade failed");
|
ESP_LOGE(TAG, "OTA upgrade failed");
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
@@ -106,7 +108,7 @@ void pre_encrypted_ota_task(void *pvParameter)
|
|||||||
.max_http_request_size = CONFIG_EXAMPLE_HTTP_REQUEST_SIZE,
|
.max_http_request_size = CONFIG_EXAMPLE_HTTP_REQUEST_SIZE,
|
||||||
#endif
|
#endif
|
||||||
.decrypt_cb = _decrypt_cb,
|
.decrypt_cb = _decrypt_cb,
|
||||||
.decrypt_user_ctx = NULL
|
.decrypt_user_ctx = (void *)decrypt_handle,
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_https_ota_handle_t https_ota_handle = NULL;
|
esp_https_ota_handle_t https_ota_handle = NULL;
|
||||||
|
Reference in New Issue
Block a user