1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2017-2018, Linaro Limited
4  */
5 
6 #ifndef LIBCKTEEC_PKCS11_PROCESSING_H
7 #define LIBCKTEEC_PKCS11_PROCESSING_H
8 
9 #include <pkcs11.h>
10 #include <pkcs11_ta.h>
11 
12 CK_RV ck_create_object(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR attribs,
13 		       CK_ULONG count, CK_OBJECT_HANDLE_PTR phObject);
14 
15 CK_RV ck_destroy_object(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE obj);
16 
17 CK_RV ck_encdecrypt_init(CK_SESSION_HANDLE session,
18 			 CK_MECHANISM_PTR mechanism,
19 			 CK_OBJECT_HANDLE key,
20 			 int decrypt);
21 
22 CK_RV ck_encdecrypt_update(CK_SESSION_HANDLE session,
23 			   CK_BYTE_PTR in,
24 			   CK_ULONG in_len,
25 			   CK_BYTE_PTR out,
26 			   CK_ULONG_PTR out_len,
27 			   int decrypt);
28 
29 CK_RV ck_encdecrypt_oneshot(CK_SESSION_HANDLE session,
30 			    CK_BYTE_PTR in,
31 			    CK_ULONG in_len,
32 			    CK_BYTE_PTR out,
33 			    CK_ULONG_PTR out_len,
34 			    int decrypt);
35 
36 CK_RV ck_encdecrypt_final(CK_SESSION_HANDLE session,
37 			  CK_BYTE_PTR out,
38 			  CK_ULONG_PTR out_len,
39 			  int decrypt);
40 
41 CK_RV ck_digest_init(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism);
42 
43 CK_RV ck_digest_key(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE key);
44 
45 CK_RV ck_digest_update(CK_SESSION_HANDLE session, CK_BYTE_PTR in,
46 		       CK_ULONG in_len);
47 
48 CK_RV ck_digest_oneshot(CK_SESSION_HANDLE session, CK_BYTE_PTR in,
49 			CK_ULONG in_len, CK_BYTE_PTR out,
50 			CK_ULONG_PTR out_len);
51 
52 CK_RV ck_digest_final(CK_SESSION_HANDLE session, CK_BYTE_PTR out,
53 		      CK_ULONG_PTR out_len);
54 
55 CK_RV ck_signverify_init(CK_SESSION_HANDLE session,
56 			 CK_MECHANISM_PTR mechanism,
57 			 CK_OBJECT_HANDLE key,
58 			 int sign);
59 
60 CK_RV ck_signverify_update(CK_SESSION_HANDLE session,
61 			   CK_BYTE_PTR in,
62 			   CK_ULONG in_len,
63 			   int sign);
64 
65 CK_RV ck_signverify_oneshot(CK_SESSION_HANDLE session,
66 			    CK_BYTE_PTR in,
67 			    CK_ULONG in_len,
68 			    CK_BYTE_PTR out,
69 			    CK_ULONG_PTR out_len,
70 			    int sign);
71 
72 CK_RV ck_signverify_final(CK_SESSION_HANDLE session,
73 			  CK_BYTE_PTR out,
74 			  CK_ULONG_PTR out_len,
75 			  int sign);
76 
77 CK_RV ck_generate_key(CK_SESSION_HANDLE session,
78 		      CK_MECHANISM_PTR mechanism,
79 		      CK_ATTRIBUTE_PTR attribs,
80 		      CK_ULONG count,
81 		      CK_OBJECT_HANDLE_PTR handle);
82 
83 CK_RV ck_find_objects_init(CK_SESSION_HANDLE session,
84 			   CK_ATTRIBUTE_PTR attribs,
85 			   CK_ULONG count);
86 
87 CK_RV ck_find_objects(CK_SESSION_HANDLE session,
88 		      CK_OBJECT_HANDLE_PTR obj,
89 		      CK_ULONG max_count,
90 		      CK_ULONG_PTR count);
91 
92 CK_RV ck_find_objects_final(CK_SESSION_HANDLE session);
93 
94 CK_RV ck_get_object_size(CK_SESSION_HANDLE session,
95 			 CK_OBJECT_HANDLE obj,
96 			 CK_ULONG_PTR p_size);
97 
98 CK_RV ck_get_attribute_value(CK_SESSION_HANDLE session,
99 			     CK_OBJECT_HANDLE obj,
100 			     CK_ATTRIBUTE_PTR attribs,
101 			     CK_ULONG count);
102 
103 CK_RV ck_set_attribute_value(CK_SESSION_HANDLE session,
104 			     CK_OBJECT_HANDLE obj,
105 			     CK_ATTRIBUTE_PTR attribs,
106 			     CK_ULONG count);
107 
108 CK_RV ck_copy_object(CK_SESSION_HANDLE session,
109 		     CK_OBJECT_HANDLE obj,
110 		     CK_ATTRIBUTE_PTR attribs,
111 		     CK_ULONG count,
112 		     CK_OBJECT_HANDLE_PTR handle);
113 
114 CK_RV ck_derive_key(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
115 		    CK_OBJECT_HANDLE base_key, CK_ATTRIBUTE_PTR attribs,
116 		    CK_ULONG count, CK_OBJECT_HANDLE_PTR handle);
117 
118 CK_RV ck_release_active_processing(CK_SESSION_HANDLE session,
119 				   enum pkcs11_ta_cmd command);
120 
121 CK_RV ck_generate_key_pair(CK_SESSION_HANDLE session,
122 			   CK_MECHANISM_PTR mechanism,
123 			   CK_ATTRIBUTE_PTR pub_attribs,
124 			   CK_ULONG pub_count,
125 			   CK_ATTRIBUTE_PTR priv_attribs,
126 			   CK_ULONG priv_count,
127 			   CK_OBJECT_HANDLE_PTR pub_key,
128 			   CK_OBJECT_HANDLE_PTR priv_key);
129 
130 CK_RV ck_wrap_key(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
131 		  CK_OBJECT_HANDLE wrapping_key, CK_OBJECT_HANDLE key,
132 		  CK_BYTE_PTR wrapped_key, CK_ULONG_PTR wrapped_key_len);
133 
134 CK_RV ck_unwrap_key(CK_SESSION_HANDLE session, CK_MECHANISM_PTR mechanism,
135 		    CK_OBJECT_HANDLE unwrapping_key, CK_BYTE_PTR wrapped_key,
136 		    CK_ULONG wrapped_key_len, CK_ATTRIBUTE_PTR attribs,
137 		    CK_ULONG count, CK_OBJECT_HANDLE_PTR handle);
138 
139 #endif /*LIBCKTEEC_PKCS11_PROCESSING_H*/
140