Mbed OS Reference
Loading...
Searching...
No Matches
psa_attest_inject_key.h
1/*
2* Copyright (c) 2018-2019 ARM Limited. All rights reserved.
3*
4* SPDX-License-Identifier: Apache-2.0
5*
6* Licensed under the Apache License, Version 2.0 (the License); you may
7* not use this file except in compliance with the License.
8* You may obtain a copy of the License at
9*
10* http://www.apache.org/licenses/LICENSE-2.0
11*
12* Unless required by applicable law or agreed to in writing, software
13* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15* See the License for the specific language governing permissions and
16* limitations under the License.
17*/
18
19/** @addtogroup PSA-Attestation
20 * @{
21 */
22
23#ifndef __PSA_INJECT_KEY_H__
24#define __PSA_INJECT_KEY_H__
25
26#include "psa/crypto.h"
27#include <stdint.h>
28#include <string.h>
29
30#ifdef __cplusplus
31extern "C"
32{
33#endif
34
35/**
36 * \brief Generate or import a given key pair and export the public part in a binary format.
37 * Initial attestation key: Private key for ECDSA-P256 to sign initial attestation token.
38 * Attestation private key is a persistent key that saved to
39 * persistent storage with persistent storage id = 17.
40 *
41 * \param[in] key_data Buffer containing the private key data if given.
42 * It must conain the format described in the documentation
43 * of psa_export_public_key() for
44 * the chosen type.
45 * In case of generate the private key - NULL will pass.
46 * \param key_data_length Size of the \p data buffer in bytes - must be 256 bits. in case key_data isn't NULL.
47 * In case of private key generation - 0 will pass.
48 * \param type Key type - must be a ECC key type
49 * (a \c PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_XXX) value).
50 * \param[out] public_key_data Buffer where the key data is to be written.
51 * \param public_key_data_size Size of the \p public_key_data buffer in bytes -
52 * needs to be bigger then the max size of the public part.
53 * \param[out] public_key_data_length On success, the number of bytes
54 * that make up the key data.
55 *
56 * \retval #PSA_SUCCESS
57 * Success.
58 * \retval #PSA_ERROR_INVALID_HANDLE
59 * \retval #PSA_ERROR_OCCUPIED_SLOT
60 * There is already a key in the specified slot.
61 * \retval #PSA_ERROR_NOT_SUPPORTED
62 * \retval #PSA_ERROR_INVALID_ARGUMENT
63 * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
64 * \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
65 * \retval #PSA_ERROR_COMMUNICATION_FAILURE
66 * \retval #PSA_ERROR_HARDWARE_FAILURE
67 * \retval #PSA_ERROR_TAMPERING_DETECTED
68 * \retval #PSA_ERROR_BAD_STATE
69 * The library has not been previously initialized by psa_crypto_init().
70 * It is implementation-dependent whether a failure to initialize
71 * results in this error code.
72 */
74psa_attestation_inject_key(const uint8_t *key_data,
75 size_t key_data_length,
76 psa_key_type_t type,
77 uint8_t *public_key_data,
78 size_t public_key_data_size,
79 size_t *public_key_data_length);
80
81#ifdef __cplusplus
82}
83#endif
84
85/** @}*/ // PSA-Attestation
86
87#endif /* __PSA_INJECT_KEY_H__ */
Platform Security Architecture cryptography module.
psa_status_t psa_attestation_inject_key(const uint8_t *key_data, size_t key_data_length, psa_key_type_t type, uint8_t *public_key_data, size_t public_key_data_size, size_t *public_key_data_length)
Generate or import a given key pair and export the public part in a binary format.
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:66
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:55