Part 1
요약·해설
Arm PSA interface를 Zephyr가 Mbed TLS로 구현하며 TLS, secure storage, pairing, boot, attestation과 provisioning에 사용합니다.
Mbed TLS
Opaque identifiers
Errors · Concurrency · Wipe
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
E459665ADBF68B0FA99F9744C124B07FAFCF22EDDB8EFAA1D23E7F857EC29683
.. _psa_crypto:
PSA Crypto
##########
Overview
********
The PSA (Platform Security Architecture) Crypto API offers a portable
programming interface for cryptographic operations and key storage
across a wide range of hardware. It is designed to be user-friendly
while still providing access to the low-level primitives essential for
modern cryptography.
It is created and maintained by Arm. Arm developed the PSA as a
comprehensive security framework to address the increasing security
needs of connected devices.
In Zephyr, the PSA Crypto API is implemented using Mbed TLS, an
open-source cryptographic library that provides the underlying
cryptographic functions.
Design Goals
************
The interface is suitable for a vast range of devices: from
special-purpose cryptographic processors that process data with a
built-in key, to constrained devices running custom application code,
such as microcontrollers, and multi-application devices, such as
servers. It follows the principle of cryptographic agility.
Algorithm Flexibility
The PSA Crypto API supports a wide range of cryptographic algorithms,
allowing developers to switch between different cryptographic
methods as needed. This flexibility is crucial for maintaining
security as new algorithms emerge and existing ones become obsolete.
Key Management
The PSA Crypto API includes robust key management features that
support the creation, storage, and use of cryptographic keys in a
secure and flexible manner. It uses opaque key identifiers, which
allows for easy key replacement and updates without exposing key
material.
Implementation Independence
The PSA Crypto API abstracts the underlying cryptographic library,
meaning that the specific implementation can be changed without
affecting the application code. This abstraction supports
cryptographic agility by enabling the use of different cryptographic
libraries or hardware accelerators as needed.
Future-Proofing
By adhering to cryptographic agility, PSA Crypto ensures that
applications can quickly adapt to new cryptographic standards and
practices, enhancing long-term security and compliance.
Examples of Applications
************************
Network Security (TLS)
The API provides all of the cryptographic primitives needed to establish TLS connections.
Secure Storage
The API provides all primitives related to storage encryption, block
or file-based, with master encryption keys stored inside a key store.
Network Credentials
The API provides network credential management inside a key store,
for example, for X.509-based authentication or pre-shared keys on
enterprise networks.
Device Pairing
The API provides support for key agreement protocols that are often
used for secure pairing of devices over wireless channels. For
example, the pairing of an NFC token or a Bluetooth device might use
key agreement protocols upon first use.
Secure Boot
The API provides primitives for use during firmware integrity and
authenticity validation, during a secure or trusted boot process.
Attestation
The API provides primitives used in attestation
activities. Attestation is the ability for a device to sign an array
of bytes with a device private key and return the result to the
caller. There are several use cases; ranging from attestation of the
device state, to the ability to generate a key pair and prove that it
has been generated inside a secure key store. The API provides access
to the algorithms commonly used for attestation.
Factory Provisioning
Most IoT devices receive a unique identity during the factory
provisioning process, or once they have been deployed to the
field. This API provides the APIs necessary for populating a device
with keys that represent that identity.
Usage considerations
********************
Always check for errors
Most functions in the PSA Crypto API can return errors. All functions
that can fail have the return type ``psa_status_t``. A few functions
cannot fail, and thus, return void or some other type.
If an error occurs, unless otherwise specified, the content of the
output parameters is undefined and must not be used.
Some common causes of errors include:
* In implementations where the keys are stored and processed in a
separate environment from the application, all functions that need
to access the cryptography processing environment might fail due
to an error in the communication between the two environments.
* If an algorithm is implemented with a hardware accelerator, which
is logically separate from the application processor, the
accelerator might fail, even when the application processor keeps
running normally.
* Most functions might fail due to a lack of resources. However,
some implementations guarantee that certain functions always have
sufficient memory.
* All functions that access persistent keys might fail due to a
storage failure.
* All functions that require randomness might fail due to a lack of
entropy. Implementations are encouraged to seed the random
generator with sufficient entropy during the execution of
``psa_crypto_init()``. However, some security standards require
periodic reseeding from a hardware random generator, which can
fail.
Shared memory and concurrency
Some environments allow applications to be multithreaded, while
others do not. In some environments, applications can share memory
with a different security context. In environments with
multithreaded applications or shared memory, applications must be
written carefully to avoid data corruption or leakage. This
specification requires the application to obey certain constraints.
In general, the PSA Crypto API allows either one writer or any number of
simultaneous readers, on any given object. In other words, if two or
more calls access the same object concurrently, then the behavior is
only well-defined if all the calls are only reading from the object
and do not modify it. Read accesses include reading memory by input
parameters and reading keystore content by using a key. For more
details, refer to `Concurrent calls
<https://arm-software.github.io/psa-api/crypto/1.2/overview/conventions.html#concurrent-calls>`_
If an application shares memory with another security context, it
can pass shared memory blocks as input buffers or output buffers,
but not as non-buffer parameters. For more details, refer to
`Stability of parameters <https://arm-software.github.io/psa-api/crypto/1.2/overview/conventions.html#stability-of-parameters>`_.
Cleaning up after use
To minimize impact if the system is compromised, it is recommended
that applications wipe all sensitive data from memory when it is no
longer used. That way, only data that is currently in use can be
leaked, and past data is not compromised.
Wiping sensitive data includes:
* Clearing temporary buffers in the stack or on the heap.
* Aborting operations if they will not be finished.
* Destroying keys that are no longer used.
References
**********
* `PSA Crypto`_
.. _PSA Crypto:
https://arm-software.github.io/psa-api/crypto/
* `Mbed TLS`_
.. _Mbed TLS:
https://www.trustedfirmware.org/projects/mbed-tls/
Part 3
한국어 전문 번역
개요
PSA(Platform Security Architecture) Crypto API는 폭넓은 hardware에서 cryptographic operation과 key storage를 사용할 수 있게 하는 portable programming interface입니다. 사용하기 쉽게 설계하면서도 modern cryptography에 필요한 low-level primitive에 접근할 수 있습니다.
Arm이 만들고 유지합니다. Arm은 connected device의 증가하는 security requirement에 대응하는 포괄적인 security framework로 PSA를 개발했습니다.
Zephyr에서는 기반 cryptographic function을 제공하는 open-source cryptographic library인 Mbed TLS로 PSA Crypto API를 구현합니다.
설계 목표
이 interface는 built-in key로 data를 처리하는 special-purpose cryptographic processor부터 custom application code를 실행하는 constrained microcontroller, server 같은 multi-application device까지 매우 넓은 범위에 적합합니다. Cryptographic agility 원칙을 따릅니다.
- Algorithm flexibility
- 폭넓은 cryptographic algorithm을 지원해 developer가 필요에 따라 method를 바꿀 수 있습니다. 새 algorithm이 등장하고 기존 algorithm이 obsolete될 때 security를 유지하는 데 중요합니다.
- Key management
- Cryptographic key를 안전하고 유연하게 생성·저장·사용하는 강력한 key management feature를 제공합니다. Opaque key identifier를 사용하므로 key material을 노출하지 않고 key를 쉽게 교체하고 update할 수 있습니다.
- Implementation independence
- 기반 cryptographic library를 abstract하므로 application code에 영향을 주지 않고 implementation을 바꿀 수 있습니다. 필요에 따라 다른 library나 hardware accelerator를 사용해 cryptographic agility를 지원합니다.
- Future-proofing
- Cryptographic agility를 따르면 application이 새로운 cryptographic standard와 practice에 빠르게 적응해 장기 security와 compliance를 높일 수 있습니다.
Application 예
- Network security(TLS)
- TLS connection을 수립하는 데 필요한 모든 cryptographic primitive를 제공합니다.
- Secure storage
- Block 또는 file 기반 storage encryption primitive를 제공하며 master encryption key는 key store 안에 저장합니다.
- Network credential
- Enterprise network의 X.509 authentication이나 pre-shared key처럼 key store 안에서 network credential을 관리합니다.
- Device pairing
- Wireless channel에서 secure device pairing에 흔히 사용하는 key-agreement protocol을 지원합니다. NFC token이나 Bluetooth device가 최초 사용 시 key agreement를 수행하는 경우가 예입니다.
- Secure boot
- Secure 또는 trusted boot process에서 firmware integrity와 authenticity를 검증할 때 사용할 primitive를 제공합니다.
- Attestation
- Device가 byte array를 device private key로 sign해 caller에게 돌려주는 attestation에 쓰는 primitive를 제공합니다. Device state attestation부터 key pair를 secure key store 안에서 생성했다는 proof까지 여러 use case가 있으며, 흔히 사용하는 attestation algorithm에 접근할 수 있습니다.
- Factory provisioning
- 대부분의 IoT device는 factory provisioning 또는 field deployment 이후 unique identity를 받습니다. API는 이 identity를 나타내는 key를 device에 넣는 데 필요한 operation을 제공합니다.
사용 시 고려 사항
- 항상 error 확인
-
PSA Crypto API function 대부분은 error를 반환할 수 있습니다. 실패 가능한 function은 모두
psa_status_t를 반환합니다. 실패할 수 없는 일부 function만 void나 다른 type을 반환합니다.Error가 발생하면 별도 명시가 없는 한 output parameter 내용은 undefined이므로 사용하면 안 됩니다.
흔한 error 원인은 다음과 같습니다.
- Key를 application과 분리된 environment에서 저장·처리하는 implementation에서는 두 environment의 communication error 때문에 cryptographic processing environment에 접근하는 모든 function이 실패할 수 있습니다.
- Application processor와 논리적으로 분리된 hardware accelerator로 algorithm을 구현하면 application processor가 정상 동작해도 accelerator는 실패할 수 있습니다.
- Function 대부분은 resource 부족으로 실패할 수 있습니다. 다만 일부 implementation은 특정 function에 충분한 memory가 항상 있다고 보장합니다.
- Persistent key에 접근하는 모든 function은 storage failure로 실패할 수 있습니다.
- Randomness가 필요한 모든 function은 entropy 부족으로 실패할 수 있습니다.
psa_crypto_init()실행 중 충분한 entropy로 random generator를 seed하는 것이 권장됩니다. 일부 security standard는 hardware random generator로 주기적 reseeding을 요구하며 이 과정도 실패할 수 있습니다.
- Shared memory와 concurrency
-
어떤 environment는 multithreaded application을 허용하지만 다른 environment는 허용하지 않습니다. Application이 다른 security context와 memory를 공유할 수도 있습니다. Multithreading이나 shared memory가 있으면 data corruption과 leakage를 막도록 application을 신중하게 작성하고 specification의 constraint를 지켜야 합니다.
일반적으로 PSA Crypto API는 주어진 object에 writer 하나 또는 동시 reader 여러 개를 허용합니다. 두 개 이상의 call이 같은 object에 동시에 접근할 때 모든 call이 object를 read만 하고 modify하지 않아야 behavior가 정의됩니다. Read access에는 input parameter로 memory를 읽는 것과 key를 사용해 keystore content를 읽는 것이 포함됩니다. 자세한 내용은 Concurrent calls를 참고합니다.
Application이 다른 security context와 memory를 공유하면 shared memory block을 input 또는 output buffer로 전달할 수 있지만 non-buffer parameter로는 전달할 수 없습니다. 자세한 내용은 Stability of parameters를 참고합니다.
- 사용 후 정리
-
System이 compromise됐을 때 영향을 줄이려면 더는 사용하지 않는 sensitive data를 memory에서 모두 wipe하는 것이 좋습니다. 그러면 현재 사용하는 data만 leak될 수 있고 과거 data는 보호됩니다.
- Stack이나 heap의 temporary buffer 지우기
- 끝내지 않을 operation abort
- 더는 사용하지 않는 key destroy
참고 자료
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.