Skip to content

Commit e71374f

Browse files
committed
crypto: Update to Mbed Crypto 1.0.0d0
1 parent 66cbb32 commit e71374f

22 files changed

+3907
-2762
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mbedcrypto-0.1.0b2
1+
mbedcrypto-1.0.0d0

features/mbedtls/mbed-crypto/inc/psa/crypto.h

Lines changed: 455 additions & 1621 deletions
Large diffs are not rendered by default.

features/mbedtls/mbed-crypto/inc/psa/crypto_accel_driver.h

Lines changed: 796 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* \file psa/crypto_driver_common.h
3+
* \brief Definitions for all PSA crypto drivers
4+
*
5+
* This file contains common definitions shared by all PSA crypto drivers.
6+
* Do not include it directly: instead, include the header file(s) for
7+
* the type(s) of driver that you are implementing. For example, if
8+
* you are writing a driver for a chip that provides both a hardware
9+
* random generator and an accelerator for some cryptographic algorithms,
10+
* include `psa/crypto_entropy_driver.h` and `psa/crypto_accel_driver.h`.
11+
*
12+
* This file is part of the PSA Crypto Driver Model, containing functions for
13+
* driver developers to implement to enable hardware to be called in a
14+
* standardized way by a PSA Cryptographic API implementation. The functions
15+
* comprising the driver model, which driver authors implement, are not
16+
* intended to be called by application developers.
17+
*/
18+
19+
/*
20+
* Copyright (C) 2018, ARM Limited, All Rights Reserved
21+
* SPDX-License-Identifier: Apache-2.0
22+
*
23+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
24+
* not use this file except in compliance with the License.
25+
* You may obtain a copy of the License at
26+
*
27+
* http://www.apache.org/licenses/LICENSE-2.0
28+
*
29+
* Unless required by applicable law or agreed to in writing, software
30+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
31+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32+
* See the License for the specific language governing permissions and
33+
* limitations under the License.
34+
*/
35+
#ifndef PSA_CRYPTO_DRIVER_COMMON_H
36+
#define PSA_CRYPTO_DRIVER_COMMON_H
37+
38+
#include <stddef.h>
39+
#include <stdint.h>
40+
41+
/* Include type definitions (psa_status_t, psa_algorithm_t,
42+
* psa_key_type_t, etc.) and macros to build and analyze values
43+
* of these types. */
44+
#include "crypto_types.h"
45+
#include "crypto_values.h"
46+
47+
/** For encrypt-decrypt functions, whether the operation is an encryption
48+
* or a decryption. */
49+
typedef enum {
50+
PSA_CRYPTO_DRIVER_DECRYPT,
51+
PSA_CRYPTO_DRIVER_ENCRYPT
52+
} psa_encrypt_or_decrypt_t;
53+
54+
#endif /* PSA_CRYPTO_DRIVER_COMMON_H */
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* \file psa/crypto_entropy_driver.h
3+
* \brief PSA entropy source driver module
4+
*
5+
* This header declares types and function signatures for entropy sources.
6+
*
7+
* This file is part of the PSA Crypto Driver Model, containing functions for
8+
* driver developers to implement to enable hardware to be called in a
9+
* standardized way by a PSA Cryptographic API implementation. The functions
10+
* comprising the driver model, which driver authors implement, are not
11+
* intended to be called by application developers.
12+
*/
13+
14+
/*
15+
* Copyright (C) 2018, ARM Limited, All Rights Reserved
16+
* SPDX-License-Identifier: Apache-2.0
17+
*
18+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
19+
* not use this file except in compliance with the License.
20+
* You may obtain a copy of the License at
21+
*
22+
* http://www.apache.org/licenses/LICENSE-2.0
23+
*
24+
* Unless required by applicable law or agreed to in writing, software
25+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
26+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+
* See the License for the specific language governing permissions and
28+
* limitations under the License.
29+
*/
30+
#ifndef PSA_CRYPTO_ENTROPY_DRIVER_H
31+
#define PSA_CRYPTO_ENTROPY_DRIVER_H
32+
33+
#include "crypto_driver_common.h"
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
/** \defgroup driver_rng Entropy Generation
40+
*/
41+
/**@{*/
42+
43+
/** \brief A hardware-specific structure for a entropy providing hardware
44+
*/
45+
typedef struct psa_drv_entropy_context_s psa_drv_entropy_context_t;
46+
47+
/** \brief Initialize an entropy driver
48+
*
49+
*
50+
* \param[in,out] p_context A hardware-specific structure
51+
* containing any context information for
52+
* the implementation
53+
*
54+
* \retval PSA_SUCCESS
55+
*/
56+
typedef psa_status_t (*psa_drv_entropy_init_t)(psa_drv_entropy_context_t *p_context);
57+
58+
/** \brief Get a specified number of bits from the entropy source
59+
*
60+
* It retrives `buffer_size` bytes of data from the entropy source. The entropy
61+
* source will always fill the provided buffer to its full size, however, most
62+
* entropy sources have biases, and the actual amount of entropy contained in
63+
* the buffer will be less than the number of bytes.
64+
* The driver will return the actual number of bytes of entropy placed in the
65+
* buffer in `p_received_entropy_bytes`.
66+
* A PSA Crypto API implementation will likely feed the output of this function
67+
* into a Digital Random Bit Generator (DRBG), and typically has a minimum
68+
* amount of entropy that it needs.
69+
* To accomplish this, the PSA Crypto implementation should be designed to call
70+
* this function multiple times until it has received the required amount of
71+
* entropy from the entropy source.
72+
*
73+
* \param[in,out] p_context A hardware-specific structure
74+
* containing any context information
75+
* for the implementation
76+
* \param[out] p_buffer A caller-allocated buffer for the
77+
* retrieved entropy to be placed in
78+
* \param[in] buffer_size The allocated size of `p_buffer`
79+
* \param[out] p_received_entropy_bits The amount of entropy (in bits)
80+
* actually provided in `p_buffer`
81+
*
82+
* \retval PSA_SUCCESS
83+
*/
84+
typedef psa_status_t (*psa_drv_entropy_get_bits_t)(psa_drv_entropy_context_t *p_context,
85+
uint8_t *p_buffer,
86+
uint32_t buffer_size,
87+
uint32_t *p_received_entropy_bits);
88+
89+
/**
90+
* \brief A struct containing all of the function pointers needed to interface
91+
* to an entropy source
92+
*
93+
* PSA Crypto API implementations should populate instances of the table as
94+
* appropriate upon startup.
95+
*
96+
* If one of the functions is not implemented, it should be set to NULL.
97+
*/
98+
typedef struct {
99+
/** Function that performs initialization for the entropy source */
100+
psa_drv_entropy_init_t *p_init;
101+
/** Function that performs the get_bits operation for the entropy source
102+
*/
103+
psa_drv_entropy_get_bits_t *p_get_bits;
104+
} psa_drv_entropy_t;
105+
/**@}*/
106+
107+
#ifdef __cplusplus
108+
}
109+
#endif
110+
111+
#endif /* PSA_CRYPTO_ENTROPY_DRIVER_H */

features/mbedtls/mbed-crypto/inc/psa/crypto_platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
/* PSA requires several types which C99 provides in stdint.h. */
4747
#include <stdint.h>
4848

49-
/* Integral type representing a key slot number. */
50-
typedef uint16_t psa_key_slot_t;
49+
/* Integral type representing a key handle. */
50+
typedef uint16_t psa_key_handle_t;
5151

5252
#endif /* PSA_CRYPTO_PLATFORM_H */

0 commit comments

Comments
 (0)