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