Tamas Ban | 28aeec3 | 2019-01-09 16:53:26 +0000 | [diff] [blame] | 1 | /* |
| 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 Fox | cc31d40 | 2019-01-28 17:13:52 +0000 | [diff] [blame] | 11 | #include "psa/initial_attestation.h" |
| 12 | #include "psa/crypto.h" |
Tamas Ban | 28aeec3 | 2019-01-09 16:53:26 +0000 | [diff] [blame] | 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | /** |
Raef Coles | bfe4762 | 2019-10-22 10:15:41 +0100 | [diff] [blame^] | 19 | * \brief Register the initial attestation private key to Crypto service. Loads |
| 20 | * the public key if the key has not already been loaded. |
Tamas Ban | 28aeec3 | 2019-01-09 16:53:26 +0000 | [diff] [blame] | 21 | * |
Raef Coles | bfe4762 | 2019-10-22 10:15:41 +0100 | [diff] [blame^] | 22 | * \note Private key MUST be present on the device, otherwise initial |
| 23 | * attestation token cannot be signed. |
Tamas Ban | 28aeec3 | 2019-01-09 16:53:26 +0000 | [diff] [blame] | 24 | * |
| 25 | * \retval PSA_ATTEST_ERR_SUCCESS Key(s) was registered. |
| 26 | * \retval PSA_ATTEST_ERR_GENERAL Key(s) could not be registered. |
| 27 | */ |
Raef Coles | bfe4762 | 2019-10-22 10:15:41 +0100 | [diff] [blame^] | 28 | enum psa_attest_err_t |
| 29 | attest_register_initial_attestation_key(); |
Tamas Ban | 6c08f9d | 2019-05-09 08:43:29 +0100 | [diff] [blame] | 30 | |
Tamas Ban | 28aeec3 | 2019-01-09 16:53:26 +0000 | [diff] [blame] | 31 | /** |
Tamas Ban | 6c08f9d | 2019-05-09 08:43:29 +0100 | [diff] [blame] | 32 | * \brief Unregister the initial attestation private key from Crypto service |
| 33 | * to do not occupy key slot. |
Tamas Ban | 28aeec3 | 2019-01-09 16:53:26 +0000 | [diff] [blame] | 34 | * |
| 35 | * \retval PSA_ATTEST_ERR_SUCCESS Key(s) was unregistered. |
| 36 | * \retval PSA_ATTEST_ERR_GENERAL Key(s) could not be unregistered. |
| 37 | */ |
Raef Coles | bfe4762 | 2019-10-22 10:15:41 +0100 | [diff] [blame^] | 38 | enum psa_attest_err_t |
| 39 | attest_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 | |
| 50 | enum psa_attest_err_t |
| 51 | attest_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 | |
| 65 | enum psa_attest_err_t |
| 66 | attest_get_initial_attestation_public_key(uint8_t **public_key, |
| 67 | size_t *public_key_len, |
| 68 | psa_ecc_curve_t *public_key_curve); |
Tamas Ban | 28aeec3 | 2019-01-09 16:53:26 +0000 | [diff] [blame] | 69 | #ifdef __cplusplus |
| 70 | } |
| 71 | #endif |
| 72 | |
| 73 | #endif /* __ATTESTATION_KEY_H__ */ |