1 /* 2 * Copyright (c) 2023, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef RSE_PLATFORM_API_H 9 #define RSE_PLATFORM_API_H 10 11 #include <stdint.h> 12 13 #include "psa/error.h" 14 #if CRYPTO_SUPPORT 15 #include <rse_crypto_defs.h> 16 #endif 17 18 #define RSE_PLATFORM_API_ID_NV_READ (1010) 19 #define RSE_PLATFORM_API_ID_NV_INCREMENT (1011) 20 21 /* 22 * Increments the given non-volatile (NV) counter by one 23 * 24 * counter_id NV counter ID. 25 * 26 * PSA_SUCCESS if the value is read correctly. Otherwise, 27 * it returns a PSA_ERROR. 28 */ 29 psa_status_t 30 rse_platform_nv_counter_increment(uint32_t counter_id); 31 32 /* 33 * Reads the given non-volatile (NV) counter 34 * 35 * counter_id NV counter ID. 36 * size Size of the buffer to store NV counter value 37 * in bytes. 38 * val Pointer to store the current NV counter value. 39 * 40 * PSA_SUCCESS if the value is read correctly. Otherwise, 41 * it returns a PSA_ERROR. 42 */ 43 psa_status_t 44 rse_platform_nv_counter_read(uint32_t counter_id, 45 uint32_t size, uint8_t *val); 46 47 #if CRYPTO_SUPPORT 48 /* 49 * Reads the public key or the public part of a key pair in binary format. 50 * 51 * key Identifier of the key to export. 52 * data Buffer where the key data is to be written. 53 * data_size Size of the data buffer in bytes. 54 * data_length On success, the number of bytes that make up the key data. 55 * 56 * PSA_SUCCESS if the value is read correctly. Otherwise, 57 * it returns a PSA_ERROR. 58 */ 59 psa_status_t 60 rse_platform_key_read(enum rse_key_id_builtin_t key, uint8_t *data, 61 size_t data_size, size_t *data_length); 62 63 /* 64 * Gets the entropy. 65 * 66 * data Buffer where the entropy data is to be written. 67 * data_size Size of the data buffer in bytes. 68 * 69 * PSA_SUCCESS if the entropy is generated successfully. Otherwise, 70 * it returns a PSA_ERROR. 71 */ 72 psa_status_t 73 rse_platform_get_entropy(uint8_t *data, size_t data_size); 74 #endif 75 76 #endif /* RSE_PLATFORM_API_H */ 77