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 | |
| 8 | #ifndef RSS_CRYPTO_DEFS_H |
| 9 | #define RSS_CRYPTO_DEFS_H |
| 10 | |
| 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 | */ |
| 19 | #define RSS_CRYPTO_EXPORT_PUBLIC_KEY_SID (uint16_t)(0x701) |
| 20 | |
| 21 | /* |
| 22 | * The persistent key identifiers for RSS builtin keys. |
| 23 | */ |
| 24 | enum rss_key_id_builtin_t { |
| 25 | RSS_BUILTIN_KEY_ID_HOST_S_ROTPK = 0x7FFF816Cu, |
| 26 | RSS_BUILTIN_KEY_ID_HOST_NS_ROTPK, |
| 27 | RSS_BUILTIN_KEY_ID_HOST_CCA_ROTPK, |
| 28 | }; |
| 29 | |
| 30 | /* |
| 31 | * This type is used to overcome a limitation within RSS firmware in the number of maximum |
| 32 | * IOVECs it can use especially in psa_aead_encrypt and psa_aead_decrypt. |
| 33 | */ |
| 34 | #define RSS_CRYPTO_MAX_NONCE_LENGTH (16u) |
| 35 | struct rss_crypto_aead_pack_input { |
| 36 | uint8_t nonce[RSS_CRYPTO_MAX_NONCE_LENGTH]; |
| 37 | uint32_t nonce_length; |
| 38 | }; |
| 39 | |
| 40 | /* |
David Vincze | 5813125 | 2023-12-22 14:34:22 +0100 | [diff] [blame] | 41 | * 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] | 42 | */ |
| 43 | struct rss_crypto_pack_iovec { |
David Vincze | 5813125 | 2023-12-22 14:34:22 +0100 | [diff] [blame] | 44 | psa_key_id_t key_id; /*!< Key id */ |
| 45 | psa_algorithm_t alg; /*!< Algorithm */ |
| 46 | uint32_t op_handle; /*!< Frontend context handle associated to a |
| 47 | * multipart operation |
| 48 | */ |
| 49 | uint32_t ad_length; /*!< Additional Data length for multipart AEAD */ |
| 50 | uint32_t plaintext_length; /*!< Plaintext length for multipart AEAD */ |
| 51 | |
| 52 | struct rss_crypto_aead_pack_input aead_in; /*!< Packs AEAD-related inputs */ |
| 53 | |
| 54 | uint16_t function_id; /*!< Used to identify the function in the |
| 55 | * API dispatcher to the service backend |
| 56 | * See rss_crypto_func_sid for detail |
| 57 | */ |
| 58 | uint16_t step; /*!< Key derivation step */ |
| 59 | union { |
| 60 | size_t capacity; /*!< Key derivation capacity */ |
| 61 | uint64_t value; /*!< Key derivation integer for update*/ |
| 62 | }; |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | #endif /* RSS_CRYPTO_DEFS_H */ |