mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
Merge branch 'fix/tee_basic_example_failure' into 'master'
fix(esp_tee): Fix AEAD output buffer slicing in the `tee_basic` example See merge request espressif/esp-idf!52389
This commit is contained in:
@@ -93,14 +93,14 @@ static esp_err_t aes_gcm_crypt_common(example_aes_gcm_ctx_t *ctx, uint8_t *tag,
|
|||||||
|
|
||||||
if (is_encrypt) {
|
if (is_encrypt) {
|
||||||
size_t output_tag_len = 0;
|
size_t output_tag_len = 0;
|
||||||
status = psa_aead_finish(&operation, output + output_len, ctx->input_len + tag_len - output_len, &output_len, tag, tag_len, &output_tag_len);
|
status = psa_aead_finish(&operation, output + output_len, ctx->input_len - output_len, &output_len, tag, tag_len, &output_tag_len);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
ESP_LOGE(TAG, "Error in finishing encryption: %d", status);
|
ESP_LOGE(TAG, "Error in finishing encryption: %d", status);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t plaintext_len = 0;
|
size_t plaintext_len = 0;
|
||||||
status = psa_aead_verify(&operation, output, ctx->input_len, &plaintext_len, tag, tag_len);
|
status = psa_aead_verify(&operation, output + output_len, ctx->input_len - output_len, &plaintext_len, tag, tag_len);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
ESP_LOGE(TAG, "Error in verifying decryption: %d", status);
|
ESP_LOGE(TAG, "Error in verifying decryption: %d", status);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void app_main(void)
|
|||||||
uint8_t aad_buf[AES256_GCM_AAD_LEN];
|
uint8_t aad_buf[AES256_GCM_AAD_LEN];
|
||||||
|
|
||||||
/* Generate random plaintext and AAD */
|
/* Generate random plaintext and AAD */
|
||||||
esp_fill_random(plain_text, sizeof(EXAMPLE_BUF_SZ));
|
esp_fill_random(plain_text, sizeof(plain_text));
|
||||||
esp_fill_random(aad_buf, AES256_GCM_AAD_LEN);
|
esp_fill_random(aad_buf, AES256_GCM_AAD_LEN);
|
||||||
|
|
||||||
/* Encryption operation */
|
/* Encryption operation */
|
||||||
|
|||||||
@@ -24,9 +24,8 @@ def test_example_tee_basic(dut: Dut) -> None:
|
|||||||
logging.info(f'{log_label}: {bin_size // 1024}KB')
|
logging.info(f'{log_label}: {bin_size // 1024}KB')
|
||||||
|
|
||||||
# Start test
|
# Start test
|
||||||
dut.expect('AES-256-GCM operations in TEE', timeout=10)
|
|
||||||
dut.expect('Secure service call: PROTECTED M-mode', timeout=10)
|
dut.expect('Secure service call: PROTECTED M-mode', timeout=10)
|
||||||
dut.expect('AES-256-GCM encryption', timeout=10)
|
dut.expect('AES-256-GCM encryption', timeout=10)
|
||||||
dut.expect('Secure service call: PROTECTED M-mode', timeout=10)
|
dut.expect('Secure service call: PROTECTED M-mode', timeout=10)
|
||||||
dut.expect('AES-256-GCM decryption', timeout=10)
|
dut.expect('AES-GCM decryption successful!', timeout=10)
|
||||||
dut.expect('Returned from app_main()', timeout=10)
|
dut.expect('Returned from app_main()', timeout=10)
|
||||||
|
|||||||
Reference in New Issue
Block a user