xref: /rk3399_ARM-atf/include/lib/psa/rse_crypto_defs.h (revision bd141810f456f9852cfaac00c538259f3274bab0)
1 /*
2  * Copyright (c) 2023-2025, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef RSE_CRYPTO_DEFS_H
9 #define RSE_CRYPTO_DEFS_H
10 
11 /* Declares types that encode errors, algorithms, key types, policies, etc. */
12 #include "psa/crypto_types.h"
13 
14 /* Value identifying random number generating API */
15 #define RSE_CRYPTO_GENERATE_RANDOM_SID		(uint16_t)(0x100)
16 
17 /*
18  * This type is used to overcome a limitation within RSE firmware in the number of maximum
19  * IOVECs it can use especially in psa_aead_encrypt and psa_aead_decrypt.
20  */
21 #define RSE_CRYPTO_MAX_NONCE_LENGTH (16u)
22 struct rse_crypto_aead_pack_input {
23 	uint8_t nonce[RSE_CRYPTO_MAX_NONCE_LENGTH];
24 	uint32_t nonce_length;
25 };
26 
27 /*
28  * Structure used to pack non-pointer types in a call to PSA Crypto APIs
29  */
30 struct rse_crypto_pack_iovec {
31 	psa_key_id_t key_id;		/* !< Key id */
32 	psa_algorithm_t alg;		/* !< Algorithm */
33 	uint32_t op_handle;		/*
34 					 * !< Frontend context handle
35 					 * associated to a multipart operation
36 					 */
37 	uint32_t ad_length;		/*
38 					 * !< Additional Data length for
39 					 *    multipart AEAD
40 					 */
41 	uint32_t plaintext_length;	/*
42 					 * !< Plaintext length for multipart
43 					 *    AEAD
44 					 */
45 
46 	struct rse_crypto_aead_pack_input aead_in; /*
47 						    * !< Packs AEAD-related
48 						    *    inputs
49 						    */
50 
51 	uint16_t function_id;	/*
52 				 * !< Used to identify the function in the
53 				 *    API dispatcher to the service backend
54 				 *    See rse_crypto_func_sid for detail
55 				 */
56 	uint16_t step;		/* !< Key derivation step */
57 	union {
58 		size_t capacity;	/* !< Key derivation capacity */
59 		uint64_t value;		/*
60 					 * !< Key derivation integer for
61 					 *    update
62 					 */
63 	};
64 };
65 
66 #endif /* RSE_CRYPTO_DEFS_H */
67