pytest_nvs_encr_hmac.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Unlicense OR CC0-1.0
  3. import logging
  4. import os
  5. import pytest
  6. from pytest_embedded_idf.dut import IdfDut
  7. STR_KEY_VAL = ['Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
  8. 'Fusce quis risus justo.',
  9. 'Suspendisse egestas in nisi sit amet auctor.',
  10. 'Pellentesque rhoncus dictum sodales.',
  11. 'In justo erat, viverra at interdum eget, interdum vel dui.']
  12. ENCR_TEXT_ARR = ['fe ff ff ff 00 00 00 00 fe ff ff ff ff ff ff ff',
  13. 'ca 8b c3 bb 2d c2 33 d6 6b d4 a7 3d 31 0e 9c 36',
  14. 'bd c1 2a 10 87 44 5e 1c 4b 2c 7c 5d ac 97 48 63']
  15. @pytest.mark.esp32c3
  16. @pytest.mark.nvs_encr_hmac
  17. @pytest.mark.parametrize('config', ['nvs_encr_hmac'], indirect=True)
  18. def test_nvs_flash_encr_keys_hmac(dut: IdfDut) -> None:
  19. # Logging example binary details
  20. binary_file = os.path.join(dut.app.binary_path, 'nvs_encryption_hmac.bin')
  21. bin_size = os.path.getsize(binary_file)
  22. logging.info('nvs_encryption_hmac_bin_size : {}KB'.format(bin_size // 1024))
  23. # Start test and verify serial output
  24. dut.expect('NVS partition "nvs" is encrypted.', timeout=30)
  25. dut.expect('NVS partition "custom_nvs" is encrypted', timeout=30)
  26. dut.expect('Key: u8_key | Val: 255', timeout=30)
  27. dut.expect('Key: i8_key | Val: -128', timeout=30)
  28. dut.expect('Key: u16_key | Val: 65535', timeout=30)
  29. dut.expect('Key: u32_key | Val: 4294967295', timeout=30)
  30. dut.expect('Key: i32_key | Val: -2147483648', timeout=30)
  31. for string in STR_KEY_VAL:
  32. dut.expect(string, timeout=30)
  33. for encr_txt in ENCR_TEXT_ARR:
  34. dut.expect(encr_txt, timeout=30)
  35. dut.expect('Returned from app_main()', timeout=30)