Botan 2.19.1
Crypto and TLS for C&
pkcs11.h
Go to the documentation of this file.
1/*
2 * PKCS #11 Cryptographic Token Interface Base Specification Version 2.40 Errata 01
3 * Committee Specification Draft 01 / Public Review Draft 01
4 * 09 December 2015
5 * Copyright (c) OASIS Open 2015. All Rights Reserved.
6 * Source: http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/errata01/csprd01/include/pkcs11-v2.40/
7 * Latest version of the specification: http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/pkcs11-base-v2.40.html
8 * https://www.oasis-open.org/policies-guidelines/ipr
9 */
10
11#ifndef _PKCS11_H_
12#define _PKCS11_H_ 1
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/* Before including this file (pkcs11.h) (or pkcs11t.h by
19 * itself), 5 platform-specific macros must be defined. These
20 * macros are described below, and typical definitions for them
21 * are also given. Be advised that these definitions can depend
22 * on both the platform and the compiler used (and possibly also
23 * on whether a Cryptoki library is linked statically or
24 * dynamically).
25 *
26 * In addition to defining these 5 macros, the packing convention
27 * for Cryptoki structures should be set. The Cryptoki
28 * convention on packing is that structures should be 1-byte
29 * aligned.
30 *
31 * If you're using Microsoft Developer Studio 5.0 to produce
32 * Win32 stuff, this might be done by using the following
33 * preprocessor directive before including pkcs11.h or pkcs11t.h:
34 *
35 * #pragma pack(push, cryptoki, 1)
36 *
37 * and using the following preprocessor directive after including
38 * pkcs11.h or pkcs11t.h:
39 *
40 * #pragma pack(pop, cryptoki)
41 *
42 * If you're using an earlier version of Microsoft Developer
43 * Studio to produce Win16 stuff, this might be done by using
44 * the following preprocessor directive before including
45 * pkcs11.h or pkcs11t.h:
46 *
47 * #pragma pack(1)
48 *
49 * In a UNIX environment, you're on your own for this. You might
50 * not need to do (or be able to do!) anything.
51 *
52 *
53 * Now for the macros:
54 *
55 *
56 * 1. CK_PTR: The indirection string for making a pointer to an
57 * object. It can be used like this:
58 *
59 * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
60 *
61 * If you're using Microsoft Developer Studio 5.0 to produce
62 * Win32 stuff, it might be defined by:
63 *
64 * #define CK_PTR *
65 *
66 * If you're using an earlier version of Microsoft Developer
67 * Studio to produce Win16 stuff, it might be defined by:
68 *
69 * #define CK_PTR far *
70 *
71 * In a typical UNIX environment, it might be defined by:
72 *
73 * #define CK_PTR *
74 *
75 *
76 * 2. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
77 * an importable Cryptoki library function declaration out of a
78 * return type and a function name. It should be used in the
79 * following fashion:
80 *
81 * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
82 * CK_VOID_PTR pReserved
83 * );
84 *
85 * If you're using Microsoft Developer Studio 5.0 to declare a
86 * function in a Win32 Cryptoki .dll, it might be defined by:
87 *
88 * #define CK_DECLARE_FUNCTION(returnType, name) \
89 * returnType __declspec(dllimport) name
90 *
91 * If you're using an earlier version of Microsoft Developer
92 * Studio to declare a function in a Win16 Cryptoki .dll, it
93 * might be defined by:
94 *
95 * #define CK_DECLARE_FUNCTION(returnType, name) \
96 * returnType __export _far _pascal name
97 *
98 * In a UNIX environment, it might be defined by:
99 *
100 * #define CK_DECLARE_FUNCTION(returnType, name) \
101 * returnType name
102 *
103 *
104 * 3. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
105 * which makes a Cryptoki API function pointer declaration or
106 * function pointer type declaration out of a return type and a
107 * function name. It should be used in the following fashion:
108 *
109 * // Define funcPtr to be a pointer to a Cryptoki API function
110 * // taking arguments args and returning CK_RV.
111 * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
112 *
113 * or
114 *
115 * // Define funcPtrType to be the type of a pointer to a
116 * // Cryptoki API function taking arguments args and returning
117 * // CK_RV, and then define funcPtr to be a variable of type
118 * // funcPtrType.
119 * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
120 * funcPtrType funcPtr;
121 *
122 * If you're using Microsoft Developer Studio 5.0 to access
123 * functions in a Win32 Cryptoki .dll, in might be defined by:
124 *
125 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
126 * returnType __declspec(dllimport) (* name)
127 *
128 * If you're using an earlier version of Microsoft Developer
129 * Studio to access functions in a Win16 Cryptoki .dll, it might
130 * be defined by:
131 *
132 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
133 * returnType __export _far _pascal (* name)
134 *
135 * In a UNIX environment, it might be defined by:
136 *
137 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
138 * returnType (* name)
139 *
140 *
141 * 4. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
142 * a function pointer type for an application callback out of
143 * a return type for the callback and a name for the callback.
144 * It should be used in the following fashion:
145 *
146 * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
147 *
148 * to declare a function pointer, myCallback, to a callback
149 * which takes arguments args and returns a CK_RV. It can also
150 * be used like this:
151 *
152 * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
153 * myCallbackType myCallback;
154 *
155 * If you're using Microsoft Developer Studio 5.0 to do Win32
156 * Cryptoki development, it might be defined by:
157 *
158 * #define CK_CALLBACK_FUNCTION(returnType, name) \
159 * returnType (* name)
160 *
161 * If you're using an earlier version of Microsoft Developer
162 * Studio to do Win16 development, it might be defined by:
163 *
164 * #define CK_CALLBACK_FUNCTION(returnType, name) \
165 * returnType _far _pascal (* name)
166 *
167 * In a UNIX environment, it might be defined by:
168 *
169 * #define CK_CALLBACK_FUNCTION(returnType, name) \
170 * returnType (* name)
171 *
172 *
173 * 5. NULL_PTR: This macro is the value of a NULL pointer.
174 *
175 * In any ANSI/ISO C environment (and in many others as well),
176 * this should best be defined by
177 *
178 * #ifndef NULL_PTR
179 * #define NULL_PTR 0
180 * #endif
181 */
182
183
184/* All the various Cryptoki types and #define'd values are in the
185 * file pkcs11t.h.
186 */
187#include "pkcs11t.h"
188
189#define __PASTE(x,y) x##y
190
191
192/* ==============================================================
193 * Define the "extern" form of all the entry points.
194 * ==============================================================
195 */
196
197#define CK_NEED_ARG_LIST 1
198#define CK_PKCS11_FUNCTION_INFO(name) \
199 extern CK_DECLARE_FUNCTION(CK_RV, name)
200
201/* pkcs11f.h has all the information about the Cryptoki
202 * function prototypes.
203 */
204#include "pkcs11f.h"
205
206#undef CK_NEED_ARG_LIST
207#undef CK_PKCS11_FUNCTION_INFO
208
209
210/* ==============================================================
211 * Define the typedef form of all the entry points. That is, for
212 * each Cryptoki function C_XXX, define a type CK_C_XXX which is
213 * a pointer to that kind of function.
214 * ==============================================================
215 */
216
217#define CK_NEED_ARG_LIST 1
218#define CK_PKCS11_FUNCTION_INFO(name) \
219 typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
220
221/* pkcs11f.h has all the information about the Cryptoki
222 * function prototypes.
223 */
224#include "pkcs11f.h"
225
226#undef CK_NEED_ARG_LIST
227#undef CK_PKCS11_FUNCTION_INFO
228
229
230/* ==============================================================
231 * Define structed vector of entry points. A CK_FUNCTION_LIST
232 * contains a CK_VERSION indicating a library's Cryptoki version
233 * and then a whole slew of function pointers to the routines in
234 * the library. This type was declared, but not defined, in
235 * pkcs11t.h.
236 * ==============================================================
237 */
238
239#define CK_PKCS11_FUNCTION_INFO(name) \
240 __PASTE(CK_,name) name;
241
243
244 CK_VERSION version; /* Cryptoki version */
245
246/* Pile all the function pointers into the CK_FUNCTION_LIST. */
247/* pkcs11f.h has all the information about the Cryptoki
248 * function prototypes.
249 */
250#include "pkcs11f.h"
251
252};
253
254#undef CK_PKCS11_FUNCTION_INFO
255
256
257#undef __PASTE
258
259#ifdef __cplusplus
260}
261#endif
262
263#endif /* _PKCS11_H_ */
264
CK_VERSION version
Definition: pkcs11.h:244