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_SERIALIZER_H
8 #define CIPHER_PROVIDER_SERIALIZER_H
9 
10 #include <stddef.h>
11 #include <stdint.h>
12 #include <service/crypto/backend/crypto_backend.h>
13 #include "components/rpc/common/endpoint/rpc_service_interface.h"
14 
15 /* Provides a common interface for parameter serialization operations
16  * for the cipher service provider.
17  */
18 struct cipher_provider_serializer {
19 
20 	/* Operation: cipher_setup */
21 	rpc_status_t (*deserialize_cipher_setup_req)(const struct rpc_buffer *req_buf,
22 		psa_key_id_t *id,
23 		psa_algorithm_t *alg);
24 
25 	rpc_status_t (*serialize_cipher_setup_resp)(struct rpc_buffer *resp_buf,
26 		uint32_t op_handle);
27 
28 	/* Operation: cipher_generate_iv */
29 	rpc_status_t (*deserialize_cipher_generate_iv_req)(const struct rpc_buffer *req_buf,
30 		uint32_t *op_handle);
31 
32 	rpc_status_t (*serialize_cipher_generate_iv_resp)(struct rpc_buffer *resp_buf,
33 		const uint8_t *iv, size_t iv_len);
34 
35 	/* Operation: cipher_set_iv */
36 	rpc_status_t (*deserialize_cipher_set_iv_req)(const struct rpc_buffer *req_buf,
37 		uint32_t *op_handle,
38 		const uint8_t **iv, size_t *iv_len);
39 
40 	/* Operation: cipher_update */
41 	rpc_status_t (*deserialize_cipher_update_req)(const struct rpc_buffer *req_buf,
42 		uint32_t *op_handle,
43 		const uint8_t **data, size_t *data_len);
44 
45 	rpc_status_t (*serialize_cipher_update_resp)(struct rpc_buffer *resp_buf,
46 		const uint8_t *data, size_t data_len);
47 
48 	/* Operation: cipher_finish */
49 	rpc_status_t (*deserialize_cipher_finish_req)(const struct rpc_buffer *req_buf,
50 		uint32_t *op_handle);
51 
52 	rpc_status_t (*serialize_cipher_finish_resp)(struct rpc_buffer *resp_buf,
53 		const uint8_t *data, size_t data_len);
54 
55 	/* Operation: cipher_abort */
56 	rpc_status_t (*deserialize_cipher_abort_req)(const struct rpc_buffer *req_buf,
57 		uint32_t *op_handle);
58 };
59 
60 #endif /* CIPHER_PROVIDER_SERIALIZER_H */
61