1 /* pkcs11.h include file for PKCS #11. */
\r
2 /* $Revision: 1.4 $ */
\r
4 /* License to copy and use this software is granted provided that it is
\r
5 * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
\r
6 * (Cryptoki)" in all material mentioning or referencing this software.
\r
8 * License is also granted to make and use derivative works provided that
\r
9 * such works are identified as "derived from the RSA Security Inc. PKCS #11
\r
10 * Cryptographic Token Interface (Cryptoki)" in all material mentioning or
\r
11 * referencing the derived work.
\r
13 * RSA Security Inc. makes no representations concerning either the
\r
14 * merchantability of this software or the suitability of this software for
\r
15 * any particular purpose. It is provided "as is" without express or implied
\r
16 * warranty of any kind.
\r
20 #define _PKCS11_H_ 1
\r
26 /* Before including this file (pkcs11.h) (or pkcs11t.h by
\r
27 * itself), 6 platform-specific macros must be defined. These
\r
28 * macros are described below, and typical definitions for them
\r
29 * are also given. Be advised that these definitions can depend
\r
30 * on both the platform and the compiler used (and possibly also
\r
31 * on whether a Cryptoki library is linked statically or
\r
34 * In addition to defining these 6 macros, the packing convention
\r
35 * for Cryptoki structures should be set. The Cryptoki
\r
36 * convention on packing is that structures should be 1-byte
\r
39 * If you're using Microsoft Developer Studio 5.0 to produce
\r
40 * Win32 stuff, this might be done by using the following
\r
41 * preprocessor directive before including pkcs11.h or pkcs11t.h:
\r
43 * #pragma pack(push, cryptoki, 1)
\r
45 * and using the following preprocessor directive after including
\r
46 * pkcs11.h or pkcs11t.h:
\r
48 * #pragma pack(pop, cryptoki)
\r
50 * If you're using an earlier version of Microsoft Developer
\r
51 * Studio to produce Win16 stuff, this might be done by using
\r
52 * the following preprocessor directive before including
\r
53 * pkcs11.h or pkcs11t.h:
\r
57 * In a UNIX environment, you're on your own for this. You might
\r
58 * not need to do (or be able to do!) anything.
\r
61 * Now for the macros:
\r
64 * 1. CK_PTR: The indirection string for making a pointer to an
\r
65 * object. It can be used like this:
\r
67 * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
\r
69 * If you're using Microsoft Developer Studio 5.0 to produce
\r
70 * Win32 stuff, it might be defined by:
\r
74 * If you're using an earlier version of Microsoft Developer
\r
75 * Studio to produce Win16 stuff, it might be defined by:
\r
77 * #define CK_PTR far *
\r
79 * In a typical UNIX environment, it might be defined by:
\r
84 * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes
\r
85 * an exportable Cryptoki library function definition out of a
\r
86 * return type and a function name. It should be used in the
\r
87 * following fashion to define the exposed Cryptoki functions in
\r
88 * a Cryptoki library:
\r
90 * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
\r
91 * CK_VOID_PTR pReserved
\r
97 * If you're using Microsoft Developer Studio 5.0 to define a
\r
98 * function in a Win32 Cryptoki .dll, it might be defined by:
\r
100 * #define CK_DEFINE_FUNCTION(returnType, name) \
\r
101 * returnType __declspec(dllexport) name
\r
103 * If you're using an earlier version of Microsoft Developer
\r
104 * Studio to define a function in a Win16 Cryptoki .dll, it
\r
105 * might be defined by:
\r
107 * #define CK_DEFINE_FUNCTION(returnType, name) \
\r
108 * returnType __export _far _pascal name
\r
110 * In a UNIX environment, it might be defined by:
\r
112 * #define CK_DEFINE_FUNCTION(returnType, name) \
\r
116 * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
\r
117 * an importable Cryptoki library function declaration out of a
\r
118 * return type and a function name. It should be used in the
\r
119 * following fashion:
\r
121 * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
\r
122 * CK_VOID_PTR pReserved
\r
125 * If you're using Microsoft Developer Studio 5.0 to declare a
\r
126 * function in a Win32 Cryptoki .dll, it might be defined by:
\r
128 * #define CK_DECLARE_FUNCTION(returnType, name) \
\r
129 * returnType __declspec(dllimport) name
\r
131 * If you're using an earlier version of Microsoft Developer
\r
132 * Studio to declare a function in a Win16 Cryptoki .dll, it
\r
133 * might be defined by:
\r
135 * #define CK_DECLARE_FUNCTION(returnType, name) \
\r
136 * returnType __export _far _pascal name
\r
138 * In a UNIX environment, it might be defined by:
\r
140 * #define CK_DECLARE_FUNCTION(returnType, name) \
\r
144 * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
\r
145 * which makes a Cryptoki API function pointer declaration or
\r
146 * function pointer type declaration out of a return type and a
\r
147 * function name. It should be used in the following fashion:
\r
149 * // Define funcPtr to be a pointer to a Cryptoki API function
\r
150 * // taking arguments args and returning CK_RV.
\r
151 * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
\r
155 * // Define funcPtrType to be the type of a pointer to a
\r
156 * // Cryptoki API function taking arguments args and returning
\r
157 * // CK_RV, and then define funcPtr to be a variable of type
\r
159 * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
\r
160 * funcPtrType funcPtr;
\r
162 * If you're using Microsoft Developer Studio 5.0 to access
\r
163 * functions in a Win32 Cryptoki .dll, in might be defined by:
\r
165 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
\r
166 * returnType __declspec(dllimport) (* name)
\r
168 * If you're using an earlier version of Microsoft Developer
\r
169 * Studio to access functions in a Win16 Cryptoki .dll, it might
\r
172 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
\r
173 * returnType __export _far _pascal (* name)
\r
175 * In a UNIX environment, it might be defined by:
\r
177 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
\r
178 * returnType (* name)
\r
181 * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
\r
182 * a function pointer type for an application callback out of
\r
183 * a return type for the callback and a name for the callback.
\r
184 * It should be used in the following fashion:
\r
186 * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
\r
188 * to declare a function pointer, myCallback, to a callback
\r
189 * which takes arguments args and returns a CK_RV. It can also
\r
190 * be used like this:
\r
192 * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
\r
193 * myCallbackType myCallback;
\r
195 * If you're using Microsoft Developer Studio 5.0 to do Win32
\r
196 * Cryptoki development, it might be defined by:
\r
198 * #define CK_CALLBACK_FUNCTION(returnType, name) \
\r
199 * returnType (* name)
\r
201 * If you're using an earlier version of Microsoft Developer
\r
202 * Studio to do Win16 development, it might be defined by:
\r
204 * #define CK_CALLBACK_FUNCTION(returnType, name) \
\r
205 * returnType _far _pascal (* name)
\r
207 * In a UNIX environment, it might be defined by:
\r
209 * #define CK_CALLBACK_FUNCTION(returnType, name) \
\r
210 * returnType (* name)
\r
213 * 6. NULL_PTR: This macro is the value of a NULL pointer.
\r
215 * In any ANSI/ISO C environment (and in many others as well),
\r
216 * this should best be defined by
\r
219 * #define NULL_PTR 0
\r
224 /* All the various Cryptoki types and #define'd values are in the
\r
225 * file pkcs11t.h. */
\r
226 #include "pkcs11t.h"
\r
228 #define __PASTE(x,y) x##y
\r
231 /* ==============================================================
\r
232 * Define the "extern" form of all the entry points.
\r
233 * ==============================================================
\r
236 #define CK_NEED_ARG_LIST 1
\r
237 #define CK_PKCS11_FUNCTION_INFO(name) \
\r
238 extern CK_DECLARE_FUNCTION(CK_RV, name)
\r
240 /* pkcs11f.h has all the information about the Cryptoki
\r
241 * function prototypes. */
\r
242 #include "pkcs11f.h"
\r
244 #undef CK_NEED_ARG_LIST
\r
245 #undef CK_PKCS11_FUNCTION_INFO
\r
248 /* ==============================================================
\r
249 * Define the typedef form of all the entry points. That is, for
\r
250 * each Cryptoki function C_XXX, define a type CK_C_XXX which is
\r
251 * a pointer to that kind of function.
\r
252 * ==============================================================
\r
255 #define CK_NEED_ARG_LIST 1
\r
256 #define CK_PKCS11_FUNCTION_INFO(name) \
\r
257 typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
\r
259 /* pkcs11f.h has all the information about the Cryptoki
\r
260 * function prototypes. */
\r
261 #include "pkcs11f.h"
\r
263 #undef CK_NEED_ARG_LIST
\r
264 #undef CK_PKCS11_FUNCTION_INFO
\r
267 /* ==============================================================
\r
268 * Define structed vector of entry points. A CK_FUNCTION_LIST
\r
269 * contains a CK_VERSION indicating a library's Cryptoki version
\r
270 * and then a whole slew of function pointers to the routines in
\r
271 * the library. This type was declared, but not defined, in
\r
273 * ==============================================================
\r
276 #define CK_PKCS11_FUNCTION_INFO(name) \
\r
277 __PASTE(CK_,name) name;
\r
279 struct CK_FUNCTION_LIST {
\r
281 CK_VERSION version; /* Cryptoki version */
\r
283 /* Pile all the function pointers into the CK_FUNCTION_LIST. */
\r
284 /* pkcs11f.h has all the information about the Cryptoki
\r
285 * function prototypes. */
\r
286 #include "pkcs11f.h"
\r
290 #undef CK_PKCS11_FUNCTION_INFO
\r