SW 개발

[OPTEE 문서번역] OPTEE Architecture - 5 GlobalPlatform API

. . . 2019. 10. 11. 17:00
반응형

개요

https://optee.readthedocs.io 문서를 구글 번역기 + 네이버번역기를 이용하여 번역하였습니다.

즉, 기계가 번역한 내용이므로 대략적인 내용은 확인가능합니다. 제대로 보시려면 원문을 보시길 권유드립니다.

글순서

5. GlobalPlatform API

5.1. Introduction

GlobalPlatform 은 여러 산업에서 작동하여 보안 칩 기술에서 여러 임베디드 응용 프로그램의 안전하고 상호 운용 가능한 배포 및 관리를 용이하게하는 사양을 식별, 개발 및 게시합니다. OP-TEE는 GlobalPlatform TEE 클라이언트 API Specification v1.0 (GPD_SPE_007) 및 TEE Internal Core API Specification v1.1.2 (GPD_SPE_010) 를 지원합니다.

5.2. TEE Client API

TEE 클라이언트 API는 풍부한 운영 환경 (REE)에서 실행되는 클라이언트가 TEE와 통신하는 방법을 설명하고 정의합니다. 사용할 신뢰할 수있는 응용 프로그램 (TA)을 확인하기 위해 클라이언트는 UUID를 제공합니다. 모든 TA는 하나 또는 여러 기능을 제공합니다. 이러한 함수는 클라이언트가 보낸 소위commandID에 해당합니다.

5.2.1. TEE Contexts

TEE 컨텍스트는 클라이언트와 TEE 간의 논리적 연결을 작성하는 데 사용됩니다. 컨텍스트는 TEE 세션을 생성하기 전에 초기화되어야합니다. 클라이언트가 보안 세계에서 실행중인 작업을 완료하면 컨텍스트를 완료해야하므로 리소스를 해제해야합니다.

5.2.2. TEE Sessions

세션은 클라이언트와 특정 신뢰할 수있는 응용 프로그램 간의 논리적 연결을 만드는 데 사용됩니다. 세션이 설정되면 클라이언트는 UUID로 식별되는 지정된 신뢰할 수있는 응용 프로그램에 대한 통신 채널을 열었습니다. 이 단계에서 클라이언트와 신뢰할 수있는 응용 프로그램은 데이터 교환을 시작할 수 있습니다.

5.2.3. TEE Client API example / usage

아래에는 GlobalPlatform에서 정의한 주요 기능이 있으며 클라이언트와 TEE 간의 통신에 사용됩니다.

TEEC_Result TEEC_InitializeContext(
    const char* name,
    TEEC_Context* context)

void TEEC_FinalizeContext(
    TEEC_Context* context)

TEEC_Result TEEC_OpenSession (
    TEEC_Context* context,
    TEEC_Session* session,
    const TEEC_UUID* destination,
    uint32_t connectionMethod,
    const void* connectionData,
    TEEC_Operation* operation,
    uint32_t* returnOrigin)

void TEEC_CloseSession (
    TEEC_Session* session)

TEEC_Result TEEC_InvokeCommand(
    TEEC_Session* session,
    uint32_t commandID,
    TEEC_Operation* operation,
    uint32_t* returnOrigin)

원칙적으로 명령은 다음 순서로 호출됩니다.

TEEC_InitializeContext(...)
TEEC_OpenSession(...)
TEEC_InvokeCommand(...)
TEEC_CloseSession(...)
TEEC_FinalizeContext(...)

세션이 설정되면TEEC_InvokeCommand (...)가 여러 번 연속적으로 호출된다는 것은 드문 일이 아닙니다.

전체 예제는 the GlobalPlatform TEE Client API Specification v1.0. 내에 5.2 Example 1: Using the TEE Client API 챕터를 확인하십시오.

5.3. TEE Internal Core API

Internal Core API는 보안 세계에서 실행되는 신뢰할 수있는 응용 프로그램에 노출되는 API입니다. TEE Internal API는 크게 네 부분으로 구성됩니다.

  1. Trusted Storage API for Data and Keys
  2. Cryptographic Operations API
  3. Time API
  4. Arithmetical API

