xref: /arm-trusted-firmware/include/lib/psa/rss_platform_api.h (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2023, Arm Limited. All rights reserved.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu  *
6*91f16700Schasinglulu  */
7*91f16700Schasinglulu 
8*91f16700Schasinglulu #ifndef RSS_PLATFORM_API_H
9*91f16700Schasinglulu #define RSS_PLATFORM_API_H
10*91f16700Schasinglulu 
11*91f16700Schasinglulu #include <stdint.h>
12*91f16700Schasinglulu 
13*91f16700Schasinglulu #include "psa/error.h"
14*91f16700Schasinglulu #include <rss_crypto_defs.h>
15*91f16700Schasinglulu 
16*91f16700Schasinglulu #define RSS_PLATFORM_API_ID_NV_READ       (1010)
17*91f16700Schasinglulu #define RSS_PLATFORM_API_ID_NV_INCREMENT  (1011)
18*91f16700Schasinglulu 
19*91f16700Schasinglulu /*
20*91f16700Schasinglulu  * Increments the given non-volatile (NV) counter by one
21*91f16700Schasinglulu  *
22*91f16700Schasinglulu  * counter_id	NV counter ID.
23*91f16700Schasinglulu  *
24*91f16700Schasinglulu  * PSA_SUCCESS if the value is read correctly. Otherwise,
25*91f16700Schasinglulu  *	it returns a PSA_ERROR.
26*91f16700Schasinglulu  */
27*91f16700Schasinglulu psa_status_t
28*91f16700Schasinglulu rss_platform_nv_counter_increment(uint32_t counter_id);
29*91f16700Schasinglulu 
30*91f16700Schasinglulu /*
31*91f16700Schasinglulu  * Reads the given non-volatile (NV) counter
32*91f16700Schasinglulu  *
33*91f16700Schasinglulu  * counter_id	NV counter ID.
34*91f16700Schasinglulu  * size		Size of the buffer to store NV counter value
35*91f16700Schasinglulu  *			in bytes.
36*91f16700Schasinglulu  * val		Pointer to store the current NV counter value.
37*91f16700Schasinglulu  *
38*91f16700Schasinglulu  * PSA_SUCCESS if the value is read correctly. Otherwise,
39*91f16700Schasinglulu  *	it returns a PSA_ERROR.
40*91f16700Schasinglulu  */
41*91f16700Schasinglulu psa_status_t
42*91f16700Schasinglulu rss_platform_nv_counter_read(uint32_t counter_id,
43*91f16700Schasinglulu 		uint32_t size, uint8_t *val);
44*91f16700Schasinglulu 
45*91f16700Schasinglulu /*
46*91f16700Schasinglulu  * Reads the public key or the public part of a key pair in binary format.
47*91f16700Schasinglulu  *
48*91f16700Schasinglulu  * key		Identifier of the key to export.
49*91f16700Schasinglulu  * data		Buffer where the key data is to be written.
50*91f16700Schasinglulu  * data_size	Size of the data buffer in bytes.
51*91f16700Schasinglulu  * data_length	On success, the number of bytes that make up the key data.
52*91f16700Schasinglulu  *
53*91f16700Schasinglulu  * PSA_SUCCESS if the value is read correctly. Otherwise,
54*91f16700Schasinglulu  *	it returns a PSA_ERROR.
55*91f16700Schasinglulu  */
56*91f16700Schasinglulu psa_status_t
57*91f16700Schasinglulu rss_platform_key_read(enum rss_key_id_builtin_t key, uint8_t *data,
58*91f16700Schasinglulu 		size_t data_size, size_t *data_length);
59*91f16700Schasinglulu 
60*91f16700Schasinglulu #endif /* RSS_PLATFORM_API_H */
61