mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
flash_encryption_example: Update example test to use pytest framework
This commit is contained in:
parent
c3bac72cbb
commit
600272bc5d
@ -91,6 +91,26 @@ example_test_pytest_esp32_ethernet_ip101:
|
|||||||
TARGET: ESP32
|
TARGET: ESP32
|
||||||
ENV_MARKER: ip101
|
ENV_MARKER: ip101
|
||||||
|
|
||||||
|
example_test_pytest_esp32_flash_encryption:
|
||||||
|
extends:
|
||||||
|
- .pytest_examples_dir_template
|
||||||
|
- .rules:test:example_test-esp32
|
||||||
|
needs:
|
||||||
|
- build_pytest_examples_esp32
|
||||||
|
variables:
|
||||||
|
TARGET: ESP32
|
||||||
|
ENV_MARKER: flash_encryption
|
||||||
|
|
||||||
|
example_test_pytest_esp32c3_flash_encryption:
|
||||||
|
extends:
|
||||||
|
- .pytest_examples_dir_template
|
||||||
|
- .rules:test:example_test-esp32c3
|
||||||
|
needs:
|
||||||
|
- build_pytest_examples_esp32c3
|
||||||
|
variables:
|
||||||
|
TARGET: ESP32C3
|
||||||
|
ENV_MARKER: flash_encryption
|
||||||
|
|
||||||
.pytest_components_dir_template:
|
.pytest_components_dir_template:
|
||||||
extends: .pytest_template
|
extends: .pytest_template
|
||||||
variables:
|
variables:
|
||||||
@ -413,12 +433,6 @@ example_test_007:
|
|||||||
- ESP32
|
- ESP32
|
||||||
- Example_I2C_CCS811_SENSOR
|
- Example_I2C_CCS811_SENSOR
|
||||||
|
|
||||||
example_test_008A:
|
|
||||||
extends: .example_test_esp32_template
|
|
||||||
tags:
|
|
||||||
- ESP32
|
|
||||||
- Example_Flash_Encryption
|
|
||||||
|
|
||||||
example_test_008B:
|
example_test_008B:
|
||||||
extends: .example_test_esp32_template
|
extends: .example_test_esp32_template
|
||||||
tags:
|
tags:
|
||||||
@ -491,12 +505,6 @@ example_test_C3_GENERIC:
|
|||||||
- ESP32C3
|
- ESP32C3
|
||||||
- Example_GENERIC
|
- Example_GENERIC
|
||||||
|
|
||||||
example_test_C3_FLASH_ENC:
|
|
||||||
extends: .example_test_esp32c3_template
|
|
||||||
tags:
|
|
||||||
- ESP32C3
|
|
||||||
- Example_Flash_Encryption
|
|
||||||
|
|
||||||
example_test_C3_FLASH_ENC_OTA:
|
example_test_C3_FLASH_ENC_OTA:
|
||||||
extends: .example_test_esp32c3_template
|
extends: .example_test_esp32c3_template
|
||||||
tags:
|
tags:
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
@ -6,7 +9,8 @@ import sys
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import ttfw_idf
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import espsecure
|
import espsecure
|
||||||
@ -25,13 +29,10 @@ except ImportError:
|
|||||||
# espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CONFIG 0xf
|
# espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CONFIG 0xf
|
||||||
# espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CNT 0x1
|
# espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CNT 0x1
|
||||||
# espefuse.py --do-not-confirm -p $ESPPORT burn_key flash_encryption key.bin
|
# espefuse.py --do-not-confirm -p $ESPPORT burn_key flash_encryption key.bin
|
||||||
@ttfw_idf.idf_example_test(env_tag='Example_Flash_Encryption', target=['esp32', 'esp32c3'])
|
@pytest.mark.esp32
|
||||||
def test_examples_security_flash_encryption(env, extra_data):
|
@pytest.mark.esp32c3
|
||||||
dut = env.get_dut('flash_encryption', 'examples/security/flash_encryption')
|
@pytest.mark.flash_encryption
|
||||||
|
def test_examples_security_flash_encryption(dut: Dut) -> None:
|
||||||
dut.erase_flash()
|
|
||||||
# start test
|
|
||||||
dut.start_app()
|
|
||||||
# calculate the expected ciphertext
|
# calculate the expected ciphertext
|
||||||
flash_addr = dut.app.partition_table['storage']['offset']
|
flash_addr = dut.app.partition_table['storage']['offset']
|
||||||
plain_hex_str = '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f'
|
plain_hex_str = '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f'
|
||||||
@ -40,7 +41,7 @@ def test_examples_security_flash_encryption(env, extra_data):
|
|||||||
# espsecure uses the cryptography package for encrypting
|
# espsecure uses the cryptography package for encrypting
|
||||||
# with aes-xts, but does not allow for a symmetric key
|
# with aes-xts, but does not allow for a symmetric key
|
||||||
# so the key for later chips are not all zeros
|
# so the key for later chips are not all zeros
|
||||||
if dut.TARGET == 'esp32':
|
if dut.target == 'esp32':
|
||||||
key_bytes = b'\x00' * 32
|
key_bytes = b'\x00' * 32
|
||||||
aes_xts = False
|
aes_xts = False
|
||||||
else:
|
else:
|
@ -32,6 +32,7 @@ markers =
|
|||||||
octal_psram: runners with octal psram
|
octal_psram: runners with octal psram
|
||||||
usb_host: usb host runners
|
usb_host: usb host runners
|
||||||
ethernet_ota: ethernet OTA runners
|
ethernet_ota: ethernet OTA runners
|
||||||
|
flash_encryption: Flash Encryption runners
|
||||||
|
|
||||||
# log related
|
# log related
|
||||||
log_cli = True
|
log_cli = True
|
||||||
|
Loading…
Reference in New Issue
Block a user