5.3.1. Examples / usage

Internal Core API 호출은 Client API를 사용하여 위에서 설명한 것과 같은 방법으로 수행됩니다. 이것이 어떻게 수행되어야하는지에 대한 정보를 찾는 가장 좋은 장소는 TEE Internal Core API Specification v1.1.2 입니다. 여기에는 많은 예가 들어 있습니다 다양한 API를 호출하는 방법에 대해 설명합니다. optee_examples git 에 있는 예제를 살펴볼 수도 있습니다.

5.4. Extensions

TEE Internal Core API 에 명시된 것 외에도 OP-TEE에는 비공식 확장이 있습니다.

신뢰할 수있는 응용 프로그램에는 확장의 정의를 가져 오기위한 헤더 파일tee_api_defines_extensions.h가 포함되어야합니다. 각 확장에 대해,CFG_ 접두어가 붙은 설정 지시어는 OP-TEE 패키지를 만들 때 확장에 대한 지원을 비활성화합니다.

5.4.1. Cache Maintenance Support

신뢰할 수있는 응용 프로그램이 데이터 캐시와 함께 작동 할 수 있도록하기 위해 다음 함수가이 도입되었습니다:

TEE_Result TEE_CacheClean(char *buf, size_t len);
TEE_Result TEE_CacheFlush(char *buf, size_t len);
TEE_Result TEE_CacheInvalidate(char *buf, size_t len);

이 함수들은 TA_FLAG_CACHE_MAINTENANCE 플래그가 설정된 신뢰 애플리케이션에 대해 사용할 수 있습니다. Cache maintenance Flag 를 참조하십시오. 설정되지 않은 경우 각 함수는 TEE_ERROR_NOT_SUPPORTED 오류 코드를 반환합니다. 이러한 확장 내에서 신뢰할 수있는 응용 프로그램은 다음 사양을 사용하여 데이터 캐시에서 작동 할 수 있습니다.

Function Description
TEE_CacheClean() Write back to memory any dirty data cache lines. The line is marked as not dirty. The valid bit is unchanged.
TEE_CacheFlush() Purges any valid data cache lines. Any dirty cache lines are first written back to memory, then the cache line is invalidated.
TEE_CacheInvalidate() Invalidate any valid data cache lines. Any dirty line are not written back to memory.

다음 두 가지 경우에 오류 코드TEE_ERROR_ACCESS_DENIED가 반환됩니다.

  • The memory range has not the write access, that is TEE_MEMORY_ACCESS_WRITE is not set.
  • The memory is not user space memory.

conf.mk에 다음 설정 변수를 설정하여 이 확장을 비활성화 할 수 있습니다 :

CFG_CACHE_API := n

5.4.2. PKCS#1 v5 RSASSA without hash OID

이 확장은 identiferTEE_ALG_RSASSA_PKCS1_V1_5를 추가하여 RFC 3447의 RSASSA-PKCS1-v1_5로 서명하고 검증하는 메시지를 허용합니다. 서명 내의 해시의 OID conf.mk에 다음 설정 변수를 설정하여이 확장을 비활성화 할 수 있습니다 :

CFG_CRYPTO_RSASSA_NA1 := n

TEE 내부 핵심 API는 새로운 알고리즘 설명자로 확장되었습니다.

Algorithm Possible Modes
TEE_ALG_RSASSA_PKCS1_V1_5 TEE_MODE_SIGN / TEE_MODE_VERIFY
Algorithm Identifier
TEE_ALG_RSASSA_PKCS1_V1_5 0xF0000830

5.4.3. Concat KDF

SP 800-56A (Recommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryptography) 에 따른 Concatenation Key Derivation Function (Concat KDF) 에 대한 지원은 OP-TEE에서 찾을 수 있습니다. conf.mk에 다음 설정 변수를 설정하여이 확장을 비활성화 할 수 있습니다 :

