1/**
2 * Copyright(c) 2011 Trusted Logic.   All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 *  * Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 *  * Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in
12 *    the documentation and/or other materials provided with the
13 *    distribution.
14 *  * Neither the name Trusted Logic nor the names of its
15 *    contributors may be used to endorse or promote products derived
16 *    from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/*
32 * This header file contains the definition of the PKCS#11 types and functions
33 * supported by the Trusted Foundations Software. This header file is
34 * derived from the RSA Security Inc. PKCS #11 Cryptographic Token Interface
35 * (Cryptoki)
36 */
37#ifndef __PKCS11_H__
38#define __PKCS11_H__
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/*------------------------------------------
45* Types and constants
46*------------------------------------------*/
47
48#include "s_type.h"
49
50#define CK_TRUE true
51#define CK_FALSE false
52
53#ifndef FALSE
54#define FALSE CK_FALSE
55#endif
56
57#ifndef TRUE
58#define TRUE CK_TRUE
59#endif
60
61#define NULL_PTR NULL
62
63typedef uint8_t      CK_BYTE, *CK_BYTE_PTR;
64typedef CK_BYTE      CK_CHAR, *CK_CHAR_PTR;
65typedef CK_BYTE      CK_UTF8CHAR, *CK_UTF8CHAR_PTR;
66typedef bool         CK_BBOOL;
67typedef uint32_t     CK_ULONG, *CK_ULONG_PTR;
68typedef int32_t      CK_LONG;
69typedef CK_ULONG     CK_FLAGS;
70typedef void*        CK_VOID_PTR, *CK_VOID_PTR_PTR;
71
72#define CK_INVALID_HANDLE 0
73
74typedef struct CK_VERSION
75{
76   CK_BYTE       major;
77   CK_BYTE       minor;
78}
79CK_VERSION, *CK_VERSION_PTR;
80
81typedef struct CK_INFO
82{
83   CK_VERSION    cryptokiVersion;
84   CK_UTF8CHAR   manufacturerID[32];
85   CK_FLAGS      flags;
86   CK_UTF8CHAR   libraryDescription[32];
87   CK_VERSION    libraryVersion;
88}
89CK_INFO, *CK_INFO_PTR;
90
91typedef CK_ULONG   CK_NOTIFICATION;
92typedef CK_ULONG   CK_SLOT_ID, *CK_SLOT_ID_PTR;
93typedef CK_ULONG   CK_SESSION_HANDLE, *CK_SESSION_HANDLE_PTR;
94
95typedef CK_ULONG          CK_USER_TYPE;
96#define CKU_SO                 0
97#define CKU_USER               1
98#define CKU_CONTEXT_SPECIFIC   2
99
100typedef CK_ULONG          CK_STATE;
101#define CKS_RO_PUBLIC_SESSION  0
102#define CKS_RO_USER_FUNCTIONS  1
103#define CKS_RW_PUBLIC_SESSION  2
104#define CKS_RW_USER_FUNCTIONS  3
105#define CKS_RW_SO_FUNCTIONS    4
106
107typedef struct CK_SESSION_INFO
108{
109   CK_SLOT_ID    slotID;
110   CK_STATE      state;
111   CK_FLAGS      flags;
112   CK_ULONG      ulDeviceError;
113}
114CK_SESSION_INFO, *CK_SESSION_INFO_PTR;
115
116#define CKF_RW_SESSION          0x00000002
117#define CKF_SERIAL_SESSION      0x00000004
118#define CKVF_OPEN_SUB_SESSION   0x00000008
119
120typedef CK_ULONG          CK_OBJECT_HANDLE, *CK_OBJECT_HANDLE_PTR;
121
122typedef CK_ULONG          CK_OBJECT_CLASS, *CK_OBJECT_CLASS_PTR;
123
124#define CKO_DATA              0x00000000
125#define CKO_PUBLIC_KEY        0x00000002
126#define CKO_PRIVATE_KEY       0x00000003
127#define CKO_SECRET_KEY        0x00000004
128
129typedef CK_ULONG          CK_KEY_TYPE;
130
131#define CKK_RSA             0x00000000
132#define CKK_DSA             0x00000001
133#define CKK_DH              0x00000002
134#define CKK_EC              0x00000003
135
136#define CKK_GENERIC_SECRET  0x00000010
137
138#define CKK_RC4             0x00000012
139#define CKK_DES             0x00000013
140#define CKK_DES2            0x00000014
141#define CKK_DES3            0x00000015
142
143#define CKK_AES             0x0000001F
144
145#define CKK_VENDOR_DEFINED  0x80000000
146
147typedef CK_ULONG          CK_ATTRIBUTE_TYPE;
148
149#define CKF_ARRAY_ATTRIBUTE    0x40000000
150
151#define CKA_CLASS              0x00000000
152#define CKA_TOKEN              0x00000001
153#define CKA_PRIVATE            0x00000002
154#define CKA_VALUE              0x00000011
155
156#define CKA_OBJECT_ID          0x00000012
157
158#define CKA_KEY_TYPE           0x00000100
159#define CKA_ID                 0x00000102
160#define CKA_SENSITIVE          0x00000103
161#define CKA_ENCRYPT            0x00000104
162#define CKA_DECRYPT            0x00000105
163#define CKA_WRAP               0x00000106
164#define CKA_UNWRAP             0x00000107
165#define CKA_SIGN               0x00000108
166#define CKA_VERIFY             0x0000010A
167#define CKA_DERIVE             0x0000010C
168#define CKA_MODULUS            0x00000120
169#define CKA_MODULUS_BITS       0x00000121
170#define CKA_PUBLIC_EXPONENT    0x00000122
171#define CKA_PRIVATE_EXPONENT   0x00000123
172#define CKA_PRIME_1            0x00000124
173#define CKA_PRIME_2            0x00000125
174#define CKA_EXPONENT_1         0x00000126
175#define CKA_EXPONENT_2         0x00000127
176#define CKA_COEFFICIENT        0x00000128
177#define CKA_PRIME              0x00000130
178#define CKA_SUBPRIME           0x00000131
179#define CKA_BASE               0x00000132
180
181#define CKA_VALUE_BITS         0x00000160
182#define CKA_VALUE_LEN          0x00000161
183
184#define CKA_EXTRACTABLE        0x00000162
185
186#define CKA_MODIFIABLE         0x00000170
187#define CKA_COPYABLE           0x00000171
188#define CKA_ALWAYS_AUTHENTICATE  0x00000202
189
190#define CKA_VENDOR_DEFINED     0x80000000
191
192#define CKAV_ALLOW_NON_SENSITIVE_DERIVED_KEY 0x80000001
193
194typedef struct CK_ATTRIBUTE
195{
196   CK_ATTRIBUTE_TYPE type;
197   void*             pValue;
198   CK_ULONG          ulValueLen;
199}
200CK_ATTRIBUTE, *CK_ATTRIBUTE_PTR;
201
202typedef CK_ULONG          CK_MECHANISM_TYPE, *CK_MECHANISM_TYPE_PTR;
203
204#define CKM_RSA_PKCS_KEY_PAIR_GEN      0x00000000
205#define CKM_RSA_PKCS                   0x00000001
206#define CKM_RSA_X_509                  0x00000003
207#define CKM_MD5_RSA_PKCS               0x00000005
208#define CKM_SHA1_RSA_PKCS              0x00000006
209#define CKM_RSA_PKCS_OAEP              0x00000009
210#define CKM_RSA_PKCS_PSS               0x0000000D
211#define CKM_SHA1_RSA_PKCS_PSS          0x0000000E
212#define CKM_DSA_KEY_PAIR_GEN           0x00000010
213#define CKM_DSA                        0x00000011
214#define CKM_DSA_SHA1                   0x00000012
215#define CKM_DH_PKCS_KEY_PAIR_GEN       0x00000020
216#define CKM_DH_PKCS_DERIVE             0x00000021
217#define CKM_SHA256_RSA_PKCS            0x00000040
218#define CKM_SHA384_RSA_PKCS            0x00000041
219#define CKM_SHA512_RSA_PKCS            0x00000042
220#define CKM_SHA256_RSA_PKCS_PSS        0x00000043
221#define CKM_SHA384_RSA_PKCS_PSS        0x00000044
222#define CKM_SHA512_RSA_PKCS_PSS        0x00000045
223#define CKM_SHA224_RSA_PKCS            0x00000046
224#define CKM_SHA224_RSA_PKCS_PSS        0x00000047
225#define CKM_RC4_KEY_GEN                0x00000110
226#define CKM_RC4                        0x00000111
227#define CKM_DES_KEY_GEN                0x00000120
228#define CKM_DES_ECB                    0x00000121
229#define CKM_DES_CBC                    0x00000122
230#define CKM_DES_MAC                    0x00000123
231#define CKM_DES2_KEY_GEN               0x00000130
232#define CKM_DES3_KEY_GEN               0x00000131
233#define CKM_DES3_ECB                   0x00000132
234#define CKM_DES3_CBC                   0x00000133
235#define CKM_DES3_MAC                   0x00000134
236#define CKM_MD5                        0x00000210
237#define CKM_MD5_HMAC                   0x00000211
238#define CKM_SHA_1                      0x00000220
239#define CKM_SHA_1_HMAC                 0x00000221
240#define CKM_SHA256                     0x00000250
241#define CKM_SHA256_HMAC                0x00000251
242#define CKM_SHA224                     0x00000255
243#define CKM_SHA224_HMAC                0x00000256
244#define CKM_SHA384                     0x00000260
245#define CKM_SHA384_HMAC                0x00000261
246#define CKM_SHA512                     0x00000270
247#define CKM_SHA512_HMAC                0x00000271
248#define CKM_GENERIC_SECRET_KEY_GEN     0x00000350
249#define CKM_AES_KEY_GEN                0x00001080
250#define CKM_AES_ECB                    0x00001081
251#define CKM_AES_CBC                    0x00001082
252#define CKM_AES_MAC                    0x00001083
253#define CKM_AES_CTR                    0x00001086
254#define CKM_VENDOR_DEFINED             0x80000000
255#define CKMV_AES_CTR                   0x80000001
256
257#define CKMV_IMPLEMENTATION_DEFINED_0   0xC0000000
258#define CKMV_IMPLEMENTATION_DEFINED_1   0xC0000001
259#define CKMV_IMPLEMENTATION_DEFINED_2   0xC0000002
260#define CKMV_IMPLEMENTATION_DEFINED_3   0xC0000003
261#define CKMV_IMPLEMENTATION_DEFINED_4   0xC0000004
262#define CKMV_IMPLEMENTATION_DEFINED_5   0xC0000005
263#define CKMV_IMPLEMENTATION_DEFINED_6   0xC0000006
264#define CKMV_IMPLEMENTATION_DEFINED_7   0xC0000007
265#define CKMV_IMPLEMENTATION_DEFINED_8   0xC0000008
266#define CKMV_IMPLEMENTATION_DEFINED_9   0xC0000009
267#define CKMV_IMPLEMENTATION_DEFINED_10  0xC000000A
268#define CKMV_IMPLEMENTATION_DEFINED_11  0xC000000B
269#define CKMV_IMPLEMENTATION_DEFINED_12  0xC000000C
270#define CKMV_IMPLEMENTATION_DEFINED_13  0xC000000D
271#define CKMV_IMPLEMENTATION_DEFINED_14  0xC000000E
272#define CKMV_IMPLEMENTATION_DEFINED_15  0xC000000F
273
274typedef struct CK_MECHANISM
275{
276   CK_MECHANISM_TYPE mechanism;
277   void*             pParameter;
278   CK_ULONG          ulParameterLen;  /* in bytes */
279}
280CK_MECHANISM, *CK_MECHANISM_PTR;
281
282typedef CK_ULONG          CK_RV;
283
284#define CKR_OK                                0x00000000
285#define CKR_CANCEL                            0x00000001
286#define CKR_HOST_MEMORY                       0x00000002
287#define CKR_SLOT_ID_INVALID                   0x00000003
288#define CKR_GENERAL_ERROR                     0x00000005
289#define CKR_ARGUMENTS_BAD                     0x00000007
290#define CKR_ATTRIBUTE_SENSITIVE               0x00000011
291#define CKR_ATTRIBUTE_TYPE_INVALID            0x00000012
292#define CKR_ATTRIBUTE_VALUE_INVALID           0x00000013
293#define CKR_COPY_PROHIBITED                   0x0000001A
294#define CKR_DATA_INVALID                      0x00000020
295#define CKR_DATA_LEN_RANGE                    0x00000021
296#define CKR_DEVICE_ERROR                      0x00000030
297#define CKR_DEVICE_MEMORY                     0x00000031
298#define CKR_ENCRYPTED_DATA_INVALID            0x00000040
299#define CKR_ENCRYPTED_DATA_LEN_RANGE          0x00000041
300#define CKR_KEY_HANDLE_INVALID                0x00000060
301#define CKR_KEY_SIZE_RANGE                    0x00000062
302#define CKR_KEY_TYPE_INCONSISTENT             0x00000063
303#define CKR_KEY_FUNCTION_NOT_PERMITTED        0x00000068
304#define CKR_KEY_NOT_WRAPPABLE                 0x00000069
305#define CKR_MECHANISM_INVALID                 0x00000070
306#define CKR_MECHANISM_PARAM_INVALID           0x00000071
307#define CKR_OBJECT_HANDLE_INVALID             0x00000082
308#define CKR_OPERATION_ACTIVE                  0x00000090
309#define CKR_OPERATION_NOT_INITIALIZED         0x00000091
310#define CKR_PIN_INCORRECT                     0x000000A0
311#define CKR_SESSION_COUNT                     0x000000B1
312#define CKR_SESSION_HANDLE_INVALID            0x000000B3
313#define CKR_SESSION_PARALLEL_NOT_SUPPORTED    0x000000B4
314#define CKR_SESSION_READ_ONLY                 0x000000B5
315#define CKR_SIGNATURE_INVALID                 0x000000C0
316#define CKR_SIGNATURE_LEN_RANGE               0x000000C1
317#define CKR_TEMPLATE_INCOMPLETE               0x000000D0
318#define CKR_TEMPLATE_INCONSISTENT             0x000000D1
319#define CKR_TOKEN_NOT_PRESENT                 0x000000E0
320#define CKR_USER_ALREADY_LOGGED_IN            0x00000100
321#define CKR_USER_NOT_LOGGED_IN                0x00000101
322#define CKR_USER_TYPE_INVALID                 0x00000103
323#define CKR_WRAPPED_KEY_LEN_RANGE             0x00000112
324#define CKR_WRAPPING_KEY_HANDLE_INVALID       0x00000113
325#define CKR_RANDOM_SEED_NOT_SUPPORTED         0x00000120
326#define CKR_RANDOM_NO_RNG                     0x00000121
327#define CKR_BUFFER_TOO_SMALL                  0x00000150
328#define CKR_CRYPTOKI_NOT_INITIALIZED          0x00000190
329#define CKR_CRYPTOKI_ALREADY_INITIALIZED      0x00000191
330#define CKR_VENDOR_DEFINED                    0x80000000
331
332typedef CK_RV (*CK_NOTIFY)(
333   CK_SESSION_HANDLE hSession,
334   CK_NOTIFICATION   event,
335   void*       pApplication
336);
337
338typedef CK_ULONG CK_RSA_PKCS_MGF_TYPE, *CK_RSA_PKCS_MGF_TYPE_PTR;
339
340#define CKG_MGF1_SHA1         0x00000001
341#define CKG_MGF1_SHA256       0x00000002
342#define CKG_MGF1_SHA384       0x00000003
343#define CKG_MGF1_SHA512       0x00000004
344#define CKG_MGF1_SHA224       0x00000005
345
346typedef CK_ULONG CK_RSA_PKCS_OAEP_SOURCE_TYPE, *CK_RSA_PKCS_OAEP_SOURCE_TYPE_PTR;
347
348#define CKZ_DATA_SPECIFIED    0x00000001
349typedef struct CK_RSA_PKCS_OAEP_PARAMS
350{
351   CK_MECHANISM_TYPE hashAlg;
352   CK_RSA_PKCS_MGF_TYPE mgf;
353   CK_RSA_PKCS_OAEP_SOURCE_TYPE source;
354   void*    pSourceData;
355   CK_ULONG ulSourceDataLen;
356}
357CK_RSA_PKCS_OAEP_PARAMS, *CK_RSA_PKCS_OAEP_PARAMS_PTR;
358
359typedef struct CK_RSA_PKCS_PSS_PARAMS
360{
361   CK_MECHANISM_TYPE    hashAlg;
362   CK_RSA_PKCS_MGF_TYPE mgf;
363   CK_ULONG             sLen;
364}
365CK_RSA_PKCS_PSS_PARAMS, *CK_RSA_PKCS_PSS_PARAMS_PTR;
366
367typedef struct CK_AES_CTR_PARAMS
368{
369   CK_ULONG ulCounterBits;
370   CK_BYTE cb[16];
371}
372CK_AES_CTR_PARAMS, *CK_AES_CTR_PARAMS_PTR;
373
374/*------------------------------------------
375* Functions
376*------------------------------------------*/
377CK_RV PKCS11_EXPORT C_Initialize(void* pInitArgs);
378
379CK_RV PKCS11_EXPORT C_Finalize(void* pReserved);
380
381CK_RV PKCS11_EXPORT C_GetInfo(CK_INFO* pInfo);
382
383CK_RV PKCS11_EXPORT C_OpenSession(
384   CK_SLOT_ID            slotID,
385   CK_FLAGS              flags,
386   void*                 pApplication,
387   CK_NOTIFY             Notify,
388   CK_SESSION_HANDLE*    phSession);
389
390CK_RV PKCS11_EXPORT C_CloseSession(
391   CK_SESSION_HANDLE hSession);
392
393CK_RV PKCS11_EXPORT C_Login(
394   CK_SESSION_HANDLE   hSession,
395   CK_USER_TYPE        userType,
396   const CK_UTF8CHAR*  pPin,
397   CK_ULONG            ulPinLen);
398
399CK_RV PKCS11_EXPORT C_Logout(
400   CK_SESSION_HANDLE hSession);
401
402CK_RV PKCS11_EXPORT C_CreateObject(
403   CK_SESSION_HANDLE   hSession,
404   const CK_ATTRIBUTE* pTemplate,
405   CK_ULONG            ulCount,
406   CK_OBJECT_HANDLE*   phObject);
407
408CK_RV PKCS11_EXPORT C_DestroyObject(
409   CK_SESSION_HANDLE   hSession,
410   CK_OBJECT_HANDLE    hObject);
411
412CK_RV PKCS11_EXPORT C_GetAttributeValue(
413   CK_SESSION_HANDLE   hSession,
414   CK_OBJECT_HANDLE    hObject,
415   CK_ATTRIBUTE*       pTemplate,
416   CK_ULONG            ulCount);
417
418CK_RV PKCS11_EXPORT C_FindObjectsInit(
419   CK_SESSION_HANDLE   hSession,
420   const CK_ATTRIBUTE* pTemplate,
421   CK_ULONG            ulCount);
422
423CK_RV PKCS11_EXPORT C_FindObjects(
424   CK_SESSION_HANDLE   hSession,
425   CK_OBJECT_HANDLE*   phObject,
426   CK_ULONG            ulMaxObjectCount,
427   CK_ULONG*           pulObjectCount);
428
429CK_RV PKCS11_EXPORT C_FindObjectsFinal(
430   CK_SESSION_HANDLE hSession);
431
432CK_RV PKCS11_EXPORT C_EncryptInit(
433   CK_SESSION_HANDLE   hSession,
434   const CK_MECHANISM* pMechanism,
435   CK_OBJECT_HANDLE    hKey);
436
437CK_RV PKCS11_EXPORT C_Encrypt(
438   CK_SESSION_HANDLE hSession,
439   const CK_BYTE*    pData,
440   CK_ULONG          ulDataLen,
441   CK_BYTE*          pEncryptedData,
442   CK_ULONG*         pulEncryptedDataLen);
443
444CK_RV PKCS11_EXPORT C_EncryptUpdate(
445   CK_SESSION_HANDLE hSession,
446   const CK_BYTE*    pPart,
447   CK_ULONG          ulPartLen,
448   CK_BYTE*          pEncryptedPart,
449   CK_ULONG*         pulEncryptedPartLen);
450
451CK_RV PKCS11_EXPORT C_EncryptFinal(
452   CK_SESSION_HANDLE hSession,
453   CK_BYTE*          pLastEncryptedPart,
454   CK_ULONG*         pulLastEncryptedPartLen);
455
456CK_RV PKCS11_EXPORT C_DecryptInit(
457   CK_SESSION_HANDLE   hSession,
458   const CK_MECHANISM* pMechanism,
459   CK_OBJECT_HANDLE    hKey);
460
461CK_RV PKCS11_EXPORT C_Decrypt(
462   CK_SESSION_HANDLE hSession,
463   const CK_BYTE*    pEncryptedData,
464   CK_ULONG          ulEncryptedDataLen,
465   CK_BYTE*          pData,
466   CK_ULONG*         pulDataLen);
467
468CK_RV PKCS11_EXPORT C_DecryptUpdate(
469   CK_SESSION_HANDLE hSession,
470   const CK_BYTE*    pEncryptedPart,
471   CK_ULONG          ulEncryptedPartLen,
472   CK_BYTE*          pPart,
473   CK_ULONG*         pulPartLen);
474
475CK_RV PKCS11_EXPORT C_DecryptFinal(
476   CK_SESSION_HANDLE hSession,
477   CK_BYTE*          pLastPart,
478   CK_ULONG*         pulLastPartLen);
479
480CK_RV PKCS11_EXPORT C_DigestInit(
481   CK_SESSION_HANDLE   hSession,
482   const CK_MECHANISM* pMechanism);
483
484CK_RV PKCS11_EXPORT C_Digest(
485   CK_SESSION_HANDLE hSession,
486   const CK_BYTE*    pData,
487   CK_ULONG          ulDataLen,
488   CK_BYTE*          pDigest,
489   CK_ULONG*         pulDigestLen);
490
491CK_RV PKCS11_EXPORT C_DigestUpdate(
492   CK_SESSION_HANDLE hSession,
493   const CK_BYTE*    pPart,
494   CK_ULONG          ulPartLen);
495
496CK_RV PKCS11_EXPORT C_DigestFinal(
497   CK_SESSION_HANDLE hSession,
498   CK_BYTE*          pDigest,
499   CK_ULONG*         pulDigestLen);
500
501CK_RV PKCS11_EXPORT C_SignInit(
502   CK_SESSION_HANDLE   hSession,
503   const CK_MECHANISM* pMechanism,
504   CK_OBJECT_HANDLE    hKey);
505
506CK_RV PKCS11_EXPORT C_Sign(
507   CK_SESSION_HANDLE  hSession,
508   const CK_BYTE*     pData,
509   CK_ULONG           ulDataLen,
510   CK_BYTE*           pSignature,
511   CK_ULONG*          pulSignatureLen);
512
513CK_RV PKCS11_EXPORT C_SignUpdate(
514   CK_SESSION_HANDLE hSession,
515   const CK_BYTE*    pPart,
516   CK_ULONG          ulPartLen);
517
518CK_RV PKCS11_EXPORT C_SignFinal(
519   CK_SESSION_HANDLE hSession,
520   CK_BYTE*          pSignature,
521   CK_ULONG*         pulSignatureLen);
522
523CK_RV PKCS11_EXPORT C_VerifyInit(
524   CK_SESSION_HANDLE   hSession,
525   const CK_MECHANISM* pMechanism,
526   CK_OBJECT_HANDLE    hKey);
527
528CK_RV PKCS11_EXPORT C_Verify(
529   CK_SESSION_HANDLE hSession,
530   const CK_BYTE*    pData,
531   CK_ULONG          ulDataLen,
532   CK_BYTE*          pSignature,
533   CK_ULONG          ulSignatureLen);
534
535CK_RV PKCS11_EXPORT C_VerifyUpdate(
536   CK_SESSION_HANDLE hSession,
537   const CK_BYTE*    pPart,
538   CK_ULONG          ulPartLen);
539
540CK_RV PKCS11_EXPORT C_VerifyFinal(
541   CK_SESSION_HANDLE hSession,
542   const CK_BYTE*          pSignature,
543   CK_ULONG          ulSignatureLen);
544
545CK_RV PKCS11_EXPORT C_GenerateKey(
546   CK_SESSION_HANDLE   hSession,
547   const CK_MECHANISM* pMechanism,
548   const CK_ATTRIBUTE* pTemplate,
549   CK_ULONG            ulCount,
550   CK_OBJECT_HANDLE*   phKey);
551
552CK_RV PKCS11_EXPORT C_GenerateKeyPair(
553   CK_SESSION_HANDLE    hSession,
554   const CK_MECHANISM*  pMechanism,
555   const CK_ATTRIBUTE*  pPublicKeyTemplate,
556   CK_ULONG             ulPublicKeyAttributeCount,
557   const CK_ATTRIBUTE*  pPrivateKeyTemplate,
558   CK_ULONG             ulPrivateKeyAttributeCount,
559   CK_OBJECT_HANDLE*    phPublicKey,
560   CK_OBJECT_HANDLE*    phPrivateKey);
561
562CK_RV PKCS11_EXPORT C_DeriveKey(
563   CK_SESSION_HANDLE    hSession,
564   const CK_MECHANISM*  pMechanism,
565   CK_OBJECT_HANDLE     hBaseKey,
566   const CK_ATTRIBUTE*  pTemplate,
567   CK_ULONG             ulAttributeCount,
568   CK_OBJECT_HANDLE*    phKey);
569
570CK_RV PKCS11_EXPORT C_SeedRandom(
571   CK_SESSION_HANDLE hSession,
572   const CK_BYTE*    pSeed,
573   CK_ULONG          ulSeedLen);
574
575CK_RV PKCS11_EXPORT C_GenerateRandom(
576   CK_SESSION_HANDLE hSession,
577   CK_BYTE*          pRandomData,
578   CK_ULONG          ulRandomLen);
579
580CK_RV PKCS11_EXPORT C_CloseObjectHandle(
581   CK_SESSION_HANDLE hSession,
582   CK_OBJECT_HANDLE    hObject);
583
584CK_RV PKCS11_EXPORT C_CopyObject(
585   CK_SESSION_HANDLE    hSession,
586   CK_OBJECT_HANDLE     hObject,
587   const CK_ATTRIBUTE*  pTemplate,
588   CK_ULONG             ulAttributeCount,
589   CK_OBJECT_HANDLE*    phNewObject);
590
591#ifdef __cplusplus
592}
593#endif
594
595#endif /* __PKCS11_H__ */
596