Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11.h
38918 views
/* Copyright (c) OASIS Open 2016. All Rights Reserved./1* /Distributed under the terms of the OASIS IPR Policy,2* [http://www.oasis-open.org/policies-guidelines/ipr], AS-IS, WITHOUT ANY3* IMPLIED OR EXPRESS WARRANTY; there is no warranty of MERCHANTABILITY, FITNESS FOR A4* PARTICULAR PURPOSE or NONINFRINGEMENT of the rights of others.5*/67/* Latest version of the specification:8* http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/pkcs11-base-v2.40.html9*/1011#ifndef _PKCS11_H_12#define _PKCS11_H_ 11314#ifdef __cplusplus15extern "C" {16#endif1718/* Before including this file (pkcs11.h) (or pkcs11t.h by19* itself), 5 platform-specific macros must be defined. These20* macros are described below, and typical definitions for them21* are also given. Be advised that these definitions can depend22* on both the platform and the compiler used (and possibly also23* on whether a Cryptoki library is linked statically or24* dynamically).25*26* In addition to defining these 5 macros, the packing convention27* for Cryptoki structures should be set. The Cryptoki28* convention on packing is that structures should be 1-byte29* aligned.30*31* If you're using Microsoft Developer Studio 5.0 to produce32* Win32 stuff, this might be done by using the following33* preprocessor directive before including pkcs11.h or pkcs11t.h:34*35* #pragma pack(push, cryptoki, 1)36*37* and using the following preprocessor directive after including38* pkcs11.h or pkcs11t.h:39*40* #pragma pack(pop, cryptoki)41*42* If you're using an earlier version of Microsoft Developer43* Studio to produce Win16 stuff, this might be done by using44* the following preprocessor directive before including45* pkcs11.h or pkcs11t.h:46*47* #pragma pack(1)48*49* In a UNIX environment, you're on your own for this. You might50* not need to do (or be able to do!) anything.51*52*53* Now for the macros:54*55*56* 1. CK_PTR: The indirection string for making a pointer to an57* object. It can be used like this:58*59* typedef CK_BYTE CK_PTR CK_BYTE_PTR;60*61* If you're using Microsoft Developer Studio 5.0 to produce62* Win32 stuff, it might be defined by:63*64* #define CK_PTR *65*66* If you're using an earlier version of Microsoft Developer67* Studio to produce Win16 stuff, it might be defined by:68*69* #define CK_PTR far *70*71* In a typical UNIX environment, it might be defined by:72*73* #define CK_PTR *74*75*76* 2. CK_DECLARE_FUNCTION(returnType, name): A macro which makes77* an importable Cryptoki library function declaration out of a78* return type and a function name. It should be used in the79* following fashion:80*81* extern CK_DECLARE_FUNCTION(CK_RV, C_Initialize)(82* CK_VOID_PTR pReserved83* );84*85* If you're using Microsoft Developer Studio 5.0 to declare a86* function in a Win32 Cryptoki .dll, it might be defined by:87*88* #define CK_DECLARE_FUNCTION(returnType, name) \89* returnType __declspec(dllimport) name90*91* If you're using an earlier version of Microsoft Developer92* Studio to declare a function in a Win16 Cryptoki .dll, it93* might be defined by:94*95* #define CK_DECLARE_FUNCTION(returnType, name) \96* returnType __export _far _pascal name97*98* In a UNIX environment, it might be defined by:99*100* #define CK_DECLARE_FUNCTION(returnType, name) \101* returnType name102*103*104* 3. CK_DECLARE_FUNCTION_POINTER(returnType, name): A macro105* which makes a Cryptoki API function pointer declaration or106* function pointer type declaration out of a return type and a107* function name. It should be used in the following fashion:108*109* // Define funcPtr to be a pointer to a Cryptoki API function110* // taking arguments args and returning CK_RV.111* CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtr)(args);112*113* or114*115* // Define funcPtrType to be the type of a pointer to a116* // Cryptoki API function taking arguments args and returning117* // CK_RV, and then define funcPtr to be a variable of type118* // funcPtrType.119* typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, funcPtrType)(args);120* funcPtrType funcPtr;121*122* If you're using Microsoft Developer Studio 5.0 to access123* functions in a Win32 Cryptoki .dll, in might be defined by:124*125* #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \126* returnType __declspec(dllimport) (* name)127*128* If you're using an earlier version of Microsoft Developer129* Studio to access functions in a Win16 Cryptoki .dll, it might130* be defined by:131*132* #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \133* returnType __export _far _pascal (* name)134*135* In a UNIX environment, it might be defined by:136*137* #define CK_DECLARE_FUNCTION_POINTER(returnType, name) \138* returnType (* name)139*140*141* 4. CK_CALLBACK_FUNCTION(returnType, name): A macro which makes142* a function pointer type for an application callback out of143* a return type for the callback and a name for the callback.144* It should be used in the following fashion:145*146* CK_CALLBACK_FUNCTION(CK_RV, myCallback)(args);147*148* to declare a function pointer, myCallback, to a callback149* which takes arguments args and returns a CK_RV. It can also150* be used like this:151*152* typedef CK_CALLBACK_FUNCTION(CK_RV, myCallbackType)(args);153* myCallbackType myCallback;154*155* If you're using Microsoft Developer Studio 5.0 to do Win32156* Cryptoki development, it might be defined by:157*158* #define CK_CALLBACK_FUNCTION(returnType, name) \159* returnType (* name)160*161* If you're using an earlier version of Microsoft Developer162* Studio to do Win16 development, it might be defined by:163*164* #define CK_CALLBACK_FUNCTION(returnType, name) \165* returnType _far _pascal (* name)166*167* In a UNIX environment, it might be defined by:168*169* #define CK_CALLBACK_FUNCTION(returnType, name) \170* returnType (* name)171*172*173* 5. NULL_PTR: This macro is the value of a NULL pointer.174*175* In any ANSI/ISO C environment (and in many others as well),176* this should best be defined by177*178* #ifndef NULL_PTR179* #define NULL_PTR 0180* #endif181*/182183184/* All the various Cryptoki types and #define'd values are in the185* file pkcs11t.h.186*/187#include "pkcs11t.h"188189#define __PASTE(x,y) x##y190191192/* ==============================================================193* Define the "extern" form of all the entry points.194* ==============================================================195*/196197#define CK_NEED_ARG_LIST 1198#define CK_PKCS11_FUNCTION_INFO(name) \199extern CK_DECLARE_FUNCTION(CK_RV, name)200201/* pkcs11f.h has all the information about the Cryptoki202* function prototypes.203*/204#include "pkcs11f.h"205206#undef CK_NEED_ARG_LIST207#undef CK_PKCS11_FUNCTION_INFO208209210/* ==============================================================211* Define the typedef form of all the entry points. That is, for212* each Cryptoki function C_XXX, define a type CK_C_XXX which is213* a pointer to that kind of function.214* ==============================================================215*/216217#define CK_NEED_ARG_LIST 1218#define CK_PKCS11_FUNCTION_INFO(name) \219typedef CK_DECLARE_FUNCTION_POINTER(CK_RV, __PASTE(CK_,name))220221/* pkcs11f.h has all the information about the Cryptoki222* function prototypes.223*/224#include "pkcs11f.h"225226#undef CK_NEED_ARG_LIST227#undef CK_PKCS11_FUNCTION_INFO228229230/* ==============================================================231* Define structed vector of entry points. A CK_FUNCTION_LIST232* contains a CK_VERSION indicating a library's Cryptoki version233* and then a whole slew of function pointers to the routines in234* the library. This type was declared, but not defined, in235* pkcs11t.h.236* ==============================================================237*/238239#define CK_PKCS11_FUNCTION_INFO(name) \240__PASTE(CK_,name) name;241242struct CK_FUNCTION_LIST {243244CK_VERSION version; /* Cryptoki version */245246/* Pile all the function pointers into the CK_FUNCTION_LIST. */247/* pkcs11f.h has all the information about the Cryptoki248* function prototypes.249*/250#include "pkcs11f.h"251252};253254#undef CK_PKCS11_FUNCTION_INFO255256257#undef __PASTE258259#ifdef __cplusplus260}261#endif262263#endif /* _PKCS11_H_ */264265266267