* tar xzf utvpn-src-unix-v101-7101-public-2010.06.27.tar.gz
[lab.git] / utvpn / utvpn-unix-v101-7101-public / src / Mayaqua / pkcs11.h
diff --git a/utvpn/utvpn-unix-v101-7101-public/src/Mayaqua/pkcs11.h b/utvpn/utvpn-unix-v101-7101-public/src/Mayaqua/pkcs11.h
new file mode 100644 (file)
index 0000000..5afbb7a
--- /dev/null
@@ -0,0 +1,299 @@
+/* pkcs11.h include file for PKCS #11. */\r
+/* $Revision: 1.4 $ */\r
+\r
+/* License to copy and use this software is granted provided that it is\r
+ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface\r
+ * (Cryptoki)" in all material mentioning or referencing this software.\r
+\r
+ * License is also granted to make and use derivative works provided that\r
+ * such works are identified as "derived from the RSA Security Inc. PKCS #11\r
+ * Cryptographic Token Interface (Cryptoki)" in all material mentioning or \r
+ * referencing the derived work.\r
+\r
+ * RSA Security Inc. makes no representations concerning either the \r
+ * merchantability of this software or the suitability of this software for\r
+ * any particular purpose. It is provided "as is" without express or implied\r
+ * warranty of any kind.\r
+ */\r
+\r
+#ifndef _PKCS11_H_\r
+#define _PKCS11_H_ 1\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/* Before including this file (pkcs11.h) (or pkcs11t.h by\r
+ * itself), 6 platform-specific macros must be defined.  These\r
+ * macros are described below, and typical definitions for them\r
+ * are also given.  Be advised that these definitions can depend\r
+ * on both the platform and the compiler used (and possibly also\r
+ * on whether a Cryptoki library is linked statically or\r
+ * dynamically).\r
+ *\r
+ * In addition to defining these 6 macros, the packing convention\r
+ * for Cryptoki structures should be set.  The Cryptoki\r
+ * convention on packing is that structures should be 1-byte\r
+ * aligned.\r
+ *\r
+ * If you're using Microsoft Developer Studio 5.0 to produce\r
+ * Win32 stuff, this might be done by using the following\r
+ * preprocessor directive before including pkcs11.h or pkcs11t.h:\r
+ *\r
+ * #pragma pack(push, cryptoki, 1)\r
+ *\r
+ * and using the following preprocessor directive after including\r
+ * pkcs11.h or pkcs11t.h:\r
+ *\r
+ * #pragma pack(pop, cryptoki)\r
+ *\r
+ * If you're using an earlier version of Microsoft Developer\r
+ * Studio to produce Win16 stuff, this might be done by using\r
+ * the following preprocessor directive before including\r
+ * pkcs11.h or pkcs11t.h:\r
+ *\r
+ * #pragma pack(1)\r
+ *\r
+ * In a UNIX environment, you're on your own for this.  You might\r
+ * not need to do (or be able to do!) anything.\r
+ *\r
+ *\r
+ * Now for the macros:\r
+ *\r
+ *\r
+ * 1. CK_PTR: The indirection string for making a pointer to an\r
+ * object.  It can be used like this:\r
+ *\r
+ * typedef CK_BYTE CK_PTR CK_BYTE_PTR;\r
+ *\r
+ * If you're using Microsoft Developer Studio 5.0 to produce\r
+ * Win32 stuff, it might be defined by:\r
+ *\r
+ * #define CK_PTR *\r
+ *\r
+ * If you're using an earlier version of Microsoft Developer\r
+ * Studio to produce Win16 stuff, it might be defined by:\r
+ *\r
+ * #define CK_PTR far *\r
+ *\r
+ * In a typical UNIX environment, it might be defined by:\r
+ *\r
+ * #define CK_PTR *\r
+ *\r
+ *\r
+ * 2. CK_DEFINE_FUNCTION(returnType, name): A macro which makes\r
+ * an exportable Cryptoki library function definition out of a\r
+ * return type and a function name.  It should be used in the\r
+ * following fashion to define the exposed Cryptoki functions in\r
+ * a Cryptoki library:\r
+ *\r
+ * CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(\r
+ *   CK_VOID_PTR pReserved\r
+ * )\r
+ * {\r
+ *   ...\r
+ * }\r
+ *\r
+ * If you're using Microsoft Developer Studio 5.0 to define a\r
+ * function in a Win32 Cryptoki .dll, it might be defined by:\r
+ *\r
+ * #define CK_DEFINE_FUNCTION(returnType, name) \\r
+ *   returnType __declspec(dllexport) name\r
+ *\r
+ * If you're using an earlier version of Microsoft Developer\r
+ * Studio to define a function in a Win16 Cryptoki .dll, it\r
+ * might be defined by:\r
+ *\r
+ * #define CK_DEFINE_FUNCTION(returnType, name) \\r
+ *   returnType __export _far _pascal name\r
+ *\r
+ * In a UNIX environment, it might be defined by:\r
+ *\r
+ * #define CK_DEFINE_FUNCTION(returnType, name) \\r
+ *   returnType name\r
+ *\r
+ *\r
+ * 3. CK_DECLARE_FUNCTION(returnType, name): A macro which makes\r
+ * an importable Cryptoki library function declaration out of a\r
+ * return type and a function name.  It should be used in the\r
+ * following fashion:\r
+ *\r
+ * extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(\r
+ *   CK_VOID_PTR pReserved\r
+ * );\r
+ *\r
+ * If you're using Microsoft Developer Studio 5.0 to declare a\r
+ * function in a Win32 Cryptoki .dll, it might be defined by:\r
+ *\r
+ * #define CK_DECLARE_FUNCTION(returnType, name) \\r
+ *   returnType __declspec(dllimport) name\r
+ *\r
+ * If you're using an earlier version of Microsoft Developer\r
+ * Studio to declare a function in a Win16 Cryptoki .dll, it\r
+ * might be defined by:\r
+ *\r
+ * #define CK_DECLARE_FUNCTION(returnType, name) \\r
+ *   returnType __export _far _pascal name\r
+ *\r
+ * In a UNIX environment, it might be defined by:\r
+ *\r
+ * #define CK_DECLARE_FUNCTION(returnType, name) \\r
+ *   returnType name\r
+ *\r
+ *\r
+ * 4. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro\r
+ * which makes a Cryptoki API function pointer declaration or\r
+ * function pointer type declaration out of a return type and a\r
+ * function name.  It should be used in the following fashion:\r
+ *\r
+ * // Define funcPtr to be a pointer to a Cryptoki API function\r
+ * // taking arguments args and returning CK_RV.\r
+ * CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);\r
+ *\r
+ * or\r
+ *\r
+ * // Define funcPtrType to be the type of a pointer to a\r
+ * // Cryptoki API function taking arguments args and returning\r
+ * // CK_RV, and then define funcPtr to be a variable of type\r
+ * // funcPtrType.\r
+ * typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);\r
+ * funcPtrType funcPtr;\r
+ *\r
+ * If you're using Microsoft Developer Studio 5.0 to access\r
+ * functions in a Win32 Cryptoki .dll, in might be defined by:\r
+ *\r
+ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \\r
+ *   returnType __declspec(dllimport) (* name)\r
+ *\r
+ * If you're using an earlier version of Microsoft Developer\r
+ * Studio to access functions in a Win16 Cryptoki .dll, it might\r
+ * be defined by:\r
+ *\r
+ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \\r
+ *   returnType __export _far _pascal (* name)\r
+ *\r
+ * In a UNIX environment, it might be defined by:\r
+ *\r
+ * #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \\r
+ *   returnType (* name)\r
+ *\r
+ *\r
+ * 5. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes\r
+ * a function pointer type for an application callback out of\r
+ * a return type for the callback and a name for the callback.\r
+ * It should be used in the following fashion:\r
+ *\r
+ * CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);\r
+ *\r
+ * to declare a function pointer, myCallback, to a callback\r
+ * which takes arguments args and returns a CK_RV.  It can also\r
+ * be used like this:\r
+ *\r
+ * typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);\r
+ * myCallbackType myCallback;\r
+ *\r
+ * If you're using Microsoft Developer Studio 5.0 to do Win32\r
+ * Cryptoki development, it might be defined by:\r
+ *\r
+ * #define CK_CALLBACK_FUNCTION(returnType, name) \\r
+ *   returnType (* name)\r
+ *\r
+ * If you're using an earlier version of Microsoft Developer\r
+ * Studio to do Win16 development, it might be defined by:\r
+ *\r
+ * #define CK_CALLBACK_FUNCTION(returnType, name) \\r
+ *   returnType _far _pascal (* name)\r
+ *\r
+ * In a UNIX environment, it might be defined by:\r
+ *\r
+ * #define CK_CALLBACK_FUNCTION(returnType, name) \\r
+ *   returnType (* name)\r
+ *\r
+ *\r
+ * 6. NULL_PTR: This macro is the value of a NULL pointer.\r
+ *\r
+ * In any ANSI/ISO C environment (and in many others as well),\r
+ * this should best be defined by\r
+ *\r
+ * #ifndef NULL_PTR\r
+ * #define NULL_PTR 0\r
+ * #endif\r
+ */\r
+\r
+\r
+/* All the various Cryptoki types and #define'd values are in the\r
+ * file pkcs11t.h. */\r
+#include "pkcs11t.h"\r
+\r
+#define __PASTE(x,y)      x##y\r
+\r
+\r
+/* ==============================================================\r
+ * Define the "extern" form of all the entry points.\r
+ * ==============================================================\r
+ */\r
+\r
+#define CK_NEED_ARG_LIST  1\r
+#define CK_PKCS11_FUNCTION_INFO(name) \\r
+  extern CK_DECLARE_FUNCTION(CK_RV, name)\r
+\r
+/* pkcs11f.h has all the information about the Cryptoki\r
+ * function prototypes. */\r
+#include "pkcs11f.h"\r
+\r
+#undef CK_NEED_ARG_LIST\r
+#undef CK_PKCS11_FUNCTION_INFO\r
+\r
+\r
+/* ==============================================================\r
+ * Define the typedef form of all the entry points.  That is, for\r
+ * each Cryptoki function C_XXX, define a type CK_C_XXX which is\r
+ * a pointer to that kind of function.\r
+ * ==============================================================\r
+ */\r
+\r
+#define CK_NEED_ARG_LIST  1\r
+#define CK_PKCS11_FUNCTION_INFO(name) \\r
+  typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))\r
+\r
+/* pkcs11f.h has all the information about the Cryptoki\r
+ * function prototypes. */\r
+#include "pkcs11f.h"\r
+\r
+#undef CK_NEED_ARG_LIST\r
+#undef CK_PKCS11_FUNCTION_INFO\r
+\r
+\r
+/* ==============================================================\r
+ * Define structed vector of entry points.  A CK_FUNCTION_LIST\r
+ * contains a CK_VERSION indicating a library's Cryptoki version\r
+ * and then a whole slew of function pointers to the routines in\r
+ * the library.  This type was declared, but not defined, in\r
+ * pkcs11t.h.\r
+ * ==============================================================\r
+ */\r
+\r
+#define CK_PKCS11_FUNCTION_INFO(name) \\r
+  __PASTE(CK_,name) name;\r
+  \r
+struct CK_FUNCTION_LIST {\r
+\r
+  CK_VERSION    version;  /* Cryptoki version */\r
+\r
+/* Pile all the function pointers into the CK_FUNCTION_LIST. */\r
+/* pkcs11f.h has all the information about the Cryptoki\r
+ * function prototypes. */\r
+#include "pkcs11f.h"\r
+\r
+};\r
+\r
+#undef CK_PKCS11_FUNCTION_INFO\r
+\r
+\r
+#undef __PASTE\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r