blob: 3c0f8d89772a764cad88d1eded71029da063bd48 [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 <service/common/provider/service_provider.h>
julhal01c3f4e9a2020-12-15 13:39:01 +000012#include <service/crypto/provider/serializer/crypto_provider_serializer.h>
julhal013a4207d2021-03-08 13:32:08 +000013#include <service/secure_storage/backend/storage_backend.h>
julhal01c3f4e9a2020-12-15 13:39:01 +000014#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
julhal011260f102021-02-15 17:34:08 +000030 * backend.
Julian Hallc02fffb2020-11-23 18:22:06 +010031 */
julhal01c3f4e9a2020-12-15 13:39:01 +000032struct rpc_interface *mbed_crypto_provider_init(struct mbed_crypto_provider *context,
julhal013a4207d2021-03-08 13:32:08 +000033 struct storage_backend *storage_backend,
julhal012c18fbf2021-02-01 08:29:28 +000034 int trng_instance);
Julian Hallc02fffb2020-11-23 18:22:06 +010035
36/*
37 * When operation of the provider is no longer required, this function
38 * frees any resource used by the previously initialized provider instance.
39 */
40void mbed_crypto_provider_deinit(struct mbed_crypto_provider *context);
41
julhal01c3f4e9a2020-12-15 13:39:01 +000042/*
43 * Register a serializer for supportng a particular parameter encoding. At
44 * least one serializer must be registered but additional ones may be registered
45 * to allow alternative parameter serialization schemes to be used to allow
46 * for compatibility with different types of client.
47 */
48void mbed_crypto_provider_register_serializer(struct mbed_crypto_provider *context,
49 unsigned int encoding, const struct crypto_provider_serializer *serializer);
50
Julian Hallc02fffb2020-11-23 18:22:06 +010051#ifdef __cplusplus
52} /* extern "C" */
53#endif
54
55#endif /* MBED_CRYPTO_PROVIDER_H */