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