* copy vendor drop to trunk
[lab.git] / Dev / utvpn / utvpn-unix-v101-7101-public / src / Mayaqua / pkcs11.h
1 /* pkcs11.h include file for PKCS #11. */\r
2 /* $Revision: 1.4 $ */\r
3 \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
7 \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
12 \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
17  */\r
18 \r
19 #ifndef _PKCS11_H_\r
20 #define _PKCS11_H_ 1\r
21 \r
22 #ifdef __cplusplus\r
23 extern "C" {\r
24 #endif\r
25 \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
32  * dynamically).\r
33  *\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
37  * aligned.\r
38  *\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
42  *\r
43  * #pragma pack(push, cryptoki, 1)\r
44  *\r
45  * and using the following preprocessor directive after including\r
46  * pkcs11.h or pkcs11t.h:\r
47  *\r
48  * #pragma pack(pop, cryptoki)\r
49  *\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
54  *\r
55  * #pragma pack(1)\r
56  *\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
59  *\r
60  *\r
61  * Now for the macros:\r
62  *\r
63  *\r
64  * 1. CK_PTR: The indirection string for making a pointer to an\r
65  * object.  It can be used like this:\r
66  *\r
67  * typedef CK_BYTE CK_PTR CK_BYTE_PTR;\r
68  *\r
69  * If you're using Microsoft Developer Studio 5.0 to produce\r
70  * Win32 stuff, it might be defined by:\r
71  *\r
72  * #define CK_PTR *\r
73  *\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
76  *\r
77  * #define CK_PTR far *\r
78  *\r
79  * In a typical UNIX environment, it might be defined by:\r
80  *\r
81  * #define CK_PTR *\r
82  *\r
83  *\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
89  *\r
90  * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(\r
91  *   CK_VOID_PTR pReserved\r
92  * )\r
93  * {\r
94  *   ...\r
95  * }\r
96  *\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
99  *\r
100  * #define CK_DEFINE_FUNCTION(returnType, name) \\r
101  *   returnType __declspec(dllexport) name\r
102  *\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
106  *\r
107  * #define CK_DEFINE_FUNCTION(returnType, name) \\r
108  *   returnType __export _far _pascal name\r
109  *\r
110  * In a UNIX environment, it might be defined by:\r
111  *\r
112  * #define CK_DEFINE_FUNCTION(returnType, name) \\r
113  *   returnType name\r
114  *\r
115  *\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
120  *\r
121  * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(\r
122  *   CK_VOID_PTR pReserved\r
123  * );\r
124  *\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
127  *\r
128  * #define CK_DECLARE_FUNCTION(returnType, name) \\r
129  *   returnType __declspec(dllimport) name\r
130  *\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
134  *\r
135  * #define CK_DECLARE_FUNCTION(returnType, name) \\r
136  *   returnType __export _far _pascal name\r
137  *\r
138  * In a UNIX environment, it might be defined by:\r
139  *\r
140  * #define CK_DECLARE_FUNCTION(returnType, name) \\r
141  *   returnType name\r
142  *\r
143  *\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
148  *\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
152  *\r
153  * or\r
154  *\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
158  * // funcPtrType.\r
159  * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);\r
160  * funcPtrType funcPtr;\r
161  *\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
164  *\r
165  * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \\r
166  *   returnType __declspec(dllimport) (* name)\r
167  *\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
170  * be defined by:\r
171  *\r
172  * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \\r
173  *   returnType __export _far _pascal (* name)\r
174  *\r
175  * In a UNIX environment, it might be defined by:\r
176  *\r
177  * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \\r
178  *   returnType (* name)\r
179  *\r
180  *\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
185  *\r
186  * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);\r
187  *\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
191  *\r
192  * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);\r
193  * myCallbackType myCallback;\r
194  *\r
195  * If you're using Microsoft Developer Studio 5.0 to do Win32\r
196  * Cryptoki development, it might be defined by:\r
197  *\r
198  * #define CK_CALLBACK_FUNCTION(returnType, name) \\r
199  *   returnType (* name)\r
200  *\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
203  *\r
204  * #define CK_CALLBACK_FUNCTION(returnType, name) \\r
205  *   returnType _far _pascal (* name)\r
206  *\r
207  * In a UNIX environment, it might be defined by:\r
208  *\r
209  * #define CK_CALLBACK_FUNCTION(returnType, name) \\r
210  *   returnType (* name)\r
211  *\r
212  *\r
213  * 6. NULL_PTR: This macro is the value of a NULL pointer.\r
214  *\r
215  * In any ANSI/ISO C environment (and in many others as well),\r
216  * this should best be defined by\r
217  *\r
218  * #ifndef NULL_PTR\r
219  * #define NULL_PTR 0\r
220  * #endif\r
221  */\r
222 \r
223 \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
227 \r
228 #define __PASTE(x,y)      x##y\r
229 \r
230 \r
231 /* ==============================================================\r
232  * Define the "extern" form of all the entry points.\r
233  * ==============================================================\r
234  */\r
235 \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
239 \r
240 /* pkcs11f.h has all the information about the Cryptoki\r
241  * function prototypes. */\r
242 #include "pkcs11f.h"\r
243 \r
244 #undef CK_NEED_ARG_LIST\r
245 #undef CK_PKCS11_FUNCTION_INFO\r
246 \r
247 \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
253  */\r
254 \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
258 \r
259 /* pkcs11f.h has all the information about the Cryptoki\r
260  * function prototypes. */\r
261 #include "pkcs11f.h"\r
262 \r
263 #undef CK_NEED_ARG_LIST\r
264 #undef CK_PKCS11_FUNCTION_INFO\r
265 \r
266 \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
272  * pkcs11t.h.\r
273  * ==============================================================\r
274  */\r
275 \r
276 #define CK_PKCS11_FUNCTION_INFO(name) \\r
277   __PASTE(CK_,name) name;\r
278   \r
279 struct CK_FUNCTION_LIST {\r
280 \r
281   CK_VERSION    version;  /* Cryptoki version */\r
282 \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
287 \r
288 };\r
289 \r
290 #undef CK_PKCS11_FUNCTION_INFO\r
291 \r
292 \r
293 #undef __PASTE\r
294 \r
295 #ifdef __cplusplus\r
296 }\r
297 #endif\r
298 \r
299 #endif\r