blob: b94664fb6521ef0df156a62257c6f28dbffd81a8 [file] [log] [blame]
laurenw-arm6c4d0412023-06-13 16:40:51 -05001/*
David Vincze58131252023-12-22 14:34:22 +01002 * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
laurenw-arm6c4d0412023-06-13 16:40:51 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Tamas Bandc2a2862024-02-22 11:41:25 +01008#ifndef RSE_CRYPTO_DEFS_H
9#define RSE_CRYPTO_DEFS_H
laurenw-arm6c4d0412023-06-13 16:40:51 -050010
11/* Declares types that encode errors, algorithms, key types, policies, etc. */
12#include "psa/crypto_types.h"
13
14/*
15 * Value identifying export public key function API, used to dispatch the request
16 * to the corresponding API implementation in the Crypto service backend.
17 *
18 */
Leo Yan18a93222024-07-04 12:38:26 +010019#define RSE_CRYPTO_EXPORT_PUBLIC_KEY_SID (uint16_t)(0x206)
laurenw-arm6c4d0412023-06-13 16:40:51 -050020
21/*
Tamas Bandc2a2862024-02-22 11:41:25 +010022 * The persistent key identifiers for RSE builtin keys.
laurenw-arm6c4d0412023-06-13 16:40:51 -050023 */
Tamas Bandc2a2862024-02-22 11:41:25 +010024enum rse_key_id_builtin_t {
25 RSE_BUILTIN_KEY_ID_HOST_S_ROTPK = 0x7FFF816Cu,
26 RSE_BUILTIN_KEY_ID_HOST_NS_ROTPK,
27 RSE_BUILTIN_KEY_ID_HOST_CCA_ROTPK,
laurenw-arm6c4d0412023-06-13 16:40:51 -050028};
29
30/*
Tamas Bandc2a2862024-02-22 11:41:25 +010031 * This type is used to overcome a limitation within RSE firmware in the number of maximum
laurenw-arm6c4d0412023-06-13 16:40:51 -050032 * IOVECs it can use especially in psa_aead_encrypt and psa_aead_decrypt.
33 */
Tamas Bandc2a2862024-02-22 11:41:25 +010034#define RSE_CRYPTO_MAX_NONCE_LENGTH (16u)
35struct rse_crypto_aead_pack_input {
36 uint8_t nonce[RSE_CRYPTO_MAX_NONCE_LENGTH];
laurenw-arm6c4d0412023-06-13 16:40:51 -050037 uint32_t nonce_length;
38};
39
40/*
David Vincze58131252023-12-22 14:34:22 +010041 * Structure used to pack non-pointer types in a call to PSA Crypto APIs
laurenw-arm6c4d0412023-06-13 16:40:51 -050042 */
Tamas Bandc2a2862024-02-22 11:41:25 +010043struct rse_crypto_pack_iovec {
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000044 psa_key_id_t key_id; /* !< Key id */
45 psa_algorithm_t alg; /* !< Algorithm */
46 uint32_t op_handle; /*
47 * !< Frontend context handle
48 * associated to a multipart operation
49 */
50 uint32_t ad_length; /*
51 * !< Additional Data length for
52 * multipart AEAD
53 */
54 uint32_t plaintext_length; /*
55 * !< Plaintext length for multipart
56 * AEAD
57 */
David Vincze58131252023-12-22 14:34:22 +010058
Tamas Bandc2a2862024-02-22 11:41:25 +010059 struct rse_crypto_aead_pack_input aead_in; /*
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000060 * !< Packs AEAD-related
61 * inputs
62 */
David Vincze58131252023-12-22 14:34:22 +010063
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000064 uint16_t function_id; /*
65 * !< Used to identify the function in the
66 * API dispatcher to the service backend
Tamas Bandc2a2862024-02-22 11:41:25 +010067 * See rse_crypto_func_sid for detail
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000068 */
69 uint16_t step; /* !< Key derivation step */
70 union {
71 size_t capacity; /* !< Key derivation capacity */
72 uint64_t value; /*
73 * !< Key derivation integer for
74 * update
75 */
76 };
laurenw-arm6c4d0412023-06-13 16:40:51 -050077};
78
Tamas Bandc2a2862024-02-22 11:41:25 +010079#endif /* RSE_CRYPTO_DEFS_H */