blob: 4a94be71cf80bb275f803fcb1162f0dc4a0b1423 [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,
Julian Hallc02fffb2020-11-23 18:22:06 +010037 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 */
43void mbed_crypto_provider_deinit(struct mbed_crypto_provider *context);
44
julhal01c3f4e9a2020-12-15 13:39:01 +000045/*
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 */
51void mbed_crypto_provider_register_serializer(struct mbed_crypto_provider *context,
52 unsigned int encoding, const struct crypto_provider_serializer *serializer);
53
Julian Hallc02fffb2020-11-23 18:22:06 +010054#ifdef __cplusplus
55} /* extern "C" */
56#endif
57
58#endif /* MBED_CRYPTO_PROVIDER_H */