Pkcs #11: Cryptographic Token Interface Standard rsa laboratories


Sample platform- and compiler-dependent code



Download 1.99 Mb.
Page9/50
Date28.01.2017
Size1.99 Mb.
#9297
1   ...   5   6   7   8   9   10   11   12   ...   50

7.3. Sample platform- and compiler-dependent code

7.3.1. Win32


Developers using Microsoft Developer Studio 5.0 to produce C or C++ code which implements or makes use of a Win32 Cryptoki .dll might issue the following directives before including any Cryptoki header files:

#pragma pack(push, cryptoki, 1)


#define CK_PTR *
#define CK_DEFINE_FUNCTION(returnType, name) \

returnType __declspec(dllexport) name


#define CK_DECLARE_FUNCTION(returnType, name) \

returnType __declspec(dllimport) name


#define CK_DECLARE_FUNCTION_POINTER(returnType, name) \

returnType __declspec(dllimport) (* name)


#define CK_CALLBACK_FUNCTION(returnType, name) \

returnType (* name)


#ifndef NULL_PTR

#define NULL_PTR 0

#endif
After including any Cryptoki header files, they might issue the following directives to reset the structure packing to its earlier value:

#pragma pack(pop, cryptoki)


7.3.2. Win16


Developers using a pre-5.0 version of Microsoft Developer Studio to produce C or C++ code which implements or makes use of a Win16 Cryptoki .dll might issue the following directives before including any Cryptoki header files:

#pragma pack(1)


#define CK_PTR far *
#define CK_DEFINE_FUNCTION(returnType, name) \

returnType __export _far _pascal name


#define CK_DECLARE_FUNCTION(returnType, name) \

returnType __export _far _pascal name


#define CK_DECLARE_FUNCTION_POINTER(returnType, name) \

returnType __export _far _pascal (* name)


#define CK_CALLBACK_FUNCTION(returnType, name) \

returnType _far _pascal (* name)


#ifndef NULL_PTR

#define NULL_PTR 0

#endif

7.3.3. Generic UNIX


Developers performing generic UNIX development might issue the following directives before including any Cryptoki header files:

#define CK_PTR *


#define CK_DEFINE_FUNCTION(returnType, name) \

returnType name


#define CK_DECLARE_FUNCTION(returnType, name) \

returnType name


#define CK_DECLARE_FUNCTION_POINTER(returnType, name) \

returnType (* name)


#define CK_CALLBACK_FUNCTION(returnType, name) \

returnType (* name)


#ifndef NULL_PTR

#define NULL_PTR 0

#endif

8. General data types


The general Cryptoki data types are described in the following subsections. The data types for holding parameters for various mechanisms, and the pointers to those parameters, are not described here; these types are described with the information on the mechanisms themselves, in Section .

A C or C++ source file in a Cryptoki application or library can define all these types (the types described here and the types that are specifically used for particular mechanism parameters) by including the top-level Cryptoki include file, pkcs11.h. pkcs11.h, in turn, includes the other Cryptoki include files, pkcs11t.h and pkcs11f.h. A source file can also include just pkcs11t.h (instead of pkcs11.h); this defines most (but not all) of the types specified here.

When including either of these header files, a source file must specify the preprocessor directives indicated in Section .

8.1. General information


Cryptoki represents general information with the following types:
  • CK_VERSION; CK_VERSION_PTR


CK_VERSION is a structure that describes the version of a Cryptoki interface, a Cryptoki library, or an SSL implementation, or the hardware or firmware version of a slot or token. It is defined as follows:

typedef struct CK_VERSION {

CK_BYTE major;

CK_BYTE minor;

} CK_VERSION;
The fields of the structure have the following meanings:

major major version number (the integer portion of the version)

minor minor version number (the hundredths portion of the version)

For version 1.0, major = 1 and minor = 0. For version 2.1, major = 2 and minor = 10. Minor revisions of the Cryptoki standard are always upwardly compatible within the same major version number.



CK_VERSION_PTR is a pointer to a CK_VERSION.
  • CK_INFO; CK_INFO_PTR


CK_INFO provides general information about Cryptoki. It is defined as follows:

typedef struct CK_INFO {

CK_VERSION cryptokiVersion;

CK_CHAR manufacturerID[32];

CK_FLAGS flags;

CK_CHAR libraryDescription[32];

CK_VERSION libraryVersion;

} CK_INFO;

The fields of the structure have the following meanings:

cryptokiVersion Cryptoki interface version number, for compatibility with future revisions of this interface

manufacturerID ID of the Cryptoki library manufacturer. Must be padded with the blank character (‘ ‘). Should not be null-terminated.

flags bit flags reserved for future versions. Must be zero for this version

libraryDescription character-string description of the library. Must be padded with the blank character (‘ ‘). Should not be null-terminated.

libraryVersion Cryptoki library version number

For libraries written to this document, the value of cryptokiVersion should be 2.01; the value of libraryVersion is the version number of the library software itself.



CK_INFO_PTR is a pointer to a CK_INFO.
  • CK_NOTIFICATION


CK_NOTIFICATION holds the types of notifications that Cryptoki provides to an application. It is defined as follows:

typedef CK_ULONG CK_NOTIFICATION;


For this version of Cryptoki, the following types of notifications are defined:

#define CKN_SURRENDER 0


The notifications have the following meanings:

CKN_SURRENDER Cryptoki is surrendering the execution of a function executing in a session so that the application may perform other operations. After performing any desired operations, the application should indicate to Cryptoki whether to continue or cancel the function (see Section ).

Download 1.99 Mb.

Share with your friends:
1   ...   5   6   7   8   9   10   11   12   ...   50




The database is protected by copyright ©ininet.org 2024
send message

    Main page