blob: c1b7b3c393ef26c6d2b1e3843dde2036ab287b68 [file] [log] [blame]
Tamas Ban28aeec32019-01-09 16:53:26 +00001/*
2 * Copyright (c) 2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __ATTESTATION_KEY_H__
9#define __ATTESTATION_KEY_H__
10
Jamie Foxcc31d402019-01-28 17:13:52 +000011#include "psa/initial_attestation.h"
12#include "psa/crypto.h"
Tamas Ban28aeec32019-01-09 16:53:26 +000013
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/**
Raef Colesbfe47622019-10-22 10:15:41 +010019 * \brief Register the initial attestation private key to Crypto service. Loads
20 * the public key if the key has not already been loaded.
Tamas Ban28aeec32019-01-09 16:53:26 +000021 *
Raef Colesbfe47622019-10-22 10:15:41 +010022 * \note Private key MUST be present on the device, otherwise initial
23 * attestation token cannot be signed.
Tamas Ban28aeec32019-01-09 16:53:26 +000024 *
25 * \retval PSA_ATTEST_ERR_SUCCESS Key(s) was registered.
26 * \retval PSA_ATTEST_ERR_GENERAL Key(s) could not be registered.
27 */
Raef Colesbfe47622019-10-22 10:15:41 +010028enum psa_attest_err_t
29attest_register_initial_attestation_key();
Tamas Ban6c08f9d2019-05-09 08:43:29 +010030
Tamas Ban28aeec32019-01-09 16:53:26 +000031/**
Tamas Ban6c08f9d2019-05-09 08:43:29 +010032 * \brief Unregister the initial attestation private key from Crypto service
33 * to do not occupy key slot.
Tamas Ban28aeec32019-01-09 16:53:26 +000034 *
35 * \retval PSA_ATTEST_ERR_SUCCESS Key(s) was unregistered.
36 * \retval PSA_ATTEST_ERR_GENERAL Key(s) could not be unregistered.
37 */
Raef Colesbfe47622019-10-22 10:15:41 +010038enum psa_attest_err_t
39attest_unregister_initial_attestation_key();
40
41/**
42 * \brief Get a handle to the attestion private key.
43 *
44 * \param[out] key_handle Key handle for private key
45 *
46 * \retval PSA_ATTEST_ERR_SUCCESS Private key was successfully returned.
47 * \retval PSA_ATTEST_ERR_GENERAL Private key could not be returned.
48 */
49
50enum psa_attest_err_t
51attest_get_initial_attestation_private_key_handle(psa_key_handle_t *key_handle);
52
53/**
54 * \brief Get the public key derived from the initial attestation private key.
55 *
56 * \param[out] public_key Pointer to public key buffer.
57 * \param[out] public_key_len Size of public key in bytes.
58 * \param[out] public_key_curve Type of the curve that is used in the public
59 * key.
60 *
61 * \retval PSA_ATTEST_ERR_SUCCESS Public key was successfully returned.
62 * \retval PSA_ATTEST_ERR_GENERAL Public key could not be returned.
63 */
64
65enum psa_attest_err_t
66attest_get_initial_attestation_public_key(uint8_t **public_key,
67 size_t *public_key_len,
68 psa_ecc_curve_t *public_key_curve);
Tamas Ban28aeec32019-01-09 16:53:26 +000069#ifdef __cplusplus
70}
71#endif
72
73#endif /* __ATTESTATION_KEY_H__ */