1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 /*
5  * Copyright (C) 1994-1999 RSA Security Inc. Licence to copy this document
6  * is granted provided that it is identified as "RSA Security In.c Public-Key
7  * Cryptography Standards (PKCS)" in all material mentioning or referencing
8  * this document.
9  */
10 /* This function contains pretty much everything about all the */
11 /* PKCS #11  function prototypes.  Because this information is */
12 /* used for more than just declaring function prototypes, the */
13 /* order of the functions appearing herein is important, and */
14 /* should not be altered. */
15 
16 /* General-purpose */
17 
18 /* C_Initialize initializes the PKCS #11 library. */
19 CK_PKCS11_FUNCTION_INFO(C_Initialize)
20 #ifdef CK_NEED_ARG_LIST
21 (
22     CK_VOID_PTR pInitArgs /* if this is not NULL_PTR, it gets
23                            * cast to CK_C_INITIALIZE_ARGS_PTR
24                            * and dereferenced */
25     );
26 #endif
27 
28 /* C_Finalize indicates that an application is done with the
29  * PKCS #11 library. */
30 CK_PKCS11_FUNCTION_INFO(C_Finalize)
31 #ifdef CK_NEED_ARG_LIST
32 (
33     CK_VOID_PTR pReserved /* reserved.  Should be NULL_PTR */
34     );
35 #endif
36 
37 /* C_GetInfo returns general information about PKCS #11. */
38 CK_PKCS11_FUNCTION_INFO(C_GetInfo)
39 #ifdef CK_NEED_ARG_LIST
40 (
41     CK_INFO_PTR pInfo /* location that receives information */
42     );
43 #endif
44 
45 /* C_GetFunctionList returns the function list. */
46 CK_PKCS11_FUNCTION_INFO(C_GetFunctionList)
47 #ifdef CK_NEED_ARG_LIST
48 (
49     CK_FUNCTION_LIST_PTR_PTR ppFunctionList /* receives pointer to
50                                              * function list */
51     );
52 #endif
53 
54 /* Slot and token management */
55 
56 /* C_GetSlotList obtains a list of slots in the system. */
57 CK_PKCS11_FUNCTION_INFO(C_GetSlotList)
58 #ifdef CK_NEED_ARG_LIST
59 (
60     CK_BBOOL tokenPresent,    /* only slots with tokens? */
61     CK_SLOT_ID_PTR pSlotList, /* receives array of slot IDs */
62     CK_ULONG_PTR pulCount     /* receives number of slots */
63     );
64 #endif
65 
66 /* C_GetSlotInfo obtains information about a particular slot in
67  * the system. */
68 CK_PKCS11_FUNCTION_INFO(C_GetSlotInfo)
69 #ifdef CK_NEED_ARG_LIST
70 (
71     CK_SLOT_ID slotID,     /* the ID of the slot */
72     CK_SLOT_INFO_PTR pInfo /* receives the slot information */
73     );
74 #endif
75 
76 /* C_GetTokenInfo obtains information about a particular token
77  * in the system. */
78 CK_PKCS11_FUNCTION_INFO(C_GetTokenInfo)
79 #ifdef CK_NEED_ARG_LIST
80 (
81     CK_SLOT_ID slotID,      /* ID of the token's slot */
82     CK_TOKEN_INFO_PTR pInfo /* receives the token information */
83     );
84 #endif
85 
86 /* C_GetMechanismList obtains a list of mechanism types
87  * supported by a token. */
88 CK_PKCS11_FUNCTION_INFO(C_GetMechanismList)
89 #ifdef CK_NEED_ARG_LIST
90 (
91     CK_SLOT_ID slotID,                    /* ID of token's slot */
92     CK_MECHANISM_TYPE_PTR pMechanismList, /* gets mech. array */
93     CK_ULONG_PTR pulCount                 /* gets # of mechs. */
94     );
95 #endif
96 
97 /* C_GetMechanismInfo obtains information about a particular
98  * mechanism possibly supported by a token. */
99 CK_PKCS11_FUNCTION_INFO(C_GetMechanismInfo)
100 #ifdef CK_NEED_ARG_LIST
101 (
102     CK_SLOT_ID slotID,          /* ID of the token's slot */
103     CK_MECHANISM_TYPE type,     /* type of mechanism */
104     CK_MECHANISM_INFO_PTR pInfo /* receives mechanism info */
105     );
106 #endif
107 
108 /* C_InitToken initializes a token. */
109 CK_PKCS11_FUNCTION_INFO(C_InitToken)
110 #ifdef CK_NEED_ARG_LIST
111 /* pLabel changed from CK_CHAR_PTR to CK_UTF8CHAR_PTR for v2.10 */
112 (
113     CK_SLOT_ID slotID,     /* ID of the token's slot */
114     CK_UTF8CHAR_PTR pPin,  /* the SO's initial PIN */
115     CK_ULONG ulPinLen,     /* length in bytes of the PIN */
116     CK_UTF8CHAR_PTR pLabel /* 32-byte token label (blank padded) */
117     );
118 #endif
119 
120 /* C_InitPIN initializes the normal user's PIN. */
121 CK_PKCS11_FUNCTION_INFO(C_InitPIN)
122 #ifdef CK_NEED_ARG_LIST
123 (
124     CK_SESSION_HANDLE hSession, /* the session's handle */
125     CK_UTF8CHAR_PTR pPin,       /* the normal user's PIN */
126     CK_ULONG ulPinLen           /* length in bytes of the PIN */
127     );
128 #endif
129 
130 /* C_SetPIN modifies the PIN of the user who is logged in. */
131 CK_PKCS11_FUNCTION_INFO(C_SetPIN)
132 #ifdef CK_NEED_ARG_LIST
133 (
134     CK_SESSION_HANDLE hSession, /* the session's handle */
135     CK_UTF8CHAR_PTR pOldPin,    /* the old PIN */
136     CK_ULONG ulOldLen,          /* length of the old PIN */
137     CK_UTF8CHAR_PTR pNewPin,    /* the new PIN */
138     CK_ULONG ulNewLen           /* length of the new PIN */
139     );
140 #endif
141 
142 /* Session management */
143 
144 /* C_OpenSession opens a session between an application and a
145  * token. */
146 CK_PKCS11_FUNCTION_INFO(C_OpenSession)
147 #ifdef CK_NEED_ARG_LIST
148 (
149     CK_SLOT_ID slotID,              /* the slot's ID */
150     CK_FLAGS flags,                 /* from CK_SESSION_INFO */
151     CK_VOID_PTR pApplication,       /* passed to callback */
152     CK_NOTIFY Notify,               /* callback function */
153     CK_SESSION_HANDLE_PTR phSession /* gets session handle */
154     );
155 #endif
156 
157 /* C_CloseSession closes a session between an application and a
158  * token. */
159 CK_PKCS11_FUNCTION_INFO(C_CloseSession)
160 #ifdef CK_NEED_ARG_LIST
161 (
162     CK_SESSION_HANDLE hSession /* the session's handle */
163     );
164 #endif
165 
166 /* C_CloseAllSessions closes all sessions with a token. */
167 CK_PKCS11_FUNCTION_INFO(C_CloseAllSessions)
168 #ifdef CK_NEED_ARG_LIST
169 (
170     CK_SLOT_ID slotID /* the token's slot */
171     );
172 #endif
173 
174 /* C_GetSessionInfo obtains information about the session. */
175 CK_PKCS11_FUNCTION_INFO(C_GetSessionInfo)
176 #ifdef CK_NEED_ARG_LIST
177 (
178     CK_SESSION_HANDLE hSession, /* the session's handle */
179     CK_SESSION_INFO_PTR pInfo   /* receives session info */
180     );
181 #endif
182 
183 /* C_GetOperationState obtains the state of the cryptographic operation
184  * in a session. */
185 CK_PKCS11_FUNCTION_INFO(C_GetOperationState)
186 #ifdef CK_NEED_ARG_LIST
187 (
188     CK_SESSION_HANDLE hSession,       /* session's handle */
189     CK_BYTE_PTR pOperationState,      /* gets state */
190     CK_ULONG_PTR pulOperationStateLen /* gets state length */
191     );
192 #endif
193 
194 /* C_SetOperationState restores the state of the cryptographic
195  * operation in a session. */
196 CK_PKCS11_FUNCTION_INFO(C_SetOperationState)
197 #ifdef CK_NEED_ARG_LIST
198 (
199     CK_SESSION_HANDLE hSession,         /* session's handle */
200     CK_BYTE_PTR pOperationState,        /* holds state */
201     CK_ULONG ulOperationStateLen,       /* holds state length */
202     CK_OBJECT_HANDLE hEncryptionKey,    /* en/decryption key */
203     CK_OBJECT_HANDLE hAuthenticationKey /* sign/verify key */
204     );
205 #endif
206 
207 /* C_Login logs a user into a token. */
208 CK_PKCS11_FUNCTION_INFO(C_Login)
209 #ifdef CK_NEED_ARG_LIST
210 (
211     CK_SESSION_HANDLE hSession, /* the session's handle */
212     CK_USER_TYPE userType,      /* the user type */
213     CK_UTF8CHAR_PTR pPin,       /* the user's PIN */
214     CK_ULONG ulPinLen           /* the length of the PIN */
215     );
216 #endif
217 
218 /* C_Logout logs a user out from a token. */
219 CK_PKCS11_FUNCTION_INFO(C_Logout)
220 #ifdef CK_NEED_ARG_LIST
221 (
222     CK_SESSION_HANDLE hSession /* the session's handle */
223     );
224 #endif
225 
226 /* Object management */
227 
228 /* C_CreateObject creates a new object. */
229 CK_PKCS11_FUNCTION_INFO(C_CreateObject)
230 #ifdef CK_NEED_ARG_LIST
231 (
232     CK_SESSION_HANDLE hSession,   /* the session's handle */
233     CK_ATTRIBUTE_PTR pTemplate,   /* the object's template */
234     CK_ULONG ulCount,             /* attributes in template */
235     CK_OBJECT_HANDLE_PTR phObject /* gets new object's handle. */
236     );
237 #endif
238 
239 /* C_CopyObject copies an object, creating a new object for the
240  * copy. */
241 CK_PKCS11_FUNCTION_INFO(C_CopyObject)
242 #ifdef CK_NEED_ARG_LIST
243 (
244     CK_SESSION_HANDLE hSession,      /* the session's handle */
245     CK_OBJECT_HANDLE hObject,        /* the object's handle */
246     CK_ATTRIBUTE_PTR pTemplate,      /* template for new object */
247     CK_ULONG ulCount,                /* attributes in template */
248     CK_OBJECT_HANDLE_PTR phNewObject /* receives handle of copy */
249     );
250 #endif
251 
252 /* C_DestroyObject destroys an object. */
253 CK_PKCS11_FUNCTION_INFO(C_DestroyObject)
254 #ifdef CK_NEED_ARG_LIST
255 (
256     CK_SESSION_HANDLE hSession, /* the session's handle */
257     CK_OBJECT_HANDLE hObject    /* the object's handle */
258     );
259 #endif
260 
261 /* C_GetObjectSize gets the size of an object in bytes. */
262 CK_PKCS11_FUNCTION_INFO(C_GetObjectSize)
263 #ifdef CK_NEED_ARG_LIST
264 (
265     CK_SESSION_HANDLE hSession, /* the session's handle */
266     CK_OBJECT_HANDLE hObject,   /* the object's handle */
267     CK_ULONG_PTR pulSize        /* receives size of object */
268     );
269 #endif
270 
271 /* C_GetAttributeValue obtains the value of one or more object
272  * attributes. */
273 CK_PKCS11_FUNCTION_INFO(C_GetAttributeValue)
274 #ifdef CK_NEED_ARG_LIST
275 (
276     CK_SESSION_HANDLE hSession, /* the session's handle */
277     CK_OBJECT_HANDLE hObject,   /* the object's handle */
278     CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs; gets vals */
279     CK_ULONG ulCount            /* attributes in template */
280     );
281 #endif
282 
283 /* C_SetAttributeValue modifies the value of one or more object
284  * attributes */
285 CK_PKCS11_FUNCTION_INFO(C_SetAttributeValue)
286 #ifdef CK_NEED_ARG_LIST
287 (
288     CK_SESSION_HANDLE hSession, /* the session's handle */
289     CK_OBJECT_HANDLE hObject,   /* the object's handle */
290     CK_ATTRIBUTE_PTR pTemplate, /* specifies attrs and values */
291     CK_ULONG ulCount            /* attributes in template */
292     );
293 #endif
294 
295 /* C_FindObjectsInit initializes a search for token and session
296  * objects that match a template. */
297 CK_PKCS11_FUNCTION_INFO(C_FindObjectsInit)
298 #ifdef CK_NEED_ARG_LIST
299 (
300     CK_SESSION_HANDLE hSession, /* the session's handle */
301     CK_ATTRIBUTE_PTR pTemplate, /* attribute values to match */
302     CK_ULONG ulCount            /* attrs in search template */
303     );
304 #endif
305 
306 /* C_FindObjects continues a search for token and session
307  * objects that match a template, obtaining additional object
308  * handles. */
309 CK_PKCS11_FUNCTION_INFO(C_FindObjects)
310 #ifdef CK_NEED_ARG_LIST
311 (
312     CK_SESSION_HANDLE hSession,    /* session's handle */
313     CK_OBJECT_HANDLE_PTR phObject, /* gets obj. handles */
314     CK_ULONG ulMaxObjectCount,     /* max handles to get */
315     CK_ULONG_PTR pulObjectCount    /* actual # returned */
316     );
317 #endif
318 
319 /* C_FindObjectsFinal finishes a search for token and session
320  * objects. */
321 CK_PKCS11_FUNCTION_INFO(C_FindObjectsFinal)
322 #ifdef CK_NEED_ARG_LIST
323 (
324     CK_SESSION_HANDLE hSession /* the session's handle */
325     );
326 #endif
327 
328 /* Encryption and decryption */
329 
330 /* C_EncryptInit initializes an encryption operation. */
331 CK_PKCS11_FUNCTION_INFO(C_EncryptInit)
332 #ifdef CK_NEED_ARG_LIST
333 (
334     CK_SESSION_HANDLE hSession,  /* the session's handle */
335     CK_MECHANISM_PTR pMechanism, /* the encryption mechanism */
336     CK_OBJECT_HANDLE hKey        /* handle of encryption key */
337     );
338 #endif
339 
340 /* C_Encrypt encrypts single-part data. */
341 CK_PKCS11_FUNCTION_INFO(C_Encrypt)
342 #ifdef CK_NEED_ARG_LIST
343 (
344     CK_SESSION_HANDLE hSession,      /* session's handle */
345     CK_BYTE_PTR pData,               /* the plaintext data */
346     CK_ULONG ulDataLen,              /* bytes of plaintext */
347     CK_BYTE_PTR pEncryptedData,      /* gets ciphertext */
348     CK_ULONG_PTR pulEncryptedDataLen /* gets c-text size */
349     );
350 #endif
351 
352 /* C_EncryptUpdate continues a multiple-part encryption
353  * operation. */
354 CK_PKCS11_FUNCTION_INFO(C_EncryptUpdate)
355 #ifdef CK_NEED_ARG_LIST
356 (
357     CK_SESSION_HANDLE hSession,      /* session's handle */
358     CK_BYTE_PTR pPart,               /* the plaintext data */
359     CK_ULONG ulPartLen,              /* plaintext data len */
360     CK_BYTE_PTR pEncryptedPart,      /* gets ciphertext */
361     CK_ULONG_PTR pulEncryptedPartLen /* gets c-text size */
362     );
363 #endif
364 
365 /* C_EncryptFinal finishes a multiple-part encryption
366  * operation. */
367 CK_PKCS11_FUNCTION_INFO(C_EncryptFinal)
368 #ifdef CK_NEED_ARG_LIST
369 (
370     CK_SESSION_HANDLE hSession,          /* session handle */
371     CK_BYTE_PTR pLastEncryptedPart,      /* last c-text */
372     CK_ULONG_PTR pulLastEncryptedPartLen /* gets last size */
373     );
374 #endif
375 
376 /* C_DecryptInit initializes a decryption operation. */
377 CK_PKCS11_FUNCTION_INFO(C_DecryptInit)
378 #ifdef CK_NEED_ARG_LIST
379 (
380     CK_SESSION_HANDLE hSession,  /* the session's handle */
381     CK_MECHANISM_PTR pMechanism, /* the decryption mechanism */
382     CK_OBJECT_HANDLE hKey        /* handle of decryption key */
383     );
384 #endif
385 
386 /* C_Decrypt decrypts encrypted data in a single part. */
387 CK_PKCS11_FUNCTION_INFO(C_Decrypt)
388 #ifdef CK_NEED_ARG_LIST
389 (
390     CK_SESSION_HANDLE hSession,  /* session's handle */
391     CK_BYTE_PTR pEncryptedData,  /* ciphertext */
392     CK_ULONG ulEncryptedDataLen, /* ciphertext length */
393     CK_BYTE_PTR pData,           /* gets plaintext */
394     CK_ULONG_PTR pulDataLen      /* gets p-text size */
395     );
396 #endif
397 
398 /* C_DecryptUpdate continues a multiple-part decryption
399  * operation. */
400 CK_PKCS11_FUNCTION_INFO(C_DecryptUpdate)
401 #ifdef CK_NEED_ARG_LIST
402 (
403     CK_SESSION_HANDLE hSession,  /* session's handle */
404     CK_BYTE_PTR pEncryptedPart,  /* encrypted data */
405     CK_ULONG ulEncryptedPartLen, /* input length */
406     CK_BYTE_PTR pPart,           /* gets plaintext */
407     CK_ULONG_PTR pulPartLen      /* p-text size */
408     );
409 #endif
410 
411 /* C_DecryptFinal finishes a multiple-part decryption
412  * operation. */
413 CK_PKCS11_FUNCTION_INFO(C_DecryptFinal)
414 #ifdef CK_NEED_ARG_LIST
415 (
416     CK_SESSION_HANDLE hSession, /* the session's handle */
417     CK_BYTE_PTR pLastPart,      /* gets plaintext */
418     CK_ULONG_PTR pulLastPartLen /* p-text size */
419     );
420 #endif
421 
422 /* Message digesting */
423 
424 /* C_DigestInit initializes a message-digesting operation. */
425 CK_PKCS11_FUNCTION_INFO(C_DigestInit)
426 #ifdef CK_NEED_ARG_LIST
427 (
428     CK_SESSION_HANDLE hSession, /* the session's handle */
429     CK_MECHANISM_PTR pMechanism /* the digesting mechanism */
430     );
431 #endif
432 
433 /* C_Digest digests data in a single part. */
434 CK_PKCS11_FUNCTION_INFO(C_Digest)
435 #ifdef CK_NEED_ARG_LIST
436 (
437     CK_SESSION_HANDLE hSession, /* the session's handle */
438     CK_BYTE_PTR pData,          /* data to be digested */
439     CK_ULONG ulDataLen,         /* bytes of data to digest */
440     CK_BYTE_PTR pDigest,        /* gets the message digest */
441     CK_ULONG_PTR pulDigestLen   /* gets digest length */
442     );
443 #endif
444 
445 /* C_DigestUpdate continues a multiple-part message-digesting
446  * operation. */
447 CK_PKCS11_FUNCTION_INFO(C_DigestUpdate)
448 #ifdef CK_NEED_ARG_LIST
449 (
450     CK_SESSION_HANDLE hSession, /* the session's handle */
451     CK_BYTE_PTR pPart,          /* data to be digested */
452     CK_ULONG ulPartLen          /* bytes of data to be digested */
453     );
454 #endif
455 
456 /* C_DigestKey continues a multi-part message-digesting
457  * operation, by digesting the value of a secret key as part of
458  * the data already digested. */
459 CK_PKCS11_FUNCTION_INFO(C_DigestKey)
460 #ifdef CK_NEED_ARG_LIST
461 (
462     CK_SESSION_HANDLE hSession, /* the session's handle */
463     CK_OBJECT_HANDLE hKey       /* secret key to digest */
464     );
465 #endif
466 
467 /* C_DigestFinal finishes a multiple-part message-digesting
468  * operation. */
469 CK_PKCS11_FUNCTION_INFO(C_DigestFinal)
470 #ifdef CK_NEED_ARG_LIST
471 (
472     CK_SESSION_HANDLE hSession, /* the session's handle */
473     CK_BYTE_PTR pDigest,        /* gets the message digest */
474     CK_ULONG_PTR pulDigestLen   /* gets byte count of digest */
475     );
476 #endif
477 
478 /* Signing and MACing */
479 
480 /* C_SignInit initializes a signature (private key encryption)
481  * operation, where the signature is (will be) an appendix to
482  * the data, and plaintext cannot be recovered from the
483  *signature. */
484 CK_PKCS11_FUNCTION_INFO(C_SignInit)
485 #ifdef CK_NEED_ARG_LIST
486 (
487     CK_SESSION_HANDLE hSession,  /* the session's handle */
488     CK_MECHANISM_PTR pMechanism, /* the signature mechanism */
489     CK_OBJECT_HANDLE hKey        /* handle of signature key */
490     );
491 #endif
492 
493 /* C_Sign signs (encrypts with private key) data in a single
494  * part, where the signature is (will be) an appendix to the
495  * data, and plaintext cannot be recovered from the signature. */
496 CK_PKCS11_FUNCTION_INFO(C_Sign)
497 #ifdef CK_NEED_ARG_LIST
498 (
499     CK_SESSION_HANDLE hSession,  /* the session's handle */
500     CK_BYTE_PTR pData,           /* the data to sign */
501     CK_ULONG ulDataLen,          /* count of bytes to sign */
502     CK_BYTE_PTR pSignature,      /* gets the signature */
503     CK_ULONG_PTR pulSignatureLen /* gets signature length */
504     );
505 #endif
506 
507 /* C_SignUpdate continues a multiple-part signature operation,
508  * where the signature is (will be) an appendix to the data,
509  * and plaintext cannot be recovered from the signature. */
510 CK_PKCS11_FUNCTION_INFO(C_SignUpdate)
511 #ifdef CK_NEED_ARG_LIST
512 (
513     CK_SESSION_HANDLE hSession, /* the session's handle */
514     CK_BYTE_PTR pPart,          /* the data to sign */
515     CK_ULONG ulPartLen          /* count of bytes to sign */
516     );
517 #endif
518 
519 /* C_SignFinal finishes a multiple-part signature operation,
520  * returning the signature. */
521 CK_PKCS11_FUNCTION_INFO(C_SignFinal)
522 #ifdef CK_NEED_ARG_LIST
523 (
524     CK_SESSION_HANDLE hSession,  /* the session's handle */
525     CK_BYTE_PTR pSignature,      /* gets the signature */
526     CK_ULONG_PTR pulSignatureLen /* gets signature length */
527     );
528 #endif
529 
530 /* C_SignRecoverInit initializes a signature operation, where
531  * the data can be recovered from the signature. */
532 CK_PKCS11_FUNCTION_INFO(C_SignRecoverInit)
533 #ifdef CK_NEED_ARG_LIST
534 (
535     CK_SESSION_HANDLE hSession,  /* the session's handle */
536     CK_MECHANISM_PTR pMechanism, /* the signature mechanism */
537     CK_OBJECT_HANDLE hKey        /* handle of the signature key */
538     );
539 #endif
540 
541 /* C_SignRecover signs data in a single operation, where the
542  * data can be recovered from the signature. */
543 CK_PKCS11_FUNCTION_INFO(C_SignRecover)
544 #ifdef CK_NEED_ARG_LIST
545 (
546     CK_SESSION_HANDLE hSession,  /* the session's handle */
547     CK_BYTE_PTR pData,           /* the data to sign */
548     CK_ULONG ulDataLen,          /* count of bytes to sign */
549     CK_BYTE_PTR pSignature,      /* gets the signature */
550     CK_ULONG_PTR pulSignatureLen /* gets signature length */
551     );
552 #endif
553 
554 /* Verifying signatures and MACs */
555 
556 /* C_VerifyInit initializes a verification operation, where the
557  * signature is an appendix to the data, and plaintext cannot
558  *  cannot be recovered from the signature (e.g. DSA). */
559 CK_PKCS11_FUNCTION_INFO(C_VerifyInit)
560 #ifdef CK_NEED_ARG_LIST
561 (
562     CK_SESSION_HANDLE hSession,  /* the session's handle */
563     CK_MECHANISM_PTR pMechanism, /* the verification mechanism */
564     CK_OBJECT_HANDLE hKey        /* verification key */
565     );
566 #endif
567 
568 /* C_Verify verifies a signature in a single-part operation,
569  * where the signature is an appendix to the data, and plaintext
570  * cannot be recovered from the signature. */
571 CK_PKCS11_FUNCTION_INFO(C_Verify)
572 #ifdef CK_NEED_ARG_LIST
573 (
574     CK_SESSION_HANDLE hSession, /* the session's handle */
575     CK_BYTE_PTR pData,          /* signed data */
576     CK_ULONG ulDataLen,         /* length of signed data */
577     CK_BYTE_PTR pSignature,     /* signature */
578     CK_ULONG ulSignatureLen     /* signature length*/
579     );
580 #endif
581 
582 /* C_VerifyUpdate continues a multiple-part verification
583  * operation, where the signature is an appendix to the data,
584  * and plaintext cannot be recovered from the signature. */
585 CK_PKCS11_FUNCTION_INFO(C_VerifyUpdate)
586 #ifdef CK_NEED_ARG_LIST
587 (
588     CK_SESSION_HANDLE hSession, /* the session's handle */
589     CK_BYTE_PTR pPart,          /* signed data */
590     CK_ULONG ulPartLen          /* length of signed data */
591     );
592 #endif
593 
594 /* C_VerifyFinal finishes a multiple-part verification
595  * operation, checking the signature. */
596 CK_PKCS11_FUNCTION_INFO(C_VerifyFinal)
597 #ifdef CK_NEED_ARG_LIST
598 (
599     CK_SESSION_HANDLE hSession, /* the session's handle */
600     CK_BYTE_PTR pSignature,     /* signature to verify */
601     CK_ULONG ulSignatureLen     /* signature length */
602     );
603 #endif
604 
605 /* C_VerifyRecoverInit initializes a signature verification
606  * operation, where the data is recovered from the signature. */
607 CK_PKCS11_FUNCTION_INFO(C_VerifyRecoverInit)
608 #ifdef CK_NEED_ARG_LIST
609 (
610     CK_SESSION_HANDLE hSession,  /* the session's handle */
611     CK_MECHANISM_PTR pMechanism, /* the verification mechanism */
612     CK_OBJECT_HANDLE hKey        /* verification key */
613     );
614 #endif
615 
616 /* C_VerifyRecover verifies a signature in a single-part
617  * operation, where the data is recovered from the signature. */
618 CK_PKCS11_FUNCTION_INFO(C_VerifyRecover)
619 #ifdef CK_NEED_ARG_LIST
620 (
621     CK_SESSION_HANDLE hSession, /* the session's handle */
622     CK_BYTE_PTR pSignature,     /* signature to verify */
623     CK_ULONG ulSignatureLen,    /* signature length */
624     CK_BYTE_PTR pData,          /* gets signed data */
625     CK_ULONG_PTR pulDataLen     /* gets signed data len */
626     );
627 #endif
628 
629 /* Dual-function cryptographic operations */
630 
631 /* C_DigestEncryptUpdate continues a multiple-part digesting
632  * and encryption operation. */
633 CK_PKCS11_FUNCTION_INFO(C_DigestEncryptUpdate)
634 #ifdef CK_NEED_ARG_LIST
635 (
636     CK_SESSION_HANDLE hSession,      /* session's handle */
637     CK_BYTE_PTR pPart,               /* the plaintext data */
638     CK_ULONG ulPartLen,              /* plaintext length */
639     CK_BYTE_PTR pEncryptedPart,      /* gets ciphertext */
640     CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */
641     );
642 #endif
643 
644 /* C_DecryptDigestUpdate continues a multiple-part decryption and
645  * digesting operation. */
646 CK_PKCS11_FUNCTION_INFO(C_DecryptDigestUpdate)
647 #ifdef CK_NEED_ARG_LIST
648 (
649     CK_SESSION_HANDLE hSession,  /* session's handle */
650     CK_BYTE_PTR pEncryptedPart,  /* ciphertext */
651     CK_ULONG ulEncryptedPartLen, /* ciphertext length */
652     CK_BYTE_PTR pPart,           /* gets plaintext */
653     CK_ULONG_PTR pulPartLen      /* gets plaintext len */
654     );
655 #endif
656 
657 /* C_SignEncryptUpdate continues a multiple-part signing and
658  * encryption operation. */
659 CK_PKCS11_FUNCTION_INFO(C_SignEncryptUpdate)
660 #ifdef CK_NEED_ARG_LIST
661 (
662     CK_SESSION_HANDLE hSession,      /* session's handle */
663     CK_BYTE_PTR pPart,               /* the plaintext data */
664     CK_ULONG ulPartLen,              /* plaintext length */
665     CK_BYTE_PTR pEncryptedPart,      /* gets ciphertext */
666     CK_ULONG_PTR pulEncryptedPartLen /* gets c-text length */
667     );
668 #endif
669 
670 /* C_DecryptVerifyUpdate continues a multiple-part decryption and
671  * verify operation. */
672 CK_PKCS11_FUNCTION_INFO(C_DecryptVerifyUpdate)
673 #ifdef CK_NEED_ARG_LIST
674 (
675     CK_SESSION_HANDLE hSession,  /* session's handle */
676     CK_BYTE_PTR pEncryptedPart,  /* ciphertext */
677     CK_ULONG ulEncryptedPartLen, /* ciphertext length */
678     CK_BYTE_PTR pPart,           /* gets plaintext */
679     CK_ULONG_PTR pulPartLen      /* gets p-text length */
680     );
681 #endif
682 
683 /* Key management */
684 
685 /* C_GenerateKey generates a secret key, creating a new key
686  * object. */
687 CK_PKCS11_FUNCTION_INFO(C_GenerateKey)
688 #ifdef CK_NEED_ARG_LIST
689 (
690     CK_SESSION_HANDLE hSession,  /* the session's handle */
691     CK_MECHANISM_PTR pMechanism, /* key generation mech. */
692     CK_ATTRIBUTE_PTR pTemplate,  /* template for new key */
693     CK_ULONG ulCount,            /* # of attrs in template */
694     CK_OBJECT_HANDLE_PTR phKey   /* gets handle of new key */
695     );
696 #endif
697 
698 /* C_GenerateKeyPair generates a public-key/private-key pair,
699  * creating new key objects. */
700 CK_PKCS11_FUNCTION_INFO(C_GenerateKeyPair)
701 #ifdef CK_NEED_ARG_LIST
702 (
703     CK_SESSION_HANDLE hSession,           /* session handle */
704     CK_MECHANISM_PTR pMechanism,          /* key-gen mech. */
705     CK_ATTRIBUTE_PTR pPublicKeyTemplate,  /* template for pub. key */
706     CK_ULONG ulPublicKeyAttributeCount,   /* # pub. attrs. */
707     CK_ATTRIBUTE_PTR pPrivateKeyTemplate, /* template for priv. key */
708     CK_ULONG ulPrivateKeyAttributeCount,  /* # priv. attrs. */
709     CK_OBJECT_HANDLE_PTR phPublicKey,     /* gets pub. key handle */
710     CK_OBJECT_HANDLE_PTR phPrivateKey     /* gets priv. key handle */
711     );
712 #endif
713 
714 /* C_WrapKey wraps (i.e., encrypts) a key. */
715 CK_PKCS11_FUNCTION_INFO(C_WrapKey)
716 #ifdef CK_NEED_ARG_LIST
717 (
718     CK_SESSION_HANDLE hSession,    /* the session's handle */
719     CK_MECHANISM_PTR pMechanism,   /* the wrapping mechanism */
720     CK_OBJECT_HANDLE hWrappingKey, /* wrapping key */
721     CK_OBJECT_HANDLE hKey,         /* key to be wrapped */
722     CK_BYTE_PTR pWrappedKey,       /* gets wrapped key */
723     CK_ULONG_PTR pulWrappedKeyLen  /* gets wrapped key size */
724     );
725 #endif
726 
727 /* C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new
728  * key object. */
729 CK_PKCS11_FUNCTION_INFO(C_UnwrapKey)
730 #ifdef CK_NEED_ARG_LIST
731 (
732     CK_SESSION_HANDLE hSession,      /* session's handle */
733     CK_MECHANISM_PTR pMechanism,     /* unwrapping mech. */
734     CK_OBJECT_HANDLE hUnwrappingKey, /* unwrapping key */
735     CK_BYTE_PTR pWrappedKey,         /* the wrapped key */
736     CK_ULONG ulWrappedKeyLen,        /* wrapped key len */
737     CK_ATTRIBUTE_PTR pTemplate,      /* new key template */
738     CK_ULONG ulAttributeCount,       /* template length */
739     CK_OBJECT_HANDLE_PTR phKey       /* gets new handle */
740     );
741 #endif
742 
743 /* C_DeriveKey derives a key from a base key, creating a new key
744  * object. */
745 CK_PKCS11_FUNCTION_INFO(C_DeriveKey)
746 #ifdef CK_NEED_ARG_LIST
747 (
748     CK_SESSION_HANDLE hSession,  /* session's handle */
749     CK_MECHANISM_PTR pMechanism, /* key deriv. mech. */
750     CK_OBJECT_HANDLE hBaseKey,   /* base key */
751     CK_ATTRIBUTE_PTR pTemplate,  /* new key template */
752     CK_ULONG ulAttributeCount,   /* template length */
753     CK_OBJECT_HANDLE_PTR phKey   /* gets new handle */
754     );
755 #endif
756 
757 /* Random number generation */
758 
759 /* C_SeedRandom mixes additional seed material into the token's
760  * random number generator. */
761 CK_PKCS11_FUNCTION_INFO(C_SeedRandom)
762 #ifdef CK_NEED_ARG_LIST
763 (
764     CK_SESSION_HANDLE hSession, /* the session's handle */
765     CK_BYTE_PTR pSeed,          /* the seed material */
766     CK_ULONG ulSeedLen          /* length of seed material */
767     );
768 #endif
769 
770 /* C_GenerateRandom generates random data. */
771 CK_PKCS11_FUNCTION_INFO(C_GenerateRandom)
772 #ifdef CK_NEED_ARG_LIST
773 (
774     CK_SESSION_HANDLE hSession, /* the session's handle */
775     CK_BYTE_PTR RandomData,     /* receives the random data */
776     CK_ULONG ulRandomLen        /* # of bytes to generate */
777     );
778 #endif
779 
780 /* Parallel function management */
781 
782 /* C_GetFunctionStatus is a legacy function; it obtains an
783  * updated status of a function running in parallel with an
784  * application. */
785 CK_PKCS11_FUNCTION_INFO(C_GetFunctionStatus)
786 #ifdef CK_NEED_ARG_LIST
787 (
788     CK_SESSION_HANDLE hSession /* the session's handle */
789     );
790 #endif
791 
792 /* C_CancelFunction is a legacy function; it cancels a function
793  * running in parallel. */
794 CK_PKCS11_FUNCTION_INFO(C_CancelFunction)
795 #ifdef CK_NEED_ARG_LIST
796 (
797     CK_SESSION_HANDLE hSession /* the session's handle */
798     );
799 #endif
800 
801 /* Functions added in for PKCS #11 Version 2.01 or later */
802 
803 /* C_WaitForSlotEvent waits for a slot event (token insertion,
804  * removal, etc.) to occur. */
805 CK_PKCS11_FUNCTION_INFO(C_WaitForSlotEvent)
806 #ifdef CK_NEED_ARG_LIST
807 (
808     CK_FLAGS flags,       /* blocking/nonblocking flag */
809     CK_SLOT_ID_PTR pSlot, /* location that receives the slot ID */
810     CK_VOID_PTR pRserved  /* reserved.  Should be NULL_PTR */
811     );
812 #endif
813 
814 #if defined(CK_PKCS11_3_0) && !defined(CK_PKCS11_2_0_ONLY)
815 CK_PKCS11_FUNCTION_INFO(C_GetInterfaceList)
816 #ifdef CK_NEED_ARG_LIST
817 (
818     CK_INTERFACE_PTR interfaces,
819     CK_ULONG_PTR pulCount);
820 #endif
821 
822 CK_PKCS11_FUNCTION_INFO(C_GetInterface)
823 #ifdef CK_NEED_ARG_LIST
824 (
825     CK_UTF8CHAR_PTR pInterfaceName,
826     CK_VERSION_PTR pVersion,
827     CK_INTERFACE_PTR_PTR ppInterface,
828     CK_FLAGS flags);
829 #endif
830 
831 CK_PKCS11_FUNCTION_INFO(C_LoginUser)
832 #ifdef CK_NEED_ARG_LIST
833 (
834     CK_SESSION_HANDLE hSession,
835     CK_USER_TYPE userType,
836     CK_CHAR_PTR pPin,
837     CK_ULONG ulPinLen,
838     CK_UTF8CHAR_PTR pUsername,
839     CK_ULONG ulUsernameLen);
840 #endif
841 
842 CK_PKCS11_FUNCTION_INFO(C_SessionCancel)
843 #ifdef CK_NEED_ARG_LIST
844 (
845     CK_SESSION_HANDLE hSession,
846     CK_FLAGS flags);
847 #endif
848 
849 CK_PKCS11_FUNCTION_INFO(C_MessageEncryptInit)
850 #ifdef CK_NEED_ARG_LIST
851 (
852     CK_SESSION_HANDLE hSession,
853     CK_MECHANISM_PTR pMechanism,
854     CK_OBJECT_HANDLE hKey);
855 #endif
856 
857 CK_PKCS11_FUNCTION_INFO(C_EncryptMessage)
858 #ifdef CK_NEED_ARG_LIST
859 (
860     CK_SESSION_HANDLE hSession,
861     CK_VOID_PTR pParameter,
862     CK_ULONG ulParameterLen,
863     CK_BYTE_PTR pAssociatedData,
864     CK_ULONG ulAssociatedDataLen,
865     CK_BYTE_PTR pPlaintext,
866     CK_ULONG ulPlaintextLen,
867     CK_BYTE_PTR pCiphertext,
868     CK_ULONG_PTR pulCiphertextLen);
869 #endif
870 
871 CK_PKCS11_FUNCTION_INFO(C_EncryptMessageBegin)
872 #ifdef CK_NEED_ARG_LIST
873 (
874     CK_SESSION_HANDLE hSession,
875     CK_VOID_PTR pParameter,
876     CK_ULONG ulParameterLen,
877     CK_BYTE_PTR pAssociatedData,
878     CK_ULONG ulAssociatedDataLen);
879 #endif
880 
881 CK_PKCS11_FUNCTION_INFO(C_EncryptMessageNext)
882 #ifdef CK_NEED_ARG_LIST
883 (
884     CK_SESSION_HANDLE hSession,
885     CK_VOID_PTR pParameter,
886     CK_ULONG ulParameterLen,
887     CK_BYTE_PTR pPlaintextPart,
888     CK_ULONG ulPlaintextPartLen,
889     CK_BYTE_PTR pCiphertextPart,
890     CK_ULONG_PTR pulCiphertextPartLen,
891     CK_FLAGS flags);
892 #endif
893 
894 CK_PKCS11_FUNCTION_INFO(C_MessageEncryptFinal)
895 #ifdef CK_NEED_ARG_LIST
896 (
897     CK_SESSION_HANDLE hSession);
898 #endif
899 
900 CK_PKCS11_FUNCTION_INFO(C_MessageDecryptInit)
901 #ifdef CK_NEED_ARG_LIST
902 (
903     CK_SESSION_HANDLE hSession,
904     CK_MECHANISM_PTR pMechanism,
905     CK_OBJECT_HANDLE hKey);
906 #endif
907 
908 CK_PKCS11_FUNCTION_INFO(C_DecryptMessage)
909 #ifdef CK_NEED_ARG_LIST
910 (
911     CK_SESSION_HANDLE hSession,
912     CK_VOID_PTR pParameter,
913     CK_ULONG ulParameterLen,
914     CK_BYTE_PTR pAssociatedData,
915     CK_ULONG ulAssociatedDataLen,
916     CK_BYTE_PTR pCiphertext,
917     CK_ULONG ulCiphertextLen,
918     CK_BYTE_PTR pPlaintext,
919     CK_ULONG_PTR pulPlaintextLen);
920 #endif
921 
922 CK_PKCS11_FUNCTION_INFO(C_DecryptMessageBegin)
923 #ifdef CK_NEED_ARG_LIST
924 (
925     CK_SESSION_HANDLE hSession,
926     CK_VOID_PTR pParameter,
927     CK_ULONG ulParameterLen,
928     CK_BYTE_PTR pAssociatedData,
929     CK_ULONG ulAssociatedDataLen);
930 #endif
931 
932 CK_PKCS11_FUNCTION_INFO(C_DecryptMessageNext)
933 #ifdef CK_NEED_ARG_LIST
934 (
935     CK_SESSION_HANDLE hSession,
936     CK_VOID_PTR pParameter,
937     CK_ULONG ulParameterLen,
938     CK_BYTE_PTR pCiphertextPart,
939     CK_ULONG ulCiphertextPartLen,
940     CK_BYTE_PTR pPlaintextPart,
941     CK_ULONG_PTR pulPlaintextPartLen,
942     CK_FLAGS flags);
943 #endif
944 
945 CK_PKCS11_FUNCTION_INFO(C_MessageDecryptFinal)
946 #ifdef CK_NEED_ARG_LIST
947 (
948     CK_SESSION_HANDLE hSession);
949 #endif
950 
951 CK_PKCS11_FUNCTION_INFO(C_MessageSignInit)
952 #ifdef CK_NEED_ARG_LIST
953 (
954     CK_SESSION_HANDLE hSession,
955     CK_MECHANISM_PTR pMechanism,
956     CK_OBJECT_HANDLE hKey);
957 #endif
958 
959 CK_PKCS11_FUNCTION_INFO(C_SignMessage)
960 #ifdef CK_NEED_ARG_LIST
961 (
962     CK_SESSION_HANDLE hSession,
963     CK_VOID_PTR pParameter,
964     CK_ULONG ulParameterLen,
965     CK_BYTE_PTR pData,
966     CK_ULONG ulDataLen,
967 
968     CK_BYTE_PTR pSignature,
969     CK_ULONG_PTR pulSignatureLen);
970 #endif
971 
972 CK_PKCS11_FUNCTION_INFO(C_SignMessageBegin)
973 #ifdef CK_NEED_ARG_LIST
974 (
975     CK_SESSION_HANDLE hSession,
976     CK_VOID_PTR pParameter,
977     CK_ULONG ulParameterLen);
978 #endif
979 
980 CK_PKCS11_FUNCTION_INFO(C_SignMessageNext)
981 #ifdef CK_NEED_ARG_LIST
982 (
983     CK_SESSION_HANDLE hSession,
984     CK_VOID_PTR pParameter,
985     CK_ULONG ulParameterLen,
986     CK_BYTE_PTR pData,
987     CK_ULONG ulDataLen,
988     CK_BYTE_PTR pSignature,
989     CK_ULONG_PTR pulSignatureLen);
990 #endif
991 
992 CK_PKCS11_FUNCTION_INFO(C_MessageSignFinal)
993 #ifdef CK_NEED_ARG_LIST
994 (
995     CK_SESSION_HANDLE hSession);
996 #endif
997 
998 CK_PKCS11_FUNCTION_INFO(C_MessageVerifyInit)
999 #ifdef CK_NEED_ARG_LIST
1000 (
1001     CK_SESSION_HANDLE hSession,
1002     CK_MECHANISM_PTR pMechanism,
1003     CK_OBJECT_HANDLE hKey);
1004 #endif
1005 
1006 CK_PKCS11_FUNCTION_INFO(C_VerifyMessage)
1007 #ifdef CK_NEED_ARG_LIST
1008 (
1009     CK_SESSION_HANDLE hSession,
1010     CK_VOID_PTR pParameter,
1011     CK_ULONG ulParameterLen,
1012     CK_BYTE_PTR pData,
1013     CK_ULONG ulDataLen,
1014     CK_BYTE_PTR pSignature,
1015     CK_ULONG ulSignatureLen);
1016 #endif
1017 
1018 CK_PKCS11_FUNCTION_INFO(C_VerifyMessageBegin)
1019 #ifdef CK_NEED_ARG_LIST
1020 (
1021     CK_SESSION_HANDLE hSession,
1022     CK_VOID_PTR pParameter,
1023     CK_ULONG ulParameterLen);
1024 #endif
1025 
1026 CK_PKCS11_FUNCTION_INFO(C_VerifyMessageNext)
1027 #ifdef CK_NEED_ARG_LIST
1028 (
1029     CK_SESSION_HANDLE hSession,
1030     CK_VOID_PTR pParameter,
1031     CK_ULONG ulParameterLen,
1032     CK_BYTE_PTR pData,
1033     CK_ULONG ulDataLen,
1034     CK_BYTE_PTR pSignature,
1035     CK_ULONG ulSignatureLen);
1036 #endif
1037 
1038 CK_PKCS11_FUNCTION_INFO(C_MessageVerifyFinal)
1039 #ifdef CK_NEED_ARG_LIST
1040 (
1041     CK_SESSION_HANDLE hSession);
1042 #endif
1043 
1044 #endif
1045