laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 1 | /* |
David Vincze | 5813125 | 2023-12-22 14:34:22 +0100 | [diff] [blame] | 2 | * Copyright (c) 2023-2024, Arm Limited. All rights reserved. |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 8 | #ifndef RSE_CRYPTO_DEFS_H |
| 9 | #define RSE_CRYPTO_DEFS_H |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 10 | |
| 11 | /* Declares types that encode errors, algorithms, key types, policies, etc. */ |
| 12 | #include "psa/crypto_types.h" |
| 13 | |
Leo Yan | 21591bb | 2025-01-31 10:07:51 +0000 | [diff] [blame] | 14 | /* Value identifying random number generating API */ |
| 15 | #define RSE_CRYPTO_GENERATE_RANDOM_SID (uint16_t)(0x100) |
| 16 | |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 17 | /* |
| 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 Yan | 18a9322 | 2024-07-04 12:38:26 +0100 | [diff] [blame] | 22 | #define RSE_CRYPTO_EXPORT_PUBLIC_KEY_SID (uint16_t)(0x206) |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 23 | |
| 24 | /* |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 25 | * The persistent key identifiers for RSE builtin keys. |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 26 | */ |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 27 | enum 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-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | /* |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 34 | * This type is used to overcome a limitation within RSE firmware in the number of maximum |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 35 | * IOVECs it can use especially in psa_aead_encrypt and psa_aead_decrypt. |
| 36 | */ |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 37 | #define RSE_CRYPTO_MAX_NONCE_LENGTH (16u) |
| 38 | struct rse_crypto_aead_pack_input { |
| 39 | uint8_t nonce[RSE_CRYPTO_MAX_NONCE_LENGTH]; |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 40 | uint32_t nonce_length; |
| 41 | }; |
| 42 | |
| 43 | /* |
David Vincze | 5813125 | 2023-12-22 14:34:22 +0100 | [diff] [blame] | 44 | * Structure used to pack non-pointer types in a call to PSA Crypto APIs |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 45 | */ |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 46 | struct rse_crypto_pack_iovec { |
Manish V Badarkhe | 07b699d | 2024-02-17 23:30:31 +0000 | [diff] [blame] | 47 | 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 Vincze | 5813125 | 2023-12-22 14:34:22 +0100 | [diff] [blame] | 61 | |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 62 | struct rse_crypto_aead_pack_input aead_in; /* |
Manish V Badarkhe | 07b699d | 2024-02-17 23:30:31 +0000 | [diff] [blame] | 63 | * !< Packs AEAD-related |
| 64 | * inputs |
| 65 | */ |
David Vincze | 5813125 | 2023-12-22 14:34:22 +0100 | [diff] [blame] | 66 | |
Manish V Badarkhe | 07b699d | 2024-02-17 23:30:31 +0000 | [diff] [blame] | 67 | uint16_t function_id; /* |
| 68 | * !< Used to identify the function in the |
| 69 | * API dispatcher to the service backend |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 70 | * See rse_crypto_func_sid for detail |
Manish V Badarkhe | 07b699d | 2024-02-17 23:30:31 +0000 | [diff] [blame] | 71 | */ |
| 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-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 80 | }; |
| 81 | |
Tamas Ban | dc2a286 | 2024-02-22 11:41:25 +0100 | [diff] [blame] | 82 | #endif /* RSE_CRYPTO_DEFS_H */ |