Mistake on this page?
Report an issue in GitHub or email us
TARGET_MBED_PSA_SRV/inc/psa/crypto_platform.h
1 /**
2  * \file psa/crypto_platform.h
3  *
4  * \brief PSA cryptography module: Mbed TLS platform definitions
5  *
6  * \note This file may not be included directly. Applications must
7  * include psa/crypto.h.
8  *
9  * This file contains platform-dependent type definitions.
10  *
11  * In implementations with isolation between the application and the
12  * cryptography module, implementers should take care to ensure that
13  * the definitions that are exposed to applications match what the
14  * module implements.
15  */
16 /*
17  * Copyright The Mbed TLS Contributors
18  * SPDX-License-Identifier: Apache-2.0
19  *
20  * Licensed under the Apache License, Version 2.0 (the "License"); you may
21  * not use this file except in compliance with the License.
22  * You may obtain a copy of the License at
23  *
24  * http://www.apache.org/licenses/LICENSE-2.0
25  *
26  * Unless required by applicable law or agreed to in writing, software
27  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
28  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  * See the License for the specific language governing permissions and
30  * limitations under the License.
31  */
32 
33 #ifndef PSA_CRYPTO_PLATFORM_H
34 #define PSA_CRYPTO_PLATFORM_H
35 
36 /* Include the Mbed TLS configuration file, the way Mbed TLS does it
37  * in each of its header files. */
38 #if !defined(MBEDTLS_CONFIG_FILE)
39 #include "mbedtls/config.h"
40 #else
41 #include MBEDTLS_CONFIG_FILE
42 #endif
43 
44 /* PSA requires several types which C99 provides in stdint.h. */
45 #include <stdint.h>
46 
47 /* Integral type representing a key handle. */
48 typedef uint16_t psa_key_handle_t;
49 
50 /* This implementation distinguishes *application key identifiers*, which
51  * are the key identifiers specified by the application, from
52  * *key file identifiers*, which are the key identifiers that the library
53  * sees internally. The two types can be different if there is a remote
54  * call layer between the application and the library which supports
55  * multiple client applications that do not have access to each others'
56  * keys. The point of having different types is that the key file
57  * identifier may encode not only the key identifier specified by the
58  * application, but also the the identity of the application.
59  *
60  * Note that this is an internal concept of the library and the remote
61  * call layer. The application itself never sees anything other than
62  * #psa_app_key_id_t with its standard definition.
63  */
64 
65 /* The application key identifier is always what the application sees as
66  * #psa_key_id_t. */
67 typedef uint32_t psa_app_key_id_t;
68 
69 #if defined(MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER)
70 
71 #if defined(PSA_CRYPTO_SECURE)
72 /* Building for the PSA Crypto service on a PSA platform. */
73 /* A key owner is a PSA partition identifier. */
74 typedef int32_t psa_key_owner_id_t;
75 #endif
76 
77 typedef struct
78 {
79  uint32_t key_id;
80  psa_key_owner_id_t owner;
81 } psa_key_file_id_t;
82 #define PSA_KEY_FILE_GET_KEY_ID( file_id ) ( ( file_id ).key_id )
83 
84 /* Since crypto.h is used as part of the PSA Cryptography API specification,
85  * it must use standard types for things like the argument of psa_open_key().
86  * If it wasn't for that constraint, psa_open_key() would take a
87  * `psa_key_file_id_t` argument. As a workaround, make `psa_key_id_t` an
88  * alias for `psa_key_file_id_t` when building for a multi-client service. */
89 typedef psa_key_file_id_t psa_key_id_t;
90 #define PSA_KEY_ID_INIT {0, 0}
91 
92 #else /* !MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER */
93 
94 /* By default, a key file identifier is just the application key identifier. */
95 typedef psa_app_key_id_t psa_key_file_id_t;
96 #define PSA_KEY_FILE_GET_KEY_ID( id ) ( id )
97 
98 #endif /* !MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER */
99 
100 #endif /* PSA_CRYPTO_PLATFORM_H */
uint32_t psa_key_id_t
Encoding of identifiers of persistent keys.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.