xref: /rk3399_ARM-atf/include/lib/psa/rse_platform_api.h (revision 697290a9166a4d62f757eeefcb7376817b0f0e4a)
13857898fSTamas Ban /*
23857898fSTamas Ban  * Copyright (c) 2023, Arm Limited. All rights reserved.
33857898fSTamas Ban  *
43857898fSTamas Ban  * SPDX-License-Identifier: BSD-3-Clause
53857898fSTamas Ban  *
63857898fSTamas Ban  */
73857898fSTamas Ban 
8d797665cSTamas Ban #ifndef RSE_PLATFORM_API_H
9d797665cSTamas Ban #define RSE_PLATFORM_API_H
103857898fSTamas Ban 
113857898fSTamas Ban #include <stdint.h>
123857898fSTamas Ban 
133857898fSTamas Ban #include "psa/error.h"
148a41106cSLeo Yan #if CRYPTO_SUPPORT
15d797665cSTamas Ban #include <rse_crypto_defs.h>
168a41106cSLeo Yan #endif
173857898fSTamas Ban 
18d797665cSTamas Ban #define RSE_PLATFORM_API_ID_NV_READ       (1010)
19d797665cSTamas Ban #define RSE_PLATFORM_API_ID_NV_INCREMENT  (1011)
203857898fSTamas Ban 
213857898fSTamas Ban /*
223857898fSTamas Ban  * Increments the given non-volatile (NV) counter by one
233857898fSTamas Ban  *
243857898fSTamas Ban  * counter_id	NV counter ID.
253857898fSTamas Ban  *
263857898fSTamas Ban  * PSA_SUCCESS if the value is read correctly. Otherwise,
273857898fSTamas Ban  *	it returns a PSA_ERROR.
283857898fSTamas Ban  */
293857898fSTamas Ban psa_status_t
30d797665cSTamas Ban rse_platform_nv_counter_increment(uint32_t counter_id);
313857898fSTamas Ban 
323857898fSTamas Ban /*
333857898fSTamas Ban  * Reads the given non-volatile (NV) counter
343857898fSTamas Ban  *
353857898fSTamas Ban  * counter_id	NV counter ID.
363857898fSTamas Ban  * size		Size of the buffer to store NV counter value
373857898fSTamas Ban  *			in bytes.
383857898fSTamas Ban  * val		Pointer to store the current NV counter value.
393857898fSTamas Ban  *
403857898fSTamas Ban  * PSA_SUCCESS if the value is read correctly. Otherwise,
413857898fSTamas Ban  *	it returns a PSA_ERROR.
423857898fSTamas Ban  */
433857898fSTamas Ban psa_status_t
44d797665cSTamas Ban rse_platform_nv_counter_read(uint32_t counter_id,
453857898fSTamas Ban 		uint32_t size, uint8_t *val);
463857898fSTamas Ban 
478a41106cSLeo Yan #if CRYPTO_SUPPORT
483857898fSTamas Ban /*
493857898fSTamas Ban  * Reads the public key or the public part of a key pair in binary format.
503857898fSTamas Ban  *
513857898fSTamas Ban  * key		Identifier of the key to export.
523857898fSTamas Ban  * data		Buffer where the key data is to be written.
533857898fSTamas Ban  * data_size	Size of the data buffer in bytes.
543857898fSTamas Ban  * data_length	On success, the number of bytes that make up the key data.
553857898fSTamas Ban  *
563857898fSTamas Ban  * PSA_SUCCESS if the value is read correctly. Otherwise,
573857898fSTamas Ban  *	it returns a PSA_ERROR.
583857898fSTamas Ban  */
593857898fSTamas Ban psa_status_t
60d797665cSTamas Ban rse_platform_key_read(enum rse_key_id_builtin_t key, uint8_t *data,
613857898fSTamas Ban 		size_t data_size, size_t *data_length);
62*1147a470SLeo Yan 
63*1147a470SLeo Yan /*
64*1147a470SLeo Yan  * Gets the entropy.
65*1147a470SLeo Yan  *
66*1147a470SLeo Yan  * data		Buffer where the entropy data is to be written.
67*1147a470SLeo Yan  * data_size	Size of the data buffer in bytes.
68*1147a470SLeo Yan  *
69*1147a470SLeo Yan  * PSA_SUCCESS if the entropy is generated successfully. Otherwise,
70*1147a470SLeo Yan  *	it returns a PSA_ERROR.
71*1147a470SLeo Yan  */
72*1147a470SLeo Yan psa_status_t
73*1147a470SLeo Yan rse_platform_get_entropy(uint8_t *data, size_t data_size);
748a41106cSLeo Yan #endif
753857898fSTamas Ban 
76d797665cSTamas Ban #endif /* RSE_PLATFORM_API_H */
77