1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2017-2020, Linaro Limited
4  */
5 
6 #ifndef PKCS11_TA_SANITIZE_OBJECT_H
7 #define PKCS11_TA_SANITIZE_OBJECT_H
8 
9 #include "serializer.h"
10 
11 /*
12  * sanitize_consistent_class_and_type - Check object type matches object class
13  *
14  * @attrs - object attributes
15  * Return true if class/type matches, else return false
16  */
17 bool sanitize_consistent_class_and_type(struct obj_attrs *attrs);
18 
19 /**
20  * sanitize_client_object - Setup a serializer from a serialized object
21  *
22  * @dst - output structure tracking the generated serial object
23  * @head - pointer to the formatted serialized object (its head)
24  * @size - byte size of the serialized binary blob
25  * @class_hint - Hint for class to be added to template if not presnet
26  *               in serialized object.
27  * @type_hint - Hint for type to be added to template if not presnet
28  *               in serialized object.
29  *
30  * This function copies an attribute list from a client API attribute head
31  * into a PKCS11 TA internal attribute structure. It generates a serialized
32  * attribute list with a consistent format and identified attribute IDs.
33  *
34  * @head points to a blob starting with a pkcs11 attribute header.
35  * @head may point to an unaligned address.
36  * This function allocates, fills and returns a serialized attribute list
37  * into a serializer container.
38  */
39 enum pkcs11_rc sanitize_client_object(struct obj_attrs **dst, void *head,
40 				      size_t size, uint32_t class_hint,
41 				      uint32_t type_hint);
42 
43 /* Debug: dump attribute content as debug traces */
44 void trace_attributes_from_api_head(const char *prefix, void *ref, size_t size);
45 
46 #endif /*PKCS11_TA_SANITIZE_OBJECT_H*/
47