1 // Copyright 2017 Marcus Heese
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #![allow(non_camel_case_types, non_snake_case)]
15 
16 use types::*;
17 
18 /// `C_Initialize` initializes the Cryptoki library.
19 ///
20 /// # Function Parameters
21 ///
22 /// * `pInitArgs`: if this is not NULL_PTR, it gets cast to CK_C_INITIALIZE_ARGS_PTR and dereferenced
23 ///
24 pub type C_Initialize = extern "C" fn(pInitArgs: CK_C_INITIALIZE_ARGS_PTR) -> CK_RV;
25 
26 /// `C_Finalize` indicates that an application is done with the Cryptoki library.
27 ///
28 /// # Function Parameters
29 ///
30 /// * `pReserved`: reserved.  Should be NULL_PTR
31 ///
32 pub type C_Finalize = extern "C" fn(pReserved: CK_VOID_PTR) -> CK_RV;
33 
34 /// `C_GetInfo` returns general information about Cryptoki.
35 ///
36 /// # Function Parameters
37 ///
38 /// * `pInfo`: location that receives information
39 ///
40 pub type C_GetInfo = extern "C" fn(pInfo: CK_INFO_PTR) -> CK_RV;
41 
42 /// `C_GetFunctionList` returns the function list.
43 ///
44 /// # Function Parameters
45 ///
46 /// * `ppFunctionList`: receives pointer to function list
47 ///
48 pub type C_GetFunctionList = extern "C" fn(ppFunctionList: CK_FUNCTION_LIST_PTR_PTR) -> CK_RV;
49 
50 /// `C_GetSlotList` obtains a list of slots in the system.
51 ///
52 /// # Function Parameters
53 ///
54 /// * `tokenPresent`: only slots with tokens
55 /// * `pSlotList`: receives array of slot IDs
56 /// * `pulCount`: receives number of slots
57 ///
58 pub type C_GetSlotList = extern "C" fn(tokenPresent: CK_BBOOL, pSlotList: CK_SLOT_ID_PTR, pulCount: CK_ULONG_PTR) -> CK_RV;
59 
60 /// `C_GetSlotInfo` obtains information about a particular slot in the system.
61 ///
62 /// # Function Parameters
63 ///
64 /// * `slotID`: the ID of the slot
65 /// * `pInfo`: receives the slot information
66 ///
67 pub type C_GetSlotInfo = extern "C" fn(slotID: CK_SLOT_ID, pInfo: CK_SLOT_INFO_PTR) -> CK_RV;
68 
69 /// `C_GetTokenInfo` obtains information about a particular token in the system.
70 ///
71 /// # Function Parameters
72 ///
73 /// * `slotID`: ID of the token's slot
74 /// * `pInfo`: receives the token information
75 ///
76 pub type C_GetTokenInfo = extern "C" fn(slotID: CK_SLOT_ID, pInfo: CK_TOKEN_INFO_PTR) -> CK_RV;
77 
78 /// `C_GetMechanismList` obtains a list of mechanism types supported by a token.
79 ///
80 /// # Function Parameters
81 ///
82 /// * `slotID`: ID of token's slot
83 /// * `pMechanismList`: gets mech. array
84 /// * `pulCount`: gets # of mechs.
85 ///
86 pub type C_GetMechanismList = extern "C" fn(slotID: CK_SLOT_ID, pMechanismList: CK_MECHANISM_TYPE_PTR, pulCount: CK_ULONG_PTR) -> CK_RV;
87 
88 /// `C_GetMechanismInfo` obtains information about a particular mechanism possibly supported by a token.
89 ///
90 /// # Function Parameters
91 ///
92 /// * `slotID`: ID of the token's slot
93 /// * `mechType`: type of mechanism
94 /// * `pInfo`: receives mechanism info
95 ///
96 pub type C_GetMechanismInfo = extern "C" fn(slotID: CK_SLOT_ID, mechType: CK_MECHANISM_TYPE, pInfo: CK_MECHANISM_INFO_PTR) -> CK_RV;
97 
98 /// `C_InitToken` initializes a token.
99 ///
100 /// # Function Parameters
101 ///
102 /// * `slotID`: ID of the token's slot
103 /// * `pPin`: the SO's initial PIN
104 /// * `ulPinLen`: length in bytes of the PIN
105 /// * `pLabel`: 32-byte token label (blank padded)
106 ///
107 pub type C_InitToken = extern "C" fn(slotID: CK_SLOT_ID, pPin: CK_UTF8CHAR_PTR, ulPinLen: CK_ULONG, pLabel: CK_UTF8CHAR_PTR) -> CK_RV;
108 
109 /// `C_InitPIN` initializes the normal user's PIN.
110 ///
111 /// # Function Parameters
112 ///
113 /// * `hSession`: the session's handle
114 /// * `pPin`: the normal user's PIN
115 /// * `ulPinLen`: length in bytes of the PIN
116 ///
117 pub type C_InitPIN = extern "C" fn(hSession: CK_SESSION_HANDLE, pPin: CK_UTF8CHAR_PTR, ulPinLen: CK_ULONG) -> CK_RV;
118 
119 /// `C_SetPIN` modifies the PIN of the user who is logged in.
120 ///
121 /// # Function Parameters
122 ///
123 /// * `hSession`: the session's handle
124 /// * `pOldPin`: the old PIN
125 /// * `ulOldLen`: length of the old PIN
126 /// * `pNewPin`: the new PIN
127 /// * `ulNewLen`: length of the new PIN
128 ///
129 pub type C_SetPIN = extern "C" fn(hSession: CK_SESSION_HANDLE, pOldPin: CK_UTF8CHAR_PTR, ulOldLen: CK_ULONG, pNewPin: CK_UTF8CHAR_PTR, ulNewLen: CK_ULONG) -> CK_RV;
130 
131 /// `C_OpenSession` opens a session between an application and a token.
132 ///
133 /// # Function Parameters
134 ///
135 /// * `slotID`: the slot's ID
136 /// * `flags`: from CK_SESSION_INFO
137 /// * `pApplication`: passed to callback
138 /// * `Notify`: callback function
139 /// * `phSession`: gets session handle
140 ///
141 pub type C_OpenSession = extern "C" fn(slotID: CK_SLOT_ID, flags: CK_FLAGS, pApplication: CK_VOID_PTR, Notify: CK_NOTIFY, phSession: CK_SESSION_HANDLE_PTR) -> CK_RV;
142 
143 /// `C_CloseSession` closes a session between an application and a token.
144 ///
145 /// # Function Parameters
146 ///
147 /// * `hSession`: the session's handle
148 ///
149 pub type C_CloseSession = extern "C" fn(hSession: CK_SESSION_HANDLE) -> CK_RV;
150 
151 /// `C_CloseAllSessions` closes all sessions with a token.
152 ///
153 /// # Function Parameters
154 ///
155 /// * `slotID`: the token's slot
156 ///
157 pub type C_CloseAllSessions = extern "C" fn(slotID: CK_SLOT_ID) -> CK_RV;
158 
159 /// `C_GetSessionInfo` obtains information about the session.
160 ///
161 /// # Function Paramters
162 ///
163 /// * `hSession`: the session's handle
164 /// * `pInfo`: receives session info
165 ///
166 pub type C_GetSessionInfo = extern "C" fn(hSession: CK_SESSION_HANDLE, pInfo: CK_SESSION_INFO_PTR) -> CK_RV;
167 
168 /// `C_GetOperationState` obtains the state of the cryptographic operation in a session.
169 ///
170 /// # Function Paramters
171 ///
172 /// * `hSession`: session's handle
173 /// * `pOperationState`: gets state
174 /// * `pulOperationStateLen`: gets state length
175 ///
176 pub type C_GetOperationState = extern "C" fn(hSession: CK_SESSION_HANDLE, pOperationState: CK_BYTE_PTR, pulOperationStateLen: CK_ULONG_PTR) -> CK_RV;
177 
178 /// `C_SetOperationState` restores the state of the cryptographic operation in a session.
179 ///
180 /// # Function Paramters
181 ///
182 /// * `hSession`: session's handle
183 /// * `pOperationState`: holds state
184 /// * `ulOperationStateLen`: holds state length
185 /// * `hEncryptionKey`: en/decryption key
186 /// * `hAuthenticationKey`: sign/verify key
187 ///
188 pub type C_SetOperationState = extern "C" fn(
189   hSession: CK_SESSION_HANDLE,
190   pOperationState: CK_BYTE_PTR,
191   ulOperationStateLen: CK_ULONG,
192   hEncryptionKey: CK_OBJECT_HANDLE,
193   hAuthenticationKey: CK_OBJECT_HANDLE,
194 ) -> CK_RV;
195 
196 /// `C_Login` logs a user into a token.
197 ///
198 /// # Function Parameters
199 ///
200 /// * `hSession`: the session's handle
201 /// * `userType`: the user type
202 /// * `pPin`: the user's PIN
203 /// * `ulPinLen`: the length of the PIN
204 ///
205 pub type C_Login = extern "C" fn(hSession: CK_SESSION_HANDLE, userType: CK_USER_TYPE, pPin: CK_UTF8CHAR_PTR, ulPinLen: CK_ULONG) -> CK_RV;
206 
207 /// `C_Logout` logs a user out from a token.
208 ///
209 /// # Function Parameters
210 ///
211 /// * `hSession`: the session's handle
212 pub type C_Logout = extern "C" fn(hSession: CK_SESSION_HANDLE) -> CK_RV;
213 
214 /// `C_CreateObject` creates a new object.
215 ///
216 /// # Function Parameters
217 ///
218 /// * `hSession`: the session's handle
219 /// * `pTemplate`: the object's template
220 /// * `ulCount`: attributes in template
221 /// * `phObject`: gets new object's handle.
222 ///
223 pub type C_CreateObject = extern "C" fn(hSession: CK_SESSION_HANDLE, pTemplate: CK_ATTRIBUTE_PTR, ulCount: CK_ULONG, phObject: CK_OBJECT_HANDLE_PTR) -> CK_RV;
224 
225 /// `C_CopyObject` copies an object, creating a new object for the copy.
226 ///
227 /// # Function Parameters
228 ///
229 /// * `hSession`: the session's handle
230 /// * `hObject`: the object's handle
231 /// * `pTemplate`: template for new object
232 /// * `ulCount`: attributes in template
233 /// * `phNewObject`: receives handle of copy
234 ///
235 pub type C_CopyObject = extern "C" fn(hSession: CK_SESSION_HANDLE, hObject: CK_OBJECT_HANDLE, pTemplate: CK_ATTRIBUTE_PTR, ulCount: CK_ULONG, phNewObject: CK_OBJECT_HANDLE_PTR) -> CK_RV;
236 
237 /// `C_DestroyObject` destroys an object.
238 ///
239 /// # Function Parameters
240 ///
241 /// * `hSession`: the session's handle
242 /// * `hObject`: the object's handle
243 ///
244 pub type C_DestroyObject = extern "C" fn(hSession: CK_SESSION_HANDLE, hObject: CK_OBJECT_HANDLE) -> CK_RV;
245 
246 /// `C_GetObjectSize` gets the size of an object in bytes.
247 ///
248 /// # Function Parameters
249 ///
250 /// * `hSession`: the session's handle
251 /// * `hObject`: the object's handle
252 /// * `pulSize`: receives size of object
253 ///
254 pub type C_GetObjectSize = extern "C" fn(hSession: CK_SESSION_HANDLE, hObject: CK_OBJECT_HANDLE, pulSize: CK_ULONG_PTR) -> CK_RV;
255 
256 /// `C_GetAttributeValue` obtains the value of one or more object attributes.
257 ///
258 /// # Function Parameters
259 ///
260 /// * `hSession`: the session's handle
261 /// * `hObject`: the object's handle
262 /// * `pTemplate`: specifies attrs; gets vals
263 /// * `ulCount`: attributes in template
264 ///
265 pub type C_GetAttributeValue = extern "C" fn(hSession: CK_SESSION_HANDLE, hObject: CK_OBJECT_HANDLE, pTemplate: CK_ATTRIBUTE_PTR, ulCount: CK_ULONG) -> CK_RV;
266 
267 /// `C_SetAttributeValue` modifies the value of one or more object attributes.
268 ///
269 /// # Function Parameters
270 ///
271 /// * `hSession`: the session's handle
272 /// * `hObject`: the object's handle
273 /// * `pTemplate`: specifies attrs and values
274 /// * `ulCount`: attributes in template
275 ///
276 pub type C_SetAttributeValue = extern "C" fn(hSession: CK_SESSION_HANDLE, hObject: CK_OBJECT_HANDLE, pTemplate: CK_ATTRIBUTE_PTR, ulCount: CK_ULONG) -> CK_RV;
277 
278 /// `C_FindObjectsInit` initializes a search for token and session objects that match a template.
279 ///
280 /// # Function Parameters
281 ///
282 /// * `hSession`: the session's handle
283 /// * `pTemplate`: attribute values to match
284 /// * `ulCount`: attrs in search template
285 ///
286 pub type C_FindObjectsInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pTemplate: CK_ATTRIBUTE_PTR, ulCount: CK_ULONG) -> CK_RV;
287 
288 /// `C_FindObjects` continues a search for token and session objects that match a template, obtaining additional object handles.
289 ///
290 /// # Function Parameters
291 ///
292 /// * `hSession`: session's handle
293 /// * `phObject`: gets obj. handles
294 /// * `ulMaxObjectCount`: max handles to get
295 /// * `pulObjectCount`: actual # returned
296 ///
297 pub type C_FindObjects = extern "C" fn(hSession: CK_SESSION_HANDLE, phObject: CK_OBJECT_HANDLE_PTR, ulMaxObjectCount: CK_ULONG, pulObjectCount: CK_ULONG_PTR) -> CK_RV;
298 
299 /// `C_FindObjectsFinal` finishes a search for token and session objects.
300 ///
301 /// # Function Parameters
302 ///
303 /// * `hSession`: the session's handle
304 ///
305 pub type C_FindObjectsFinal = extern "C" fn(hSession: CK_SESSION_HANDLE) -> CK_RV;
306 
307 /// `C_EncryptInit` initializes an encryption operation.
308 ///
309 /// # Function Parameters
310 ///
311 /// * `hSession`: the session's handle
312 /// * `pMechanism`: the encryption mechanism
313 /// * `hKey`: handle of encryption key
314 ///
315 pub type C_EncryptInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR, hKey: CK_OBJECT_HANDLE) -> CK_RV;
316 
317 /// `C_Encrypt` encrypts single-part data.
318 ///
319 /// # Function Parameters
320 ///
321 /// * `hSession`: session's handle
322 /// * `pData`: the plaintext data
323 /// * `ulDataLen`: bytes of plaintext
324 /// * `pEncryptedData`: gets ciphertext
325 /// * `pulEncryptedDataLen`: gets c-text size
326 ///
327 pub type C_Encrypt = extern "C" fn(hSession: CK_SESSION_HANDLE, pData: CK_BYTE_PTR, ulDataLen: CK_ULONG, pEncryptedData: CK_BYTE_PTR, pulEncryptedDataLen: CK_ULONG_PTR) -> CK_RV;
328 
329 /// `C_EncryptUpdate` continues a multiple-part encryption operation.
330 ///
331 /// # Function Parameters
332 ///
333 /// * `hSession`: session's handle
334 /// * `pPart`: the plaintext data
335 /// * `ulPartLen`: plaintext data len
336 /// * `pEncryptedPart`: gets ciphertext
337 /// * `pulEncryptedPartLen`: gets c-text size
338 ///
339 pub type C_EncryptUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pPart: CK_BYTE_PTR, ulPartLen: CK_ULONG, pEncryptedPart: CK_BYTE_PTR, pulEncryptedPartLen: CK_ULONG_PTR) -> CK_RV;
340 
341 /// `C_EncryptFinal` finishes a multiple-part encryption operation
342 ///
343 /// # Function Parameters
344 ///
345 /// * `hSession`: session handle
346 /// * `pLastEncryptedPart` last c-text
347 /// * `pulLastEncryptedPartLen`: gets last size
348 ///
349 pub type C_EncryptFinal = extern "C" fn(hSession: CK_SESSION_HANDLE, pLastEncryptedPart: CK_BYTE_PTR, pulLastEncryptedPartLen: CK_ULONG_PTR) -> CK_RV;
350 
351 /// `C_DecryptInit` initializes a decryption operation.
352 ///
353 /// # Function Parameters
354 ///
355 /// * `hSession`: the session's handle
356 /// * `pMechanism`: the decryption mechanism
357 /// * `hKey`: handle of decryption key
358 ///
359 pub type C_DecryptInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR, hKey: CK_OBJECT_HANDLE) -> CK_RV;
360 
361 /// `C_Decrypt` decrypts encrypted data in a single part.
362 ///
363 /// # Function Parameters
364 ///
365 /// * `hSession`: session's handle
366 /// * `pEncryptedData`: ciphertext
367 /// * `ulEncryptedDataLen`: ciphertext length
368 /// * `pData`: gets plaintext
369 /// * `pulDataLen`: gets p-text size
370 ///
371 pub type C_Decrypt = extern "C" fn(hSession: CK_SESSION_HANDLE, pEncryptedData: CK_BYTE_PTR, ulEncryptedDataLen: CK_ULONG, pData: CK_BYTE_PTR, pulDataLen: CK_ULONG_PTR) -> CK_RV;
372 
373 /// `C_DecryptUpdate` continues a multiple-part decryption operation.
374 ///
375 /// # Function Parameters
376 ///
377 /// * `hSession`: session's handle
378 /// * `pEncryptedPart`: encrypted data
379 /// * `ulEncryptedPartLen`: input length
380 /// * `pPart`: gets plaintext
381 /// * `pulPartLen`: p-text size
382 ///
383 pub type C_DecryptUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pEncryptedPart: CK_BYTE_PTR, ulEncryptedPartLen: CK_ULONG, pPart: CK_BYTE_PTR, pulPartLen: CK_ULONG_PTR) -> CK_RV;
384 
385 /// `C_DecryptFinal` finishes a multiple-part decryption operation.
386 ///
387 /// # Function Parameters
388 ///
389 /// * `hSession`: the session's handle
390 /// * `pLastPart`: gets plaintext
391 /// * `pulLastPartLen`: p-text size
392 ///
393 pub type C_DecryptFinal = extern "C" fn(hSession: CK_SESSION_HANDLE, pLastPart: CK_BYTE_PTR, pulLastPartLen: CK_ULONG_PTR) -> CK_RV;
394 
395 /// `C_DigestInit` initializes a message-digesting operation.
396 ///
397 /// # Function Parameters
398 ///
399 /// * `hSession`: the session's handle
400 /// * `pMechanism`: the digesting mechanism
401 ///
402 pub type C_DigestInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR) -> CK_RV;
403 
404 /// `C_Digest` digests data in a single part.
405 ///
406 /// # Function Parameters
407 ///
408 /// * `hSession`: the session's handle
409 /// * `pData`: data to be digested
410 /// * `ulDataLen`: bytes of data to digest
411 /// * `pDigest`: gets the message digest
412 /// * `pulDigestLen`: gets digest length
413 ///
414 pub type C_Digest = extern "C" fn(hSession: CK_SESSION_HANDLE, pData: CK_BYTE_PTR, ulDataLen: CK_ULONG, pDigest: CK_BYTE_PTR, pulDigestLen: CK_ULONG_PTR) -> CK_RV;
415 
416 /// `C_DigestUpdate` continues a multiple-part message-digesting operation.
417 ///
418 /// # Function Parameters
419 ///
420 /// * `hSession`: the session's handle
421 /// * `pPart`: data to be digested
422 /// * `ulPartLen`: bytes of data to be digested
423 ///
424 pub type C_DigestUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pPart: CK_BYTE_PTR, ulPartLen: CK_ULONG) -> CK_RV;
425 
426 /// `C_DigestKey` continues a multi-part message-digesting operation, by digesting the value of a secret key as part of the data already digested.
427 ///
428 /// # Function Parameters
429 ///
430 /// * `hSession`: the session's handle
431 /// * `hKey`: secret key to digest
432 pub type C_DigestKey = extern "C" fn(hSession: CK_SESSION_HANDLE, hKey: CK_OBJECT_HANDLE) -> CK_RV;
433 
434 /// `C_DigestFinal` finishes a multiple-part message-digesting operation.
435 ///
436 /// # Function Parameters
437 ///
438 /// * `hSession`: the session's handle
439 /// * `pDigest`: gets the message digest
440 /// * `pulDigestLen`: gets byte count of digest
441 ///
442 pub type C_DigestFinal = extern "C" fn(hSession: CK_SESSION_HANDLE, pDigest: CK_BYTE_PTR, pulDigestLen: CK_ULONG_PTR) -> CK_RV;
443 
444 /// `C_SignInit` initializes a signature (private key encryption) operation, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.
445 ///
446 /// # Function Parameters
447 ///
448 /// * `hSession`: the session's handle
449 /// * `pMechanism`: the signature mechanism
450 /// * `hKey`: handle of signature key
451 ///
452 pub type C_SignInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR, hKey: CK_OBJECT_HANDLE) -> CK_RV;
453 
454 /// `C_Sign` signs (encrypts with private key) data in a single part, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.
455 ///
456 /// # Function Parameters
457 ///
458 /// * `hSession`: the session's handle
459 /// * `pData`: the data to sign
460 /// * `ulDataLen`: count of bytes to sign
461 /// * `pSignature`: gets the signature
462 /// * `pulSignatureLen`: gets signature length
463 ///
464 pub type C_Sign = extern "C" fn(hSession: CK_SESSION_HANDLE, pData: CK_BYTE_PTR, ulDataLen: CK_ULONG, pSignature: CK_BYTE_PTR, pulSignatureLen: CK_ULONG_PTR) -> CK_RV;
465 
466 /// `C_SignUpdate` continues a multiple-part signature operation, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.
467 ///
468 /// # Function Parameters
469 ///
470 /// * `hSession`: the session's handle
471 /// * `pPart`: the data to sign
472 /// * `ulPartLen`: count of bytes to sign
473 ///
474 pub type C_SignUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pPart: CK_BYTE_PTR, ulPartLen: CK_ULONG) -> CK_RV;
475 
476 /// `C_SignFinal` finishes a multiple-part signature operation, returning the signature.
477 ///
478 /// # Function Parameters
479 ///
480 /// * `hSession`: the session's handle
481 /// * `pSignature`: gets the signature
482 /// * `pulSignatureLen`: gets signature length
483 ///
484 pub type C_SignFinal = extern "C" fn(hSession: CK_SESSION_HANDLE, pSignature: CK_BYTE_PTR, pulSignatureLen: CK_ULONG_PTR) -> CK_RV;
485 
486 /// `C_SignRecoverInit` initializes a signature operation, where the data can be recovered from the signature.
487 /// `hSession`: the session's handle
488 /// `pMechanism`: the signature mechanism
489 /// `hKey`: handle of the signature key
490 pub type C_SignRecoverInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR, hKey: CK_OBJECT_HANDLE) -> CK_RV;
491 
492 /// `C_SignRecover` signs data in a single operation, where the data can be recovered from the signature.
493 ///
494 /// # Function Parameters
495 ///
496 /// * `hSession`: the session's handle
497 /// * `pData`: the data to sign
498 /// * `ulDataLen`: count of bytes to sign
499 /// * `pSignature`: gets the signature
500 /// * `pulSignatureLen`: gets signature length
501 ///
502 pub type C_SignRecover = extern "C" fn(hSession: CK_SESSION_HANDLE, pData: CK_BYTE_PTR, ulDataLen: CK_ULONG, pSignature: CK_BYTE_PTR, pulSignatureLen: CK_ULONG_PTR) -> CK_RV;
503 
504 /// `C_VerifyInit` initializes a verification operation, where the signature is an appendix to the data, and plaintext cannot cannot be recovered from the signature (e.g. DSA).
505 ///
506 /// # Function Parameters
507 ///
508 /// * `hSession`: the session's handle
509 /// * `pMechanism`: the verification mechanism
510 /// * `hKey`: verification key
511 ///
512 pub type C_VerifyInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR, hKey: CK_OBJECT_HANDLE) -> CK_RV;
513 
514 /// `C_Verify` verifies a signature in a single-part operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature.
515 ///
516 /// # Function Parameters
517 ///
518 /// * `hSession`: the session's handle
519 /// * `pData`: signed data
520 /// * `ulDataLen`: length of signed data
521 /// * `pSignature`: signature
522 /// * `ulSignatureLen`: signature length
523 ///
524 pub type C_Verify = extern "C" fn(hSession: CK_SESSION_HANDLE, pData: CK_BYTE_PTR, ulDataLen: CK_ULONG, pSignature: CK_BYTE_PTR, ulSignatureLen: CK_ULONG) -> CK_RV;
525 
526 /// `C_VerifyUpdate` continues a multiple-part verification operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature.
527 ///
528 /// # Function Parameters
529 ///
530 /// * `hSession`: the session's handle
531 /// * `pPart`: signed data
532 /// * `ulPartLen`: length of signed data
533 ///
534 pub type C_VerifyUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pPart: CK_BYTE_PTR, ulPartLen: CK_ULONG) -> CK_RV;
535 
536 /// `C_VerifyFinal` finishes a multiple-part verification operation, checking the signature.
537 ///
538 /// # Function Parameters
539 ///
540 /// * `hSession`: the session's handle
541 /// * `pSignature`: signature to verify
542 /// * `ulSignatureLen`: signature length
543 ///
544 pub type C_VerifyFinal = extern "C" fn(hSession: CK_SESSION_HANDLE, pSignature: CK_BYTE_PTR, ulSignatureLen: CK_ULONG) -> CK_RV;
545 
546 /// `C_VerifyRecoverInit` initializes a signature verification operation, where the data is recovered from the signature.
547 ///
548 /// # Function Parameters
549 ///
550 /// * `hSession`: the session's handle
551 /// * `pMechanism`: the verification mechanism
552 /// * `hKey`: verification key
553 ///
554 pub type C_VerifyRecoverInit = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR, hKey: CK_OBJECT_HANDLE) -> CK_RV;
555 
556 /// `C_VerifyRecover` verifies a signature in a single-part operation, where the data is recovered from the signature.
557 ///
558 /// # Function Parameters
559 ///
560 /// * `hSession`: the session's handle
561 /// * `pSignature`: signature to verify
562 /// * `ulSignatureLen`: signature length
563 /// * `pData`: gets signed data
564 /// * `pulDataLen`: gets signed data len
565 ///
566 pub type C_VerifyRecover = extern "C" fn(hSession: CK_SESSION_HANDLE, pSignature: CK_BYTE_PTR, ulSignatureLen: CK_ULONG, pData: CK_BYTE_PTR, pulDataLen: CK_ULONG_PTR) -> CK_RV;
567 
568 /// `C_DigestEncryptUpdate` continues a multiple-part digesting and encryption operation.
569 ///
570 /// # Function Parameters
571 ///
572 /// * `hSession`: session's handle
573 /// * `pPart`: the plaintext data
574 /// * `ulPartLen`: plaintext length
575 /// * `pEncryptedPart`: gets ciphertext
576 /// * `pulEncryptedPartLen`: gets c-text length
577 ///
578 pub type C_DigestEncryptUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pPart: CK_BYTE_PTR, ulPartLen: CK_ULONG, pEncryptedPart: CK_BYTE_PTR, pulEncryptedPartLen: CK_ULONG_PTR) -> CK_RV;
579 
580 /// `C_DecryptDigestUpdate` continues a multiple-part decryption and digesting operation.
581 ///
582 /// # Function Parameters
583 ///
584 /// * `hSession`: session's handle
585 /// * `pEncryptedPart`: ciphertext
586 /// * `ulEncryptedPartLen`: ciphertext length
587 /// * `pPart:`: gets plaintext
588 /// * `pulPartLen`: gets plaintext len
589 ///
590 pub type C_DecryptDigestUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pEncryptedPart: CK_BYTE_PTR, ulEncryptedPartLen: CK_ULONG, pPart: CK_BYTE_PTR, pulPartLen: CK_ULONG_PTR) -> CK_RV;
591 
592 /// `C_SignEncryptUpdate` continues a multiple-part signing and encryption operation.
593 ///
594 /// # Function Parameters
595 ///
596 /// * `hSession`: session's handle
597 /// * `pPart`: the plaintext data
598 /// * `ulPartLen`: plaintext length
599 /// * `pEncryptedPart`: gets ciphertext
600 /// * `pulEncryptedPartLen`: gets c-text length
601 ///
602 pub type C_SignEncryptUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pPart: CK_BYTE_PTR, ulPartLen: CK_ULONG, pEncryptedPart: CK_BYTE_PTR, pulEncryptedPartLen: CK_ULONG_PTR) -> CK_RV;
603 
604 /// `C_DecryptVerifyUpdate` continues a multiple-part decryption and verify operation.
605 ///
606 /// # Function Parameters
607 ///
608 /// * `hSession`: session's handle
609 /// * `pEncryptedPart`: ciphertext
610 /// * `ulEncryptedPartLen`: ciphertext length
611 /// * `pPart`: gets plaintext
612 /// * `pulPartLen`: gets p-text length
613 ///
614 pub type C_DecryptVerifyUpdate = extern "C" fn(hSession: CK_SESSION_HANDLE, pEncryptedPart: CK_BYTE_PTR, ulEncryptedPartLen: CK_ULONG, pPart: CK_BYTE_PTR, pulPartLen: CK_ULONG_PTR) -> CK_RV;
615 
616 /// `C_GenerateKey` generates a secret key, creating a new key object.
617 ///
618 /// # Function Parameters
619 ///
620 /// * `hSession`: the session's handle
621 /// * `pMechanism`: key generation mech.
622 /// * `pTemplate`: template for new key
623 /// * `ulCount`: # of attrs in template
624 /// * `phKey`: gets handle of new key
625 ///
626 pub type C_GenerateKey = extern "C" fn(hSession: CK_SESSION_HANDLE, pMechanism: CK_MECHANISM_PTR, pTemplate: CK_ATTRIBUTE_PTR, ulCount: CK_ULONG, phKey: CK_OBJECT_HANDLE_PTR) -> CK_RV;
627 
628 /// `C_GenerateKeyPair` generates a public-key/private-key pair, creating new key objects.
629 ///
630 /// # Function Parameters
631 ///
632 /// * `hSession`: session handle
633 /// * `pMechanism`: key-gen mech.
634 /// * `pPublicKeyTemplate`: template for pub. key
635 /// * `ulPublicKeyAttributeCount`: # pub. attrs.
636 /// * `pPrivateKeyTemplate`: template for priv. key
637 /// * `ulPrivateKeyAttributeCount`: # priv.  attrs.
638 /// * `phPublicKey`: gets pub. key handle
639 /// * `phPrivateKey`: gets priv. key handle
640 ///
641 pub type C_GenerateKeyPair = extern "C" fn(
642   hSession: CK_SESSION_HANDLE,
643   pMechanism: CK_MECHANISM_PTR,
644   pPublicKeyTemplate: CK_ATTRIBUTE_PTR,
645   ulPublicKeyAttributeCount: CK_ULONG,
646   pPrivateKeyTemplate: CK_ATTRIBUTE_PTR,
647   ulPrivateKeyAttributeCount: CK_ULONG,
648   phPublicKey: CK_OBJECT_HANDLE_PTR,
649   phPrivateKey: CK_OBJECT_HANDLE_PTR,
650 ) -> CK_RV;
651 
652 /// `C_WrapKey` wraps (i.e., encrypts) a key.
653 ///
654 /// # Function Parameters
655 ///
656 /// * `hSession`: the session's handle
657 /// * `pMechanism`: the wrapping mechanism
658 /// * `hWrappingKey`: wrapping key
659 /// * `hKey`: key to be wrapped
660 /// * `pWrappedKey`: gets wrapped key
661 /// * `pulWrappedKeyLen`: gets wrapped key size
662 ///
663 pub type C_WrapKey = extern "C" fn(
664   hSession: CK_SESSION_HANDLE,
665   pMechanism: CK_MECHANISM_PTR,
666   hWrappingKey: CK_OBJECT_HANDLE,
667   hKey: CK_OBJECT_HANDLE,
668   pWrappedKey: CK_BYTE_PTR,
669   pulWrappedKeyLen: CK_ULONG_PTR,
670 ) -> CK_RV;
671 
672 /// `C_UnwrapKey` unwraps (decrypts) a wrapped key, creating a new key object.
673 ///
674 /// # Function Parameters
675 ///
676 /// * `hSession`: session's handle
677 /// * `pMechanism`: unwrapping mech.
678 /// * `hUnwrappingKey`: unwrapping key
679 /// * `pWrappedKey`: the wrapped key
680 /// * `ulWrappedKeyLen`: wrapped key len
681 /// * `pTemplate`: new key template
682 /// * `ulAttributeCount`: template length
683 /// * `phKey`: gets new handle
684 ///
685 pub type C_UnwrapKey = extern "C" fn(
686   hSession: CK_SESSION_HANDLE,
687   pMechanism: CK_MECHANISM_PTR,
688   hUnwrappingKey: CK_OBJECT_HANDLE,
689   pWrappedKey: CK_BYTE_PTR,
690   ulWrappedKeyLen: CK_ULONG,
691   pTemplate: CK_ATTRIBUTE_PTR,
692   ulAttributeCount: CK_ULONG,
693   phKey: CK_OBJECT_HANDLE_PTR,
694 ) -> CK_RV;
695 
696 /// `C_DeriveKey` derives a key from a base key, creating a new key object.
697 ///
698 /// # Function Parameters
699 ///
700 /// * `hSession`: session's handle
701 /// * `pMechanism`: key deriv. mech.
702 /// * `hBaseKey`: base key
703 /// * `pTemplate`: new key template
704 /// * `ulAttributeCount`: template length
705 /// * `phKey`: gets new handle
706 ///
707 pub type C_DeriveKey = extern "C" fn(
708   hSession: CK_SESSION_HANDLE,
709   pMechanism: CK_MECHANISM_PTR,
710   hBaseKey: CK_OBJECT_HANDLE,
711   pTemplate: CK_ATTRIBUTE_PTR,
712   ulAttributeCount: CK_ULONG,
713   phKey: CK_OBJECT_HANDLE_PTR,
714 ) -> CK_RV;
715 
716 /// `C_SeedRandom` mixes additional seed material into the token's random number generator.
717 ///
718 /// # Function Parameters
719 ///
720 /// * `hSession`: the session's handle
721 /// * `pSeed`: the seed material
722 /// * `ulSeedLen`: length of seed material
723 ///
724 pub type C_SeedRandom = extern "C" fn(hSession: CK_SESSION_HANDLE, pSeed: CK_BYTE_PTR, ulSeedLen: CK_ULONG) -> CK_RV;
725 
726 /// `C_GenerateRandom` generates random data.
727 ///
728 /// # Function Parameters
729 ///
730 /// * `hSession`: the session's handle
731 /// * `RandomData`: receives the random data
732 /// * `ulRandomLen`: # of bytes to generate
733 ///
734 pub type C_GenerateRandom = extern "C" fn(hSession: CK_SESSION_HANDLE, RandomData: CK_BYTE_PTR, ulRandomLen: CK_ULONG) -> CK_RV;
735 
736 /// `C_GetFunctionStatus` is a legacy function; it obtains an updated status of a function running in parallel with an application.
737 ///
738 /// # Function Parameters
739 ///
740 /// * `hSession`: the session's handle
741 ///
742 pub type C_GetFunctionStatus = extern "C" fn(hSession: CK_SESSION_HANDLE) -> CK_RV;
743 
744 /// `C_CancelFunction` is a legacy function; it cancels a function running in parallel.
745 ///
746 /// # Function Parameters
747 ///
748 /// * `hSession`: the session's handle
749 ///
750 pub type C_CancelFunction = extern "C" fn(hSession: CK_SESSION_HANDLE) -> CK_RV;
751 
752 /// `C_WaitForSlotEvent` waits for a slot event (token insertion, removal, etc.) to occur.
753 ///
754 /// # Function Parameters
755 ///
756 /// * `flags`: blocking/nonblocking flag
757 /// * `pSlot`: location that receives the slot ID
758 /// * `pRserved`: reserved.  Should be NULL_PTR
759 ///
760 pub type C_WaitForSlotEvent = extern "C" fn(flags: CK_FLAGS, pSlot: CK_SLOT_ID_PTR, pRserved: CK_VOID_PTR) -> CK_RV;
761