blob: fcfeb5050e042200e3f9230fc2b8117d58768783 [file] [log] [blame]
laurenw-arm4fc77a72022-08-11 15:29:56 -05001/*
2 * Copyright (c) 2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Tamas Bandc2a2862024-02-22 11:41:25 +01008#ifndef RSE_PLATFORM_API_H
9#define RSE_PLATFORM_API_H
laurenw-arm4fc77a72022-08-11 15:29:56 -050010
11#include <stdint.h>
12
13#include "psa/error.h"
Leo Yan42269422025-01-31 17:16:34 +000014#if CRYPTO_SUPPORT
Tamas Bandc2a2862024-02-22 11:41:25 +010015#include <rse_crypto_defs.h>
Leo Yan42269422025-01-31 17:16:34 +000016#endif
laurenw-arm4fc77a72022-08-11 15:29:56 -050017
Tamas Bandc2a2862024-02-22 11:41:25 +010018#define RSE_PLATFORM_API_ID_NV_READ (1010)
19#define RSE_PLATFORM_API_ID_NV_INCREMENT (1011)
laurenw-arm4fc77a72022-08-11 15:29:56 -050020
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 */
29psa_status_t
Tamas Bandc2a2862024-02-22 11:41:25 +010030rse_platform_nv_counter_increment(uint32_t counter_id);
laurenw-arm4fc77a72022-08-11 15:29:56 -050031
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 */
43psa_status_t
Tamas Bandc2a2862024-02-22 11:41:25 +010044rse_platform_nv_counter_read(uint32_t counter_id,
laurenw-arm4fc77a72022-08-11 15:29:56 -050045 uint32_t size, uint8_t *val);
46
Leo Yan42269422025-01-31 17:16:34 +000047#if CRYPTO_SUPPORT
laurenw-arm6c4d0412023-06-13 16:40:51 -050048/*
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 */
59psa_status_t
Tamas Bandc2a2862024-02-22 11:41:25 +010060rse_platform_key_read(enum rse_key_id_builtin_t key, uint8_t *data,
laurenw-arm6c4d0412023-06-13 16:40:51 -050061 size_t data_size, size_t *data_length);
Leo Yan21591bb2025-01-31 10:07:51 +000062
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 */
72psa_status_t
73rse_platform_get_entropy(uint8_t *data, size_t data_size);
Leo Yan42269422025-01-31 17:16:34 +000074#endif
laurenw-arm6c4d0412023-06-13 16:40:51 -050075
Tamas Bandc2a2862024-02-22 11:41:25 +010076#endif /* RSE_PLATFORM_API_H */