1 /* 2 * SPDX-License-Identifier: BSD-3-Clause 3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. 4 */ 5 6 #ifndef ATTESTATION_H 7 #define ATTESTATION_H 8 9 #include <t_cose/q_useful_buf.h> 10 11 struct buffer_alloc_ctx; 12 13 /* 14 * Performs any early initialization needed for the crypto library. 15 */ 16 int attestation_init(void); 17 18 /* 19 * Return the platform token that was previously retrieved from the monitor. 20 * 21 * Arguments: 22 * buf - pointer to a q_useful_buf structure where the reference to the 23 * platform token will be returned. 24 * 25 * Returns 0 on success, and a negative error code otherwise. 26 */ 27 int attest_get_platform_token(struct q_useful_buf_c **buf); 28 29 /* 30 * Initialize the heap buffer to be used with the given buffer_alloc_ctx. 31 * This is done when a REC is created. 32 * 33 * As a pre-requisite, ensure that a buffer_alloc_ctx has been assigned to this 34 * PE prior to calling this function. 35 * 36 * Arguments: 37 * buf - pointer to start of heap 38 * buf_size - size of the heap 39 * 40 * Returns 0 on success, negative error code on error. 41 */ 42 int attestation_heap_ctx_init(unsigned char *buf, size_t buf_size); 43 44 /* 45 * Assign a given buf_alloc_ctx to this CPU. This needs to be called 46 * prior to entering a Realm to allow it invoking RMM crypto operations. 47 * 48 * Arguments: 49 * ctx - pointer to buffer_alloc_ctx 50 * 51 * Returns 0 on success, negative error code on error. 52 */ 53 int attestation_heap_ctx_assign_pe(struct buffer_alloc_ctx *ctx); 54 55 56 /* 57 * Unassign a given buf_alloc_ctx from CPU. This needs to be called 58 * after exiting the realm. 59 * 60 * Arguments: 61 * ctx - pointer to buffer_alloc_ctx 62 * 63 * Returns 0 on success, negative error code on error. 64 */ 65 int attestation_heap_ctx_unassign_pe(struct buffer_alloc_ctx *ctx); 66 67 /* 68 * Reinit the heap on this CPU used for attestation operations. 69 * 70 * Arguments: 71 * buf - Buffer to use as heap. 72 * buf_size - Size of the buffer to use as heap. 73 * 74 * Returns 0 on success, negative error code otherwise. 75 * 76 * Note: This function assumes that a the allocator has a 77 * buffer_alloc_ctx assigned to it. 78 */ 79 int attestation_heap_reinit_pe(unsigned char *buf, size_t buf_size); 80 81 #endif /* ATTESTATION_H */ 82