blob: ea1342fd52df7f55e83beeaea796f190fa699c0c [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
Leo Yan21591bb2025-01-31 10:07:51 +000014/* Value identifying random number generating API */
15#define RSE_CRYPTO_GENERATE_RANDOM_SID (uint16_t)(0x100)
16
laurenw-arm6c4d0412023-06-13 16:40:51 -050017/*
18 * Value identifying export public key function API, used to dispatch the request
19 * to the corresponding API implementation in the Crypto service backend.
20 *
21 */
Leo Yan18a93222024-07-04 12:38:26 +010022#define RSE_CRYPTO_EXPORT_PUBLIC_KEY_SID (uint16_t)(0x206)
laurenw-arm6c4d0412023-06-13 16:40:51 -050023
24/*
Tamas Bandc2a2862024-02-22 11:41:25 +010025 * The persistent key identifiers for RSE builtin keys.
laurenw-arm6c4d0412023-06-13 16:40:51 -050026 */
Tamas Bandc2a2862024-02-22 11:41:25 +010027enum rse_key_id_builtin_t {
28 RSE_BUILTIN_KEY_ID_HOST_S_ROTPK = 0x7FFF816Cu,
29 RSE_BUILTIN_KEY_ID_HOST_NS_ROTPK,
30 RSE_BUILTIN_KEY_ID_HOST_CCA_ROTPK,
laurenw-arm6c4d0412023-06-13 16:40:51 -050031};
32
33/*
Tamas Bandc2a2862024-02-22 11:41:25 +010034 * This type is used to overcome a limitation within RSE firmware in the number of maximum
laurenw-arm6c4d0412023-06-13 16:40:51 -050035 * IOVECs it can use especially in psa_aead_encrypt and psa_aead_decrypt.
36 */
Tamas Bandc2a2862024-02-22 11:41:25 +010037#define RSE_CRYPTO_MAX_NONCE_LENGTH (16u)
38struct rse_crypto_aead_pack_input {
39 uint8_t nonce[RSE_CRYPTO_MAX_NONCE_LENGTH];
laurenw-arm6c4d0412023-06-13 16:40:51 -050040 uint32_t nonce_length;
41};
42
43/*
David Vincze58131252023-12-22 14:34:22 +010044 * Structure used to pack non-pointer types in a call to PSA Crypto APIs
laurenw-arm6c4d0412023-06-13 16:40:51 -050045 */
Tamas Bandc2a2862024-02-22 11:41:25 +010046struct rse_crypto_pack_iovec {
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000047 psa_key_id_t key_id; /* !< Key id */
48 psa_algorithm_t alg; /* !< Algorithm */
49 uint32_t op_handle; /*
50 * !< Frontend context handle
51 * associated to a multipart operation
52 */
53 uint32_t ad_length; /*
54 * !< Additional Data length for
55 * multipart AEAD
56 */
57 uint32_t plaintext_length; /*
58 * !< Plaintext length for multipart
59 * AEAD
60 */
David Vincze58131252023-12-22 14:34:22 +010061
Tamas Bandc2a2862024-02-22 11:41:25 +010062 struct rse_crypto_aead_pack_input aead_in; /*
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000063 * !< Packs AEAD-related
64 * inputs
65 */
David Vincze58131252023-12-22 14:34:22 +010066
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000067 uint16_t function_id; /*
68 * !< Used to identify the function in the
69 * API dispatcher to the service backend
Tamas Bandc2a2862024-02-22 11:41:25 +010070 * See rse_crypto_func_sid for detail
Manish V Badarkhe07b699d2024-02-17 23:30:31 +000071 */
72 uint16_t step; /* !< Key derivation step */
73 union {
74 size_t capacity; /* !< Key derivation capacity */
75 uint64_t value; /*
76 * !< Key derivation integer for
77 * update
78 */
79 };
laurenw-arm6c4d0412023-06-13 16:40:51 -050080};
81
Tamas Bandc2a2862024-02-22 11:41:25 +010082#endif /* RSE_CRYPTO_DEFS_H */