blob: 788e501968983b4ac589759830670a3e2a963dbd [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
Julian Hall9061e6c2021-06-29 14:24:20 +01007#ifndef CRYPTO_PROVIDER_H
8#define CRYPTO_PROVIDER_H
Julian Hallc02fffb2020-11-23 18:22:06 +01009
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>
13#include <protocols/rpc/common/packed-c/encoding.h>
Julian Hallc02fffb2020-11-23 18:22:06 +010014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Julian Hall9061e6c2021-06-29 14:24:20 +010019struct crypto_provider
Julian Hallc02fffb2020-11-23 18:22:06 +010020{
21 struct service_provider base_provider;
julhal01c3f4e9a2020-12-15 13:39:01 +000022 const struct crypto_provider_serializer *serializers[TS_RPC_ENCODING_LIMIT];
Julian Hallc02fffb2020-11-23 18:22:06 +010023};
24
25/*
Julian Hall9061e6c2021-06-29 14:24:20 +010026 * Initializes an instance of the crypto service provider. A suitable
27 * backend that realizes the PSA Crypto API should have been initialized
28 * prior to initializing the crypto provider.
Julian Hallc02fffb2020-11-23 18:22:06 +010029 */
Julian Hall9061e6c2021-06-29 14:24:20 +010030struct rpc_interface *crypto_provider_init(struct crypto_provider *context);
Julian Hallc02fffb2020-11-23 18:22:06 +010031
32/*
33 * When operation of the provider is no longer required, this function
34 * frees any resource used by the previously initialized provider instance.
35 */
Julian Hall9061e6c2021-06-29 14:24:20 +010036void crypto_provider_deinit(struct crypto_provider *context);
Julian Hallc02fffb2020-11-23 18:22:06 +010037
julhal01c3f4e9a2020-12-15 13:39:01 +000038/*
39 * Register a serializer for supportng a particular parameter encoding. At
40 * least one serializer must be registered but additional ones may be registered
41 * to allow alternative parameter serialization schemes to be used to allow
42 * for compatibility with different types of client.
43 */
Julian Hall9061e6c2021-06-29 14:24:20 +010044void crypto_provider_register_serializer(struct crypto_provider *context,
julhal01c3f4e9a2020-12-15 13:39:01 +000045 unsigned int encoding, const struct crypto_provider_serializer *serializer);
46
Julian Hall13e76952021-07-13 12:17:09 +010047/*
48 * Extend the core set of operations provided by the crypto provider.
49 */
50void crypto_provider_extend(struct crypto_provider *context,
51 struct service_provider *sub_provider);
52
Julian Hallc02fffb2020-11-23 18:22:06 +010053#ifdef __cplusplus
54} /* extern "C" */
55#endif
56
Julian Hall9061e6c2021-06-29 14:24:20 +010057#endif /* CRYPTO_PROVIDER_H */