Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 1 | /* |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef MBED_CRYPTO_PROVIDER_H |
| 8 | #define MBED_CRYPTO_PROVIDER_H |
| 9 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 10 | #include <rpc/common/endpoint/rpc_interface.h> |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 11 | #include <rpc_caller.h> |
| 12 | #include <service/common/provider/service_provider.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 13 | #include <service/crypto/provider/serializer/crypto_provider_serializer.h> |
| 14 | #include <protocols/rpc/common/packed-c/encoding.h> |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
| 20 | struct mbed_crypto_provider |
| 21 | { |
| 22 | struct service_provider base_provider; |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 23 | const struct crypto_provider_serializer *serializers[TS_RPC_ENCODING_LIMIT]; |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | /* |
| 27 | * Initializes an instance of the crypto service provider that uses the |
| 28 | * Mbed Crypto library to implement crypto operations. Secure storage |
| 29 | * for persistent keys needs to be provided by a suitable storage |
| 30 | * provider, accessed using the secure storage service access protocol |
| 31 | * using the provided rpc_caller. Any rpc endpoint discovery and |
| 32 | * session establishment should have been performed prior to initializing |
| 33 | * the mbed_crypto_provider. On successfully initializing the provider, |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 34 | * a pointer to the rpc_interface for the service is returned. |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 35 | */ |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 36 | struct rpc_interface *mbed_crypto_provider_init(struct mbed_crypto_provider *context, |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 37 | struct rpc_caller *storage_provider); |
| 38 | |
| 39 | /* |
| 40 | * When operation of the provider is no longer required, this function |
| 41 | * frees any resource used by the previously initialized provider instance. |
| 42 | */ |
| 43 | void mbed_crypto_provider_deinit(struct mbed_crypto_provider *context); |
| 44 | |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame^] | 45 | /* |
| 46 | * Register a serializer for supportng a particular parameter encoding. At |
| 47 | * least one serializer must be registered but additional ones may be registered |
| 48 | * to allow alternative parameter serialization schemes to be used to allow |
| 49 | * for compatibility with different types of client. |
| 50 | */ |
| 51 | void mbed_crypto_provider_register_serializer(struct mbed_crypto_provider *context, |
| 52 | unsigned int encoding, const struct crypto_provider_serializer *serializer); |
| 53 | |
Julian Hall | c02fffb | 2020-11-23 18:22:06 +0100 | [diff] [blame] | 54 | #ifdef __cplusplus |
| 55 | } /* extern "C" */ |
| 56 | #endif |
| 57 | |
| 58 | #endif /* MBED_CRYPTO_PROVIDER_H */ |