aboutsummaryrefslogtreecommitdiff
path: root/secure_fw/services/initial_attestation/attestation_key.h
blob: c1b7b3c393ef26c6d2b1e3843dde2036ab287b68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright (c) 2019, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

#ifndef __ATTESTATION_KEY_H__
#define __ATTESTATION_KEY_H__

#include "psa/initial_attestation.h"
#include "psa/crypto.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \brief Register the initial attestation private key to Crypto service. Loads
 *        the public key if the key has not already been loaded.
 *
 * \note  Private key MUST be present on the device, otherwise initial
 *        attestation token cannot be signed.
 *
 * \retval  PSA_ATTEST_ERR_SUCCESS   Key(s) was registered.
 * \retval  PSA_ATTEST_ERR_GENERAL   Key(s) could not be registered.
 */
enum psa_attest_err_t
attest_register_initial_attestation_key();

/**
 * \brief Unregister the initial attestation private key from Crypto service
 *        to do not occupy key slot.
 *
 * \retval  PSA_ATTEST_ERR_SUCCESS   Key(s) was unregistered.
 * \retval  PSA_ATTEST_ERR_GENERAL   Key(s) could not be unregistered.
 */
enum psa_attest_err_t
attest_unregister_initial_attestation_key();

/**
 * \brief Get a handle to the attestion private key.
 *
 * \param[out] key_handle Key handle for private key
 *
 * \retval  PSA_ATTEST_ERR_SUCCESS   Private key was successfully returned.
 * \retval  PSA_ATTEST_ERR_GENERAL   Private key could not be returned.
 */

enum psa_attest_err_t
attest_get_initial_attestation_private_key_handle(psa_key_handle_t *key_handle);

/**
 * \brief Get the public key derived from the initial attestation private key.
 *
 * \param[out] public_key       Pointer to public key buffer.
 * \param[out] public_key_len   Size of public key in bytes.
 * \param[out] public_key_curve Type of the curve that is used in the public
 *                              key.
 *
 * \retval  PSA_ATTEST_ERR_SUCCESS   Public key was successfully returned.
 * \retval  PSA_ATTEST_ERR_GENERAL   Public key could not be returned.
 */

enum psa_attest_err_t
attest_get_initial_attestation_public_key(uint8_t **public_key,
                                          size_t *public_key_len,
                                          psa_ecc_curve_t *public_key_curve);
#ifdef __cplusplus
}
#endif

#endif /* __ATTESTATION_KEY_H__ */