samples/boards/esp32/flash_encryption/README.html · samples/boards/esp32/flash_encryption/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Boards · ESP32 Security

ESP32 Flash Encryption Test

첫 boot의 in-place encryption과 development·release mode의 보안 차이를 검증합니다.

Official pathsamples/boards/esp32/flash_encryption/README.html
Source filesamples/boards/esp32/flash_encryption/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Key 보관·eFuse 주의사항과 bootloader/application/storage 기본 암호화 범위를 설명합니다.

Modes

Development · Release

Key

Device · Host generated

Protected

Bootloader · App · Storage

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 DB34663AF19130F4F509724E6C020C7B91E1A63BF4F0414D75873F19D241CA2B
.. _flash_encryption_test:

Espressif ESP32 Flash Encryption Test
#####################################

Overview
********

Flash encryption is intended for encrypting the contents of the ESP32's off-chip flash memory.
Once this feature is enabled, firmware is flashed as plaintext and then the data is encrypted
in place on the first boot. As a result, physical readout of flash will not be sufficient to
recover most flash contents. This is a hardware feature that can be enabled in MCUboot build process
and is an additional security measure beyond MCUboot existent features.

The following flash encryption modes are available:

* Development Mode

   Recommended for use ONLY DURING DEVELOPMENT, as it does not prevent modification and
   readout of encrypted flash contents.

* Release Mode

   Recommended for manufacturing and production to prevent physical readout of encrypted flash
   contents. When release mode is selected..

With flash encryption enabled, the following types of data are encrypted by default:

* Bootloader area
* Application area
* Storage area

For more details, check `ESP32 Flash Encryption`_ and `MCUBoot Readme`_.

Software Requirements
*********************

The following Python modules are required when building flash encryption sample:

* cryptography
* imgtool>=1.9.0

Setup
*****

This sample code isn't enough to enable flash encryption as it only consists on displaying
encrypted/decrypted data. It requires MCUBoot bootloader previously configured to enable the
feature. Follow the instructions provided at `MCUBoot Readme`_ prior to running this sample.

.. warning::
  When enabling the Flash Encryption, user can encrypt the content either using a device
  generated key (remains unknown and unreadable) or a host generated key (owner is responsible
  for keeping the key private and safe as .bin file). After the flash encryption gets enabled
  through eFuse burning on the device, all read and write operations are decrypted/encrypted
  in runtime.


Supported SoCs
**************

The following SoCs are supported by this sample code so far:

* ESP32

Building and Running
********************

Make sure you have your board connected over USB port.

.. code-block:: console

   west build -b esp32_devkitc_wrover samples/boards/esp32/flash_encryption
   west flash

Sample Output
=============

To check the output of this sample, run ``west espressif monitor`` or any other serial
console program (e.g., minicom, putty, screen, etc).
This example uses ``west espressif monitor``, which automatically detects the serial
port at ``/dev/ttyUSB0``:

.. code-block:: console

   $ west espressif monitor

The sample code writes a known buffer into the storage area defined in DTS file.
Then, it dumps 32-bytes of the same memory area in plaintext mode. The content is encrypted, meaning
that a reading attack to the off-chip memory is safe. Last step is to perform the
memory reading using proper spi_flash call, which decrypts the content as expected.

.. code-block:: console

   *** Booting Zephyr OS build v2.7.99-2729-geb08584393d6  ***
   [00:00:00.453,000] <inf> flash_encryption: Found flash controller FLASH_CTRL.

   [00:00:00.453,000] <inf> flash_encryption: BUFFER CONTENT
                                           00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f |........ ........
                                           10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f |........ ........
   [00:00:00.482,000] <inf> flash_encryption: FLASH RAW DATA (Encrypted)
                                           9a 06 93 76 12 cb 0f 7e  ec c5 12 6f 64 db d1 ff |...v...~ ...od...
                                           08 e6 be 0c cd 06 6d ad  7d 55 3d 57 bf b7 be 0a |......m. }U=W....
   [00:00:00.482,000] <inf> flash_encryption: FLASH DECRYPTED DATA
                                           00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f |........ ........
                                           10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f |........ ........


