Skip to content

Commit ffc3aa6

Browse files
author
itayzafrir
committed
crypto: Separate crypto_types.h implementations
- Execute the crypto importer in order to move crypto_types.h to its new location, this is done only for non-secure devices. - Add different implementations (between client and server) of crypto_types.h for secure devices. Specifically, the type psa_key_id_t is defined as a 32 bit type for the client and as a 64 bit type for the server. Eventually, the 64 bit psa_key_id_t will be tunneled to ITS via crypto API.
1 parent 7dc989a commit ffc3aa6

File tree

4 files changed

+207
-0
lines changed

4 files changed

+207
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef PSA_CRYPTO_SECURE
2+
#include "crypto_types_spe.h"
3+
#else
4+
#include "crypto_types_ipc.h"
5+
#endif
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* \file psa/crypto_types.h
3+
*
4+
* \brief PSA cryptography module: type aliases.
5+
*
6+
* \note This file may not be included directly. Applications must
7+
* include psa/crypto.h. Drivers must include the appropriate driver
8+
* header file.
9+
*
10+
* This file contains portable definitions of integral types for properties
11+
* of cryptographic keys, designations of cryptographic algorithms, and
12+
* error codes returned by the library.
13+
*
14+
* This header file does not declare any function.
15+
*/
16+
/*
17+
* Copyright (C) 2018, ARM Limited, All Rights Reserved
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+
* This file is part of mbed TLS (https://tls.mbed.org)
33+
*/
34+
35+
#ifndef PSA_CRYPTO_TYPES_H
36+
#define PSA_CRYPTO_TYPES_H
37+
38+
#include <stdint.h>
39+
40+
/** \defgroup error Error codes
41+
* @{
42+
*/
43+
44+
/**
45+
* \brief Function return status.
46+
*
47+
* This is either #PSA_SUCCESS (which is zero), indicating success,
48+
* or a nonzero value indicating that an error occurred. Errors are
49+
* encoded as one of the \c PSA_ERROR_xxx values defined here.
50+
*/
51+
typedef int32_t psa_status_t;
52+
53+
/**@}*/
54+
55+
/** \defgroup crypto_types Key and algorithm types
56+
* @{
57+
*/
58+
59+
/** \brief Encoding of a key type.
60+
*/
61+
typedef uint32_t psa_key_type_t;
62+
63+
/** The type of PSA elliptic curve identifiers. */
64+
typedef uint16_t psa_ecc_curve_t;
65+
66+
/** \brief Encoding of a cryptographic algorithm.
67+
*
68+
* For algorithms that can be applied to multiple key types, this type
69+
* does not encode the key type. For example, for symmetric ciphers
70+
* based on a block cipher, #psa_algorithm_t encodes the block cipher
71+
* mode and the padding mode while the block cipher itself is encoded
72+
* via #psa_key_type_t.
73+
*/
74+
typedef uint32_t psa_algorithm_t;
75+
76+
/**@}*/
77+
78+
/** \defgroup key_lifetimes Key lifetimes
79+
* @{
80+
*/
81+
82+
/** Encoding of key lifetimes.
83+
*/
84+
typedef uint32_t psa_key_lifetime_t;
85+
86+
/** Encoding of identifiers of persistent keys.
87+
*/
88+
typedef uint64_t psa_key_id_t;
89+
90+
/**@}*/
91+
92+
/** \defgroup policy Key policies
93+
* @{
94+
*/
95+
96+
/** \brief Encoding of permitted usage on a key. */
97+
typedef uint32_t psa_key_usage_t;
98+
99+
/**@}*/
100+
101+
#endif /* PSA_CRYPTO_TYPES_H */
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* \file psa/crypto_types.h
3+
*
4+
* \brief PSA cryptography module: type aliases.
5+
*
6+
* \note This file may not be included directly. Applications must
7+
* include psa/crypto.h. Drivers must include the appropriate driver
8+
* header file.
9+
*
10+
* This file contains portable definitions of integral types for properties
11+
* of cryptographic keys, designations of cryptographic algorithms, and
12+
* error codes returned by the library.
13+
*
14+
* This header file does not declare any function.
15+
*/
16+
/*
17+
* Copyright (C) 2018, ARM Limited, All Rights Reserved
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+
* This file is part of mbed TLS (https://tls.mbed.org)
33+
*/
34+
35+
#ifndef PSA_CRYPTO_TYPES_H
36+
#define PSA_CRYPTO_TYPES_H
37+
38+
#include <stdint.h>
39+
40+
/** \defgroup error Error codes
41+
* @{
42+
*/
43+
44+
/**
45+
* \brief Function return status.
46+
*
47+
* This is either #PSA_SUCCESS (which is zero), indicating success,
48+
* or a nonzero value indicating that an error occurred. Errors are
49+
* encoded as one of the \c PSA_ERROR_xxx values defined here.
50+
*/
51+
typedef int32_t psa_status_t;
52+
53+
/**@}*/
54+
55+
/** \defgroup crypto_types Key and algorithm types
56+
* @{
57+
*/
58+
59+
/** \brief Encoding of a key type.
60+
*/
61+
typedef uint32_t psa_key_type_t;
62+
63+
/** The type of PSA elliptic curve identifiers. */
64+
typedef uint16_t psa_ecc_curve_t;
65+
66+
/** \brief Encoding of a cryptographic algorithm.
67+
*
68+
* For algorithms that can be applied to multiple key types, this type
69+
* does not encode the key type. For example, for symmetric ciphers
70+
* based on a block cipher, #psa_algorithm_t encodes the block cipher
71+
* mode and the padding mode while the block cipher itself is encoded
72+
* via #psa_key_type_t.
73+
*/
74+
typedef uint32_t psa_algorithm_t;
75+
76+
/**@}*/
77+
78+
/** \defgroup key_lifetimes Key lifetimes
79+
* @{
80+
*/
81+
82+
/** Encoding of key lifetimes.
83+
*/
84+
typedef uint32_t psa_key_lifetime_t;
85+
86+
/** Encoding of identifiers of persistent keys.
87+
*/
88+
typedef uint32_t psa_key_id_t;
89+
90+
/**@}*/
91+
92+
/** \defgroup policy Key policies
93+
* @{
94+
*/
95+
96+
/** \brief Encoding of permitted usage on a key. */
97+
typedef uint32_t psa_key_usage_t;
98+
99+
/**@}*/
100+
101+
#endif /* PSA_CRYPTO_TYPES_H */

0 commit comments

Comments
 (0)