Bug 1888590 - Mark some subtests on trusted-types-event-handlers.html as failing...
[gecko.git] / third_party / rust / pkcs11-bindings / pkcs11.h
blobcf520ce0496a25388739e563e2469f555dd71503
1 /* Copyright (c) OASIS Open 2016,2019. All Rights Reserved./
2 * /Distributed under the terms of the OASIS IPR Policy,
3 * [http://www.oasis-open.org/policies-guidelines/ipr], AS-IS, WITHOUT ANY
4 * IMPLIED OR EXPRESS WARRANTY; there is no warranty of MERCHANTABILITY, FITNESS FOR A
5 * PARTICULAR PURPOSE or NONINFRINGEMENT of the rights of others.
6 */
8 /* Latest version of the specification:
9 * http://docs.oasis-open.org/pkcs11/pkcs11-base/v3.0/pkcs11-base-v3.0.html
12 #ifndef _PKCS11_H_
13 #define _PKCS11_H_ 1
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
19 /* Before including this file (pkcs11.h) (or pkcs11t.h by
20 * itself), 5 platform-specific macros must be defined. These
21 * macros are described below, and typical definitions for them
22 * are also given. Be advised that these definitions can depend
23 * on both the platform and the compiler used (and possibly also
24 * on whether a Cryptoki library is linked statically or
25 * dynamically).
27 * In addition to defining these 5 macros, the packing convention
28 * for Cryptoki structures should be set. The Cryptoki
29 * convention on packing is that structures should be 1-byte
30 * aligned.
32 * If you're using Windows this might be done by using the following
33 * preprocessor directive before including pkcs11.h or pkcs11t.h:
35 * #pragma pack(push, cryptoki, 1)
37 * and using the following preprocessor directive after including
38 * pkcs11.h or pkcs11t.h:
40 * #pragma pack(pop, cryptoki)
42 * In a UNIX environment, you're on your own for this. You might
43 * not need to do (or be able to do!) anything.
46 * Now for the macros:
49 * 1. CK_PTR: The indirection string for making a pointer to an
50 * object. It can be used like this:
52 * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
54 * If you're using Windows, it might be defined by:
56 * #define CK_PTR *
58 * In a typical UNIX environment, it might be defined by:
60 * #define CK_PTR *
63 * 2. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
64 * an importable Cryptoki library function declaration out of a
65 * return type and a function name. It should be used in the
66 * following fashion:
68 * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
69 * CK_VOID_PTR pReserved
70 * );
72 * If you're using Windows to declare a function in a Win32 Cryptoki .dll,
73 * it might be defined by:
75 * #define CK_DECLARE_FUNCTION(returnType, name) \
76 * returnType __declspec(dllimport) name
78 * In a UNIX environment, it might be defined by:
80 * #define CK_DECLARE_FUNCTION(returnType, name) \
81 * returnType name
84 * 3. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
85 * which makes a Cryptoki API function pointer declaration or
86 * function pointer type declaration out of a return type and a
87 * function name. It should be used in the following fashion:
89 * // Define funcPtr to be a pointer to a Cryptoki API function
90 * // taking arguments args and returning CK_RV.
91 * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
93 * or
95 * // Define funcPtrType to be the type of a pointer to a
96 * // Cryptoki API function taking arguments args and returning
97 * // CK_RV, and then define funcPtr to be a variable of type
98 * // funcPtrType.
99 * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
100 * funcPtrType funcPtr;
102 * If you're using Windows to access
103 * functions in a Win32 Cryptoki .dll, in might be defined by:
105 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
106 * returnType __declspec(dllimport) (* name)
108 * In a UNIX environment, it might be defined by:
110 * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
111 * returnType (* name)
114 * 4. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
115 * a function pointer type for an application callback out of
116 * a return type for the callback and a name for the callback.
117 * It should be used in the following fashion:
119 * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
121 * to declare a function pointer, myCallback, to a callback
122 * which takes arguments args and returns a CK_RV. It can also
123 * be used like this:
125 * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
126 * myCallbackType myCallback;
128 * If you're using Windows, it might be defined by:
130 * #define CK_CALLBACK_FUNCTION(returnType, name) \
131 * returnType (* name)
133 * In a UNIX environment, it might be defined by:
135 * #define CK_CALLBACK_FUNCTION(returnType, name) \
136 * returnType (* name)
139 * 5. NULL_PTR: This macro is the value of a NULL pointer.
141 * In any ANSI/ISO C environment (and in many others as well),
142 * this should best be defined by
144 * #ifndef NULL_PTR
145 * #define NULL_PTR 0
146 * #endif
150 /* All the various Cryptoki types and #define'd values are in the
151 * file pkcs11t.h.
153 #include "pkcs11t.h"
155 #define __PASTE(x,y) x##y
158 /* ==============================================================
159 * Define the "extern" form of all the entry points.
160 * ==============================================================
163 #define CK_NEED_ARG_LIST 1
164 #define CK_PKCS11_FUNCTION_INFO(name) \
165 extern CK_DECLARE_FUNCTION(CK_RV, name)
167 /* pkcs11f.h has all the information about the Cryptoki
168 * function prototypes.
170 #include "pkcs11f.h"
172 #undef CK_NEED_ARG_LIST
173 #undef CK_PKCS11_FUNCTION_INFO
176 /* ==============================================================
177 * Define the typedef form of all the entry points. That is, for
178 * each Cryptoki function C_XXX, define a type CK_C_XXX which is
179 * a pointer to that kind of function.
180 * ==============================================================
183 #define CK_NEED_ARG_LIST 1
184 #define CK_PKCS11_FUNCTION_INFO(name) \
185 typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
187 /* pkcs11f.h has all the information about the Cryptoki
188 * function prototypes.
190 #include "pkcs11f.h"
192 #undef CK_NEED_ARG_LIST
193 #undef CK_PKCS11_FUNCTION_INFO
196 /* ==============================================================
197 * Define structed vector of entry points. A CK_FUNCTION_LIST
198 * contains a CK_VERSION indicating a library's Cryptoki version
199 * and then a whole slew of function pointers to the routines in
200 * the library. This type was declared, but not defined, in
201 * pkcs11t.h.
202 * ==============================================================
205 #define CK_PKCS11_FUNCTION_INFO(name) \
206 __PASTE(CK_,name) name;
208 /* Create the 3.0 Function list */
209 struct CK_FUNCTION_LIST_3_0 {
211 CK_VERSION version; /* Cryptoki version */
213 /* Pile all the function pointers into the CK_FUNCTION_LIST. */
214 /* pkcs11f.h has all the information about the Cryptoki
215 * function prototypes.
217 #include "pkcs11f.h"
221 #define CK_PKCS11_2_0_ONLY 1
223 /* Continue to define the old CK_FUNCTION_LIST */
224 struct CK_FUNCTION_LIST {
226 CK_VERSION version; /* Cryptoki version */
228 /* Pile all the function pointers into the CK_FUNCTION_LIST. */
229 /* pkcs11f.h has all the information about the Cryptoki
230 * function prototypes.
232 #include "pkcs11f.h"
236 #undef CK_PKCS11_FUNCTION_INFO
237 #undef CK_PKCS11_2_0_ONLY
240 #undef __PASTE
242 #ifdef __cplusplus
244 #endif
246 #endif /* _PKCS11_H_ */