.. _ESP32 Flash Encryption:
   https://docs.espressif.com/projects/esp-idf/en/latest/esp32/security/flash-encryption.html

.. _MCUBoot Readme:
   https://docs.mcuboot.com/readme-espressif

Part 3

한국어 전문 번역

개요

Flash encryption은 ESP32의 off-chip flash memory 내용을 암호화하기 위한 기능입니다. 이 기능을 활성화하면 firmware를 plaintext로 flash한 뒤 첫 boot에서 data를 제자리에서 암호화합니다. 따라서 flash를 물리적으로 읽는 것만으로는 flash 내용 대부분을 복구할 수 없습니다. MCUboot build 과정에서 활성화할 수 있는 hardware 기능이며 기존 MCUboot 기능에 더하는 추가 security measure입니다.

다음 flash encryption mode를 사용할 수 있습니다.

  • Development Mode: 암호화된 flash 내용의 수정과 readout을 막지 못하므로 개발 중에만 사용하는 것을 권장합니다.
  • Release Mode: 암호화된 flash 내용의 물리적 readout을 막아야 하는 제조·production 환경에 권장합니다. Release mode를 선택하면..

Flash encryption을 활성화하면 기본적으로 다음 data가 암호화됩니다.

  • Bootloader area
  • Application area
  • Storage area

자세한 내용은 ESP32 Flash Encryption과 MCUboot Readme를 참조하십시오.

Software 요구사항

Flash encryption sample을 build하려면 다음 Python module이 필요합니다.

  • cryptography
  • imgtool>=1.9.0

설정

이 sample code는 암호화·복호화된 data를 표시하기만 하므로 이것만으로는 flash encryption을 활성화할 수 없습니다. 먼저 이 기능을 활성화하도록 MCUboot bootloader를 구성해야 합니다. Sample을 실행하기 전에 MCUboot Readme의 지침을 따르십시오.

지원 SoC

현재 이 sample code는 다음 SoC를 지원합니다.

  • ESP32

Build와 실행

Board가 USB port에 연결되어 있는지 확인하십시오.

west build -b esp32_devkitc_wrover samples/boards/esp32/flash_encryption
west flash

Sample 출력

이 sample의 출력을 확인하려면 west espressif monitor 또는 minicom, PuTTY, screen 같은 serial console program을 실행합니다. 이 예제에서 사용하는 west espressif monitor는 /dev/ttyUSB0 serial port를 자동으로 감지합니다.

$ west espressif monitor

Sample code는 DTS file에 정의된 storage area에 알려진 buffer를 기록합니다. 그런 다음 같은 memory area의 32 byte를 plaintext mode로 dump합니다. 실제 내용은 암호화되어 있으므로 off-chip memory read attack으로부터 보호됩니다. 마지막으로 올바른 spi_flash call로 memory를 읽으면 예상대로 내용이 복호화됩니다.

*** Booting Zephyr OS build v2.7.99-2729-geb08584393d6  ***
[00:00:00.453,000] <inf> flash_encryption: Found flash controller FLASH_CTRL.

[00:00:00.453,000] <inf> flash_encryption: BUFFER CONTENT
                                        00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f |........ ........
                                        10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f |........ ........
[00:00:00.482,000] <inf> flash_encryption: FLASH RAW DATA (Encrypted)
                                        9a 06 93 76 12 cb 0f 7e  ec c5 12 6f 64 db d1 ff |...v...~ ...od...
                                        08 e6 be 0c cd 06 6d ad  7d 55 3d 57 bf b7 be 0a |......m. }U=W....
[00:00:00.482,000] <inf> flash_encryption: FLASH DECRYPTED DATA
                                        00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f |........ ........
                                        10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f |........ ........

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.