13857898fSTamas Ban /* 23857898fSTamas Ban * Copyright (c) 2023-2024, Arm Limited. All rights reserved. 33857898fSTamas Ban * 43857898fSTamas Ban * SPDX-License-Identifier: BSD-3-Clause 53857898fSTamas Ban * 63857898fSTamas Ban */ 73857898fSTamas Ban 8d797665cSTamas Ban #ifndef RSE_CRYPTO_DEFS_H 9d797665cSTamas Ban #define RSE_CRYPTO_DEFS_H 103857898fSTamas Ban 113857898fSTamas Ban /* Declares types that encode errors, algorithms, key types, policies, etc. */ 123857898fSTamas Ban #include "psa/crypto_types.h" 133857898fSTamas Ban 143857898fSTamas Ban /* 153857898fSTamas Ban * Value identifying export public key function API, used to dispatch the request 163857898fSTamas Ban * to the corresponding API implementation in the Crypto service backend. 173857898fSTamas Ban * 183857898fSTamas Ban */ 19*759994aaSLeo Yan #define RSE_CRYPTO_EXPORT_PUBLIC_KEY_SID (uint16_t)(0x206) 203857898fSTamas Ban 213857898fSTamas Ban /* 22d797665cSTamas Ban * The persistent key identifiers for RSE builtin keys. 233857898fSTamas Ban */ 24d797665cSTamas Ban enum rse_key_id_builtin_t { 25d797665cSTamas Ban RSE_BUILTIN_KEY_ID_HOST_S_ROTPK = 0x7FFF816Cu, 26d797665cSTamas Ban RSE_BUILTIN_KEY_ID_HOST_NS_ROTPK, 27d797665cSTamas Ban RSE_BUILTIN_KEY_ID_HOST_CCA_ROTPK, 283857898fSTamas Ban }; 293857898fSTamas Ban 303857898fSTamas Ban /* 31d797665cSTamas Ban * This type is used to overcome a limitation within RSE firmware in the number of maximum 323857898fSTamas Ban * IOVECs it can use especially in psa_aead_encrypt and psa_aead_decrypt. 333857898fSTamas Ban */ 34d797665cSTamas Ban #define RSE_CRYPTO_MAX_NONCE_LENGTH (16u) 35d797665cSTamas Ban struct rse_crypto_aead_pack_input { 36d797665cSTamas Ban uint8_t nonce[RSE_CRYPTO_MAX_NONCE_LENGTH]; 373857898fSTamas Ban uint32_t nonce_length; 383857898fSTamas Ban }; 393857898fSTamas Ban 403857898fSTamas Ban /* 413857898fSTamas Ban * Structure used to pack non-pointer types in a call to PSA Crypto APIs 423857898fSTamas Ban */ 43d797665cSTamas Ban struct rse_crypto_pack_iovec { 443857898fSTamas Ban psa_key_id_t key_id; /* !< Key id */ 453857898fSTamas Ban psa_algorithm_t alg; /* !< Algorithm */ 463857898fSTamas Ban uint32_t op_handle; /* 473857898fSTamas Ban * !< Frontend context handle 483857898fSTamas Ban * associated to a multipart operation 493857898fSTamas Ban */ 503857898fSTamas Ban uint32_t ad_length; /* 513857898fSTamas Ban * !< Additional Data length for 523857898fSTamas Ban * multipart AEAD 533857898fSTamas Ban */ 543857898fSTamas Ban uint32_t plaintext_length; /* 553857898fSTamas Ban * !< Plaintext length for multipart 563857898fSTamas Ban * AEAD 573857898fSTamas Ban */ 583857898fSTamas Ban 59d797665cSTamas Ban struct rse_crypto_aead_pack_input aead_in; /* 603857898fSTamas Ban * !< Packs AEAD-related 613857898fSTamas Ban * inputs 623857898fSTamas Ban */ 633857898fSTamas Ban 643857898fSTamas Ban uint16_t function_id; /* 653857898fSTamas Ban * !< Used to identify the function in the 663857898fSTamas Ban * API dispatcher to the service backend 67d797665cSTamas Ban * See rse_crypto_func_sid for detail 683857898fSTamas Ban */ 693857898fSTamas Ban uint16_t step; /* !< Key derivation step */ 703857898fSTamas Ban union { 713857898fSTamas Ban size_t capacity; /* !< Key derivation capacity */ 723857898fSTamas Ban uint64_t value; /* 733857898fSTamas Ban * !< Key derivation integer for 743857898fSTamas Ban * update 753857898fSTamas Ban */ 763857898fSTamas Ban }; 773857898fSTamas Ban }; 783857898fSTamas Ban 79d797665cSTamas Ban #endif /* RSE_CRYPTO_DEFS_H */ 80