1 /*
2  * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef CIPHER_PROVIDER_H
8 #define CIPHER_PROVIDER_H
9 
10 #include "components/rpc/common/endpoint/rpc_service_interface.h"
11 #include <service/common/provider/service_provider.h>
12 #include <service/crypto/provider/extension/cipher/serializer/cipher_provider_serializer.h>
13 #include <service/crypto/provider/crypto_context_pool.h>
14 #include <protocols/rpc/common/packed-c/encoding.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /**
21  * A service provider that can be used to add symmetric cipher operations to the core
22  * crypto provider.
23  */
24 struct cipher_provider
25 {
26 	struct service_provider base_provider;
27 	struct crypto_context_pool context_pool;
28 	const struct cipher_provider_serializer *serializers[TS_RPC_ENCODING_LIMIT];
29 };
30 
31 /*
32  * Initializes an instance of the cipher service provider.
33  */
34 void cipher_provider_init(struct cipher_provider *context);
35 
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  */
40 void cipher_provider_deinit(struct cipher_provider *context);
41 
42 /*
43  * Register a serializer for supportng a particular parameter encoding.
44  */
45 void cipher_provider_register_serializer(struct cipher_provider *context,
46 	unsigned int encoding, const struct cipher_provider_serializer *serializer);
47 
48 #ifdef __cplusplus
49 } /* extern "C" */
50 #endif
51 
52 #endif /* CIPHER_PROVIDER_H */
53