Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _globalplatform_api: |
| 2 | |
| 3 | ################## |
| 4 | GlobalPlatform API |
| 5 | ################## |
| 6 | Introduction |
| 7 | ************ |
| 8 | GlobalPlatform_ works across industries to identify, develop and publish |
| 9 | specifications which facilitate the secure and interoperable deployment and |
| 10 | management of multiple embedded applications on secure chip technology. OP-TEE |
| 11 | has support for GlobalPlatform TEE Client API Specification_ v1.0 (GPD_SPE_007) |
| 12 | and TEE Internal Core API Specification v1.1.2 (GPD_SPE_010). |
| 13 | |
| 14 | |
| 15 | .. _tee_client_api: |
| 16 | |
| 17 | TEE Client API |
| 18 | ************** |
| 19 | The TEE Client API describes and defines how a client running in a rich |
| 20 | operating environment (REE) should communicate with the TEE. To identify a |
| 21 | Trusted Application (TA) to be used, the client provides an UUID_. All TA's |
| 22 | exposes one or several functions. Those functions corresponds to a so called |
| 23 | ``commandID`` which also is sent by the client. |
| 24 | |
| 25 | TEE Contexts |
| 26 | ============ |
| 27 | The TEE Context is used for creating a logical connection between the client and |
| 28 | the TEE. The context must be initialized before the TEE Session can be created. |
| 29 | When the client has completed a job running in secure world, it should finalize |
| 30 | the context and thereby also release resources. |
| 31 | |
| 32 | TEE Sessions |
| 33 | ============ |
| 34 | Sessions are used to create logical connections between a client and a specific |
| 35 | Trusted Application. When the session has been established the client has opened |
| 36 | up the communication channel towards the specified Trusted Application |
| 37 | identified by the ``UUID``. At this stage the client and the Trusted Application |
| 38 | can start to exchange data. |
| 39 | |
| 40 | |
| 41 | TEE Client API example / usage |
| 42 | ============================== |
| 43 | Below you will find the main functions as defined by GlobalPlatform and are used |
| 44 | in the communication between the client and the TEE. |
| 45 | |
| 46 | .. code-block:: c |
| 47 | |
| 48 | TEEC_Result TEEC_InitializeContext( |
| 49 | const char* name, |
| 50 | TEEC_Context* context) |
| 51 | |
| 52 | void TEEC_FinalizeContext( |
| 53 | TEEC_Context* context) |
| 54 | |
| 55 | TEEC_Result TEEC_OpenSession ( |
| 56 | TEEC_Context* context, |
| 57 | TEEC_Session* session, |
| 58 | const TEEC_UUID* destination, |
| 59 | uint32_t connectionMethod, |
| 60 | const void* connectionData, |
| 61 | TEEC_Operation* operation, |
| 62 | uint32_t* returnOrigin) |
| 63 | |
| 64 | void TEEC_CloseSession ( |
| 65 | TEEC_Session* session) |
| 66 | |
| 67 | TEEC_Result TEEC_InvokeCommand( |
| 68 | TEEC_Session* session, |
| 69 | uint32_t commandID, |
| 70 | TEEC_Operation* operation, |
| 71 | uint32_t* returnOrigin) |
| 72 | |
| 73 | In principle the commands are called in this order: |
| 74 | |
| 75 | .. code-block:: c |
| 76 | |
| 77 | TEEC_InitializeContext(...) |
| 78 | TEEC_OpenSession(...) |
| 79 | TEEC_InvokeCommand(...) |
| 80 | TEEC_CloseSession(...) |
| 81 | TEEC_FinalizeContext(...) |
| 82 | |
| 83 | It is not uncommon that ``TEEC_InvokeCommand(...)`` is called several times in |
| 84 | a row when the session has been established. |
| 85 | |
| 86 | For a complete example, please see chapter **5.2 Example 1: Using the TEE Client |
| 87 | API** in the GlobalPlatform TEE Client API Specification_ v1.0. |
| 88 | |
| 89 | |
| 90 | .. _tee_internal_core_api: |
| 91 | |
| 92 | TEE Internal Core API |
| 93 | ********************* |
| 94 | The Internal Core API is the API that is exposed to the Trusted Applications |
| 95 | running in the secure world. The TEE Internal API consists of four major parts: |
| 96 | |
| 97 | 1. Trusted Storage API for Data and Keys |
| 98 | 2. Cryptographic Operations API |
| 99 | 3. Time API |
| 100 | 4. Arithmetical API |
| 101 | |
| 102 | Examples / usage |
| 103 | ================ |
| 104 | Calling the Internal Core API is done in the same way as described above using |
| 105 | Client API. The best place to find information how this should be done is in the |
| 106 | TEE Internal Core API Specification_ v1.1.2 which contains many examples of how |
| 107 | to call the various APIs. One can also have a look at the examples in the |
| 108 | optee_examples_ git. |
| 109 | |
| 110 | |
| 111 | .. _extensions: |
| 112 | |
| 113 | Extensions |
| 114 | ********** |
| 115 | In addition to what is stated in :ref:`tee_internal_core_api`, there are some |
| 116 | non-official extensions in OP-TEE. |
| 117 | |
| 118 | Trusted Applications should include header file ``tee_api_defines_extensions.h`` |
| 119 | to import the definitions of the extensions. For each extension, a configuration |
| 120 | directive prefixed ``CFG_`` allows one to disable support for the extension when |
| 121 | building the OP-TEE packages. |
| 122 | |
Etienne Carriere | 5b99ccc | 2019-03-11 11:57:30 +0100 | [diff] [blame] | 123 | |
| 124 | .. _extensions_cache_maintenance: |
| 125 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 126 | Cache Maintenance Support |
| 127 | ========================= |
| 128 | Following functions have been introduced in order to allow Trusted Applications |
| 129 | to operate with the data cache: |
| 130 | |
| 131 | .. code-block:: c |
| 132 | |
| 133 | TEE_Result TEE_CacheClean(char *buf, size_t len); |
| 134 | TEE_Result TEE_CacheFlush(char *buf, size_t len); |
| 135 | TEE_Result TEE_CacheInvalidate(char *buf, size_t len); |
| 136 | |
| 137 | These functions are available to any Trusted Application defined with the flag |
Etienne Carriere | 5b99ccc | 2019-03-11 11:57:30 +0100 | [diff] [blame] | 138 | ``TA_FLAG_CACHE_MAINTENANCE`` sets on, see :ref:`ta_property_cache_maintenance`. |
| 139 | When not set, each function returns the error code ``TEE_ERROR_NOT_SUPPORTED``. |
| 140 | Within these extensions, a Trusted Application is able to operate on the data |
| 141 | cache, with the following specification: |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 142 | |
| 143 | .. list-table:: |
| 144 | :widths: 10 60 |
| 145 | :header-rows: 1 |
| 146 | |
| 147 | * - Function |
| 148 | - Description |
| 149 | |
| 150 | * - ``TEE_CacheClean()`` |
| 151 | - Write back to memory any dirty data cache lines. The line is marked as |
| 152 | not dirty. The valid bit is unchanged. |
| 153 | |
| 154 | * - ``TEE_CacheFlush()`` |
| 155 | - Purges any valid data cache lines. Any dirty cache lines are first |
| 156 | written back to memory, then the cache line is invalidated. |
| 157 | |
| 158 | * - ``TEE_CacheInvalidate()`` |
| 159 | - Invalidate any valid data cache lines. Any dirty line are not written |
| 160 | back to memory. |
| 161 | |
| 162 | In the following two cases, the error code ``TEE_ERROR_ACCESS_DENIED`` is |
| 163 | returned: |
| 164 | |
| 165 | - The memory range has not the write access, that is |
| 166 | ``TEE_MEMORY_ACCESS_WRITE`` is not set. |
| 167 | - The memory is **not** user space memory. |
| 168 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 169 | You may disable this extension by setting the following configuration variable |
| 170 | in ``conf.mk``: |
| 171 | |
| 172 | .. code-block:: make |
| 173 | |
| 174 | CFG_CACHE_API := n |
| 175 | |
| 176 | |
| 177 | .. _rsassa_na1: |
| 178 | |
| 179 | PKCS#1 v1.5 RSASSA without hash OID |
| 180 | =================================== |
| 181 | This extension adds identifer``TEE_ALG_RSASSA_PKCS1_V1_5`` to allow signing and |
| 182 | verifying messages with RSASSA-PKCS1-v1_5, in `RFC 3447`_, without including the |
| 183 | OID of the hash in the signature. You may disable this extension by setting the |
| 184 | following configuration variable in ``conf.mk``: |
| 185 | |
| 186 | .. code-block:: make |
| 187 | |
| 188 | CFG_CRYPTO_RSASSA_NA1 := n |
| 189 | |
| 190 | The TEE Internal Core API was extended with a new algorithm descriptor. |
| 191 | |
| 192 | .. list-table:: |
| 193 | :widths: 10 60 |
| 194 | :header-rows: 1 |
| 195 | |
| 196 | * - Algorithm |
| 197 | - Possible Modes |
| 198 | |
| 199 | * - TEE_ALG_RSASSA_PKCS1_V1_5 |
| 200 | - TEE_MODE_SIGN / TEE_MODE_VERIFY |
| 201 | |
| 202 | .. list-table:: |
| 203 | :widths: 10 60 |
| 204 | :header-rows: 1 |
| 205 | |
| 206 | * - Algorithm |
| 207 | - Identifier |
| 208 | |
| 209 | * - TEE_ALG_RSASSA_PKCS1_V1_5 |
| 210 | - 0xF0000830 |
| 211 | |
| 212 | |
| 213 | .. _concat_kdf: |
| 214 | |
| 215 | Concat KDF |
| 216 | ========== |
| 217 | Support for the Concatenation Key Derivation Function (Concat KDF) according to |
| 218 | `SP 800-56A`_ (*Recommendation for Pair-Wise Key Establishment Schemes Using |
| 219 | Discrete Logarithm Cryptography*) can be found in OP-TEE. You may disable this |
| 220 | extension by setting the following configuration variable in ``conf.mk``: |
| 221 | |
| 222 | .. code-block:: make |
| 223 | |
| 224 | CFG_CRYPTO_CONCAT_KDF := n |
| 225 | |
| 226 | **Implementation notes** |
| 227 | |
| 228 | All key and parameter sizes **must** be multiples of 8 bits. That is: |
| 229 | |
| 230 | - Input parameters: the shared secret (``Z``) and ``OtherInfo``. |
| 231 | - Output parameter: the derived key (``DerivedKeyingMaterial``). |
| 232 | |
| 233 | In addition, the maximum size of the derived key is limited by the size of an |
| 234 | object of type ``TEE_TYPE_GENERIC_SECRET`` (512 bytes). This implementation does |
| 235 | **not** enforce any requirement on the content of the ``OtherInfo`` parameter. |
| 236 | It is the application's responsibility to make sure this parameter is |
| 237 | constructed as specified by the NIST specification if compliance is desired. |
| 238 | |
| 239 | **API extension** |
| 240 | |
| 241 | To support Concat KDF, the :ref:`tee_internal_core_api` v1.1 was extended with |
| 242 | new algorithm descriptors, new object types, and new object attributes as |
| 243 | described below. |
| 244 | |
| 245 | **p.95 Add new object type to TEE_PopulateTransientObject** |
| 246 | |
| 247 | The following entry shall be added to **Table 5-8**: |
| 248 | |
| 249 | .. list-table:: |
| 250 | :widths: 10 60 |
| 251 | :header-rows: 1 |
| 252 | |
| 253 | * - Object type |
| 254 | - Parts |
| 255 | |
| 256 | * - TEE_TYPE_CONCAT_KDF_Z |
| 257 | - The ``TEE_ATTR_CONCAT_KDF_Z`` part (input shared secret) must be |
| 258 | provided. |
| 259 | |
| 260 | **p.121 Add new algorithms for TEE_AllocateOperation** |
| 261 | |
| 262 | The following entry shall be added to **Table 6-3**: |
| 263 | |
| 264 | .. list-table:: |
| 265 | :widths: 10 60 |
| 266 | :header-rows: 1 |
| 267 | |
| 268 | * - Algorithm |
| 269 | - Possible Modes |
| 270 | |
| 271 | * - TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY |
| 272 | TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY |
| 273 | TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY |
| 274 | TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY |
| 275 | TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY |
| 276 | TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY |
| 277 | - TEE_MODE_DERIVE |
| 278 | |
| 279 | **p.126 Explain usage of HKDF algorithms in TEE_SetOperationKey** |
| 280 | |
| 281 | In the bullet list about operation mode, the following shall be added: |
| 282 | |
| 283 | - For the Concat KDF algorithms, the only supported mode is |
| 284 | ``TEE_MODE_DERIVE``. |
| 285 | |
| 286 | **p.150 Define TEE_DeriveKey input attributes for new algorithms** |
| 287 | |
| 288 | The following sentence shall be deleted: |
| 289 | |
| 290 | .. code-block:: none |
| 291 | |
| 292 | The TEE_DeriveKey function can only be used with the algorithm |
| 293 | TEE_ALG_DH_DERIVE_SHARED_SECRET. |
| 294 | |
| 295 | The following entry shall be added to **Table 6-7**: |
| 296 | |
| 297 | .. list-table:: |
| 298 | :header-rows: 1 |
| 299 | |
| 300 | * - Algorithm |
| 301 | - Possible operation parameters |
| 302 | |
| 303 | * - TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY |
| 304 | TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY |
| 305 | TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY |
| 306 | TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY |
| 307 | TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY |
| 308 | TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY |
| 309 | - TEE_ATTR_CONCAT_KDF_DKM_LENGTH: up to 512 bytes. This parameter is |
| 310 | mandatory: TEE_ATTR_CONCAT_KDF_OTHER_INFO |
| 311 | |
| 312 | **p.152 Add new algorithm identifiers** |
| 313 | |
| 314 | The following entries shall be added to **Table 6-8**: |
| 315 | |
| 316 | .. list-table:: |
| 317 | :header-rows: 1 |
| 318 | |
| 319 | * - Algorithm |
| 320 | - Identifier |
| 321 | |
| 322 | * - TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY |
| 323 | - 0x800020C1 |
| 324 | |
| 325 | * - TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY |
| 326 | - 0x800030C1 |
| 327 | |
| 328 | * - TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY |
| 329 | - 0x800040C1 |
| 330 | |
| 331 | * - TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY |
| 332 | - 0x800050C1 |
| 333 | |
| 334 | * - TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY |
| 335 | - 0x800060C1 |
| 336 | |
| 337 | **p.154 Define new main algorithm** |
| 338 | |
| 339 | In **Table 6-9** in section 6.10.1, a new value shall be added to the value |
| 340 | column for row bits ``[7:0]``: |
| 341 | |
| 342 | .. list-table:: |
| 343 | :header-rows: 1 |
| 344 | |
| 345 | * - Bits |
| 346 | - Function |
| 347 | - Value |
| 348 | |
| 349 | * - Bits [7:0] |
| 350 | - Identifiy the main underlying algorithm itself |
| 351 | - ... |
| 352 | |
| 353 | 0xC1: Concat KDF |
| 354 | |
| 355 | The function column for ``bits[15:12]`` shall also be modified to read: |
| 356 | |
| 357 | .. list-table:: |
| 358 | :header-rows: 1 |
| 359 | |
| 360 | * - Bits |
| 361 | - Function |
| 362 | - Value |
| 363 | |
| 364 | * - Bits [15:12] |
| 365 | - Define the message digest for asymmetric signature algorithms or Concat KDF |
| 366 | - |
| 367 | |
| 368 | **p.155 Add new object type for Concat KDF input shared secret** |
| 369 | |
| 370 | The following entry shall be added to **Table 6-10**: |
| 371 | |
| 372 | .. list-table:: |
| 373 | :header-rows: 1 |
| 374 | |
| 375 | * - Name |
| 376 | - Identifier |
| 377 | - Possible sizes |
| 378 | |
| 379 | * - TEE_TYPE_CONCAT_KDF_Z |
| 380 | - 0xA10000C1 |
| 381 | - 8 to 4096 bits (multiple of 8) |
| 382 | |
| 383 | **p.156 Add new operation attributes for Concat KDF** |
| 384 | |
| 385 | The following entries shall be added to **Table 6-11**: |
| 386 | |
| 387 | .. list-table:: |
| 388 | :header-rows: 1 |
| 389 | |
| 390 | * - Name |
| 391 | - Value |
| 392 | - Protection |
| 393 | - Type |
| 394 | - Comment |
| 395 | |
| 396 | * - TEE_ATTR_CONCAT_KDF_Z |
| 397 | - 0xC00001C1 |
| 398 | - Protected |
| 399 | - Ref |
| 400 | - The shared secret (``Z``) |
| 401 | |
| 402 | * - TEE_ATTR_CONCAT_KDF_OTHER_INFO |
| 403 | - 0xD00002C1 |
| 404 | - Public |
| 405 | - Ref |
| 406 | - ``OtherInfo`` |
| 407 | |
| 408 | * - TEE_ATTR_CONCAT_KDF_DKM_LENGTH |
| 409 | - 0xF00003C1 |
| 410 | - Public |
| 411 | - Value |
| 412 | - The length (in bytes) of the derived keying material to be generated, |
| 413 | maximum 512. This is ``KeyDataLen`` / 8. |
| 414 | |
| 415 | |
| 416 | .. _hkdf: |
| 417 | |
| 418 | HKDF |
| 419 | ==== |
| 420 | OP-TEE implements the *HMAC-based Extract-and-Expand Key Derivation Function |
| 421 | (HKDF)* as specified in `RFC 5869`_. This file documents the extensions to the |
| 422 | :ref:`tee_internal_core_api` v1.1 that were implemented to support this |
| 423 | algorithm. Trusted Applications should include |
| 424 | ``<tee_api_defines_extensions.h>`` to import the definitions. |
| 425 | |
| 426 | Note that the implementation follows the recommendations of version 1.1 of the |
| 427 | specification for adding new algorithms. It should make it compatible with |
| 428 | future changes to the official specification. You can disable this extension by |
| 429 | setting the following in ``conf.mk``: |
| 430 | |
| 431 | .. code-block:: make |
| 432 | |
| 433 | CFG_CRYPTO_HKDF := n |
| 434 | |
| 435 | **p.95 Add new object type to TEE_PopulateTransientObject** |
| 436 | |
| 437 | The following entry shall be added to **Table 5-8**: |
| 438 | |
| 439 | .. list-table:: |
| 440 | :header-rows: 1 |
| 441 | |
| 442 | * - Object type |
| 443 | - Parts |
| 444 | |
| 445 | * - TEE_TYPE_HKDF_IKM |
| 446 | - The TEE_ATTR_HKDF_IKM (Input Keying Material) part must be provided. |
| 447 | |
| 448 | **p.121 Add new algorithms for TEE_AllocateOperation** |
| 449 | |
| 450 | The following entry shall be added to **Table 6-3**: |
| 451 | |
| 452 | .. list-table:: |
| 453 | :header-rows: 1 |
| 454 | |
| 455 | * - Algorithm |
| 456 | - Possible Modes |
| 457 | |
| 458 | * - TEE_ALG_HKDF_MD5_DERIVE_KEY |
| 459 | TEE_ALG_HKDF_SHA1_DERIVE_KEY |
| 460 | TEE_ALG_HKDF_SHA224_DERIVE_KEY |
| 461 | TEE_ALG_HKDF_SHA256_DERIVE_KEY |
| 462 | TEE_ALG_HKDF_SHA384_DERIVE_KEY |
| 463 | TEE_ALG_HKDF_SHA512_DERIVE_KEY |
| 464 | TEE_ALG_HKDF_SHA512_DERIVE_KEY |
| 465 | - TEE_MODE_DERIVE |
| 466 | |
| 467 | **p.126 Explain usage of HKDF algorithms in TEE_SetOperationKey** |
| 468 | |
| 469 | In the bullet list about operation mode, the following shall be added: |
| 470 | |
| 471 | - For the HKDF algorithms, the only supported mode is TEE_MODE_DERIVE. |
| 472 | |
| 473 | **p.150 Define TEE_DeriveKey input attributes for new algorithms** |
| 474 | |
| 475 | The following sentence shall be deleted: |
| 476 | |
| 477 | .. code-block:: none |
| 478 | |
| 479 | The TEE_DeriveKey function can only be used with the algorithm |
| 480 | TEE_ALG_DH_DERIVE_SHARED_SECRET |
| 481 | |
| 482 | The following entry shall be added to **Table 6-7**: |
| 483 | |
| 484 | .. list-table:: |
| 485 | :header-rows: 1 |
| 486 | |
| 487 | * - Algorithm |
| 488 | - Possible operation parameters |
| 489 | |
| 490 | * - TEE_ALG_HKDF_MD5_DERIVE_KEY |
| 491 | TEE_ALG_HKDF_SHA1_DERIVE_KEY |
| 492 | TEE_ALG_HKDF_SHA224_DERIVE_KEY |
| 493 | TEE_ALG_HKDF_SHA256_DERIVE_KEY |
| 494 | TEE_ALG_HKDF_SHA384_DERIVE_KEY |
| 495 | TEE_ALG_HKDF_SHA512_DERIVE_KEY |
| 496 | TEE_ALG_HKDF_SHA512_DERIVE_KEY |
| 497 | - TEE_ATTR_HKDF_OKM_LENGTH: Number of bytes in the Output Keying Material |
| 498 | |
| 499 | TEE_ATTR_HKDF_SALT (optional) Salt to be used during the extract step |
| 500 | |
| 501 | TEE_ATTR_HKDF_INFO (optional) Info to be used during the expand step |
| 502 | |
| 503 | **p.152 Add new algorithm identifiers** |
| 504 | |
| 505 | The following entries shall be added to **Table 6-8**: |
| 506 | |
| 507 | .. list-table:: |
| 508 | :header-rows: 1 |
| 509 | |
| 510 | * - Algorithm |
| 511 | - Identifier |
| 512 | |
| 513 | * - TEE_ALG_HKDF_MD5_DERIVE_KEY |
| 514 | - 0x800010C0 |
| 515 | |
| 516 | * - TEE_ALG_HKDF_SHA1_DERIVE_KEY |
| 517 | - 0x800020C0 |
| 518 | |
| 519 | * - TEE_ALG_HKDF_SHA224_DERIVE_KEY |
| 520 | - 0x800030C0 |
| 521 | |
| 522 | * - TEE_ALG_HKDF_SHA256_DERIVE_KEY |
| 523 | - 0x800040C0 |
| 524 | |
| 525 | * - TEE_ALG_HKDF_SHA384_DERIVE_KEY |
| 526 | - 0x800050C0 |
| 527 | |
| 528 | * - TEE_ALG_HKDF_SHA512_DERIVE_KEY |
| 529 | - 0x800060C0 |
| 530 | |
| 531 | ## p.154 Define new main algorithm |
| 532 | |
| 533 | In **Table 6-9** in section 6.10.1, a new value shall be added to the value column |
| 534 | for row ``bits [7:0]``: |
| 535 | |
| 536 | .. list-table:: |
| 537 | :header-rows: 1 |
| 538 | |
| 539 | * - Bits |
| 540 | - Function |
| 541 | - Value |
| 542 | |
| 543 | * - Bits [7:0] |
| 544 | - Identifiy the main underlying algorithm itself |
| 545 | - ... |
| 546 | |
| 547 | 0xC0: HKDF |
| 548 | |
| 549 | The function column for ``bits[15:12]`` shall also be modified to read: |
| 550 | |
| 551 | .. list-table:: |
| 552 | :header-rows: 1 |
| 553 | |
| 554 | * - Bits |
| 555 | - Function |
| 556 | - Value |
| 557 | |
| 558 | * - Bits [15:12] |
| 559 | - Define the message digest for asymmetric signature algorithms or HKDF |
| 560 | - |
| 561 | |
| 562 | **p.155 Add new object type for HKDF input keying material** |
| 563 | |
| 564 | The following entry shall be added to **Table 6-10**: |
| 565 | |
| 566 | .. list-table:: |
| 567 | :header-rows: 1 |
| 568 | |
| 569 | * - Name |
| 570 | - Identifier |
| 571 | - Possible sizes |
| 572 | |
| 573 | * - TEE_TYPE_HKDF_IKM |
| 574 | - 0xA10000C0 |
| 575 | - 8 to 4096 bits (multiple of 8) |
| 576 | |
| 577 | **p.156 Add new operation attributes for HKDF salt and info** |
| 578 | |
| 579 | The following entries shall be added to **Table 6-11**: |
| 580 | |
| 581 | .. list-table:: |
| 582 | :widths: 40 10 10 10 40 |
| 583 | :header-rows: 1 |
| 584 | |
| 585 | * - Name |
| 586 | - Value |
| 587 | - Protection |
| 588 | - Type |
| 589 | - Comment |
| 590 | |
| 591 | * - TEE_ATTR_HKDF_IKM |
| 592 | - 0xC00001C0 |
| 593 | - Protected |
| 594 | - Ref |
| 595 | - |
| 596 | |
| 597 | * - TEE_ATTR_HKDF_SALT |
| 598 | - 0xD00002C0 |
| 599 | - Public |
| 600 | - Ref |
| 601 | - |
| 602 | |
| 603 | * - TEE_ATTR_HKDF_INFO |
| 604 | - 0xD00003C0 |
| 605 | - Public |
| 606 | - Ref |
| 607 | - |
| 608 | |
| 609 | * - TEE_ATTR_HKDF_OKM_LENGTH |
| 610 | - 0xF00004C0 |
| 611 | - Public |
| 612 | - Value |
| 613 | - |
| 614 | |
| 615 | .. _pbkdf2: |
| 616 | |
| 617 | PBKDF2 |
| 618 | ====== |
| 619 | This document describes the OP-TEE implementation of the key derivation |
| 620 | function, *PBKDF2* as specified in `RFC 2898`_ section 5.2. This RFC is a |
| 621 | republication of PKCS #5 v2.0 from RSA Laboratories' Public-Key Cryptography |
| 622 | Standards (PKCS) series. You may disable this extension by setting the following |
| 623 | configuration variable in ``conf.mk``: |
| 624 | |
| 625 | .. code-block:: make |
| 626 | |
| 627 | CFG_CRYPTO_PBKDF2 := n |
| 628 | |
| 629 | **API extension** |
| 630 | |
| 631 | To support PBKDF2, the :ref:`tee_internal_core_api` v1.1 was extended with a new |
| 632 | algorithm descriptor, new object types, and new object attributes as described |
| 633 | below. |
| 634 | |
| 635 | **p.95 Add new object type to TEE_PopulateTransientObject** |
| 636 | |
| 637 | The following entry shall be added to **Table 5-8**: |
| 638 | |
| 639 | .. list-table:: |
| 640 | :header-rows: 1 |
| 641 | |
| 642 | * - Object type |
| 643 | - Parts |
| 644 | |
| 645 | * - TEE_TYPE_PBKDF2_PASSWORD |
| 646 | - The TEE_ATTR_PBKDF2_PASSWORD part must be provided. |
| 647 | |
| 648 | **p.121 Add new algorithms for TEE_AllocateOperation** |
| 649 | |
| 650 | The following entry shall be added to **Table 6-3**: |
| 651 | |
| 652 | .. list-table:: |
| 653 | :header-rows: 1 |
| 654 | |
| 655 | * - Algorithm |
| 656 | - Possible Modes |
| 657 | |
| 658 | * - TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY |
| 659 | - TEE_MODE_DERIVE |
| 660 | |
| 661 | **p.126 Explain usage of PBKDF2 algorithm in TEE_SetOperationKey** |
| 662 | |
| 663 | In the bullet list about operation mode, the following shall be added: |
| 664 | |
| 665 | - For the PBKDF2 algorithm, the only supported mode is TEE_MODE_DERIVE. |
| 666 | |
| 667 | **p.150 Define TEE_DeriveKey input attributes for new algorithms** |
| 668 | |
| 669 | The following sentence shall be deleted: |
| 670 | |
| 671 | .. code-block:: none |
| 672 | |
| 673 | The TEE_DeriveKey function can only be used with the algorithm |
| 674 | TEE_ALG_DH_DERIVE_SHARED_SECRET |
| 675 | |
| 676 | The following entry shall be added to **Table 6-7**: |
| 677 | |
| 678 | .. list-table:: |
| 679 | :header-rows: 1 |
| 680 | |
| 681 | * - Algorithm |
| 682 | - Possible operation parameters |
| 683 | |
| 684 | * - TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY |
| 685 | - TEE_ATTR_PBKDF2_DKM_LENGTH: up to 512 bytes. This parameter is |
| 686 | mandatory. |
| 687 | |
| 688 | TEE_ATTR_PBKDF2_SALT |
| 689 | |
| 690 | TEE_ATTR_PBKDF2_ITERATION_COUNT: This parameter is mandatory. |
| 691 | |
| 692 | **p.152 Add new algorithm identifiers** |
| 693 | |
| 694 | The following entries shall be added to **Table 6-8**: |
| 695 | |
| 696 | .. list-table:: |
| 697 | :header-rows: 1 |
| 698 | |
| 699 | * - Algorithm |
| 700 | - Identifier |
| 701 | |
| 702 | * - TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY |
| 703 | - 0x800020C2 |
| 704 | |
| 705 | **p.154 Define new main algorithm** |
| 706 | |
| 707 | In **Table 6-9** in section 6.10.1, a new value shall be added to the value |
| 708 | column for row ``bits [7:0]``: |
| 709 | |
| 710 | .. list-table:: |
| 711 | :header-rows: 1 |
| 712 | |
| 713 | * - Bits |
| 714 | - Function |
| 715 | - Value |
| 716 | |
| 717 | * - Bits [7:0] |
| 718 | - Identifiy the main underlying algorithm itself |
| 719 | - ... |
| 720 | |
| 721 | 0xC2: PBKDF2 |
| 722 | |
| 723 | The function column for ``bits[15:12]`` shall also be modified to read: |
| 724 | |
| 725 | .. list-table:: |
| 726 | :header-rows: 1 |
| 727 | |
| 728 | * - Bits |
| 729 | - Function |
| 730 | - Value |
| 731 | |
| 732 | * - Bits [15:12] |
| 733 | - Define the message digest for asymmetric signature algorithms or PBKDF2 |
| 734 | - |
| 735 | |
| 736 | **p.155 Add new object type for PBKDF2 password** |
| 737 | |
| 738 | The following entry shall be added to **Table 6-10**: |
| 739 | |
| 740 | .. list-table:: |
| 741 | :header-rows: 1 |
| 742 | |
| 743 | * - Name |
| 744 | - Identifier |
| 745 | - Possible sizes |
| 746 | |
| 747 | * - TEE_TYPE_PBKDF2_PASSWORD |
| 748 | - 0xA10000C2 |
| 749 | - 8 to 4096 bits (multiple of 8) |
| 750 | |
| 751 | **p.156 Add new operation attributes for Concat KDF** |
| 752 | |
| 753 | The following entries shall be added to **Table 6-11**: |
| 754 | |
| 755 | .. list-table:: |
| 756 | :widths: 40 10 10 10 40 |
| 757 | :header-rows: 1 |
| 758 | |
| 759 | * - Name |
| 760 | - Value |
| 761 | - Protection |
| 762 | - Type |
| 763 | - Comment |
| 764 | |
| 765 | * - TEE_ATTR_PBKDF2_PASSWORD |
| 766 | - 0xC00001C2 |
| 767 | - Protected |
| 768 | - Ref |
| 769 | - |
| 770 | |
| 771 | * - TEE_ATTR_PBKDF2_SALT |
| 772 | - 0xD00002C2 |
| 773 | - Public |
| 774 | - Ref |
| 775 | - |
| 776 | |
| 777 | * - TEE_ATTR_PBKDF2_ITERATION_COUNT |
| 778 | - 0xF00003C2 |
| 779 | - Public |
| 780 | - Value |
| 781 | - |
| 782 | |
| 783 | * - TEE_ATTR_PBKDF2_DKM_LENGTH |
| 784 | - 0xF00004C2 |
| 785 | - Public |
| 786 | - Value |
| 787 | - The length (in bytes) of the derived keying material to be generated, |
| 788 | maximum 512. |
| 789 | |
| 790 | |
| 791 | .. _GlobalPlatform: https://globalplatform.org |
| 792 | .. _optee_examples: https://github.com/linaro-swg/optee_examples |
| 793 | .. _TZC-400: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0504c/index.html |
| 794 | .. _RFC 2898: https://www.ietf.org/rfc/rfc2898.txt |
| 795 | .. _RFC 3447: https://tools.ietf.org/html/rfc3447#section-8.2 |
| 796 | .. _RFC 5869: https://tools.ietf.org/html/rfc5869 |
| 797 | .. _Specification: https://globalplatform.org/specs-library/?filter-committee=tee |
| 798 | .. _SP 800-56A: http://csrc.nist.gov/publications/nistpubs/800-56A/SP800-56A_Revision1_Mar08-2007.pdf |
| 799 | .. _UUID: https://en.wikipedia.org/wiki/Universally_unique_identifier |