Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / bind / dist / bin / pkcs11 / include / pkcs11.h
blob11b79c9fd0d2010865d1284303ba09a350142af2
1 /* $NetBSD$ */
3 /* pkcs11.h include file for PKCS #11. */
4 /* Revision: 1.2 */
6 /* License to copy and use this software is granted provided that it is
7 * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
8 * (Cryptoki)" in all material mentioning or referencing this software.
10 * License is also granted to make and use derivative works provided that
11 * such works are identified as "derived from the RSA Security Inc. PKCS #11
12 * Cryptographic Token Interface (Cryptoki)" in all material mentioning or
13 * referencing the derived work.
15 * RSA Security Inc. makes no representations concerning either the
16 * merchantability of this software or the suitability of this software for
17 * any particular purpose. It is provided "as is" without express or implied
18 * warranty of any kind.
21 #ifndef _PKCS11_H_
22 #define _PKCS11_H_ 1
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Before including this file (pkcs11.h) (or pkcs11t.h by
29 * itself), 6 platform-specific macros must be defined. These
30 * macros are described below, and typical definitions for them
31 * are also given. Be advised that these definitions can depend
32 * on both the platform and the compiler used (and possibly also
33 * on whether a Cryptoki library is linked statically or
34 * dynamically).
36 * In addition to defining these 6 macros, the packing convention
37 * for Cryptoki structures should be set. The Cryptoki
38 * convention on packing is that structures should be 1-byte
39 * aligned.
41 * If you're using Microsoft Developer Studio 5.0 to produce
42 * Win32 stuff, this might be done by using the following
43 * preprocessor directive before including pkcs11.h or pkcs11t.h:
45 * #pragma pack(push, cryptoki, 1)
47 * and using the following preprocessor directive after including
48 * pkcs11.h or pkcs11t.h:
50 * #pragma pack(pop, cryptoki)
52 * If you're using an earlier version of Microsoft Developer
53 * Studio to produce Win16 stuff, this might be done by using
54 * the following preprocessor directive before including
55 * pkcs11.h or pkcs11t.h:
57 * #pragma pack(1)
59 * In a UNIX environment, you're on your own for this. You might
60 * not need to do (or be able to do!) anything.
63 * Now for the macros:
66 * 1. CK_PTR: The indirection string for making a pointer to an
67 * object. It can be used like this:
69 * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
71 * If you're using Microsoft Developer Studio 5.0 to produce
72 * Win32 stuff, it might be defined by:
74 * #define CK_PTR *
76 * If you're using an earlier version of Microsoft Developer
77 * Studio to produce Win16 stuff, it might be defined by:
79 * #define CK_PTR far *
81 * In a typical UNIX environment, it might be defined by:
83 * #define CK_PTR *
86 * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes
87 * an exportable Cryptoki library function definition out of a
88 * return type and a function name. It should be used in the
89 * following fashion to define the exposed Cryptoki functions in
90 * a Cryptoki library:
92 * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
93 * CK_VOID_PTR pReserved
94 * )
95 * {
96 * ...
97 * }
99 * If you're using Microsoft Developer Studio 5.0 to define a
100 * function in a Win32 Cryptoki .dll, it might be defined by:
102 * #define CK_DEFINE_FUNCTION(returnType, name) \
103 * returnType __declspec(dllexport) name
105 * If you're using an earlier version of Microsoft Developer
106 * Studio to define a function in a Win16 Cryptoki .dll, it
107 * might be defined by:
109 * #define CK_DEFINE_FUNCTION(returnType, name) \
110 * returnType __export _far _pascal name
112 * In a UNIX environment, it might be defined by:
114 * #define CK_DEFINE_FUNCTION(returnType, name) \
115 * returnType name
118 * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
119 * an importable Cryptoki library function declaration out of a
120 * return type and a function name. It should be used in the
121 * following fashion:
123 * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
124 * CK_VOID_PTR pReserved
125 * );
127 * If you're using Microsoft Developer Studio 5.0 to declare a
128 * function in a Win32 Cryptoki .dll, it might be defined by:
130 * #define CK_DECLARE_FUNCTION(returnType, name) \
131 * returnType __declspec(dllimport) name
133 * If you're using an earlier version of Microsoft Developer
134 * Studio to declare a function in a Win16 Cryptoki .dll, it
135 * might be defined by:
137 * #define CK_DECLARE_FUNCTION(returnType, name) \
138 * returnType __export _far _pascal name
140 * In a UNIX environment, it might be defined by:
142 * #define CK_DECLARE_FUNCTION(returnType, name) \
143 * returnType name
146 * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
147 * which makes a Cryptoki API function pointer declaration or
148 * function pointer type declaration out of a return type and a
149 * function name. It should be used in the following fashion:
151 * // Define funcPtr to be a pointer to a Cryptoki API function
152 * // taking arguments args and returning CK_RV.
153 * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
155 * or
157 * // Define funcPtrType to be the type of a pointer to a
158 * // Cryptoki API function taking arguments args and returning
159 * // CK_RV, and then define funcPtr to be a variable of type
160 * // funcPtrType.
161 * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
162 * funcPtrType funcPtr;
164 * If you're using Microsoft Developer Studio 5.0 to access
165 * functions in a Win32 Cryptoki .dll, in might be defined by:
167 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
168 * returnType __declspec(dllimport) (* name)
170 * If you're using an earlier version of Microsoft Developer
171 * Studio to access functions in a Win16 Cryptoki .dll, it might
172 * be defined by:
174 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
175 * returnType __export _far _pascal (* name)
177 * In a UNIX environment, it might be defined by:
179 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
180 * returnType (* name)
183 * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
184 * a function pointer type for an application callback out of
185 * a return type for the callback and a name for the callback.
186 * It should be used in the following fashion:
188 * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
190 * to declare a function pointer, myCallback, to a callback
191 * which takes arguments args and returns a CK_RV. It can also
192 * be used like this:
194 * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
195 * myCallbackType myCallback;
197 * If you're using Microsoft Developer Studio 5.0 to do Win32
198 * Cryptoki development, it might be defined by:
200 * #define CK_CALLBACK_FUNCTION(returnType, name) \
201 * returnType (* name)
203 * If you're using an earlier version of Microsoft Developer
204 * Studio to do Win16 development, it might be defined by:
206 * #define CK_CALLBACK_FUNCTION(returnType, name) \
207 * returnType _far _pascal (* name)
209 * In a UNIX environment, it might be defined by:
211 * #define CK_CALLBACK_FUNCTION(returnType, name) \
212 * returnType (* name)
215 * 6. NULL_PTR: This macro is the value of a NULL pointer.
217 * In any ANSI/ISO C environment (and in many others as well),
218 * this should best be defined by
220 * #ifndef NULL_PTR
221 * #define NULL_PTR 0
222 * #endif
226 /* All the various Cryptoki types and #define'd values are in the
227 * file pkcs11t.h. */
228 #include "pkcs11t.h"
230 #define __PASTE(x,y) x##y
233 /* ==============================================================
234 * Define the "extern" form of all the entry points.
235 * ==============================================================
238 #define CK_NEED_ARG_LIST 1
239 #define CK_PKCS11_FUNCTION_INFO(name) \
240 extern CK_DECLARE_FUNCTION(CK_RV, name)
242 /* pkcs11f.h has all the information about the Cryptoki
243 * function prototypes. */
244 #include "pkcs11f.h"
246 #undef CK_NEED_ARG_LIST
247 #undef CK_PKCS11_FUNCTION_INFO
250 /* ==============================================================
251 * Define the typedef form of all the entry points. That is, for
252 * each Cryptoki function C_XXX, define a type CK_C_XXX which is
253 * a pointer to that kind of function.
254 * ==============================================================
257 #define CK_NEED_ARG_LIST 1
258 #define CK_PKCS11_FUNCTION_INFO(name) \
259 typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
261 /* pkcs11f.h has all the information about the Cryptoki
262 * function prototypes. */
263 #include "pkcs11f.h"
265 #undef CK_NEED_ARG_LIST
266 #undef CK_PKCS11_FUNCTION_INFO
269 /* ==============================================================
270 * Define structed vector of entry points. A CK_FUNCTION_LIST
271 * contains a CK_VERSION indicating a library's Cryptoki version
272 * and then a whole slew of function pointers to the routines in
273 * the library. This type was declared, but not defined, in
274 * pkcs11t.h.
275 * ==============================================================
278 #define CK_PKCS11_FUNCTION_INFO(name) \
279 __PASTE(CK_,name) name;
281 struct CK_FUNCTION_LIST {
283 CK_VERSION version; /* Cryptoki version */
285 /* Pile all the function pointers into the CK_FUNCTION_LIST. */
286 /* pkcs11f.h has all the information about the Cryptoki
287 * function prototypes. */
288 #include "pkcs11f.h"
292 #undef CK_PKCS11_FUNCTION_INFO
295 #undef __PASTE
297 #ifdef __cplusplus
299 #endif
301 #endif