blob: 5ffd0c34eb9f1a481ec037e6e470f8fe5198b6ac [file] [log] [blame]
Julian Hallc02fffb2020-11-23 18:22:06 +01001/*
julhal01c3f4e9a2020-12-15 13:39:01 +00002 * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
Julian Hallc02fffb2020-11-23 18:22:06 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef MBED_CRYPTO_PROVIDER_H
8#define MBED_CRYPTO_PROVIDER_H
9
julhal01c3f4e9a2020-12-15 13:39:01 +000010#include <rpc/common/endpoint/rpc_interface.h>
Julian Hallc02fffb2020-11-23 18:22:06 +010011#include <rpc_caller.h>
12#include <service/common/provider/service_provider.h>
julhal01c3f4e9a2020-12-15 13:39:01 +000013#include <service/crypto/provider/serializer/crypto_provider_serializer.h>
14#include <protocols/rpc/common/packed-c/encoding.h>
Julian Hallc02fffb2020-11-23 18:22:06 +010015
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20struct mbed_crypto_provider
21{
22 struct service_provider base_provider;
julhal01c3f4e9a2020-12-15 13:39:01 +000023 const struct crypto_provider_serializer *serializers[TS_RPC_ENCODING_LIMIT];
Julian Hallc02fffb2020-11-23 18:22:06 +010024};
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,
julhal01c3f4e9a2020-12-15 13:39:01 +000034 * a pointer to the rpc_interface for the service is returned.
Julian Hallc02fffb2020-11-23 18:22:06 +010035 */
julhal01c3f4e9a2020-12-15 13:39:01 +000036struct rpc_interface *mbed_crypto_provider_init(struct mbed_crypto_provider *context,
julhal01ffa98d82021-01-20 13:51:58 +000037 struct rpc_caller *storage_provider,
38 void *entropy_adapter_config);
Julian Hallc02fffb2020-11-23 18:22:06 +010039
40/*
41 * When operation of the provider is no longer required, this function
42 * frees any resource used by the previously initialized provider instance.
43 */
44void mbed_crypto_provider_deinit(struct mbed_crypto_provider *context);
45
julhal01c3f4e9a2020-12-15 13:39:01 +000046/*
47 * Register a serializer for supportng a particular parameter encoding. At
48 * least one serializer must be registered but additional ones may be registered
49 * to allow alternative parameter serialization schemes to be used to allow
50 * for compatibility with different types of client.
51 */
52void mbed_crypto_provider_register_serializer(struct mbed_crypto_provider *context,
53 unsigned int encoding, const struct crypto_provider_serializer *serializer);
54
Julian Hallc02fffb2020-11-23 18:22:06 +010055#ifdef __cplusplus
56} /* extern "C" */
57#endif
58
59#endif /* MBED_CRYPTO_PROVIDER_H */