1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2017-2020, Linaro Limited
4  */
5 #ifndef LIBCKTEEC_SERIALIZER_H
6 #define LIBCKTEEC_SERIALIZER_H
7 
8 #include <pkcs11.h>
9 #include <pkcs11_ta.h>
10 #include <stddef.h>
11 #include <stdint.h>
12 
13 /*
14  * Struct used to create the buffer storing the serialized data.
15  * Contains some fields to help parsing content (type/boolprops).
16  */
17 struct serializer {
18 	char *buffer;		/* serial buffer base address */
19 	size_t size;		/* serial buffer current byte size */
20 	size_t item_count;	/* number of items in entry table */
21 	uint32_t object;
22 	uint32_t type;
23 };
24 
25 /* Init/finalize/release a serializer object */
26 CK_RV init_serial_object(struct serializer *obj);
27 void finalize_serial_object(struct serializer *obj);
28 void release_serial_object(struct serializer *obj);
29 
30 CK_RV serialize_buffer(struct serializer *obj, void *data, size_t size);
31 CK_RV serialize_32b(struct serializer *obj, uint32_t data);
32 CK_RV serialize_ck_ulong(struct serializer *obj, CK_ULONG data);
33 
34 #endif /*LIBCKTEEC_SERIALIZER_H*/
35