CFG_CRYPTO_CONCAT_KDF := n

Implementation notes

모든 키 및 매개 변수 크기는 8 비트의 배수 여야합니다.That is:

  • Input parameters: the shared secret (Z) and OtherInfo.
  • Output parameter: the derived key (DerivedKeyingMaterial).

또한 파생 키의 최대 크기는TEE_TYPE_GENERIC_SECRET (512 바이트) 유형의 객체의 크기에 의해 제한됩니다. 이 구현은OtherInfo 매개 변수의 내용에 대한 요구 사항을 적용하지 않습니다. 준수가 필요한 경우이 매개 변수가 NIST 사양에 지정된대로 구성되었는지 확인하는 것은 응용 프로그램의 책임입니다.

API extension

"Concert KDF"를 지원하기 위해 "TEE Internal Core API v1.1"이 새로운 알고리즘 설명자로 확장되었습니다 , 새 객체 유형 및 새 객체 속성을 정의합니다.

p.95 Add new object type to TEE_PopulateTransientObject

The following entry shall be added to Table 5-8:

Object type Parts
TEE_TYPE_CONCAT_KDF_Z The TEE_ATTR_CONCAT_KDF_Z part (input shared secret) must be provided.

p.121 Add new algorithms for TEE_AllocateOperation

The following entry shall be added to Table 6-3:

Algorithm Possible Modes
TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY TEE_MODE_DERIVE

p.126 Explain usage of HKDF algorithms in TEE_SetOperationKey

작동 모드에 관한 글 머리 기호 목록에 다음 내용이 추가됩니다.

  • For the Concat KDF algorithms, the only supported mode is TEE_MODE_DERIVE.

p.150 Define TEE_DeriveKey input attributes for new algorithms

다음 문장이 삭제됩니다.

The TEE_DeriveKey function can only be used with the algorithm TEE_ALG_DH_DERIVE_SHARED_SECRET.

The following entry shall be added to Table 6-7:

Algorithm Possible operation parameters
TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY TEE_ATTR_CONCAT_KDF_DKM_LENGTH: up to 512 bytes. This parameter is mandatory: TEE_ATTR_CONCAT_KDF_OTHER_INFO

p.152 Add new algorithm identifiers

The following entries shall be added to Table 6-8:

Algorithm Identifier
TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY 0x800020C1
TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY 0x800030C1
TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY 0x800040C1
TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY 0x800050C1
TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY 0x800060C1

p.154 Define new main algorithm

6.10.1 절의 표 6-9에서 행 비트[7:0]의 값 열에 새로운 값이 추가된다.

Bits Function Value
Bits [7:0] Identifiy the main underlying algorithm itself …0xC1: Concat KDF

bits [15:12]에 대한 함수 칼럼은 다음과 같이 수정되어야한다 :

Bits Function Value
Bits [15:12] Define the message digest for asymmetric signature algorithms or Concat KDF

p.155 Add new object type for Concat KDF input shared secret

표 6-10에 다음 항목을 추가해야한다.

Name Identifier Possible sizes
TEE_TYPE_CONCAT_KDF_Z 0xA10000C1 8 to 4096 bits (multiple of 8)

p.156 Add new operation attributes for Concat KDF

다음 항목이 표 6-11에 추가되어야한다.

Name Value Protection Type Comment
TEE_ATTR_CONCAT_KDF_Z 0xC00001C1 Protected Ref The shared secret (Z)
TEE_ATTR_CONCAT_KDF_OTHER_INFO 0xD00002C1 Public Ref OtherInfo
TEE_ATTR_CONCAT_KDF_DKM_LENGTH 0xF00003C1 Public Value The length (in bytes) of the derived keying material to be generated, maximum 512. This is KeyDataLen/ 8.

5.4.4. HKDF

OP-TEE는 "RFC 5869)"에 명시된 "HMAC-based Extract-and-Expand Key Derivation Function (HKDF)"을 구현합니다. 이 파일은이 알고리즘을 지원하도록 구현 된 "TEE Internal Core API v1.1"에 대한 확장을 문서화합니다 . 신뢰할 수있는 응용 프로그램은 정의를 가져 오기 위해 를 포함해야합니다.

