/* $OpenBSD: pkcs11.h,v 1.3 2013/11/26 19:15:09 deraadt Exp $ */
/* pkcs11.h
Copyright 2006, 2007 g10 Code GmbH
Copyright 2006 Andreas Jellinghaus
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. */
/* Please submit changes back to the Scute project at
http://www.scute.org/ (or send them to marcus@g10code.com), so that
they can be picked up by other projects from there as well. */
/* This file is a modified implementation of the PKCS #11 standard by
RSA Security Inc. It is mostly a drop-in replacement, with the
following change:
This header file does not require any macro definitions by the user
(like CK_DEFINE_FUNCTION etc). In fact, it defines those macros
for you (if useful, some are missing, let me know if you need
more).
There is an additional API available that does comply better to the
GNU coding standard. It can be switched on by defining
CRYPTOKI_GNU before including this header file. For this, the
following changes are made to the specification:
All structure types are changed to a "struct ck_foo" where CK_FOO
is the type name in PKCS #11.
All non-structure types are changed to ck_foo_t where CK_FOO is the
lowercase version of the type name in PKCS #11. The basic types
(CK_ULONG et al.) are removed without substitute.
All members of structures are modified in the following way: Type
indication prefixes are removed, and underscore characters are
inserted before words. Then the result is lowercased.
Note that function names are still in the original case, as they
need for ABI compatibility.
CK_FALSE, CK_TRUE and NULL_PTR are removed without substitute. Use
<stdbool.h>.
If CRYPTOKI_COMPAT is defined before including this header file,
then none of the API changes above take place, and the API is the
one defined by the PKCS #11 standard. */
#ifndef PKCS11_H
#define PKCS11_H 1
#if defined(__cplusplus)
extern "C" {
#endif
/* The version of cryptoki we implement. The revision is changed with
each modification of this file. If you do not use the "official"
version of this file, please consider deleting the revision macro
(you may use a macro with a different name to keep track of your
versions). */
#define CRYPTOKI_VERSION_MAJOR 2
#define CRYPTOKI_VERSION_MINOR 20
#define CRYPTOKI_VERSION_REVISION 6
/* Compatibility interface is default, unless CRYPTOKI_GNU is
given. */
#ifndef CRYPTOKI_GNU
#ifndef CRYPTOKI_COMPAT
#define CRYPTOKI_COMPAT 1
#endif
#endif
/* System dependencies. */
#if defined(_WIN32) || defined(CRYPTOKI_FORCE_WIN32)
/* There is a matching pop below. */
#pragma pack(push, cryptoki, 1)
#ifdef CRYPTOKI_EXPORTS
#define CK_SPEC __declspec(dllexport)
#else
#define CK_SPEC __declspec(dllimport)
#endif
#else
#define CK_SPEC
#endif
#ifdef CRYPTOKI_COMPAT
/* If we are in compatibility mode, switch all exposed names to the
PKCS #11 variant. There are corresponding #undefs below. */
#define ck_flags_t CK_FLAGS
#define ck_version _CK_VERSION
#define ck_info _CK_INFO
#define cryptoki_version cryptokiVersion
#define manufacturer_id manufacturerID
#define library_description libraryDescription
#define library_version libraryVersion
#define ck_notification_t CK_NOTIFICATION
#define ck_slot_id_t CK_SLOT_ID
#define ck_slot_info _CK_SLOT_INFO
#define slot_description slotDescription
#define hardware_version hardwareVersion
#define firmware_version firmwareVersion
#define ck_token_info _CK_TOKEN_INFO
#define serial_number serialNumber
#define max_session_count ulMaxSessionCount
#define session_count ulSessionCount
#define max_rw_session_count ulMaxRwSessionCount
#define rw_session_count ulRwSessionCount
#define max_pin_len ulMaxPinLen
#define min_pin_len ulMinPinLen
#define total_public_memory ulTotalPublicMemory
#define free_public_memory ulFreePublicMemory
#define total_private_memory ulTotalPrivateMemory
#define free_private_memory ulFreePrivateMemory
#define utc_time utcTime
#define ck_session_handle_t CK_SESSION_HANDLE
#define ck_user_type_t CK_USER_TYPE
#define ck_state_t CK_STATE
#define ck_session_info _CK_SESSION_INFO
#define slot_id slotID
#define device_error ulDeviceError
#define ck_object_handle_t CK_OBJECT_HANDLE
#define ck_object_class_t CK_OBJECT_CLASS
#define ck_hw_feature_type_t CK_HW_FEATURE_TYPE
#define ck_key_type_t CK_KEY_TYPE
#define ck_certificate_type_t CK_CERTIFICATE_TYPE
#define ck_attribute_type_t CK_ATTRIBUTE_TYPE
#define ck_attribute _CK_ATTRIBUTE
#define value pValue
#define value_len ulValueLen
#define ck_date _CK_DATE
#define ck_mechanism_type_t CK_MECHANISM_TYPE
#define ck_mechanism _CK_MECHANISM
#define parameter pParameter
#define parameter_len ulParameterLen
#define ck_mecha