blob: 827ccc23f5783482e397f8892ada090a4caf7fa9 [file] [log] [blame]
Joakim Bech8e5c5b32018-10-25 08:18:32 +02001.. _globalplatform_api:
2
3##################
4GlobalPlatform API
5##################
6Introduction
7************
8GlobalPlatform_ works across industries to identify, develop and publish
9specifications which facilitate the secure and interoperable deployment and
10management of multiple embedded applications on secure chip technology. OP-TEE
11has support for GlobalPlatform TEE Client API Specification_ v1.0 (GPD_SPE_007)
Etienne Carriere17bb9b72023-06-26 10:00:50 +020012plus Errata and Precisions 2.0 (GPD_EPR_028) and TEE Internal Core API
13Specification v1.3.1 (GPD_SPE_010).
Joakim Bech8e5c5b32018-10-25 08:18:32 +020014
15
16.. _tee_client_api:
17
18TEE Client API
19**************
20The TEE Client API describes and defines how a client running in a rich
21operating environment (REE) should communicate with the TEE. To identify a
22Trusted Application (TA) to be used, the client provides an UUID_. All TA's
23exposes one or several functions. Those functions corresponds to a so called
24``commandID`` which also is sent by the client.
25
26TEE Contexts
27============
28The TEE Context is used for creating a logical connection between the client and
29the TEE. The context must be initialized before the TEE Session can be created.
30When the client has completed a job running in secure world, it should finalize
31the context and thereby also release resources.
32
33TEE Sessions
34============
35Sessions are used to create logical connections between a client and a specific
36Trusted Application. When the session has been established the client has opened
37up the communication channel towards the specified Trusted Application
38identified by the ``UUID``. At this stage the client and the Trusted Application
39can start to exchange data.
40
Jens Wiklander07f018b2023-08-22 16:33:01 +020041TEE Shared memory
42=================
43The TEE Client API describes many ways of sharing memory between the client
44and the TEE. Some ways are more efficient than others due to how they are
45implemented, but they have all their advantages too. For example, using a
46temporary memory reference (``TEEC_TempMemoryReference``) is often
47convenient, but depending on the situation often not the most efficient. A
48temporary memory reference is established internally in the TEE Client
49library before it is used, and when the call to secure world has returned
50it is torn down again. That results in a few extra re-entries into the TEE.
51
52For more efficient communication a shared memory block
53(``TEEC_SharedMemory``) should be used since it can be reused between calls
54and also tuned in more ways. A shared memory block can be initialized
55either with ``TEEC_RegisterSharedMemory()`` or
56``TEEC_AllocateSharedMemory()``.
57
58``TEEC_RegisterSharedMemory()`` sometimes fails to establish zero-copy
59shared memory and must in those cases fall back to a temporary "shadow
60buffer". The TEE framework will for instance refuse to register a memory
61block that is mapped read-only in the client. Another reason can be if FF-A
62is used and a part of the memory range has been registered previously.
63
64``TEEC_AllocateSharedMemory()`` is the best choice to establish zero-copy
65shared memory. If ``TEEC_RegisterSharedMemory()`` must be used instead
66because the buffer is allocated in advance or externally there are still a
67few things that helps avoid a fallback to a "shadow buffer". Make sure that
68the memory range is normal read/write memory and if possible use
69page-aligned memory buffers.
70
Joakim Bech8e5c5b32018-10-25 08:18:32 +020071
72TEE Client API example / usage
73==============================
74Below you will find the main functions as defined by GlobalPlatform and are used
75in the communication between the client and the TEE.
76
77.. code-block:: c
78
79 TEEC_Result TEEC_InitializeContext(
80 const char* name,
81 TEEC_Context* context)
82
83 void TEEC_FinalizeContext(
84 TEEC_Context* context)
85
86 TEEC_Result TEEC_OpenSession (
87 TEEC_Context* context,
88 TEEC_Session* session,
89 const TEEC_UUID* destination,
90 uint32_t connectionMethod,
91 const void* connectionData,
92 TEEC_Operation* operation,
93 uint32_t* returnOrigin)
94
95 void TEEC_CloseSession (
96 TEEC_Session* session)
97
98 TEEC_Result TEEC_InvokeCommand(
99 TEEC_Session* session,
100 uint32_t commandID,
101 TEEC_Operation* operation,
102 uint32_t* returnOrigin)
103
104In principle the commands are called in this order:
105
106.. code-block:: c
107
108 TEEC_InitializeContext(...)
109 TEEC_OpenSession(...)
110 TEEC_InvokeCommand(...)
111 TEEC_CloseSession(...)
112 TEEC_FinalizeContext(...)
113
114It is not uncommon that ``TEEC_InvokeCommand(...)`` is called several times in
115a row when the session has been established.
116
117For a complete example, please see chapter **5.2 Example 1: Using the TEE Client
118API** in the GlobalPlatform TEE Client API Specification_ v1.0.
119
120
121.. _tee_internal_core_api:
122
123TEE Internal Core API
124*********************
125The Internal Core API is the API that is exposed to the Trusted Applications
126running in the secure world. The TEE Internal API consists of four major parts:
127
128 1. Trusted Storage API for Data and Keys
129 2. Cryptographic Operations API
130 3. Time API
131 4. Arithmetical API
132
133Examples / usage
134================
135Calling the Internal Core API is done in the same way as described above using
136Client API. The best place to find information how this should be done is in the
Etienne Carrieredf106e02023-06-26 09:54:51 +0200137TEE Internal Core API Specification_ which contains many examples of how
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200138to call the various APIs. One can also have a look at the examples in the
139optee_examples_ git.
140
141
142.. _extensions:
143
144Extensions
145**********
146In addition to what is stated in :ref:`tee_internal_core_api`, there are some
147non-official extensions in OP-TEE.
148
Jerome Forissier6f47b162021-09-20 10:48:22 +0200149Trusted Applications should include header file ``tee_internal_api_extensions.h``
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200150to import the definitions of the extensions. For each extension, a configuration
151directive prefixed ``CFG_`` allows one to disable support for the extension when
152building the OP-TEE packages.
153
Etienne Carriere5b99ccc2019-03-11 11:57:30 +0100154
155.. _extensions_cache_maintenance:
156
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200157Cache Maintenance Support
158=========================
159Following functions have been introduced in order to allow Trusted Applications
160to operate with the data cache:
161
162.. code-block:: c
163
164 TEE_Result TEE_CacheClean(char *buf, size_t len);
165 TEE_Result TEE_CacheFlush(char *buf, size_t len);
166 TEE_Result TEE_CacheInvalidate(char *buf, size_t len);
167
168These functions are available to any Trusted Application defined with the flag
Etienne Carriere5b99ccc2019-03-11 11:57:30 +0100169``TA_FLAG_CACHE_MAINTENANCE`` sets on, see :ref:`ta_property_cache_maintenance`.
170When not set, each function returns the error code ``TEE_ERROR_NOT_SUPPORTED``.
171Within these extensions, a Trusted Application is able to operate on the data
172cache, with the following specification:
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200173
174.. list-table::
175 :widths: 10 60
176 :header-rows: 1
177
178 * - Function
179 - Description
180
181 * - ``TEE_CacheClean()``
182 - Write back to memory any dirty data cache lines. The line is marked as
183 not dirty. The valid bit is unchanged.
184
185 * - ``TEE_CacheFlush()``
186 - Purges any valid data cache lines. Any dirty cache lines are first
187 written back to memory, then the cache line is invalidated.
188
189 * - ``TEE_CacheInvalidate()``
190 - Invalidate any valid data cache lines. Any dirty line are not written
191 back to memory.
192
193In the following two cases, the error code ``TEE_ERROR_ACCESS_DENIED`` is
194returned:
195
196 - The memory range has not the write access, that is
197 ``TEE_MEMORY_ACCESS_WRITE`` is not set.
198 - The memory is **not** user space memory.
199
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200200You may disable this extension by setting the following configuration variable
201in ``conf.mk``:
202
203.. code-block:: make
204
205 CFG_CACHE_API := n
206
207
208.. _rsassa_na1:
209
210PKCS#1 v1.5 RSASSA without hash OID
211===================================
212This extension adds identifer``TEE_ALG_RSASSA_PKCS1_V1_5`` to allow signing and
213verifying messages with RSASSA-PKCS1-v1_5, in `RFC 3447`_, without including the
214OID of the hash in the signature. You may disable this extension by setting the
215following configuration variable in ``conf.mk``:
216
217.. code-block:: make
218
219 CFG_CRYPTO_RSASSA_NA1 := n
220
221The TEE Internal Core API was extended with a new algorithm descriptor.
222
223.. list-table::
224 :widths: 10 60
225 :header-rows: 1
226
227 * - Algorithm
228 - Possible Modes
229
230 * - TEE_ALG_RSASSA_PKCS1_V1_5
231 - TEE_MODE_SIGN / TEE_MODE_VERIFY
232
233.. list-table::
234 :widths: 10 60
235 :header-rows: 1
236
237 * - Algorithm
238 - Identifier
239
240 * - TEE_ALG_RSASSA_PKCS1_V1_5
241 - 0xF0000830
242
243
244.. _concat_kdf:
245
246Concat KDF
247==========
248Support for the Concatenation Key Derivation Function (Concat KDF) according to
249`SP 800-56A`_ (*Recommendation for Pair-Wise Key Establishment Schemes Using
250Discrete Logarithm Cryptography*) can be found in OP-TEE. You may disable this
251extension by setting the following configuration variable in ``conf.mk``:
252
253.. code-block:: make
254
255 CFG_CRYPTO_CONCAT_KDF := n
256
257**Implementation notes**
258
259All key and parameter sizes **must** be multiples of 8 bits. That is:
260
261 - Input parameters: the shared secret (``Z``) and ``OtherInfo``.
262 - Output parameter: the derived key (``DerivedKeyingMaterial``).
263
264In addition, the maximum size of the derived key is limited by the size of an
265object of type ``TEE_TYPE_GENERIC_SECRET`` (512 bytes). This implementation does
266**not** enforce any requirement on the content of the ``OtherInfo`` parameter.
267It is the application's responsibility to make sure this parameter is
268constructed as specified by the NIST specification if compliance is desired.
269
270**API extension**
271
Etienne Carrieredf106e02023-06-26 09:54:51 +0200272To support Concat KDF, the :ref:`tee_internal_core_api` v1.3.1 was extended with
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200273new algorithm descriptors, new object types, and new object attributes as
274described below.
275
276**p.95 Add new object type to TEE_PopulateTransientObject**
277
278The following entry shall be added to **Table 5-8**:
279
280.. list-table::
281 :widths: 10 60
282 :header-rows: 1
283
284 * - Object type
285 - Parts
286
287 * - TEE_TYPE_CONCAT_KDF_Z
288 - The ``TEE_ATTR_CONCAT_KDF_Z`` part (input shared secret) must be
289 provided.
290
291**p.121 Add new algorithms for TEE_AllocateOperation**
292
293The following entry shall be added to **Table 6-3**:
294
295.. list-table::
296 :widths: 10 60
297 :header-rows: 1
298
299 * - Algorithm
300 - Possible Modes
301
302 * - TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY
303 TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY
304 TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY
305 TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY
306 TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY
307 TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY
308 - TEE_MODE_DERIVE
309
310**p.126 Explain usage of HKDF algorithms in TEE_SetOperationKey**
311
312In the bullet list about operation mode, the following shall be added:
313
314 - For the Concat KDF algorithms, the only supported mode is
315 ``TEE_MODE_DERIVE``.
316
317**p.150 Define TEE_DeriveKey input attributes for new algorithms**
318
319The following sentence shall be deleted:
320
321.. code-block:: none
322
323 The TEE_DeriveKey function can only be used with the algorithm
324 TEE_ALG_DH_DERIVE_SHARED_SECRET.
325
326The following entry shall be added to **Table 6-7**:
327
328.. list-table::
329 :header-rows: 1
330
331 * - Algorithm
332 - Possible operation parameters
333
334 * - TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY
335 TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY
336 TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY
337 TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY
338 TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY
339 TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY
340 - TEE_ATTR_CONCAT_KDF_DKM_LENGTH: up to 512 bytes. This parameter is
341 mandatory: TEE_ATTR_CONCAT_KDF_OTHER_INFO
342
343**p.152 Add new algorithm identifiers**
344
345The following entries shall be added to **Table 6-8**:
346
347.. list-table::
348 :header-rows: 1
349
350 * - Algorithm
351 - Identifier
352
353 * - TEE_ALG_CONCAT_KDF_SHA1_DERIVE_KEY
354 - 0x800020C1
355
356 * - TEE_ALG_CONCAT_KDF_SHA224_DERIVE_KEY
357 - 0x800030C1
358
359 * - TEE_ALG_CONCAT_KDF_SHA256_DERIVE_KEY
360 - 0x800040C1
361
362 * - TEE_ALG_CONCAT_KDF_SHA384_DERIVE_KEY
363 - 0x800050C1
364
365 * - TEE_ALG_CONCAT_KDF_SHA512_DERIVE_KEY
366 - 0x800060C1
367
368**p.154 Define new main algorithm**
369
370In **Table 6-9** in section 6.10.1, a new value shall be added to the value
371column for row bits ``[7:0]``:
372
373.. list-table::
374 :header-rows: 1
375
376 * - Bits
377 - Function
378 - Value
379
380 * - Bits [7:0]
381 - Identifiy the main underlying algorithm itself
382 - ...
383
384 0xC1: Concat KDF
385
386The function column for ``bits[15:12]`` shall also be modified to read:
387
388.. list-table::
389 :header-rows: 1
390
391 * - Bits
392 - Function
393 - Value
394
395 * - Bits [15:12]
396 - Define the message digest for asymmetric signature algorithms or Concat KDF
397 -
398
399**p.155 Add new object type for Concat KDF input shared secret**
400
401The following entry shall be added to **Table 6-10**:
402
403.. list-table::
404 :header-rows: 1
405
406 * - Name
407 - Identifier
408 - Possible sizes
409
410 * - TEE_TYPE_CONCAT_KDF_Z
411 - 0xA10000C1
412 - 8 to 4096 bits (multiple of 8)
413
414**p.156 Add new operation attributes for Concat KDF**
415
416The following entries shall be added to **Table 6-11**:
417
418.. list-table::
419 :header-rows: 1
420
421 * - Name
422 - Value
423 - Protection
424 - Type
425 - Comment
426
427 * - TEE_ATTR_CONCAT_KDF_Z
428 - 0xC00001C1
429 - Protected
430 - Ref
431 - The shared secret (``Z``)
432
433 * - TEE_ATTR_CONCAT_KDF_OTHER_INFO
434 - 0xD00002C1
435 - Public
436 - Ref
437 - ``OtherInfo``
438
439 * - TEE_ATTR_CONCAT_KDF_DKM_LENGTH
440 - 0xF00003C1
441 - Public
442 - Value
443 - The length (in bytes) of the derived keying material to be generated,
444 maximum 512. This is ``KeyDataLen`` / 8.
445
446
447.. _hkdf:
448
449HKDF
450====
451OP-TEE implements the *HMAC-based Extract-and-Expand Key Derivation Function
452(HKDF)* as specified in `RFC 5869`_. This file documents the extensions to the
Etienne Carrieredf106e02023-06-26 09:54:51 +0200453:ref:`tee_internal_core_api` v1.3.1 that were implemented to support this
Jerome Forissier6f47b162021-09-20 10:48:22 +0200454algorithm.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200455
Etienne Carrieredf106e02023-06-26 09:54:51 +0200456Note that the implementation follows the recommendations of version 1.3.1 of the
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200457specification for adding new algorithms. It should make it compatible with
458future changes to the official specification. You can disable this extension by
459setting the following in ``conf.mk``:
460
461.. code-block:: make
462
463 CFG_CRYPTO_HKDF := n
464
465**p.95 Add new object type to TEE_PopulateTransientObject**
466
467The following entry shall be added to **Table 5-8**:
468
469.. list-table::
470 :header-rows: 1
471
472 * - Object type
473 - Parts
474
475 * - TEE_TYPE_HKDF_IKM
476 - The TEE_ATTR_HKDF_IKM (Input Keying Material) part must be provided.
477
478**p.121 Add new algorithms for TEE_AllocateOperation**
479
480The following entry shall be added to **Table 6-3**:
481
482.. list-table::
483 :header-rows: 1
484
485 * - Algorithm
486 - Possible Modes
487
488 * - TEE_ALG_HKDF_MD5_DERIVE_KEY
489 TEE_ALG_HKDF_SHA1_DERIVE_KEY
490 TEE_ALG_HKDF_SHA224_DERIVE_KEY
491 TEE_ALG_HKDF_SHA256_DERIVE_KEY
492 TEE_ALG_HKDF_SHA384_DERIVE_KEY
493 TEE_ALG_HKDF_SHA512_DERIVE_KEY
494 TEE_ALG_HKDF_SHA512_DERIVE_KEY
495 - TEE_MODE_DERIVE
496
497**p.126 Explain usage of HKDF algorithms in TEE_SetOperationKey**
498
499In the bullet list about operation mode, the following shall be added:
500
501 - For the HKDF algorithms, the only supported mode is TEE_MODE_DERIVE.
502
503**p.150 Define TEE_DeriveKey input attributes for new algorithms**
504
505The following sentence shall be deleted:
506
507.. code-block:: none
508
509 The TEE_DeriveKey function can only be used with the algorithm
510 TEE_ALG_DH_DERIVE_SHARED_SECRET
511
512The following entry shall be added to **Table 6-7**:
513
514.. list-table::
515 :header-rows: 1
516
517 * - Algorithm
518 - Possible operation parameters
519
520 * - TEE_ALG_HKDF_MD5_DERIVE_KEY
521 TEE_ALG_HKDF_SHA1_DERIVE_KEY
522 TEE_ALG_HKDF_SHA224_DERIVE_KEY
523 TEE_ALG_HKDF_SHA256_DERIVE_KEY
524 TEE_ALG_HKDF_SHA384_DERIVE_KEY
525 TEE_ALG_HKDF_SHA512_DERIVE_KEY
526 TEE_ALG_HKDF_SHA512_DERIVE_KEY
527 - TEE_ATTR_HKDF_OKM_LENGTH: Number of bytes in the Output Keying Material
528
529 TEE_ATTR_HKDF_SALT (optional) Salt to be used during the extract step
530
531 TEE_ATTR_HKDF_INFO (optional) Info to be used during the expand step
532
533**p.152 Add new algorithm identifiers**
534
535The following entries shall be added to **Table 6-8**:
536
537.. list-table::
538 :header-rows: 1
539
540 * - Algorithm
541 - Identifier
542
543 * - TEE_ALG_HKDF_MD5_DERIVE_KEY
544 - 0x800010C0
545
546 * - TEE_ALG_HKDF_SHA1_DERIVE_KEY
547 - 0x800020C0
548
549 * - TEE_ALG_HKDF_SHA224_DERIVE_KEY
550 - 0x800030C0
551
552 * - TEE_ALG_HKDF_SHA256_DERIVE_KEY
553 - 0x800040C0
554
555 * - TEE_ALG_HKDF_SHA384_DERIVE_KEY
556 - 0x800050C0
557
558 * - TEE_ALG_HKDF_SHA512_DERIVE_KEY
559 - 0x800060C0
560
561## p.154 Define new main algorithm
562
563In **Table 6-9** in section 6.10.1, a new value shall be added to the value column
564for row ``bits [7:0]``:
565
566.. list-table::
567 :header-rows: 1
568
569 * - Bits
570 - Function
571 - Value
572
573 * - Bits [7:0]
574 - Identifiy the main underlying algorithm itself
575 - ...
576
577 0xC0: HKDF
578
579The function column for ``bits[15:12]`` shall also be modified to read:
580
581.. list-table::
582 :header-rows: 1
583
584 * - Bits
585 - Function
586 - Value
587
588 * - Bits [15:12]
589 - Define the message digest for asymmetric signature algorithms or HKDF
590 -
591
592**p.155 Add new object type for HKDF input keying material**
593
594The following entry shall be added to **Table 6-10**:
595
596.. list-table::
597 :header-rows: 1
598
599 * - Name
600 - Identifier
601 - Possible sizes
602
603 * - TEE_TYPE_HKDF_IKM
604 - 0xA10000C0
605 - 8 to 4096 bits (multiple of 8)
606
607**p.156 Add new operation attributes for HKDF salt and info**
608
609The following entries shall be added to **Table 6-11**:
610
611.. list-table::
612 :widths: 40 10 10 10 40
613 :header-rows: 1
614
615 * - Name
616 - Value
617 - Protection
618 - Type
619 - Comment
620
621 * - TEE_ATTR_HKDF_IKM
622 - 0xC00001C0
623 - Protected
624 - Ref
625 -
626
627 * - TEE_ATTR_HKDF_SALT
628 - 0xD00002C0
629 - Public
630 - Ref
631 -
632
633 * - TEE_ATTR_HKDF_INFO
634 - 0xD00003C0
635 - Public
636 - Ref
637 -
638
639 * - TEE_ATTR_HKDF_OKM_LENGTH
640 - 0xF00004C0
641 - Public
642 - Value
643 -
644
645.. _pbkdf2:
646
647PBKDF2
648======
649This document describes the OP-TEE implementation of the key derivation
650function, *PBKDF2* as specified in `RFC 2898`_ section 5.2. This RFC is a
651republication of PKCS #5 v2.0 from RSA Laboratories' Public-Key Cryptography
652Standards (PKCS) series. You may disable this extension by setting the following
653configuration variable in ``conf.mk``:
654
655.. code-block:: make
656
657 CFG_CRYPTO_PBKDF2 := n
658
659**API extension**
660
Etienne Carrieredf106e02023-06-26 09:54:51 +0200661To support PBKDF2, the :ref:`tee_internal_core_api` v1.3.1 was extended with a new
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200662algorithm descriptor, new object types, and new object attributes as described
663below.
664
665**p.95 Add new object type to TEE_PopulateTransientObject**
666
667The following entry shall be added to **Table 5-8**:
668
669.. list-table::
670 :header-rows: 1
671
672 * - Object type
673 - Parts
674
675 * - TEE_TYPE_PBKDF2_PASSWORD
676 - The TEE_ATTR_PBKDF2_PASSWORD part must be provided.
677
678**p.121 Add new algorithms for TEE_AllocateOperation**
679
680The following entry shall be added to **Table 6-3**:
681
682.. list-table::
683 :header-rows: 1
684
685 * - Algorithm
686 - Possible Modes
687
688 * - TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY
689 - TEE_MODE_DERIVE
690
691**p.126 Explain usage of PBKDF2 algorithm in TEE_SetOperationKey**
692
693In the bullet list about operation mode, the following shall be added:
694
695 - For the PBKDF2 algorithm, the only supported mode is TEE_MODE_DERIVE.
696
697**p.150 Define TEE_DeriveKey input attributes for new algorithms**
698
699The following sentence shall be deleted:
700
701.. code-block:: none
702
703 The TEE_DeriveKey function can only be used with the algorithm
704 TEE_ALG_DH_DERIVE_SHARED_SECRET
705
706The following entry shall be added to **Table 6-7**:
707
708.. list-table::
709 :header-rows: 1
710
711 * - Algorithm
712 - Possible operation parameters
713
714 * - TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY
715 - TEE_ATTR_PBKDF2_DKM_LENGTH: up to 512 bytes. This parameter is
716 mandatory.
717
718 TEE_ATTR_PBKDF2_SALT
719
720 TEE_ATTR_PBKDF2_ITERATION_COUNT: This parameter is mandatory.
721
722**p.152 Add new algorithm identifiers**
723
724The following entries shall be added to **Table 6-8**:
725
726.. list-table::
727 :header-rows: 1
728
729 * - Algorithm
730 - Identifier
731
732 * - TEE_ALG_PBKDF2_HMAC_SHA1_DERIVE_KEY
733 - 0x800020C2
734
735**p.154 Define new main algorithm**
736
737In **Table 6-9** in section 6.10.1, a new value shall be added to the value
738column for row ``bits [7:0]``:
739
740.. list-table::
741 :header-rows: 1
742
743 * - Bits
744 - Function
745 - Value
746
747 * - Bits [7:0]
748 - Identifiy the main underlying algorithm itself
749 - ...
750
751 0xC2: PBKDF2
752
753The function column for ``bits[15:12]`` shall also be modified to read:
754
755.. list-table::
756 :header-rows: 1
757
758 * - Bits
759 - Function
760 - Value
761
762 * - Bits [15:12]
763 - Define the message digest for asymmetric signature algorithms or PBKDF2
764 -
765
766**p.155 Add new object type for PBKDF2 password**
767
768The following entry shall be added to **Table 6-10**:
769
770.. list-table::
771 :header-rows: 1
772
773 * - Name
774 - Identifier
775 - Possible sizes
776
777 * - TEE_TYPE_PBKDF2_PASSWORD
778 - 0xA10000C2
779 - 8 to 4096 bits (multiple of 8)
780
781**p.156 Add new operation attributes for Concat KDF**
782
783The following entries shall be added to **Table 6-11**:
784
785.. list-table::
786 :widths: 40 10 10 10 40
787 :header-rows: 1
788
789 * - Name
790 - Value
791 - Protection
792 - Type
793 - Comment
794
795 * - TEE_ATTR_PBKDF2_PASSWORD
796 - 0xC00001C2
797 - Protected
798 - Ref
799 -
800
801 * - TEE_ATTR_PBKDF2_SALT
802 - 0xD00002C2
803 - Public
804 - Ref
805 -
806
807 * - TEE_ATTR_PBKDF2_ITERATION_COUNT
808 - 0xF00003C2
809 - Public
810 - Value
811 -
812
813 * - TEE_ATTR_PBKDF2_DKM_LENGTH
814 - 0xF00004C2
815 - Public
816 - Value
817 - The length (in bytes) of the derived keying material to be generated,
818 maximum 512.
819
820
Aleksandr Anisimova6f9a612021-03-10 20:33:58 +0300821.. _loadable_plugins_framework:
822
823Loadable plugins framework
824==========================
825This framework makes the supplicant a bit more flexible in terms of providing
826services. It is possible to design any REE service for the TEE as
827a tee-supplicant plugin. It makes it easy to:
828
829 - add new features to the supplicant that aren't needed in upstream,
830 e.g. Rich OS-specific services
831 - sync an own fork of the supplicant with the upstream version
832
833To create a plugin, developers have to implement the following structure from
834the ``public/tee_plugin_method.h`` file from the optee_client_ git.:
835
836.. code-block:: c
837
838 struct plugin_method {
839 const char *name; /* short friendly name of the plugin */
840 TEEC_UUID uuid;
841 TEEC_Result (*init)(void);
842 TEEC_Result (*invoke)(unsigned int cmd, unsigned int sub_cmd,
843 void *data, size_t in_len, size_t *out_len);
844 };
845
846The plugin framework is based on the RPC - ``OPTEE_MSG_RPC_CMD_PLUGIN``.
847This is a unified interface between TEE and plugins.
848TEE can only access the plugins by its UUID.
849
850After implementing this structure, a plugin has to be compiled as a shared
851object. The objects have to be placed into the directory defined
852by ``CFG_TEE_PLUGIN_LOAD_PATH``. This path can be set in the ``config.mk`` file
853in the optee_client_ git. By default it is set to
854**/usr/lib/tee-supplicant/plugins/**.
855
856The supplicant loads all of the plugins from the directory during the startup
857process using **libdl**. After this, any requests to plugins
858from TEE will be processed in the common RPC handler.
859
860On TEE side users can use any plugin by its UUID from TAs code and from
861the OP-TEE kernel code. The following function has been introduced like
862an extension of the TEE API to allow Trusted Applications to operate with
863plugins:
864
865.. code-block:: c
866
867 /*
868 * tee_invoke_supp_plugin() - invoke a tee-supplicant's plugin
869 * @uuid: uuid of the plugin
870 * @cmd: command for the plugin
871 * @sub_cmd: subcommand for the plugin
872 * @buf: data [to/from] the plugin [in/out]
873 * @len: length of the input buf
874 * @outlen: pointer to length of the output data (if they will be used)
875 *
876 * Return TEE_SUCCESS on success or TEE_ERRROR_* on failure.
877 */
878 TEE_Result tee_invoke_supp_plugin(const TEE_UUID *uuid, uint32_t cmd,
879 uint32_t sub_cmd, void *buf, size_t len,
880 size_t *outlen);
881
882This API calls the ``system-pta``, which uses the RPC to call a plugin.
883See ``OPTEE_RPC_CMD_SUPP_PLUGIN`` in the ``core/include/optee_rpc_cmd.h`` file
884from optee_os_ git. If there is a need to use plugins from the OP-TEE kernel,
885then the following function can be called directly:
886
887.. code-block:: c
888
889 TEE_Result tee_invoke_supp_plugin_rpc(const TEE_UUID *uuid, uint32_t cmd,
890 uint32_t sub_cmd, void *buf, size_t len,
891 size_t *outlen);
892
893.. NOTE::
894 One buffer is used for input data to a plugin and for output data
895 from a plugin. See an example of using this feature in the optee_examples_
896 git.
897
898
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200899.. _GlobalPlatform: https://globalplatform.org
900.. _optee_examples: https://github.com/linaro-swg/optee_examples
Aleksandr Anisimova6f9a612021-03-10 20:33:58 +0300901.. _optee_client: https://github.com/OP-TEE/optee_client
902.. _optee_os: https://github.com/OP-TEE/optee_os
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200903.. _TZC-400: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0504c/index.html
904.. _RFC 2898: https://www.ietf.org/rfc/rfc2898.txt
905.. _RFC 3447: https://tools.ietf.org/html/rfc3447#section-8.2
906.. _RFC 5869: https://tools.ietf.org/html/rfc5869
907.. _Specification: https://globalplatform.org/specs-library/?filter-committee=tee
908.. _SP 800-56A: http://csrc.nist.gov/publications/nistpubs/800-56A/SP800-56A_Revision1_Mar08-2007.pdf
909.. _UUID: https://en.wikipedia.org/wiki/Universally_unique_identifier