pkcs11.h

Go to the documentation of this file.
00001 /* pkcs11.h include file for PKCS #11. */
00002 /* $Revision: 1.2 $ */
00003 
00004 /* License to copy and use this software is granted provided that it is
00005  * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
00006  * (Cryptoki)" in all material mentioning or referencing this software.
00007 
00008  * License is also granted to make and use derivative works provided that
00009  * such works are identified as "derived from the RSA Security Inc. PKCS #11
00010  * Cryptographic Token Interface (Cryptoki)" in all material mentioning or 
00011  * referencing the derived work.
00012 
00013  * RSA Security Inc. makes no representations concerning either the 
00014  * merchantability of this software or the suitability of this software for
00015  * any particular purpose. It is provided "as is" without express or implied
00016  * warranty of any kind.
00017  */
00018 
00019 #ifndef _PKCS11_H_
00020 #define _PKCS11_H_ 1
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 /* Before including this file (pkcs11.h) (or pkcs11t.h by
00027  * itself), 6 platform-specific macros must be defined.  These
00028  * macros are described below, and typical definitions for them
00029  * are also given.  Be advised that these definitions can depend
00030  * on both the platform and the compiler used (and possibly also
00031  * on whether a Cryptoki library is linked statically or
00032  * dynamically).
00033  *
00034  * In addition to defining these 6 macros, the packing convention
00035  * for Cryptoki structures should be set.  The Cryptoki
00036  * convention on packing is that structures should be 1-byte
00037  * aligned.
00038  *
00039  * If you're using Microsoft Developer Studio 5.0 to produce
00040  * Win32 stuff, this might be done by using the following
00041  * preprocessor directive before including pkcs11.h or pkcs11t.h:
00042  *
00043  * #pragma pack(push, cryptoki, 1)
00044  *
00045  * and using the following preprocessor directive after including
00046  * pkcs11.h or pkcs11t.h:
00047  *
00048  * #pragma pack(pop, cryptoki)
00049  *
00050  * If you're using an earlier version of Microsoft Developer
00051  * Studio to produce Win16 stuff, this might be done by using
00052  * the following preprocessor directive before including
00053  * pkcs11.h or pkcs11t.h:
00054  *
00055  * #pragma pack(1)
00056  *
00057  * In a UNIX environment, you're on your own for this.  You might
00058  * not need to do (or be able to do!) anything.
00059  *
00060  *
00061  * Now for the macros:
00062  *
00063  *
00064  * 1. CK_PTR: The indirection string for making a pointer to an
00065  * object.  It can be used like this:
00066  *
00067  * typedef CK_BYTE CK_PTR CK_BYTE_PTR;
00068  *
00069  * If you're using Microsoft Developer Studio 5.0 to produce
00070  * Win32 stuff, it might be defined by:
00071  *
00072  * #define CK_PTR *
00073  *
00074  * If you're using an earlier version of Microsoft Developer
00075  * Studio to produce Win16 stuff, it might be defined by:
00076  *
00077  * #define CK_PTR far *
00078  *
00079  * In a typical UNIX environment, it might be defined by:
00080  *
00081  * #define CK_PTR *
00082  *
00083  *
00084  * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes
00085  * an exportable Cryptoki library function definition out of a
00086  * return type and a function name.  It should be used in the
00087  * following fashion to define the exposed Cryptoki functions in
00088  * a Cryptoki library:
00089  *
00090  * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
00091  *   CK_VOID_PTR pReserved
00092  * )
00093  * {
00094  *   ...
00095  * }
00096  *
00097  * If you're using Microsoft Developer Studio 5.0 to define a
00098  * function in a Win32 Cryptoki .dll, it might be defined by:
00099  *
00100  * #define CK_DEFINE_FUNCTION(returnType, name) \
00101  *   returnType __declspec(dllexport) name
00102  *
00103  * If you're using an earlier version of Microsoft Developer
00104  * Studio to define a function in a Win16 Cryptoki .dll, it
00105  * might be defined by:
00106  *
00107  * #define CK_DEFINE_FUNCTION(returnType, name) \
00108  *   returnType __export _far _pascal name
00109  *
00110  * In a UNIX environment, it might be defined by:
00111  *
00112  * #define CK_DEFINE_FUNCTION(returnType, name) \
00113  *   returnType name
00114  *
00115  *
00116  * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes
00117  * an importable Cryptoki library function declaration out of a
00118  * return type and a function name.  It should be used in the
00119  * following fashion:
00120  *
00121  * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(
00122  *   CK_VOID_PTR pReserved
00123  * );
00124  *
00125  * If you're using Microsoft Developer Studio 5.0 to declare a
00126  * function in a Win32 Cryptoki .dll, it might be defined by:
00127  *
00128  * #define CK_DECLARE_FUNCTION(returnType, name) \
00129  *   returnType __declspec(dllimport) name
00130  *
00131  * If you're using an earlier version of Microsoft Developer
00132  * Studio to declare a function in a Win16 Cryptoki .dll, it
00133  * might be defined by:
00134  *
00135  * #define CK_DECLARE_FUNCTION(returnType, name) \
00136  *   returnType __export _far _pascal name
00137  *
00138  * In a UNIX environment, it might be defined by:
00139  *
00140  * #define CK_DECLARE_FUNCTION(returnType, name) \
00141  *   returnType name
00142  *
00143  *
00144  * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro
00145  * which makes a Cryptoki API function pointer declaration or
00146  * function pointer type declaration out of a return type and a
00147  * function name.  It should be used in the following fashion:
00148  *
00149  * // Define funcPtr to be a pointer to a Cryptoki API function
00150  * // taking arguments args and returning CK_RV.
00151  * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);
00152  *
00153  * or
00154  *
00155  * // Define funcPtrType to be the type of a pointer to a
00156  * // Cryptoki API function taking arguments args and returning
00157  * // CK_RV, and then define funcPtr to be a variable of type
00158  * // funcPtrType.
00159  * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);
00160  * funcPtrType funcPtr;
00161  *
00162  * If you're using Microsoft Developer Studio 5.0 to access
00163  * functions in a Win32 Cryptoki .dll, in might be defined by:
00164  *
00165  * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
00166  *   returnType __declspec(dllimport) (* name)
00167  *
00168  * If you're using an earlier version of Microsoft Developer
00169  * Studio to access functions in a Win16 Cryptoki .dll, it might
00170  * be defined by:
00171  *
00172  * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
00173  *   returnType __export _far _pascal (* name)
00174  *
00175  * In a UNIX environment, it might be defined by:
00176  *
00177  * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \
00178  *   returnType (* name)
00179  *
00180  *
00181  * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes
00182  * a function pointer type for an application callback out of
00183  * a return type for the callback and a name for the callback.
00184  * It should be used in the following fashion:
00185  *
00186  * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);
00187  *
00188  * to declare a function pointer, myCallback, to a callback
00189  * which takes arguments args and returns a CK_RV.  It can also
00190  * be used like this:
00191  *
00192  * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);
00193  * myCallbackType myCallback;
00194  *
00195  * If you're using Microsoft Developer Studio 5.0 to do Win32
00196  * Cryptoki development, it might be defined by:
00197  *
00198  * #define CK_CALLBACK_FUNCTION(returnType, name) \
00199  *   returnType (* name)
00200  *
00201  * If you're using an earlier version of Microsoft Developer
00202  * Studio to do Win16 development, it might be defined by:
00203  *
00204  * #define CK_CALLBACK_FUNCTION(returnType, name) \
00205  *   returnType _far _pascal (* name)
00206  *
00207  * In a UNIX environment, it might be defined by:
00208  *
00209  * #define CK_CALLBACK_FUNCTION(returnType, name) \
00210  *   returnType (* name)
00211  *
00212  *
00213  * 6. NULL_PTR: This macro is the value of a NULL pointer.
00214  *
00215  * In any ANSI/ISO C environment (and in many others as well),
00216  * this should best be defined by
00217  *
00218  * #ifndef NULL_PTR
00219  * #define NULL_PTR 0
00220  * #endif
00221  */
00222 
00223 
00224 /* All the various Cryptoki types and #define'd values are in the
00225  * file pkcs11t.h. */
00226 #include "pkcs11t.h"
00227 
00228 #define __PASTE(x,y)      x##y
00229 
00230 
00231 /* ==============================================================
00232  * Define the "extern" form of all the entry points.
00233  * ==============================================================
00234  */
00235 
00236 #define CK_NEED_ARG_LIST  1
00237 #define CK_PKCS11_FUNCTION_INFO(name) \
00238   extern CK_DECLARE_FUNCTION(CK_RV, name)
00239 
00240 /* pkcs11f.h has all the information about the Cryptoki
00241  * function prototypes. */
00242 #include "pkcs11f.h"
00243 
00244 #undef CK_NEED_ARG_LIST
00245 #undef CK_PKCS11_FUNCTION_INFO
00246 
00247 
00248 /* ==============================================================
00249  * Define the typedef form of all the entry points.  That is, for
00250  * each Cryptoki function C_XXX, define a type CK_C_XXX which is
00251  * a pointer to that kind of function.
00252  * ==============================================================
00253  */
00254 
00255 #define CK_NEED_ARG_LIST  1
00256 #define CK_PKCS11_FUNCTION_INFO(name) \
00257   typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))
00258 
00259 /* pkcs11f.h has all the information about the Cryptoki
00260  * function prototypes. */
00261 #include "pkcs11f.h"
00262 
00263 #undef CK_NEED_ARG_LIST
00264 #undef CK_PKCS11_FUNCTION_INFO
00265 
00266 
00267 /* ==============================================================
00268  * Define structed vector of entry points.  A CK_FUNCTION_LIST
00269  * contains a CK_VERSION indicating a library's Cryptoki version
00270  * and then a whole slew of function pointers to the routines in
00271  * the library.  This type was declared, but not defined, in
00272  * pkcs11t.h.
00273  * ==============================================================
00274  */
00275 
00276 #define CK_PKCS11_FUNCTION_INFO(name) \
00277   __PASTE(CK_,name) name;
00278   
00279 struct CK_FUNCTION_LIST {
00280 
00281   CK_VERSION    version;  /* Cryptoki version */
00282 
00283 /* Pile all the function pointers into the CK_FUNCTION_LIST. */
00284 /* pkcs11f.h has all the information about the Cryptoki
00285  * function prototypes. */
00286 #include "pkcs11f.h"
00287 
00288 };
00289 
00290 #undef CK_PKCS11_FUNCTION_INFO
00291 
00292 
00293 #undef __PASTE
00294 
00295 #ifdef __cplusplus
00296 }
00297 #endif
00298 
00299 #endif

Generated on Tue Apr 28 17:41:04 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha