xref: /optee_os/ta/pkcs11/src/sanitize_object.h (revision a1d5c81f8834a9d2c6f4372cce2e59e70e709121)
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  *
26  * This function copies an attribute list from a client API attribute head
27  * into a PKCS11 TA internal attribute structure. It generates a serialized
28  * attribute list with a consistent format and identified attribute IDs.
29  *
30  * @head points to a blob starting with a pkcs11 attribute header.
31  * @head may point to an unaligned address.
32  * This function allocates, fills and returns a serialized attribute list
33  * into a serializer container.
34  */
35 enum pkcs11_rc sanitize_client_object(struct obj_attrs **dst, void *head,
36 				      size_t size);
37 
38 /* Debug: dump attribute content as debug traces */
39 void trace_attributes_from_api_head(const char *prefix, void *ref, size_t size);
40 
41 #endif /*PKCS11_TA_SANITIZE_OBJECT_H*/
42