1*4b09ffefSTamas Ban /* 2*4b09ffefSTamas Ban * Copyright (c) 2022, Arm Limited. All rights reserved. 3*4b09ffefSTamas Ban * 4*4b09ffefSTamas Ban * SPDX-License-Identifier: BSD-3-Clause 5*4b09ffefSTamas Ban * 6*4b09ffefSTamas Ban */ 7*4b09ffefSTamas Ban 8*4b09ffefSTamas Ban /* This file describes the Delegated Attestation API */ 9*4b09ffefSTamas Ban 10*4b09ffefSTamas Ban #ifndef DELEGATED_ATTESTATION_H 11*4b09ffefSTamas Ban #define DELEGATED_ATTESTATION_H 12*4b09ffefSTamas Ban 13*4b09ffefSTamas Ban #include <stddef.h> 14*4b09ffefSTamas Ban #include <stdint.h> 15*4b09ffefSTamas Ban 16*4b09ffefSTamas Ban #include "psa/error.h" 17*4b09ffefSTamas Ban 18*4b09ffefSTamas Ban /* RSS Delegated Attestation message types that distinguish its services. */ 19*4b09ffefSTamas Ban #define RSS_DELEGATED_ATTEST_GET_DELEGATED_KEY 1001U 20*4b09ffefSTamas Ban #define RSS_DELEGATED_ATTEST_GET_PLATFORM_TOKEN 1002U 21*4b09ffefSTamas Ban 22*4b09ffefSTamas Ban /** 23*4b09ffefSTamas Ban * The aim of these APIs to get a derived signing key (private only) for the 24*4b09ffefSTamas Ban * delegated attestation model and obtain the corresponding platform attestation 25*4b09ffefSTamas Ban * token. In the delegated attestation model the final token consist of more 26*4b09ffefSTamas Ban * than one subtokens which are signed by different entities. There is a 27*4b09ffefSTamas Ban * cryptographical binding between the tokens. The derived delegated attestation 28*4b09ffefSTamas Ban * key is bind to the platform token (details below). 29*4b09ffefSTamas Ban * 30*4b09ffefSTamas Ban * Expected usage model: 31*4b09ffefSTamas Ban * - First rss_delegated_attest_get_delegated_key() API need to be called to 32*4b09ffefSTamas Ban * obtain the private part of the delegated attestation key. The public part 33*4b09ffefSTamas Ban * of key is computed by the cryptographic library when the key is 34*4b09ffefSTamas Ban * registered. 35*4b09ffefSTamas Ban * - Secondly the rss_delegated_attest_get_token() must be called to obtain 36*4b09ffefSTamas Ban * platform attestation token. The hash of the public key (computed by 37*4b09ffefSTamas Ban * the hash_algo indicated in the rss_delegated_attest_get_delegated_key() 38*4b09ffefSTamas Ban * call) must be the input of this call. This ensures that nothing but the 39*4b09ffefSTamas Ban * previously derived delegated key is bindable to the platform token. 40*4b09ffefSTamas Ban */ 41*4b09ffefSTamas Ban 42*4b09ffefSTamas Ban /** 43*4b09ffefSTamas Ban * Get a delegated attestation key (DAK). 44*4b09ffefSTamas Ban * 45*4b09ffefSTamas Ban * The aim of the delegated attestation key is to enable other SW components 46*4b09ffefSTamas Ban * within the system to sign an attestation token which is different than the 47*4b09ffefSTamas Ban * initial/platform token. The initial attestation token MUST contain the hash 48*4b09ffefSTamas Ban * of the public delegated key to make a cryptographical binding (hash lock) 49*4b09ffefSTamas Ban * between the key and the token. 50*4b09ffefSTamas Ban * The initial attestation token has two roles in this scenario: 51*4b09ffefSTamas Ban * - Attest the device boot status and security lifecycle. 52*4b09ffefSTamas Ban * - Attest the delegated attestation key. 53*4b09ffefSTamas Ban * The delegated attestation key is derived from a preprovisioned seed. The 54*4b09ffefSTamas Ban * input for the key derivation is the platform boot status. The system can be 55*4b09ffefSTamas Ban * attestated with the two tokens together. 56*4b09ffefSTamas Ban * 57*4b09ffefSTamas Ban * ecc_curve The type of the elliptic curve to which the requested 58*4b09ffefSTamas Ban * attestation key belongs. Please check the note section for 59*4b09ffefSTamas Ban * limitations. 60*4b09ffefSTamas Ban * key_bits The size of the requested attestation key, in bits. 61*4b09ffefSTamas Ban * key_buf Pointer to the buffer where the delegated attestation key will 62*4b09ffefSTamas Ban * be stored. 63*4b09ffefSTamas Ban * key_buf_size Size of allocated buffer for the key, in bytes. 64*4b09ffefSTamas Ban * key_size Size of the key that has been returned, in bytes. 65*4b09ffefSTamas Ban * hash_algo The hash algorithm that will be used later by the owner of the 66*4b09ffefSTamas Ban * requested delegated key for binding it to the platform 67*4b09ffefSTamas Ban * attestation token. 68*4b09ffefSTamas Ban * 69*4b09ffefSTamas Ban * Returns error code as specified in psa_status_t. 70*4b09ffefSTamas Ban * 71*4b09ffefSTamas Ban * Notes: 72*4b09ffefSTamas Ban * - Currently, only the PSA_ECC_FAMILY_SECP_R1 curve type is supported. 73*4b09ffefSTamas Ban * - The delegated attestation key must be derived before requesting for the 74*4b09ffefSTamas Ban * platform attestation token as they are cryptographically linked together. 75*4b09ffefSTamas Ban */ 76*4b09ffefSTamas Ban psa_status_t 77*4b09ffefSTamas Ban rss_delegated_attest_get_delegated_key(uint8_t ecc_curve, 78*4b09ffefSTamas Ban uint32_t key_bits, 79*4b09ffefSTamas Ban uint8_t *key_buf, 80*4b09ffefSTamas Ban size_t key_buf_size, 81*4b09ffefSTamas Ban size_t *key_size, 82*4b09ffefSTamas Ban uint32_t hash_algo); 83*4b09ffefSTamas Ban 84*4b09ffefSTamas Ban /** 85*4b09ffefSTamas Ban * Get platform attestation token 86*4b09ffefSTamas Ban * 87*4b09ffefSTamas Ban * dak_pub_hash Pointer to buffer where the hash of the public DAK is 88*4b09ffefSTamas Ban * stored. 89*4b09ffefSTamas Ban * dak_pub_hash_size Size of the hash value, in bytes. 90*4b09ffefSTamas Ban * token_buf Pointer to the buffer where the platform attestation token 91*4b09ffefSTamas Ban * will be stored. 92*4b09ffefSTamas Ban * token_buf_size Size of allocated buffer for token, in bytes. 93*4b09ffefSTamas Ban * token_size Size of the token that has been returned, in bytes. 94*4b09ffefSTamas Ban * 95*4b09ffefSTamas Ban * Returns error code as specified in psa_status_t. 96*4b09ffefSTamas Ban * 97*4b09ffefSTamas Ban * A delegated attestation key must be derived before requesting for the 98*4b09ffefSTamas Ban * platform attestation token as they are cryptographically linked together. 99*4b09ffefSTamas Ban * Otherwise, the token request will fail and the PSA_ERROR_INVALID_ARGUMENT 100*4b09ffefSTamas Ban * code will be returned. 101*4b09ffefSTamas Ban */ 102*4b09ffefSTamas Ban psa_status_t 103*4b09ffefSTamas Ban rss_delegated_attest_get_token(const uint8_t *dak_pub_hash, 104*4b09ffefSTamas Ban size_t dak_pub_hash_size, 105*4b09ffefSTamas Ban uint8_t *token_buf, 106*4b09ffefSTamas Ban size_t token_buf_size, 107*4b09ffefSTamas Ban size_t *token_size); 108*4b09ffefSTamas Ban 109*4b09ffefSTamas Ban #endif /* DELEGATED_ATTESTATION_H */ 110