구현은 새로운 알고리즘을 추가하기위한 버전 1.1 사양의 권장 사항을 따릅니다. 공식 사양의 향후 변경 사항과 호환되어야합니다. conf.mk에서 다음과 같이 설정하여이 확장을 비활성화 할 수 있습니다 :

CFG_CRYPTO_HKDF := n

p.95 Add new object type to TEE_PopulateTransientObject (HKDF)

The following entry shall be added to Table 5-8:

Object type Parts
TEE_TYPE_HKDF_IKM The TEE_ATTR_HKDF_IKM (Input Keying Material) part must be provided.

p.121 Add new algorithms for TEE_AllocateOperation (HKDF)

The following entry shall be added to Table 6-3:

Algorithm Possible Modes
TEE_ALG_HKDF_MD5_DERIVE_KEY TEE_ALG_HKDF_SHA1_DERIVE_KEY TEE_ALG_HKDF_SHA224_DERIVE_KEY TEE_ALG_HKDF_SHA256_DERIVE_KEY TEE_ALG_HKDF_SHA384_DERIVE_KEY TEE_ALG_HKDF_SHA512_DERIVE_KEY TEE_ALG_HKDF_SHA512_DERIVE_KEY TEE_MODE_DERIVE

p.126 Explain usage of HKDF algorithms in TEE_SetOperationKey (HKDF)

In the bullet list about operation mode, the following shall be added:

  • For the HKDF algorithms, the only supported mode is TEE_MODE_DERIVE.

p.150 Define TEE_DeriveKey input attributes for new algorithms (HKDF)

The following sentence shall be deleted:

The TEE_DeriveKey function can only be used with the algorithm
TEE_ALG_DH_DERIVE_SHARED_SECRET

The following entry shall be added to Table 6-7:

Algorithm Possible operation parameters
TEE_ALG_HKDF_MD5_DERIVE_KEY TEE_ALG_HKDF_SHA1_DERIVE_KEY TEE_ALG_HKDF_SHA224_DERIVE_KEY TEE_ALG_HKDF_SHA256_DERIVE_KEY TEE_ALG_HKDF_SHA384_DERIVE_KEY TEE_ALG_HKDF_SHA512_DERIVE_KEY TEE_ALG_HKDF_SHA512_DERIVE_KEY TEE_ATTR_HKDF_OKM_LENGTH: Number of bytes in the Output Keying MaterialTEE_ATTR_HKDF_SALT (optional) Salt to be used during the extract stepTEE_ATTR_HKDF_INFO (optional) Info to be used during the expand step

p.152 Add new algorithm identifiers (HKDF)

The following entries shall be added to Table 6-8:

Algorithm Identifier
TEE_ALG_HKDF_MD5_DERIVE_KEY 0x800010C0
TEE_ALG_HKDF_SHA1_DERIVE_KEY 0x800020C0
TEE_ALG_HKDF_SHA224_DERIVE_KEY 0x800030C0
TEE_ALG_HKDF_SHA256_DERIVE_KEY 0x800040C0
TEE_ALG_HKDF_SHA384_DERIVE_KEY 0x800050C0
TEE_ALG_HKDF_SHA512_DERIVE_KEY 0x800060C0

p.154 Define new main algorithm (HKDF)

In Table 6-9 in section 6.10.1, a new value shall be added to the value column for row bits [7:0]:

Bits Function Value
Bits [7:0] Identifiy the main underlying algorithm itself …0xC0: HKDF

The function column for bits[15:12] shall also be modified to read:

Bits Function Value
Bits [15:12] Define the message digest for asymmetric signature algorithms or HKDF

p.155 Add new object type for HKDF input keying material (HKDF)

The following entry shall be added to Table 6-10:

Name Identifier Possible sizes
TEE_TYPE_HKDF_IKM 0xA10000C0 8 to 4096 bits (multiple of 8)

