1 /* 2 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef PSA_CRYPTO_CLIENT_H 8 #define PSA_CRYPTO_CLIENT_H 9 10 #include <psa/error.h> 11 #include <rpc_caller.h> 12 #include <service/common/client/service_client.h> 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 /** 19 * @brief The singleton psa_crypto_client state 20 * 21 * The psa crypto C API assumes a single instance of the backend provider. This 22 * structure extends the base service client. 23 */ 24 struct psa_crypto_client 25 { 26 struct service_client base; 27 psa_status_t init_status; 28 }; 29 30 extern struct psa_crypto_client psa_crypto_client_instance; 31 32 /** 33 * @brief Initialises the single psa crypto client 34 * 35 * Assignes a concrete rpc caller to the psa crypto client and performs any other 36 * initialisation needed. 37 * 38 * @param[in] caller An initailised rpc_caller 39 * 40 * @return A status indicating the success/failure of the operation 41 */ 42 psa_status_t psa_crypto_client_init(struct rpc_caller_session *session); 43 44 /** 45 * @brief De-initialises the single psa crypto client 46 * 47 * Performs clean-up when the crypto client is no longer needed 48 */ 49 void psa_crypto_client_deinit(void); 50 51 /** 52 * @brief Get most recent rpc status 53 * 54 * Returns the error status for the most recent RPC operation 55 * 56 * @return RPC status code 57 */ 58 int psa_crypto_client_rpc_status(void); 59 60 /** 61 * @brief Get the base service_client 62 * 63 * Returns a pointer to the base service_client member of the singleton psa crypto 64 * client. 65 * 66 * @return Base service_client 67 */ psa_crypto_client_base(void)68static inline struct service_client *psa_crypto_client_base(void) 69 { 70 return &psa_crypto_client_instance.base; 71 } 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 #endif /* PSA_CRYPTO_CLIENT_H */ 78