samples/tfm_integration/psa_protected_storage/README.html · samples/tfm_integration/psa_protected_storage/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · TF-M

PSA Protected Storage

AES-128-GCM key/value record를 저장·조회·보호·삭제합니다.

Official pathsamples/tfm_integration/psa_protected_storage/README.html
Source filesamples/tfm_integration/psa_protected_storage/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

PS_NUM_ASSETS·PS_MAX_ASSET_SIZE와 board erase 조건을 설명합니다.

Cipher

AES-128-GCM

Key

Hardware Unique Key

Protection

Authentication · Rollback · Overwrite

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 04FA5F93AE93F02030D629D1580295F278E496D240B535E35826950358BEF23C
.. psa_protected_storage:

PSA Protected Storage
#####################

Overview
********

This sample demonstrates how the Protected Storage (PS) API can be used for storing data.

Protected storage provides a key/value storage interface where data is (by default) encrypted, with
optional authentication and rollback protection. The default crypto algorithm is ``AES-128-GCM``.
The encryption key is derived from the Hardware Unique Key (HUK), which is often set via device
fuses, etc.

Using the PS API, this sample stores data to non-volatile storage. The sample shows how data can
be stored to and read from UIDs, and how overwrite protection can be enabled using flags.

TF-M includes a maximum number of PS records, set via ``PS_NUM_ASSETS`` (default 10 as of
TF-M 1.3.0), and a maximum record size, set via ``PS_MAX_ASSET_SIZE`` (default of 2048 as of
TF-M 1.3.0). These defaults may be different depending on the platform being used, the current
value will be printed by the build system during the TF-M compilation step.

More information about Protected Storage can be found in the Platform Security Architecture (PSA)
Secure Storage API: https://developer.arm.com/architectures/architecture-security-features/platform-security

This sample is available for platforms that are supported in the trusted-firmware-m repo:
https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/
See sample.yaml for a list of supported platforms.

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

On Target
=========

Note that the board needs to be completely erased before programming the sample, as the flash area
used might contain data from before. The board must also be erased between each time the sample is
run as the overwrite protection will not be removed with a power reset.

On QEMU
========

Refer to :ref:`tfm_ipc` for detailed instructions.
Following is an example based on ``west build``

   .. code-block:: bash

      $ west build samples/tfm_integration/psa_protected_storage/ -p -b mps2/an521/cpu0/ns -t run

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

.. code-block:: console

    *** Booting Zephyr OS build zephyr-v2.5.0-2791-g5585355dde0c  ***
    TF-M Protected Storage sample started. PSA Protected Storage API Version 1.0
    Writing data to UID1: The quick brown fox jumps over the lazy dog
    Info on data stored in UID1:
    - Size: 16
    - Capacity: 0x42
    - Flags: 0x 0
    Read and compare data stored in UID1
    Data stored in UID1: The quick brown fox jumps over the lazy dog
    Overwriting data stored in UID1 with: Lorem ipsum dolor sit amet
    Writing data to UID2 with overwrite protection: The quick brown fox jumps over the lazy dog
    Attempting to write 'The quick brown fox jumps over the lazy dog' to UID2
    Got expected error (PSA_ERROR_NOT_PERMITTED) when writing to protected UID
    Removing UID1

Part 3

한국어 전문 번역

개요

이 sample은 Protected Storage(PS) API로 data를 저장하는 방법을 보여 줍니다.

Protected Storage는 key/value storage interface를 제공합니다. 기본적으로 data를 encrypt하며 선택적으로 authentication과 rollback protection을 적용할 수 있습니다. 기본 cryptographic algorithm은 AES-128-GCM입니다. Encryption key는 흔히 device fuse 등에 설정되는 Hardware Unique Key(HUK)에서 유도합니다.

이 sample은 PS API로 non-volatile storage에 data를 저장합니다. UID에 data를 저장하고 다시 읽는 방법, flag로 overwrite protection을 활성화하는 방법을 보여 줍니다.

TF-M은 저장할 수 있는 PS record 최대 개수를 PS_NUM_ASSETS로 제한하며 TF-M 1.3.0의 기본값은 10입니다. Record 최대 크기는 PS_MAX_ASSET_SIZE로 제한하며 같은 version의 기본값은 2048입니다. Platform에 따라 기본값이 다를 수 있고 현재 값은 TF-M compile 단계에서 build system이 출력합니다.

Protected Storage의 자세한 내용은 PSA Secure Storage API에서 확인할 수 있습니다.

이 sample은 trusted-firmware-m repository가 지원하는 platform에서 사용할 수 있습니다. 지원 platform 목록은 sample.yaml을 확인하십시오.

빌드 및 실행

실제 Target

Sample을 program하기 전에 board 전체를 erase해야 합니다. 사용될 flash area에 이전 data가 남아 있을 수 있기 때문입니다. Overwrite protection은 power reset만으로 제거되지 않으므로 sample을 실행할 때마다 그 사이에도 board를 erase해야 합니다.

QEMU

자세한 instruction은 TF-M IPC sample을 참고합니다. 다음은 west build 기반 예입니다.

$ west build samples/tfm_integration/psa_protected_storage/ -p -b mps2/an521/cpu0/ns -t run

샘플 출력

Sample은 UID1에 문장을 저장하고 size·capacity·flag 정보를 읽은 뒤, 저장된 data를 읽어 비교하고 다른 문장으로 overwrite합니다. UID2에는 overwrite protection을 설정해 저장하며, 다시 쓰려 할 때 예상한 PSA_ERROR_NOT_PERMITTED가 반환되는지 확인합니다. 마지막으로 UID1을 제거합니다.

*** Booting Zephyr OS build zephyr-v2.5.0-2791-g5585355dde0c  ***
TF-M Protected Storage sample started. PSA Protected Storage API Version 1.0
Writing data to UID1: The quick brown fox jumps over the lazy dog
Info on data stored in UID1:
- Size: 16
- Capacity: 0x42
- Flags: 0x 0
Read and compare data stored in UID1
Data stored in UID1: The quick brown fox jumps over the lazy dog
Overwriting data stored in UID1 with: Lorem ipsum dolor sit amet
Writing data to UID2 with overwrite protection: The quick brown fox jumps over the lazy dog
Attempting to write 'The quick brown fox jumps over the lazy dog' to UID2
Got expected error (PSA_ERROR_NOT_PERMITTED) when writing to protected UID
Removing UID1

Source

출처

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