p.156 Add new operation attributes for HKDF salt and info (HKDF)

The following entries shall be added to Table 6-11:

Name Value Protection Type Comment
TEE_ATTR_HKDF_IKM 0xC00001C0 Protected Ref
TEE_ATTR_HKDF_SALT 0xD00002C0 Public Ref
TEE_ATTR_HKDF_INFO 0xD00003C0 Public Ref
TEE_ATTR_HKDF_OKM_LENGTH 0xF00004C0 Public Value

5.4.5. PBKDF2

이 문서는 "RFC 2898 섹션 5.2"에 명시된 키 유도 함수 인 PBKDF2의 OP-TEE 구현을 설명합니다. 이 RFC는 RSA Laboratories의 "Public-Key Cryptography Standards (PKCS)"시리즈에서 PKCS # 5 v2.0을 다시 발행 한 것입니다. conf.mk에 다음 설정 변수를 설정하여이 확장을 비활성화 할 수 있습니다 :

CFG_CRYPTO_PBKDF2 := n

API extension (PBKDF2)

PBKDF2를 지원하기 위해 "TEE Internal Core API v1.1"이 새로운 알고리즘 설명자로 확장되었으며 new 오브젝트 유형 및 새 오브젝트 속성을 설명합니다.

p.95 Add new object type to TEE_PopulateTransientObject (PBKDF2)

The following entry shall be added to Table 5-8:

Object type Parts
TEE_TYPE_PBKDF2_PASSWORD The TEE_ATTR_PBKDF2_PASSWORD part must be provided.

p.121 Add new algorithms for TEE_AllocateOperation (PBKDF2)

The following entry shall be added to Table 6-3:

Algorithm Possible Modes
TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY TEE_MODE_DERIVE

p.126 Explain usage of PBKDF2 algorithm in TEE_SetOperationKey (PBKDF2)

In the bullet list about operation mode, the following shall be added:

  • For the PBKDF2 algorithm, the only supported mode is TEE_MODE_DERIVE.

p.150 Define TEE_DeriveKey input attributes for new algorithms (PBKDF2)

The following sentence shall be deleted:

The TEE_DeriveKey function can only be used with the algorithm
TEE_ALG_DH_DERIVE_SHARED_SECRET

The following entry shall be added to Table 6-7:

Algorithm Possible operation parameters
TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY TEE_ATTR_PBKDF2_DKM_LENGTH: up to 512 bytes. This parameter is mandatory.TEE_ATTR_PBKDF2_SALTTEE_ATTR_PBKDF2_ITERATION_COUNT: This parameter is mandatory.

p.152 Add new algorithm identifiers (PBKDF2)

The following entries shall be added to Table 6-8:

Algorithm Identifier
TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY 0x800020C2

p.154 Define new main algorithm (PBKDF2)

In Table 6-9 in section 6.10.1, a new value shall be added to the value column for row bits [7:0]:

Bits Function Value
Bits [7:0] Identifiy the main underlying algorithm itself …0xC2: PBKDF2

The function column for bits[15:12] shall also be modified to read:

Bits Function Value
Bits [15:12] Define the message digest for asymmetric signature algorithms or PBKDF2

p.155 Add new object type for PBKDF2 password (PBKDF2)

The following entry shall be added to Table 6-10:

Name Identifier Possible sizes
TEE_TYPE_PBKDF2_PASSWORD 0xA10000C2 8 to 4096 bits (multiple of 8)

p.156 Add new operation attributes for Concat KDF (PBKDF2)

The following entries shall be added to Table 6-11:

Name Value Protection Type Comment
TEE_ATTR_PBKDF2_PASSWORD 0xC00001C2 Protected Ref
TEE_ATTR_PBKDF2_SALT 0xD00002C2 Public Ref
TEE_ATTR_PBKDF2_ITERATION_COUNT 0xF00003C2 Public Value
TEE_ATTR_PBKDF2_DKM_LENGTH 0xF00004C2 Public Value The length (in bytes) of the derived keying material to be generated, maximum 512.
반응형