pkcs11

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Overview

Package pkcs11 implements logic for using PKCS #11 shared libraries.

Index

Constants

View Source
const (
	UserTypeNormal          = UserType(C.CKU_USER)
	UserTypeSecurityOfficer = UserType(C.CKU_SO)
)

Variables

View Source
var (
	ErrCancel                        error = &Error{code: C.CKR_CANCEL}
	ErrHostMemory                    error = &Error{code: C.CKR_HOST_MEMORY}
	ErrSlotIdInvalid                 error = &Error{code: C.CKR_SLOT_ID_INVALID}
	ErrGeneralError                  error = &Error{code: C.CKR_GENERAL_ERROR}
	ErrFunctionFailed                error = &Error{code: C.CKR_FUNCTION_FAILED}
	ErrArgumentsBad                  error = &Error{code: C.CKR_ARGUMENTS_BAD}
	ErrNoEvent                       error = &Error{code: C.CKR_NO_EVENT}
	ErrNeedToCreateThreads           error = &Error{code: C.CKR_NEED_TO_CREATE_THREADS}
	ErrCantLock                      error = &Error{code: C.CKR_CANT_LOCK}
	ErrAttributeReadOnly             error = &Error{code: C.CKR_ATTRIBUTE_READ_ONLY}
	ErrAttributeSensitive            error = &Error{code: C.CKR_ATTRIBUTE_SENSITIVE}
	ErrAttributeTypeInvalid          error = &Error{code: C.CKR_ATTRIBUTE_TYPE_INVALID}
	ErrAttributeValueInvalid         error = &Error{code: C.CKR_ATTRIBUTE_VALUE_INVALID}
	ErrActionProhibited              error = &Error{code: C.CKR_ACTION_PROHIBITED}
	ErrDataInvalid                   error = &Error{code: C.CKR_DATA_INVALID}
	ErrDataLenRange                  error = &Error{code: C.CKR_DATA_LEN_RANGE}
	ErrDeviceError                   error = &Error{code: C.CKR_DEVICE_ERROR}
	ErrDeviceMemory                  error = &Error{code: C.CKR_DEVICE_MEMORY}
	ErrDeviceRemoved                 error = &Error{code: C.CKR_DEVICE_REMOVED}
	ErrEncryptedDataInvalid          error = &Error{code: C.CKR_ENCRYPTED_DATA_INVALID}
	ErrEncryptedDataLenRange         error = &Error{code: C.CKR_ENCRYPTED_DATA_LEN_RANGE}
	ErrAeadDecryptFailed             error = &Error{code: C.CKR_AEAD_DECRYPT_FAILED}
	ErrFunctionCanceled              error = &Error{code: C.CKR_FUNCTION_CANCELED}
	ErrFunctionNotParallel           error = &Error{code: C.CKR_FUNCTION_NOT_PARALLEL}
	ErrFunctionNotSupported          error = &Error{code: C.CKR_FUNCTION_NOT_SUPPORTED}
	ErrKeyHandleInvalid              error = &Error{code: C.CKR_KEY_HANDLE_INVALID}
	ErrKeySizeRange                  error = &Error{code: C.CKR_KEY_SIZE_RANGE}
	ErrKeyTypeInconsistent           error = &Error{code: C.CKR_KEY_TYPE_INCONSISTENT}
	ErrKeyNotNeeded                  error = &Error{code: C.CKR_KEY_NOT_NEEDED}
	ErrKeyChanged                    error = &Error{code: C.CKR_KEY_CHANGED}
	ErrKeyNeeded                     error = &Error{code: C.CKR_KEY_NEEDED}
	ErrKeyIndigestible               error = &Error{code: C.CKR_KEY_INDIGESTIBLE}
	ErrKeyFunctionNotPermitted       error = &Error{code: C.CKR_KEY_FUNCTION_NOT_PERMITTED}
	ErrKeyNotWrappable               error = &Error{code: C.CKR_KEY_NOT_WRAPPABLE}
	ErrKeyUnextractable              error = &Error{code: C.CKR_KEY_UNEXTRACTABLE}
	ErrMechanismInvalid              error = &Error{code: C.CKR_MECHANISM_INVALID}
	ErrMechanismParamInvalid         error = &Error{code: C.CKR_MECHANISM_PARAM_INVALID}
	ErrObjectHandleInvalid           error = &Error{code: C.CKR_OBJECT_HANDLE_INVALID}
	ErrOperationActive               error = &Error{code: C.CKR_OPERATION_ACTIVE}
	ErrOperationNotInitialized       error = &Error{code: C.CKR_OPERATION_NOT_INITIALIZED}
	ErrPinIncorrect                  error = &Error{code: C.CKR_PIN_INCORRECT}
	ErrPinInvalid                    error = &Error{code: C.CKR_PIN_INVALID}
	ErrPinLenRange                   error = &Error{code: C.CKR_PIN_LEN_RANGE}
	ErrPinExpired                    error = &Error{code: C.CKR_PIN_EXPIRED}
	ErrPinLocked                     error = &Error{code: C.CKR_PIN_LOCKED}
	ErrSessionClosed                 error = &Error{code: C.CKR_SESSION_CLOSED}
	ErrSessionCount                  error = &Error{code: C.CKR_SESSION_COUNT}
	ErrSessionHandleInvalid          error = &Error{code: C.CKR_SESSION_HANDLE_INVALID}
	ErrSessionParallelNotSupported   error = &Error{code: C.CKR_SESSION_PARALLEL_NOT_SUPPORTED}
	ErrSessionReadOnly               error = &Error{code: C.CKR_SESSION_READ_ONLY}
	ErrSessionExists                 error = &Error{code: C.CKR_SESSION_EXISTS}
	ErrSessionReadOnlyExists         error = &Error{code: C.CKR_SESSION_READ_ONLY_EXISTS}
	ErrSessionReadWriteSoExists      error = &Error{code: C.CKR_SESSION_READ_WRITE_SO_EXISTS}
	ErrSignatureInvalid              error = &Error{code: C.CKR_SIGNATURE_INVALID}
	ErrSignatureLenRange             error = &Error{code: C.CKR_SIGNATURE_LEN_RANGE}
	ErrTemplateIncomplete            error = &Error{code: C.CKR_TEMPLATE_INCOMPLETE}
	ErrTemplateInconsistent          error = &Error{code: C.CKR_TEMPLATE_INCONSISTENT}
	ErrTokenNotPresent               error = &Error{code: C.CKR_TOKEN_NOT_PRESENT}
	ErrTokenNotRecognized            error = &Error{code: C.CKR_TOKEN_NOT_RECOGNIZED}
	ErrTokenWriteProtected           error = &Error{code: C.CKR_TOKEN_WRITE_PROTECTED}
	ErrUnwrappingKeyHandleInvalid    error = &Error{code: C.CKR_UNWRAPPING_KEY_HANDLE_INVALID}
	ErrUnwrappingKeySizeRange        error = &Error{code: C.CKR_UNWRAPPING_KEY_SIZE_RANGE}
	ErrUnwrappingKeyTypeInconsistent error = &Error{code: C.CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT}
	ErrUserAlreadyLoggedIn           error = &Error{code: C.CKR_USER_ALREADY_LOGGED_IN}
	ErrUserNotLoggedIn               error = &Error{code: C.CKR_USER_NOT_LOGGED_IN}
	ErrUserPinNotInitialized         error = &Error{code: C.CKR_USER_PIN_NOT_INITIALIZED}
	ErrUserTypeInvalid               error = &Error{code: C.CKR_USER_TYPE_INVALID}
	ErrUserAnotherAlreadyLoggedIn    error = &Error{code: C.CKR_USER_ANOTHER_ALREADY_LOGGED_IN}
	ErrUserTooManyTypes              error = &Error{code: C.CKR_USER_TOO_MANY_TYPES}
	ErrWrappedKeyInvalid             error = &Error{code: C.CKR_WRAPPED_KEY_INVALID}
	ErrWrappedKeyLenRange            error = &Error{code: C.CKR_WRAPPED_KEY_LEN_RANGE}
	ErrWrappingKeyHandleInvalid      error = &Error{code: C.CKR_WRAPPING_KEY_HANDLE_INVALID}
	ErrWrappingKeySizeRange          error = &Error{code: C.CKR_WRAPPING_KEY_SIZE_RANGE}
	ErrWrappingKeyTypeInconsistent   error = &Error{code: C.CKR_WRAPPING_KEY_TYPE_INCONSISTENT}
	ErrRandomSeedNotSupported        error = &Error{code: C.CKR_RANDOM_SEED_NOT_SUPPORTED}
	ErrRandomNoRNG                   error = &Error{code: C.CKR_RANDOM_NO_RNG}
	ErrDomainParamsInvalid           error = &Error{code: C.CKR_DOMAIN_PARAMS_INVALID}
	ErrCurveNotSupported             error = &Error{code: C.CKR_CURVE_NOT_SUPPORTED}
	ErrBufferTooSmall                error = &Error{code: C.CKR_BUFFER_TOO_SMALL}
	ErrSavedStateInvalid             error = &Error{code: C.CKR_SAVED_STATE_INVALID}
	ErrInformationSensitive          error = &Error{code: C.CKR_INFORMATION_SENSITIVE}
	ErrStateUnsaveable               error = &Error{code: C.CKR_STATE_UNSAVEABLE}
	ErrCryptokiNotInitialized        error = &Error{code: C.CKR_CRYPTOKI_NOT_INITIALIZED}
	ErrCryptokiAlreadyInitialized    error = &Error{code: C.CKR_CRYPTOKI_ALREADY_INITIALIZED}
	ErrMutexBad                      error = &Error{code: C.CKR_MUTEX_BAD}
	ErrMutexNotLocked                error = &Error{code: C.CKR_MUTEX_NOT_LOCKED}
	ErrNewPinMode                    error = &Error{code: C.CKR_NEW_PIN_MODE}
	ErrNextOTP                       error = &Error{code: C.CKR_NEXT_OTP}
	ErrExceededMaxIterations         error = &Error{code: C.CKR_EXCEEDED_MAX_ITERATIONS}
	ErrFipsSelfTestFailed            error = &Error{code: C.CKR_FIPS_SELF_TEST_FAILED}
	ErrLibraryLoadFailed             error = &Error{code: C.CKR_LIBRARY_LOAD_FAILED}
	ErrPinTooWeak                    error = &Error{code: C.CKR_PIN_TOO_WEAK}
	ErrPublicKeyInvalid              error = &Error{code: C.CKR_PUBLIC_KEY_INVALID}
	ErrFunctionRejected              error = &Error{code: C.CKR_FUNCTION_REJECTED}
	ErrTokenResourceExceeded         error = &Error{code: C.CKR_TOKEN_RESOURCE_EXCEEDED}
	ErrOperationCancelFailed         error = &Error{code: C.CKR_OPERATION_CANCEL_FAILED}
	ErrKeyExhausted                  error = &Error{code: C.CKR_KEY_EXHAUSTED}
	ErrVendorDefined                 error = &Error{code: C.CKR_VENDOR_DEFINED}
)
View Source
var ErrNonUnique = errors.New("pkcs11: non unique public key object")
View Source
var ErrPublicKey = errors.New("pkcs11: no corresponding public key object found")

Functions

func OptLibraryCantCreateOsThreads added in v0.2.3

func OptLibraryCantCreateOsThreads(o *openOptions)

func OptOsLockingOk added in v0.2.3

func OptOsLockingOk(o *openOptions)

func OptReadWrite

func OptReadWrite(o *sessionOptions)

OptReadWrite sets a read-write session mode

Types

type Array added in v0.3.0

type Array[T ~[]E, E any] struct {
	Value T
	// contains filtered or unexported fields
}

func NewArray added in v0.3.0

func NewArray[T ~[]E, E any](typ AttributeType, val T) *Array[T, E]

func (*Array[T, E]) IsNil added in v0.3.0

func (t *Array[T, E]) IsNil() bool

func (*Array[T, E]) String added in v0.3.0

func (t *Array[T, E]) String() string

func (*Array[T, E]) Type added in v0.3.0

func (t *Array[T, E]) Type() AttributeType

type Attribute added in v0.3.0

type Attribute C.CK_ATTRIBUTE

func (*Attribute) String added in v0.3.0

func (a *Attribute) String() string

func (*Attribute) Value added in v0.3.0

func (a *Attribute) Value() Value

type AttributeType added in v0.3.0

type AttributeType C.CK_ATTRIBUTE_TYPE
const (
	AttributeClass                   AttributeType = C.CKA_CLASS
	AttributeToken                   AttributeType = C.CKA_TOKEN
	AttributePrivate                 AttributeType = C.CKA_PRIVATE
	AttributeLabel                   AttributeType = C.CKA_LABEL
	AttributeUniqueID                AttributeType = C.CKA_UNIQUE_ID
	AttributeApplication             AttributeType = C.CKA_APPLICATION
	AttributeValue                   AttributeType = C.CKA_VALUE
	AttributeObjectID                AttributeType = C.CKA_OBJECT_ID
	AttributeCertificateType         AttributeType = C.CKA_CERTIFICATE_TYPE
	AttributeIssuer                  AttributeType = C.CKA_ISSUER
	AttributeSerialNumber            AttributeType = C.CKA_SERIAL_NUMBER
	AttributeACIssuer                AttributeType = C.CKA_AC_ISSUER
	AttributeOwner                   AttributeType = C.CKA_OWNER
	AttributeAttrTypes               AttributeType = C.CKA_ATTR_TYPES
	AttributeTrusted                 AttributeType = C.CKA_TRUSTED
	AttributeCertificateCategory     AttributeType = C.CKA_CERTIFICATE_CATEGORY
	AttributeJavaMIDPSecurityDomain  AttributeType = C.CKA_JAVA_MIDP_SECURITY_DOMAIN
	AttributeURL                     AttributeType = C.CKA_URL
	AttributeHashOfSubjectPublicKey  AttributeType = C.CKA_HASH_OF_SUBJECT_PUBLIC_KEY
	AttributeHashOfIssuerPublicKey   AttributeType = C.CKA_HASH_OF_ISSUER_PUBLIC_KEY
	AttributeNameHashAlgorithm       AttributeType = C.CKA_NAME_HASH_ALGORITHM
	AttributeCheckValue              AttributeType = C.CKA_CHECK_VALUE
	AttributeKeyType                 AttributeType = C.CKA_KEY_TYPE
	AttributeSubject                 AttributeType = C.CKA_SUBJECT
	AttributeID                      AttributeType = C.CKA_ID
	AttributeSensitive               AttributeType = C.CKA_SENSITIVE
	AttributeEncrypt                 AttributeType = C.CKA_ENCRYPT
	AttributeDecrypt                 AttributeType = C.CKA_DECRYPT
	AttributeWrap                    AttributeType = C.CKA_WRAP
	AttributeUnwrap                  AttributeType = C.CKA_UNWRAP
	AttributeSign                    AttributeType = C.CKA_SIGN
	AttributeSignRecover             AttributeType = C.CKA_SIGN_RECOVER
	AttributeVerify                  AttributeType = C.CKA_VERIFY
	AttributeVerifyRecover           AttributeType = C.CKA_VERIFY_RECOVER
	AttributeDerive                  AttributeType = C.CKA_DERIVE
	AttributeStartDate               AttributeType = C.CKA_START_DATE
	AttributeEndDate                 AttributeType = C.CKA_END_DATE
	AttributeModulus                 AttributeType = C.CKA_MODULUS
	AttributeModulusBits             AttributeType = C.CKA_MODULUS_BITS
	AttributePublicExponent          AttributeType = C.CKA_PUBLIC_EXPONENT
	AttributePrivateExponent         AttributeType = C.CKA_PRIVATE_EXPONENT
	AttributePrime_1                 AttributeType = C.CKA_PRIME_1
	AttributePrime_2                 AttributeType = C.CKA_PRIME_2
	AttributeExponent_1              AttributeType = C.CKA_EXPONENT_1
	AttributeExponent_2              AttributeType = C.CKA_EXPONENT_2
	AttributeCoefficient             AttributeType = C.CKA_COEFFICIENT
	AttributePublicKeyInfo           AttributeType = C.CKA_PUBLIC_KEY_INFO
	AttributePrime                   AttributeType = C.CKA_PRIME
	AttributeSubprime                AttributeType = C.CKA_SUBPRIME
	AttributeBase                    AttributeType = C.CKA_BASE
	AttributePrimeBits               AttributeType = C.CKA_PRIME_BITS
	AttributeSubPrimeBits            AttributeType = C.CKA_SUB_PRIME_BITS
	AttributeValueBits               AttributeType = C.CKA_VALUE_BITS
	AttributeValueLen                AttributeType = C.CKA_VALUE_LEN
	AttributeExtractable             AttributeType = C.CKA_EXTRACTABLE
	AttributeLocal                   AttributeType = C.CKA_LOCAL
	AttributeNeverExtractable        AttributeType = C.CKA_NEVER_EXTRACTABLE
	AttributeAlwaysSensitive         AttributeType = C.CKA_ALWAYS_SENSITIVE
	AttributeKeyGenMechanism         AttributeType = C.CKA_KEY_GEN_MECHANISM
	AttributeModifiable              AttributeType = C.CKA_MODIFIABLE
	AttributeCopyable                AttributeType = C.CKA_COPYABLE
	AttributeDestroyable             AttributeType = C.CKA_DESTROYABLE
	AttributeECParams                AttributeType = C.CKA_EC_PARAMS
	AttributeECPoint                 AttributeType = C.CKA_EC_POINT
	AttributeAlwaysAuthenticate      AttributeType = C.CKA_ALWAYS_AUTHENTICATE
	AttributeWrapWithTrusted         AttributeType = C.CKA_WRAP_WITH_TRUSTED
	AttributeWrapTemplate            AttributeType = C.CKA_WRAP_TEMPLATE
	AttributeUnwrapTemplate          AttributeType = C.CKA_UNWRAP_TEMPLATE
	AttributeDeriveTemplate          AttributeType = C.CKA_DERIVE_TEMPLATE
	AttributeOTPFormat               AttributeType = C.CKA_OTP_FORMAT
	AttributeOTPLength               AttributeType = C.CKA_OTP_LENGTH
	AttributeOTPTimeInterval         AttributeType = C.CKA_OTP_TIME_INTERVAL
	AttributeOTPUserFriendlyMode     AttributeType = C.CKA_OTP_USER_FRIENDLY_MODE
	AttributeOTPChallengeRequirement AttributeType = C.CKA_OTP_CHALLENGE_REQUIREMENT
	AttributeOTPTimeRequirement      AttributeType = C.CKA_OTP_TIME_REQUIREMENT
	AttributeOTPCounterRequirement   AttributeType = C.CKA_OTP_COUNTER_REQUIREMENT
	AttributeOTPPinRequirement       AttributeType = C.CKA_OTP_PIN_REQUIREMENT
	AttributeOTPCounter              AttributeType = C.CKA_OTP_COUNTER
	AttributeOTPTime                 AttributeType = C.CKA_OTP_TIME
	AttributeOTPUserIdentifier       AttributeType = C.CKA_OTP_USER_IDENTIFIER
	AttributeOTPServiceIdentifier    AttributeType = C.CKA_OTP_SERVICE_IDENTIFIER
	AttributeOTPServiceLogoType      AttributeType = C.CKA_OTP_SERVICE_LOGO_TYPE
	AttributeGOSTR3410Params         AttributeType = C.CKA_GOSTR3410_PARAMS
	AttributeGOSTR3411Params         AttributeType = C.CKA_GOSTR3411_PARAMS
	AttributeGOST28147Params         AttributeType = C.CKA_GOST28147_PARAMS
	AttributeHWFeatureType           AttributeType = C.CKA_HW_FEATURE_TYPE
	AttributeResetOnInit             AttributeType = C.CKA_RESET_ON_INIT
	AttributeHasReset                AttributeType = C.CKA_HAS_RESET
	AttributePixelX                  AttributeType = C.CKA_PIXEL_X
	AttributePixelY                  AttributeType = C.CKA_PIXEL_Y
	AttributeResolution              AttributeType = C.CKA_RESOLUTION
	AttributeCharRows                AttributeType = C.CKA_CHAR_ROWS
	AttributeCharColumns             AttributeType = C.CKA_CHAR_COLUMNS
	AttributeColor                   AttributeType = C.CKA_COLOR
	AttributeBitsPerPixel            AttributeType = C.CKA_BITS_PER_PIXEL
	AttributeCharSets                AttributeType = C.CKA_CHAR_SETS
	AttributeEncodingMethods         AttributeType = C.CKA_ENCODING_METHODS
	AttributeMimeTypes               AttributeType = C.CKA_MIME_TYPES
	AttributeMechanismType           AttributeType = C.CKA_MECHANISM_TYPE
	AttributeRequiredCMSAttributes   AttributeType = C.CKA_REQUIRED_CMS_ATTRIBUTES
	AttributeDefaultCMSAttributes    AttributeType = C.CKA_DEFAULT_CMS_ATTRIBUTES
	AttributeSupportedCMSAttributes  AttributeType = C.CKA_SUPPORTED_CMS_ATTRIBUTES
	AttributeAllowedMechanisms       AttributeType = C.CKA_ALLOWED_MECHANISMS
	AttributeProfileID               AttributeType = C.CKA_PROFILE_ID
	AttributeX2RatchetBag            AttributeType = C.CKA_X2RATCHET_BAG
	AttributeX2RatchetBagSize        AttributeType = C.CKA_X2RATCHET_BAGSIZE
	AttributeX2RatchetBobs1stMsg     AttributeType = C.CKA_X2RATCHET_BOBS1STMSG
	AttributeX2RatchetCKR            AttributeType = C.CKA_X2RATCHET_CKR
	AttributeX2RatchetCKS            AttributeType = C.CKA_X2RATCHET_CKS
	AttributeX2RatchetDHP            AttributeType = C.CKA_X2RATCHET_DHP
	AttributeX2RatchetDHR            AttributeType = C.CKA_X2RATCHET_DHR
	AttributeX2RatchetDHS            AttributeType = C.CKA_X2RATCHET_DHS
	AttributeX2RatchetHKR            AttributeType = C.CKA_X2RATCHET_HKR
	AttributeX2RatchetHKS            AttributeType = C.CKA_X2RATCHET_HKS
	AttributeX2RatchetIsAlice        AttributeType = C.CKA_X2RATCHET_ISALICE
	AttributeX2RatchetNHKR           AttributeType = C.CKA_X2RATCHET_NHKR
	AttributeX2RatchetNHKS           AttributeType = C.CKA_X2RATCHET_NHKS
	AttributeX2RatchetNR             AttributeType = C.CKA_X2RATCHET_NR
	AttributeX2RatchetNS             AttributeType = C.CKA_X2RATCHET_NS
	AttributeX2RatchetPNS            AttributeType = C.CKA_X2RATCHET_PNS
	AttributeX2RatchetRK             AttributeType = C.CKA_X2RATCHET_RK
	AttributeHSSLevels               AttributeType = C.CKA_HSS_LEVELS
	AttributeHSSLMSType              AttributeType = C.CKA_HSS_LMS_TYPE
	AttributeHSSLMOTSType            AttributeType = C.CKA_HSS_LMOTS_TYPE
	AttributeHSSLMSTypes             AttributeType = C.CKA_HSS_LMS_TYPES
	AttributeHSSLMOTSTypes           AttributeType = C.CKA_HSS_LMOTS_TYPES
	AttributeHSSKeysRemaining        AttributeType = C.CKA_HSS_KEYS_REMAINING
	AttributeVendorDefined           AttributeType = C.CKA_VENDOR_DEFINED
)

func (AttributeType) String added in v0.3.0

func (a AttributeType) String() string

type BigInt added in v0.3.0

type BigInt []byte

func (BigInt) String added in v0.3.0

func (b BigInt) String() string

type Bool added in v0.3.0

type Bool C.CK_BBOOL

func (Bool) String added in v0.3.0

func (b Bool) String() string

func (Bool) ToBool added in v0.3.0

func (b Bool) ToBool() bool

type Bytes added in v0.3.0

type Bytes []byte

func (Bytes) String added in v0.3.0

func (b Bytes) String() string

type BytesValue added in v0.3.0

type BytesValue = Array[Bytes, byte]

func NewBytes added in v0.3.0

func NewBytes(typ AttributeType, src []byte) *BytesValue

type Certificate

type Certificate struct {
	// contains filtered or unexported fields
}

Certificate holds a certificate object. Because certificates object can hold various kinds of certificates, callers should check the type before calling methods that parse the certificate.

cert, err := obj.Certificate()
if err != nil {
	// ...
}
if cert.Type() != pkcs11.CertificateX509 {
	// unexpected kind of certificate ...
}
x509Cert, err := cert.X509()

func (*Certificate) Handle added in v0.3.0

func (c *Certificate) Handle() uint

func (*Certificate) Type

func (c *Certificate) Type() CertificateType

Type returns the format of the underlying certificate.

func (*Certificate) X509

func (c *Certificate) X509() (*x509.Certificate, error)

X509 parses the underlying certificate as an X.509 certificate.

If the certificate holds a different type of certificate, this method returns an error.

type CertificateType

type CertificateType C.CK_CERTIFICATE_TYPE

CertificateType determines the kind of certificate a certificate object holds. This can be X.509, WTLS, GPG, etc.

http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html#_Toc416959709

const (
	CertificateX509          CertificateType = C.CKC_X_509
	CertificateX509AttrCert  CertificateType = C.CKC_X_509_ATTR_CERT
	CertificateWTLS          CertificateType = C.CKC_WTLS
	CertificateVendorDefined CertificateType = C.CKC_VENDOR_DEFINED
)

Certificate types supported by this package.

func (CertificateType) String

func (t CertificateType) String() string

type Class

type Class C.CK_OBJECT_CLASS

Class is the primary object type. Such as a certificate, public key, or private key.

const (
	ClassData             Class = C.CKO_DATA
	ClassCertificate      Class = C.CKO_CERTIFICATE
	ClassPublicKey        Class = C.CKO_PUBLIC_KEY
	ClassPrivateKey       Class = C.CKO_PRIVATE_KEY
	ClassSecretKey        Class = C.CKO_SECRET_KEY
	ClassHWFeature        Class = C.CKO_HW_FEATURE
	ClassDomainParameters Class = C.CKO_DOMAIN_PARAMETERS
	ClassMechanism        Class = C.CKO_MECHANISM
	ClassOTPKey           Class = C.CKO_OTP_KEY
	ClassProfile          Class = C.CKO_PROFILE
	ClassVendorDefined    Class = C.CKO_VENDOR_DEFINED
)

Set of classes supported by this package.

func (Class) String

func (c Class) String() string

String returns a human readable version of the object class.

type Date added in v0.3.0

type Date C.CK_DATE

func NewDate added in v0.3.0

func NewDate(y, m, d int) Date

func (*Date) String added in v0.3.0

func (d *Date) String() string

func (*Date) Value added in v0.3.0

func (d *Date) Value() (year, month, day int, err error)

type Decrypter

type Decrypter interface {
	Decrypt(rand io.Reader, msg []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)
}

type ECDSAKeyPair added in v0.2.0

type ECDSAKeyPair struct {
	*ECDSAPrivateKey
	PublicKey *ecdsa.PublicKey
}

func (*ECDSAKeyPair) Public added in v0.2.0

func (p *ECDSAKeyPair) Public() crypto.PublicKey

type ECDSAPrivateKey added in v0.2.0

type ECDSAPrivateKey struct {
	// contains filtered or unexported fields
}

func (*ECDSAPrivateKey) AddPublic added in v0.2.0

func (e *ECDSAPrivateKey) AddPublic(pub crypto.PublicKey) (KeyPair, error)

func (*ECDSAPrivateKey) Handle added in v0.3.0

func (e *ECDSAPrivateKey) Handle() uint

func (*ECDSAPrivateKey) KeyPair added in v0.2.0

func (e *ECDSAPrivateKey) KeyPair(flags MatchFlags) (KeyPair, error)

func (*ECDSAPrivateKey) Sign added in v0.2.0

func (e *ECDSAPrivateKey) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

type Ed25519KeyPair added in v0.2.0

type Ed25519KeyPair struct {
	*Ed25519PrivateKey
	PublicKey ed25519.PublicKey
}

func (*Ed25519KeyPair) Public added in v0.2.0

func (p *Ed25519KeyPair) Public() crypto.PublicKey

type Ed25519PrivateKey added in v0.2.0

type Ed25519PrivateKey Object

func (*Ed25519PrivateKey) AddPublic added in v0.2.0

func (e *Ed25519PrivateKey) AddPublic(pub crypto.PublicKey) (KeyPair, error)

func (*Ed25519PrivateKey) Handle added in v0.3.0

func (e *Ed25519PrivateKey) Handle() uint

func (*Ed25519PrivateKey) KeyPair added in v0.2.0

func (e *Ed25519PrivateKey) KeyPair(flags MatchFlags) (KeyPair, error)

func (*Ed25519PrivateKey) Sign added in v0.2.0

func (e *Ed25519PrivateKey) Sign(_ io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is returned for cryptokit specific API codes.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

type KeyPair

type KeyPair interface {
	crypto.Signer
	Public() crypto.PublicKey
}

KeyPair represents a complete key pair. It implements crypto.Signer and optionally crypto.Decrypter (for RSA)

type KeyType

type KeyType C.CK_KEY_TYPE
const (
	KeyRSA            KeyType = C.CKK_RSA
	KeyDSA            KeyType = C.CKK_DSA
	KeyDH             KeyType = C.CKK_DH
	KeyEC             KeyType = C.CKK_EC
	KeyX9_42DH        KeyType = C.CKK_X9_42_DH
	KeyKEA            KeyType = C.CKK_KEA
	KeyGenericSecret  KeyType = C.CKK_GENERIC_SECRET
	KeyRC2            KeyType = C.CKK_RC2
	KeyRC4            KeyType = C.CKK_RC4
	KeyDES            KeyType = C.CKK_DES
	KeyDES2           KeyType = C.CKK_DES2
	KeyDES3           KeyType = C.CKK_DES3
	KeyCAST           KeyType = C.CKK_CAST
	KeyCAST3          KeyType = C.CKK_CAST3
	KeyCAST128        KeyType = C.CKK_CAST128
	KeyRC5            KeyType = C.CKK_RC5
	KeyIDEA           KeyType = C.CKK_IDEA
	KeySkipjack       KeyType = C.CKK_SKIPJACK
	KeyBATON          KeyType = C.CKK_BATON
	KeyJuniper        KeyType = C.CKK_JUNIPER
	KeyCDMF           KeyType = C.CKK_CDMF
	KeyAES            KeyType = C.CKK_AES
	KeyBlowfish       KeyType = C.CKK_BLOWFISH
	KeyTwofish        KeyType = C.CKK_TWOFISH
	KeySecurID        KeyType = C.CKK_SECURID
	KeyHOTP           KeyType = C.CKK_HOTP
	KeyACTI           KeyType = C.CKK_ACTI
	KeyCamellia       KeyType = C.CKK_CAMELLIA
	KeyARIA           KeyType = C.CKK_ARIA
	KeyMD5HMAC        KeyType = C.CKK_MD5_HMAC
	KeySHA1HMAC       KeyType = C.CKK_SHA_1_HMAC
	KeyRIPEMD128HMAC  KeyType = C.CKK_RIPEMD128_HMAC
	KeyRIPEMD160HMAC  KeyType = C.CKK_RIPEMD160_HMAC
	KeySHA256HMAC     KeyType = C.CKK_SHA256_HMAC
	KeySHA384HMAC     KeyType = C.CKK_SHA384_HMAC
	KeySHA512HMAC     KeyType = C.CKK_SHA512_HMAC
	KeySHA224HMAC     KeyType = C.CKK_SHA224_HMAC
	KeySeed           KeyType = C.CKK_SEED
	KeyGOSTR3410      KeyType = C.CKK_GOSTR3410
	KeyGOSTR3411      KeyType = C.CKK_GOSTR3411
	KeyGOST28147      KeyType = C.CKK_GOST28147
	KeyChaCha20       KeyType = C.CKK_CHACHA20
	KeyPoly1305       KeyType = C.CKK_POLY1305
	KeyAESXTS         KeyType = C.CKK_AES_XTS
	KeySHA3_224HMAC   KeyType = C.CKK_SHA3_224_HMAC
	KeySHA3_256HMAC   KeyType = C.CKK_SHA3_256_HMAC
	KeySHA3_384HMAC   KeyType = C.CKK_SHA3_384_HMAC
	KeySHA3_512HMAC   KeyType = C.CKK_SHA3_512_HMAC
	KeyBLAKE2b160HMAC KeyType = C.CKK_BLAKE2B_160_HMAC
	KeyBLAKE2b256HMAC KeyType = C.CKK_BLAKE2B_256_HMAC
	KeyBLAKE2b384HMAC KeyType = C.CKK_BLAKE2B_384_HMAC
	KeyBLAKE2b512HMAC KeyType = C.CKK_BLAKE2B_512_HMAC
	KeySalsa20        KeyType = C.CKK_SALSA20
	KeyX2Ratchet      KeyType = C.CKK_X2RATCHET
	KeyECEdwards      KeyType = C.CKK_EC_EDWARDS
	KeyECMontgomery   KeyType = C.CKK_EC_MONTGOMERY
	KeyHKDF           KeyType = C.CKK_HKDF
	KeySHA512_224HMAC KeyType = C.CKK_SHA512_224_HMAC
	KeySHA512_256HMAC KeyType = C.CKK_SHA512_256_HMAC
	KeySHA512THMAC    KeyType = C.CKK_SHA512_T_HMAC
	KeyHSS            KeyType = C.CKK_HSS
	KeyVendorDefined  KeyType = C.CKK_VENDOR_DEFINED
)

func (KeyType) String

func (k KeyType) String() string

type MatchFlags added in v0.2.0

type MatchFlags uint
const (
	MatchLabel MatchFlags = 1 << iota
	MatchID
	// ExtendedPrivate makes KeyPair to read public key value from the private key object. It's present in some implementations
	ExtendedPrivate
)

type MechanismType added in v0.3.0

type MechanismType C.CK_MECHANISM_TYPE
const (
	MechanismRSAPKCSKeyPairGen            MechanismType = C.CKM_RSA_PKCS_KEY_PAIR_GEN
	MechanismRSAPKCS                      MechanismType = C.CKM_RSA_PKCS
	MechanismRSA9796                      MechanismType = C.CKM_RSA_9796
	MechanismRSAX509                      MechanismType = C.CKM_RSA_X_509
	MechanismMD2RSAPKCS                   MechanismType = C.CKM_MD2_RSA_PKCS
	MechanismMD5RSAPKCS                   MechanismType = C.CKM_MD5_RSA_PKCS
	MechanismSHA1RSAPKCS                  MechanismType = C.CKM_SHA1_RSA_PKCS
	MechanismRIPEMD128RSAPKCS             MechanismType = C.CKM_RIPEMD128_RSA_PKCS
	MechanismRIPEMD160RSAPKCS             MechanismType = C.CKM_RIPEMD160_RSA_PKCS
	MechanismRSAPKCSOAEP                  MechanismType = C.CKM_RSA_PKCS_OAEP
	MechanismRSAX9_31KeyPairGen           MechanismType = C.CKM_RSA_X9_31_KEY_PAIR_GEN
	MechanismRSAX9_31                     MechanismType = C.CKM_RSA_X9_31
	MechanismSHA1RSAX9_31                 MechanismType = C.CKM_SHA1_RSA_X9_31
	MechanismRSAPKCSPSS                   MechanismType = C.CKM_RSA_PKCS_PSS
	MechanismSHA1RSAPKCSPSS               MechanismType = C.CKM_SHA1_RSA_PKCS_PSS
	MechanismDSAKeyPairGen                MechanismType = C.CKM_DSA_KEY_PAIR_GEN
	MechanismDSA                          MechanismType = C.CKM_DSA
	MechanismDSASHA1                      MechanismType = C.CKM_DSA_SHA1
	MechanismDSASHA224                    MechanismType = C.CKM_DSA_SHA224
	MechanismDSASHA256                    MechanismType = C.CKM_DSA_SHA256
	MechanismDSASHA384                    MechanismType = C.CKM_DSA_SHA384
	MechanismDSASHA512                    MechanismType = C.CKM_DSA_SHA512
	MechanismDSASHA3_224                  MechanismType = C.CKM_DSA_SHA3_224
	MechanismDSASHA3_256                  MechanismType = C.CKM_DSA_SHA3_256
	MechanismDSASHA3_384                  MechanismType = C.CKM_DSA_SHA3_384
	MechanismDSASHA3_512                  MechanismType = C.CKM_DSA_SHA3_512
	MechanismDHPKCSKeyPairGen             MechanismType = C.CKM_DH_PKCS_KEY_PAIR_GEN
	MechanismDHPKCSDerive                 MechanismType = C.CKM_DH_PKCS_DERIVE
	MechanismX9_42DHKeyPairGen            MechanismType = C.CKM_X9_42_DH_KEY_PAIR_GEN
	MechanismX9_42DHDerive                MechanismType = C.CKM_X9_42_DH_DERIVE
	MechanismX9_42DHHybridDerive          MechanismType = C.CKM_X9_42_DH_HYBRID_DERIVE
	MechanismX9_42MQVDerive               MechanismType = C.CKM_X9_42_MQV_DERIVE
	MechanismSHA256RSAPKCS                MechanismType = C.CKM_SHA256_RSA_PKCS
	MechanismSHA384RSAPKCS                MechanismType = C.CKM_SHA384_RSA_PKCS
	MechanismSHA512RSAPKCS                MechanismType = C.CKM_SHA512_RSA_PKCS
	MechanismSHA256RSAPKCSPSS             MechanismType = C.CKM_SHA256_RSA_PKCS_PSS
	MechanismSHA384RSAPKCSPSS             MechanismType = C.CKM_SHA384_RSA_PKCS_PSS
	MechanismSHA512RSAPKCSPSS             MechanismType = C.CKM_SHA512_RSA_PKCS_PSS
	MechanismSHA224RSAPKCS                MechanismType = C.CKM_SHA224_RSA_PKCS
	MechanismSHA224RSAPKCSPSS             MechanismType = C.CKM_SHA224_RSA_PKCS_PSS
	MechanismSHA512224                    MechanismType = C.CKM_SHA512_224
	MechanismSHA512224HMAC                MechanismType = C.CKM_SHA512_224_HMAC
	MechanismSHA512224HMACGeneral         MechanismType = C.CKM_SHA512_224_HMAC_GENERAL
	MechanismSHA512224KeyDerivation       MechanismType = C.CKM_SHA512_224_KEY_DERIVATION
	MechanismSHA512256                    MechanismType = C.CKM_SHA512_256
	MechanismSHA512256HMAC                MechanismType = C.CKM_SHA512_256_HMAC
	MechanismSHA512256HMACGeneral         MechanismType = C.CKM_SHA512_256_HMAC_GENERAL
	MechanismSHA512256KeyDerivation       MechanismType = C.CKM_SHA512_256_KEY_DERIVATION
	MechanismSHA512T                      MechanismType = C.CKM_SHA512_T
	MechanismSHA512THMAC                  MechanismType = C.CKM_SHA512_T_HMAC
	MechanismSHA512THMACGeneral           MechanismType = C.CKM_SHA512_T_HMAC_GENERAL
	MechanismSHA512TKeyDerivation         MechanismType = C.CKM_SHA512_T_KEY_DERIVATION
	MechanismSHA3_256RSAPKCS              MechanismType = C.CKM_SHA3_256_RSA_PKCS
	MechanismSHA3_384RSAPKCS              MechanismType = C.CKM_SHA3_384_RSA_PKCS
	MechanismSHA3_512RSAPKCS              MechanismType = C.CKM_SHA3_512_RSA_PKCS
	MechanismSHA3_256RSAPKCSPSS           MechanismType = C.CKM_SHA3_256_RSA_PKCS_PSS
	MechanismSHA3_384RSAPKCSPSS           MechanismType = C.CKM_SHA3_384_RSA_PKCS_PSS
	MechanismSHA3_512RSAPKCSPSS           MechanismType = C.CKM_SHA3_512_RSA_PKCS_PSS
	MechanismSHA3_224RSAPKCS              MechanismType = C.CKM_SHA3_224_RSA_PKCS
	MechanismSHA3_224RSAPKCSPSS           MechanismType = C.CKM_SHA3_224_RSA_PKCS_PSS
	MechanismRC2KeyGen                    MechanismType = C.CKM_RC2_KEY_GEN
	MechanismRC2ECB                       MechanismType = C.CKM_RC2_ECB
	MechanismRC2CBC                       MechanismType = C.CKM_RC2_CBC
	MechanismRC2MAC                       MechanismType = C.CKM_RC2_MAC
	MechanismRC2MACGeneral                MechanismType = C.CKM_RC2_MAC_GENERAL
	MechanismRC2CBCPad                    MechanismType = C.CKM_RC2_CBC_PAD
	MechanismRC4KeyGen                    MechanismType = C.CKM_RC4_KEY_GEN
	MechanismRC4                          MechanismType = C.CKM_RC4
	MechanismDESKeyGen                    MechanismType = C.CKM_DES_KEY_GEN
	MechanismDESECB                       MechanismType = C.CKM_DES_ECB
	MechanismDESCBC                       MechanismType = C.CKM_DES_CBC
	MechanismDESMAC                       MechanismType = C.CKM_DES_MAC
	MechanismDESMACGeneral                MechanismType = C.CKM_DES_MAC_GENERAL
	MechanismDESCBCPad                    MechanismType = C.CKM_DES_CBC_PAD
	MechanismDES2KeyGen                   MechanismType = C.CKM_DES2_KEY_GEN
	MechanismDES3KeyGen                   MechanismType = C.CKM_DES3_KEY_GEN
	MechanismDES3ECB                      MechanismType = C.CKM_DES3_ECB
	MechanismDES3CBC                      MechanismType = C.CKM_DES3_CBC
	MechanismDES3MAC                      MechanismType = C.CKM_DES3_MAC
	MechanismDES3MACGeneral               MechanismType = C.CKM_DES3_MAC_GENERAL
	MechanismDES3CBCPad                   MechanismType = C.CKM_DES3_CBC_PAD
	MechanismDES3CMACGeneral              MechanismType = C.CKM_DES3_CMAC_GENERAL
	MechanismDES3CMAC                     MechanismType = C.CKM_DES3_CMAC
	MechanismCDMFKeyGen                   MechanismType = C.CKM_CDMF_KEY_GEN
	MechanismCDMFECB                      MechanismType = C.CKM_CDMF_ECB
	MechanismCDMFCBC                      MechanismType = C.CKM_CDMF_CBC
	MechanismCDMFMAC                      MechanismType = C.CKM_CDMF_MAC
	MechanismCDMFMACGeneral               MechanismType = C.CKM_CDMF_MAC_GENERAL
	MechanismCDMFCBCPad                   MechanismType = C.CKM_CDMF_CBC_PAD
	MechanismDESOFB64                     MechanismType = C.CKM_DES_OFB64
	MechanismDESOFB8                      MechanismType = C.CKM_DES_OFB8
	MechanismDESCFB64                     MechanismType = C.CKM_DES_CFB64
	MechanismDESCFB8                      MechanismType = C.CKM_DES_CFB8
	MechanismMD2                          MechanismType = C.CKM_MD2
	MechanismMD2HMAC                      MechanismType = C.CKM_MD2_HMAC
	MechanismMD2HMACGeneral               MechanismType = C.CKM_MD2_HMAC_GENERAL
	MechanismMD5                          MechanismType = C.CKM_MD5
	MechanismMD5HMAC                      MechanismType = C.CKM_MD5_HMAC
	MechanismMD5HMACGeneral               MechanismType = C.CKM_MD5_HMAC_GENERAL
	MechanismSHA1                         MechanismType = C.CKM_SHA_1
	MechanismSHA1HMAC                     MechanismType = C.CKM_SHA_1_HMAC
	MechanismSHA1HMACGeneral              MechanismType = C.CKM_SHA_1_HMAC_GENERAL
	MechanismRIPEMD128                    MechanismType = C.CKM_RIPEMD128
	MechanismRIPEMD128HMAC                MechanismType = C.CKM_RIPEMD128_HMAC
	MechanismRIPEMD128HMACGeneral         MechanismType = C.CKM_RIPEMD128_HMAC_GENERAL
	MechanismRIPEMD160                    MechanismType = C.CKM_RIPEMD160
	MechanismRIPEMD160HMAC                MechanismType = C.CKM_RIPEMD160_HMAC
	MechanismRIPEMD160HMACGeneral         MechanismType = C.CKM_RIPEMD160_HMAC_GENERAL
	MechanismSHA256                       MechanismType = C.CKM_SHA256
	MechanismSHA256HMAC                   MechanismType = C.CKM_SHA256_HMAC
	MechanismSHA256HMACGeneral            MechanismType = C.CKM_SHA256_HMAC_GENERAL
	MechanismSHA224                       MechanismType = C.CKM_SHA224
	MechanismSHA224HMAC                   MechanismType = C.CKM_SHA224_HMAC
	MechanismSHA224HMACGeneral            MechanismType = C.CKM_SHA224_HMAC_GENERAL
	MechanismSHA384                       MechanismType = C.CKM_SHA384
	MechanismSHA384HMAC                   MechanismType = C.CKM_SHA384_HMAC
	MechanismSHA384HMACGeneral            MechanismType = C.CKM_SHA384_HMAC_GENERAL
	MechanismSHA512                       MechanismType = C.CKM_SHA512
	MechanismSHA512HMAC                   MechanismType = C.CKM_SHA512_HMAC
	MechanismSHA512HMACGeneral            MechanismType = C.CKM_SHA512_HMAC_GENERAL
	MechanismSecurIDKeyGen                MechanismType = C.CKM_SECURID_KEY_GEN
	MechanismSecurID                      MechanismType = C.CKM_SECURID
	MechanismHOTPKeyGen                   MechanismType = C.CKM_HOTP_KEY_GEN
	MechanismHOTP                         MechanismType = C.CKM_HOTP
	MechanismACTI                         MechanismType = C.CKM_ACTI
	MechanismACTIKeyGen                   MechanismType = C.CKM_ACTI_KEY_GEN
	MechanismSHA3_256                     MechanismType = C.CKM_SHA3_256
	MechanismSHA3_256HMAC                 MechanismType = C.CKM_SHA3_256_HMAC
	MechanismSHA3_256HMACGeneral          MechanismType = C.CKM_SHA3_256_HMAC_GENERAL
	MechanismSHA3_256KeyGen               MechanismType = C.CKM_SHA3_256_KEY_GEN
	MechanismSHA3_224                     MechanismType = C.CKM_SHA3_224
	MechanismSHA3_224HMAC                 MechanismType = C.CKM_SHA3_224_HMAC
	MechanismSHA3_224HMACGeneral          MechanismType = C.CKM_SHA3_224_HMAC_GENERAL
	MechanismSHA3_224KeyGen               MechanismType = C.CKM_SHA3_224_KEY_GEN
	MechanismSHA3_384                     MechanismType = C.CKM_SHA3_384
	MechanismSHA3_384HMAC                 MechanismType = C.CKM_SHA3_384_HMAC
	MechanismSHA3_384HMACGeneral          MechanismType = C.CKM_SHA3_384_HMAC_GENERAL
	MechanismSHA3_384KeyGen               MechanismType = C.CKM_SHA3_384_KEY_GEN
	MechanismSHA3_512                     MechanismType = C.CKM_SHA3_512
	MechanismSHA3_512HMAC                 MechanismType = C.CKM_SHA3_512_HMAC
	MechanismSHA3_512HMACGeneral          MechanismType = C.CKM_SHA3_512_HMAC_GENERAL
	MechanismSHA3_512KeyGen               MechanismType = C.CKM_SHA3_512_KEY_GEN
	MechanismCASTKeyGen                   MechanismType = C.CKM_CAST_KEY_GEN
	MechanismCASTECB                      MechanismType = C.CKM_CAST_ECB
	MechanismCASTCBC                      MechanismType = C.CKM_CAST_CBC
	MechanismCASTMAC                      MechanismType = C.CKM_CAST_MAC
	MechanismCASTMACGeneral               MechanismType = C.CKM_CAST_MAC_GENERAL
	MechanismCASTCBCPad                   MechanismType = C.CKM_CAST_CBC_PAD
	MechanismCAST3KeyGen                  MechanismType = C.CKM_CAST3_KEY_GEN
	MechanismCAST3ECB                     MechanismType = C.CKM_CAST3_ECB
	MechanismCAST3CBC                     MechanismType = C.CKM_CAST3_CBC
	MechanismCAST3MAC                     MechanismType = C.CKM_CAST3_MAC
	MechanismCAST3MACGeneral              MechanismType = C.CKM_CAST3_MAC_GENERAL
	MechanismCAST3CBCPad                  MechanismType = C.CKM_CAST3_CBC_PAD
	MechanismCAST128KeyGen                MechanismType = C.CKM_CAST128_KEY_GEN
	MechanismCAST128ECB                   MechanismType = C.CKM_CAST128_ECB
	MechanismCAST128CBC                   MechanismType = C.CKM_CAST128_CBC
	MechanismCAST128MAC                   MechanismType = C.CKM_CAST128_MAC
	MechanismCAST128MACGeneral            MechanismType = C.CKM_CAST128_MAC_GENERAL
	MechanismCAST128CBCPad                MechanismType = C.CKM_CAST128_CBC_PAD
	MechanismRC5KeyGen                    MechanismType = C.CKM_RC5_KEY_GEN
	MechanismRC5ECB                       MechanismType = C.CKM_RC5_ECB
	MechanismRC5CBC                       MechanismType = C.CKM_RC5_CBC
	MechanismRC5MAC                       MechanismType = C.CKM_RC5_MAC
	MechanismRC5MACGeneral                MechanismType = C.CKM_RC5_MAC_GENERAL
	MechanismRC5CBCPad                    MechanismType = C.CKM_RC5_CBC_PAD
	MechanismIDEAKeyGen                   MechanismType = C.CKM_IDEA_KEY_GEN
	MechanismIDEAECB                      MechanismType = C.CKM_IDEA_ECB
	MechanismIDEACBC                      MechanismType = C.CKM_IDEA_CBC
	MechanismIDEAMAC                      MechanismType = C.CKM_IDEA_MAC
	MechanismIDEAMACGeneral               MechanismType = C.CKM_IDEA_MAC_GENERAL
	MechanismIDEACBCPad                   MechanismType = C.CKM_IDEA_CBC_PAD
	MechanismGenericSecretKeyGen          MechanismType = C.CKM_GENERIC_SECRET_KEY_GEN
	MechanismConcatenateBaseAndKey        MechanismType = C.CKM_CONCATENATE_BASE_AND_KEY
	MechanismConcatenateBaseAndData       MechanismType = C.CKM_CONCATENATE_BASE_AND_DATA
	MechanismConcatenateDataAndBase       MechanismType = C.CKM_CONCATENATE_DATA_AND_BASE
	MechanismXorBaseAndData               MechanismType = C.CKM_XOR_BASE_AND_DATA
	MechanismExtractKeyFromKey            MechanismType = C.CKM_EXTRACT_KEY_FROM_KEY
	MechanismSSL3PreMasterKeyGen          MechanismType = C.CKM_SSL3_PRE_MASTER_KEY_GEN
	MechanismSSL3MasterKeyDerive          MechanismType = C.CKM_SSL3_MASTER_KEY_DERIVE
	MechanismSSL3KeyAndMACDerive          MechanismType = C.CKM_SSL3_KEY_AND_MAC_DERIVE
	MechanismSSL3MasterKeyDeriveDH        MechanismType = C.CKM_SSL3_MASTER_KEY_DERIVE_DH
	MechanismTLSPreMasterKeyGen           MechanismType = C.CKM_TLS_PRE_MASTER_KEY_GEN
	MechanismTLSMasterKeyDerive           MechanismType = C.CKM_TLS_MASTER_KEY_DERIVE
	MechanismTLSKeyAndMACDerive           MechanismType = C.CKM_TLS_KEY_AND_MAC_DERIVE
	MechanismTLSMasterKeyDeriveDH         MechanismType = C.CKM_TLS_MASTER_KEY_DERIVE_DH
	MechanismTLSPRF                       MechanismType = C.CKM_TLS_PRF
	MechanismSSL3MD5MAC                   MechanismType = C.CKM_SSL3_MD5_MAC
	MechanismSSL3SHA1MAC                  MechanismType = C.CKM_SSL3_SHA1_MAC
	MechanismMD5KeyDerivation             MechanismType = C.CKM_MD5_KEY_DERIVATION
	MechanismMD2KeyDerivation             MechanismType = C.CKM_MD2_KEY_DERIVATION
	MechanismSHA1KeyDerivation            MechanismType = C.CKM_SHA1_KEY_DERIVATION
	MechanismSHA256KeyDerivation          MechanismType = C.CKM_SHA256_KEY_DERIVATION
	MechanismSHA384KeyDerivation          MechanismType = C.CKM_SHA384_KEY_DERIVATION
	MechanismSHA512KeyDerivation          MechanismType = C.CKM_SHA512_KEY_DERIVATION
	MechanismSHA224KeyDerivation          MechanismType = C.CKM_SHA224_KEY_DERIVATION
	MechanismSHA3_256KeyDerivation        MechanismType = C.CKM_SHA3_256_KEY_DERIVATION
	MechanismSHA3_224KeyDerivation        MechanismType = C.CKM_SHA3_224_KEY_DERIVATION
	MechanismSHA3_384KeyDerivation        MechanismType = C.CKM_SHA3_384_KEY_DERIVATION
	MechanismSHA3_512KeyDerivation        MechanismType = C.CKM_SHA3_512_KEY_DERIVATION
	MechanismSHAKE128KeyDerivation        MechanismType = C.CKM_SHAKE_128_KEY_DERIVATION
	MechanismSHAKE256KeyDerivation        MechanismType = C.CKM_SHAKE_256_KEY_DERIVATION
	MechanismPBEMD2DESCBC                 MechanismType = C.CKM_PBE_MD2_DES_CBC
	MechanismPBEMD5DESCBC                 MechanismType = C.CKM_PBE_MD5_DES_CBC
	MechanismPBEMD5CASTCBC                MechanismType = C.CKM_PBE_MD5_CAST_CBC
	MechanismPBEMD5CAST3CBC               MechanismType = C.CKM_PBE_MD5_CAST3_CBC
	MechanismPBEMD5CAST128CBC             MechanismType = C.CKM_PBE_MD5_CAST128_CBC
	MechanismPBESHA1CAST128CBC            MechanismType = C.CKM_PBE_SHA1_CAST128_CBC
	MechanismPBESHA1RC4_128               MechanismType = C.CKM_PBE_SHA1_RC4_128
	MechanismPBESHA1RC4_40                MechanismType = C.CKM_PBE_SHA1_RC4_40
	MechanismPBESHA1DES3EDECBC            MechanismType = C.CKM_PBE_SHA1_DES3_EDE_CBC
	MechanismPBESHA1DES2EDECBC            MechanismType = C.CKM_PBE_SHA1_DES2_EDE_CBC
	MechanismPBESHA1RC2_128CBC            MechanismType = C.CKM_PBE_SHA1_RC2_128_CBC
	MechanismPBESHA1RC2_40CBC             MechanismType = C.CKM_PBE_SHA1_RC2_40_CBC
	MechanismPKCS5PBKD2                   MechanismType = C.CKM_PKCS5_PBKD2
	MechanismPBASHA1WithSHA1HMAC          MechanismType = C.CKM_PBA_SHA1_WITH_SHA1_HMAC
	MechanismWTLSPreMasterKeyGen          MechanismType = C.CKM_WTLS_PRE_MASTER_KEY_GEN
	MechanismWTLSMasterKeyDerive          MechanismType = C.CKM_WTLS_MASTER_KEY_DERIVE
	MechanismWTLSMasterKeyDeriveDHECC     MechanismType = C.CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC
	MechanismWTLSPRF                      MechanismType = C.CKM_WTLS_PRF
	MechanismWTLSServerKeyAndMACDerive    MechanismType = C.CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE
	MechanismWTLSClientKeyAndMACDerive    MechanismType = C.CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE
	MechanismTLS10MACServer               MechanismType = C.CKM_TLS10_MAC_SERVER
	MechanismTLS10MACClient               MechanismType = C.CKM_TLS10_MAC_CLIENT
	MechanismTLS12MAC                     MechanismType = C.CKM_TLS12_MAC
	MechanismTLS12KDF                     MechanismType = C.CKM_TLS12_KDF
	MechanismTLS12MasterKeyDerive         MechanismType = C.CKM_TLS12_MASTER_KEY_DERIVE
	MechanismTLS12KeyAndMACDerive         MechanismType = C.CKM_TLS12_KEY_AND_MAC_DERIVE
	MechanismTLS12MasterKeyDeriveDH       MechanismType = C.CKM_TLS12_MASTER_KEY_DERIVE_DH
	MechanismTLS12KeySafeDerive           MechanismType = C.CKM_TLS12_KEY_SAFE_DERIVE
	MechanismTLSMAC                       MechanismType = C.CKM_TLS_MAC
	MechanismTLSKDF                       MechanismType = C.CKM_TLS_KDF
	MechanismKeyWrapLYNKS                 MechanismType = C.CKM_KEY_WRAP_LYNKS
	MechanismKeyWrapSetOAEP               MechanismType = C.CKM_KEY_WRAP_SET_OAEP
	MechanismCMSSIG                       MechanismType = C.CKM_CMS_SIG
	MechanismKIPDerive                    MechanismType = C.CKM_KIP_DERIVE
	MechanismKIPWrap                      MechanismType = C.CKM_KIP_WRAP
	MechanismKIPMAC                       MechanismType = C.CKM_KIP_MAC
	MechanismCamelliaKeyGen               MechanismType = C.CKM_CAMELLIA_KEY_GEN
	MechanismCamelliaECB                  MechanismType = C.CKM_CAMELLIA_ECB
	MechanismCamelliaCBC                  MechanismType = C.CKM_CAMELLIA_CBC
	MechanismCamelliaMAC                  MechanismType = C.CKM_CAMELLIA_MAC
	MechanismCamelliaMACGeneral           MechanismType = C.CKM_CAMELLIA_MAC_GENERAL
	MechanismCamelliaCBCPad               MechanismType = C.CKM_CAMELLIA_CBC_PAD
	MechanismCamelliaECBEncryptData       MechanismType = C.CKM_CAMELLIA_ECB_ENCRYPT_DATA
	MechanismCamelliaCBCEncryptData       MechanismType = C.CKM_CAMELLIA_CBC_ENCRYPT_DATA
	MechanismCamelliaCTR                  MechanismType = C.CKM_CAMELLIA_CTR
	MechanismARIAKeyGen                   MechanismType = C.CKM_ARIA_KEY_GEN
	MechanismARIAECB                      MechanismType = C.CKM_ARIA_ECB
	MechanismARIACBC                      MechanismType = C.CKM_ARIA_CBC
	MechanismARIAMAC                      MechanismType = C.CKM_ARIA_MAC
	MechanismARIAMACGeneral               MechanismType = C.CKM_ARIA_MAC_GENERAL
	MechanismARIACBCPad                   MechanismType = C.CKM_ARIA_CBC_PAD
	MechanismARIAECBEncryptData           MechanismType = C.CKM_ARIA_ECB_ENCRYPT_DATA
	MechanismARIACBCEncryptData           MechanismType = C.CKM_ARIA_CBC_ENCRYPT_DATA
	MechanismSeedKeyGen                   MechanismType = C.CKM_SEED_KEY_GEN
	MechanismSeedECB                      MechanismType = C.CKM_SEED_ECB
	MechanismSeedCBC                      MechanismType = C.CKM_SEED_CBC
	MechanismSeedMAC                      MechanismType = C.CKM_SEED_MAC
	MechanismSeedMACGeneral               MechanismType = C.CKM_SEED_MAC_GENERAL
	MechanismSeedCBCPad                   MechanismType = C.CKM_SEED_CBC_PAD
	MechanismSeedECBEncryptData           MechanismType = C.CKM_SEED_ECB_ENCRYPT_DATA
	MechanismSeedCBCEncryptData           MechanismType = C.CKM_SEED_CBC_ENCRYPT_DATA
	MechanismSkipjackKeyGen               MechanismType = C.CKM_SKIPJACK_KEY_GEN
	MechanismSkipjackECB64                MechanismType = C.CKM_SKIPJACK_ECB64
	MechanismSkipjackCBC64                MechanismType = C.CKM_SKIPJACK_CBC64
	MechanismSkipjackOFB64                MechanismType = C.CKM_SKIPJACK_OFB64
	MechanismSkipjackCFB64                MechanismType = C.CKM_SKIPJACK_CFB64
	MechanismSkipjackCFB32                MechanismType = C.CKM_SKIPJACK_CFB32
	MechanismSkipjackCFB16                MechanismType = C.CKM_SKIPJACK_CFB16
	MechanismSkipjackCFB8                 MechanismType = C.CKM_SKIPJACK_CFB8
	MechanismSkipjackWrap                 MechanismType = C.CKM_SKIPJACK_WRAP
	MechanismSkipjackPrivateWrap          MechanismType = C.CKM_SKIPJACK_PRIVATE_WRAP
	MechanismSkipjackRelayx               MechanismType = C.CKM_SKIPJACK_RELAYX
	MechanismKEAKeyPairGen                MechanismType = C.CKM_KEA_KEY_PAIR_GEN
	MechanismKEAKeyDerive                 MechanismType = C.CKM_KEA_KEY_DERIVE
	MechanismKEADerive                    MechanismType = C.CKM_KEA_DERIVE
	MechanismFortezzaTimestamp            MechanismType = C.CKM_FORTEZZA_TIMESTAMP
	MechanismBATONKeyGen                  MechanismType = C.CKM_BATON_KEY_GEN
	MechanismBATONECB128                  MechanismType = C.CKM_BATON_ECB128
	MechanismBATONECB96                   MechanismType = C.CKM_BATON_ECB96
	MechanismBATONCBC128                  MechanismType = C.CKM_BATON_CBC128
	MechanismBATONCounter                 MechanismType = C.CKM_BATON_COUNTER
	MechanismBATONShuffle                 MechanismType = C.CKM_BATON_SHUFFLE
	MechanismBATONWrap                    MechanismType = C.CKM_BATON_WRAP
	MechanismECKeyPairGen                 MechanismType = C.CKM_EC_KEY_PAIR_GEN
	MechanismECDSA                        MechanismType = C.CKM_ECDSA
	MechanismECDSASHA1                    MechanismType = C.CKM_ECDSA_SHA1
	MechanismECDSASHA224                  MechanismType = C.CKM_ECDSA_SHA224
	MechanismECDSASHA256                  MechanismType = C.CKM_ECDSA_SHA256
	MechanismECDSASHA384                  MechanismType = C.CKM_ECDSA_SHA384
	MechanismECDSASHA512                  MechanismType = C.CKM_ECDSA_SHA512
	MechanismECKeyPairGenWExtraBits       MechanismType = C.CKM_EC_KEY_PAIR_GEN_W_EXTRA_BITS
	MechanismECDH1Derive                  MechanismType = C.CKM_ECDH1_DERIVE
	MechanismECDH1CofactorDerive          MechanismType = C.CKM_ECDH1_COFACTOR_DERIVE
	MechanismECMQVDerive                  MechanismType = C.CKM_ECMQV_DERIVE
	MechanismECDHAESKeyWrap               MechanismType = C.CKM_ECDH_AES_KEY_WRAP
	MechanismRSAAESKeyWrap                MechanismType = C.CKM_RSA_AES_KEY_WRAP
	MechanismJuniperKeyGen                MechanismType = C.CKM_JUNIPER_KEY_GEN
	MechanismJuniperECB128                MechanismType = C.CKM_JUNIPER_ECB128
	MechanismJuniperCBC128                MechanismType = C.CKM_JUNIPER_CBC128
	MechanismJuniperCounter               MechanismType = C.CKM_JUNIPER_COUNTER
	MechanismJuniperShuffle               MechanismType = C.CKM_JUNIPER_SHUFFLE
	MechanismJuniperWrap                  MechanismType = C.CKM_JUNIPER_WRAP
	MechanismFasthash                     MechanismType = C.CKM_FASTHASH
	MechanismAESXTS                       MechanismType = C.CKM_AES_XTS
	MechanismAESXTSKeyGen                 MechanismType = C.CKM_AES_XTS_KEY_GEN
	MechanismAESKeyGen                    MechanismType = C.CKM_AES_KEY_GEN
	MechanismAESECB                       MechanismType = C.CKM_AES_ECB
	MechanismAESCBC                       MechanismType = C.CKM_AES_CBC
	MechanismAESMAC                       MechanismType = C.CKM_AES_MAC
	MechanismAESMACGeneral                MechanismType = C.CKM_AES_MAC_GENERAL
	MechanismAESCBCPad                    MechanismType = C.CKM_AES_CBC_PAD
	MechanismAESCTR                       MechanismType = C.CKM_AES_CTR
	MechanismAESGCM                       MechanismType = C.CKM_AES_GCM
	MechanismAESCCM                       MechanismType = C.CKM_AES_CCM
	MechanismAESCTS                       MechanismType = C.CKM_AES_CTS
	MechanismAESCMAC                      MechanismType = C.CKM_AES_CMAC
	MechanismAESCMACGeneral               MechanismType = C.CKM_AES_CMAC_GENERAL
	MechanismAESXCBCMAC                   MechanismType = C.CKM_AES_XCBC_MAC
	MechanismAESXCBCMAC96                 MechanismType = C.CKM_AES_XCBC_MAC_96
	MechanismAESGMAC                      MechanismType = C.CKM_AES_GMAC
	MechanismBlowfishKeyGen               MechanismType = C.CKM_BLOWFISH_KEY_GEN
	MechanismBlowfishCBC                  MechanismType = C.CKM_BLOWFISH_CBC
	MechanismTwofishKeyGen                MechanismType = C.CKM_TWOFISH_KEY_GEN
	MechanismTwofishCBC                   MechanismType = C.CKM_TWOFISH_CBC
	MechanismBlowfishCBCPad               MechanismType = C.CKM_BLOWFISH_CBC_PAD
	MechanismTwofishCBCPad                MechanismType = C.CKM_TWOFISH_CBC_PAD
	MechanismDESECBEncryptData            MechanismType = C.CKM_DES_ECB_ENCRYPT_DATA
	MechanismDESCBCEncryptData            MechanismType = C.CKM_DES_CBC_ENCRYPT_DATA
	MechanismDES3ECBEncryptData           MechanismType = C.CKM_DES3_ECB_ENCRYPT_DATA
	MechanismDES3CBCEncryptData           MechanismType = C.CKM_DES3_CBC_ENCRYPT_DATA
	MechanismAESECBEncryptData            MechanismType = C.CKM_AES_ECB_ENCRYPT_DATA
	MechanismAESCBCEncryptData            MechanismType = C.CKM_AES_CBC_ENCRYPT_DATA
	MechanismGOSTR3410KeyPairGen          MechanismType = C.CKM_GOSTR3410_KEY_PAIR_GEN
	MechanismGOSTR3410                    MechanismType = C.CKM_GOSTR3410
	MechanismGOSTR3410WithGOSTR3411       MechanismType = C.CKM_GOSTR3410_WITH_GOSTR3411
	MechanismGOSTR3410KeyWrap             MechanismType = C.CKM_GOSTR3410_KEY_WRAP
	MechanismGOSTR3410Derive              MechanismType = C.CKM_GOSTR3410_DERIVE
	MechanismGOSTR3411                    MechanismType = C.CKM_GOSTR3411
	MechanismGOSTR3411HMAC                MechanismType = C.CKM_GOSTR3411_HMAC
	MechanismGOST28147KeyGen              MechanismType = C.CKM_GOST28147_KEY_GEN
	MechanismGOST28147ECB                 MechanismType = C.CKM_GOST28147_ECB
	MechanismGOST28147                    MechanismType = C.CKM_GOST28147
	MechanismGOST28147MAC                 MechanismType = C.CKM_GOST28147_MAC
	MechanismGOST28147KeyWrap             MechanismType = C.CKM_GOST28147_KEY_WRAP
	MechanismChaCha20KeyGen               MechanismType = C.CKM_CHACHA20_KEY_GEN
	MechanismChaCha20                     MechanismType = C.CKM_CHACHA20
	MechanismPoly1305KeyGen               MechanismType = C.CKM_POLY1305_KEY_GEN
	MechanismPoly1305                     MechanismType = C.CKM_POLY1305
	MechanismDSAParameterGen              MechanismType = C.CKM_DSA_PARAMETER_GEN
	MechanismDHPKCSParameterGen           MechanismType = C.CKM_DH_PKCS_PARAMETER_GEN
	MechanismX9_42DHParameterGen          MechanismType = C.CKM_X9_42_DH_PARAMETER_GEN
	MechanismDSAProbabilisticParameterGen MechanismType = C.CKM_DSA_PROBABILISTIC_PARAMETER_GEN
	MechanismDSAShaweTaylorParameterGen   MechanismType = C.CKM_DSA_SHAWE_TAYLOR_PARAMETER_GEN
	MechanismDSAFIPSGGen                  MechanismType = C.CKM_DSA_FIPS_G_GEN
	MechanismAESOFB                       MechanismType = C.CKM_AES_OFB
	MechanismAESCFB64                     MechanismType = C.CKM_AES_CFB64
	MechanismAESCFB8                      MechanismType = C.CKM_AES_CFB8
	MechanismAESCFB128                    MechanismType = C.CKM_AES_CFB128
	MechanismAESCFB1                      MechanismType = C.CKM_AES_CFB1
	MechanismAESKeyWrap                   MechanismType = C.CKM_AES_KEY_WRAP
	MechanismAESKeyWrapPad                MechanismType = C.CKM_AES_KEY_WRAP_PAD
	MechanismAESKeyWrapKWP                MechanismType = C.CKM_AES_KEY_WRAP_KWP
	MechanismAESKeyWrapPKCS7              MechanismType = C.CKM_AES_KEY_WRAP_PKCS7
	MechanismRSAPKCSTPM1_1                MechanismType = C.CKM_RSA_PKCS_TPM_1_1
	MechanismRSAPKCSOAEPTPM1_1            MechanismType = C.CKM_RSA_PKCS_OAEP_TPM_1_1
	MechanismSHA1KeyGen                   MechanismType = C.CKM_SHA_1_KEY_GEN
	MechanismSHA224KeyGen                 MechanismType = C.CKM_SHA224_KEY_GEN
	MechanismSHA256KeyGen                 MechanismType = C.CKM_SHA256_KEY_GEN
	MechanismSHA384KeyGen                 MechanismType = C.CKM_SHA384_KEY_GEN
	MechanismSHA512KeyGen                 MechanismType = C.CKM_SHA512_KEY_GEN
	MechanismSHA512_224KeyGen             MechanismType = C.CKM_SHA512_224_KEY_GEN
	MechanismSHA512_256KeyGen             MechanismType = C.CKM_SHA512_256_KEY_GEN
	MechanismSHA512TKeyGen                MechanismType = C.CKM_SHA512_T_KEY_GEN
	MechanismNull                         MechanismType = C.CKM_NULL
	MechanismBLAKE2b160                   MechanismType = C.CKM_BLAKE2B_160
	MechanismBLAKE2b160HMAC               MechanismType = C.CKM_BLAKE2B_160_HMAC
	MechanismBLAKE2b160HMACGeneral        MechanismType = C.CKM_BLAKE2B_160_HMAC_GENERAL
	MechanismBLAKE2b160KeyDerive          MechanismType = C.CKM_BLAKE2B_160_KEY_DERIVE
	MechanismBLAKE2b160KeyGen             MechanismType = C.CKM_BLAKE2B_160_KEY_GEN
	MechanismBLAKE2b256                   MechanismType = C.CKM_BLAKE2B_256
	MechanismBLAKE2b256HMAC               MechanismType = C.CKM_BLAKE2B_256_HMAC
	MechanismBLAKE2b256HMACGeneral        MechanismType = C.CKM_BLAKE2B_256_HMAC_GENERAL
	MechanismBLAKE2b256KeyDerive          MechanismType = C.CKM_BLAKE2B_256_KEY_DERIVE
	MechanismBLAKE2b256KeyGen             MechanismType = C.CKM_BLAKE2B_256_KEY_GEN
	MechanismBLAKE2b384                   MechanismType = C.CKM_BLAKE2B_384
	MechanismBLAKE2b384HMAC               MechanismType = C.CKM_BLAKE2B_384_HMAC
	MechanismBLAKE2b384HMACGeneral        MechanismType = C.CKM_BLAKE2B_384_HMAC_GENERAL
	MechanismBLAKE2b384KeyDerive          MechanismType = C.CKM_BLAKE2B_384_KEY_DERIVE
	MechanismBLAKE2b384KeyGen             MechanismType = C.CKM_BLAKE2B_384_KEY_GEN
	MechanismBLAKE2b512                   MechanismType = C.CKM_BLAKE2B_512
	MechanismBLAKE2b512HMAC               MechanismType = C.CKM_BLAKE2B_512_HMAC
	MechanismBLAKE2b512HMACGeneral        MechanismType = C.CKM_BLAKE2B_512_HMAC_GENERAL
	MechanismBLAKE2b512KeyDerive          MechanismType = C.CKM_BLAKE2B_512_KEY_DERIVE
	MechanismBLAKE2b512KeyGen             MechanismType = C.CKM_BLAKE2B_512_KEY_GEN
	MechanismSalsa20                      MechanismType = C.CKM_SALSA20
	MechanismChacha20Poly1305             MechanismType = C.CKM_CHACHA20_POLY1305
	MechanismSalsa20Poly1305              MechanismType = C.CKM_SALSA20_POLY1305
	MechanismX3DHInitialize               MechanismType = C.CKM_X3DH_INITIALIZE
	MechanismX3DHRespond                  MechanismType = C.CKM_X3DH_RESPOND
	MechanismX2RatchetInitialize          MechanismType = C.CKM_X2RATCHET_INITIALIZE
	MechanismX2RatchetRespond             MechanismType = C.CKM_X2RATCHET_RESPOND
	MechanismX2RatchetEncrypt             MechanismType = C.CKM_X2RATCHET_ENCRYPT
	MechanismX2RatchetDecrypt             MechanismType = C.CKM_X2RATCHET_DECRYPT
	MechanismXEDDSA                       MechanismType = C.CKM_XEDDSA
	MechanismHKDFDerive                   MechanismType = C.CKM_HKDF_DERIVE
	MechanismHKDFData                     MechanismType = C.CKM_HKDF_DATA
	MechanismHKDFKeyGen                   MechanismType = C.CKM_HKDF_KEY_GEN
	MechanismSalsa20KeyGen                MechanismType = C.CKM_SALSA20_KEY_GEN
	MechanismECDSASHA3_224                MechanismType = C.CKM_ECDSA_SHA3_224
	MechanismECDSASHA3_256                MechanismType = C.CKM_ECDSA_SHA3_256
	MechanismECDSASHA3_384                MechanismType = C.CKM_ECDSA_SHA3_384
	MechanismECDSASHA3_512                MechanismType = C.CKM_ECDSA_SHA3_512
	MechanismECEdwardsKeyPairGen          MechanismType = C.CKM_EC_EDWARDS_KEY_PAIR_GEN
	MechanismECMontgomeryKeyPairGen       MechanismType = C.CKM_EC_MONTGOMERY_KEY_PAIR_GEN
	MechanismEDDSA                        MechanismType = C.CKM_EDDSA
	MechanismSP800_108CounterKDF          MechanismType = C.CKM_SP800_108_COUNTER_KDF
	MechanismSP800_108FeedbackKDF         MechanismType = C.CKM_SP800_108_FEEDBACK_KDF
	MechanismSP800_108DoublePipelineKDF   MechanismType = C.CKM_SP800_108_DOUBLE_PIPELINE_KDF
	MechanismIKE2PRFPlusDerive            MechanismType = C.CKM_IKE2_PRF_PLUS_DERIVE
	MechanismIKEPRFDerive                 MechanismType = C.CKM_IKE_PRF_DERIVE
	MechanismIKE1PRFDerive                MechanismType = C.CKM_IKE1_PRF_DERIVE
	MechanismIKE1ExtendedDerive           MechanismType = C.CKM_IKE1_EXTENDED_DERIVE
	MechanismHSSKeyPairGen                MechanismType = C.CKM_HSS_KEY_PAIR_GEN
	MechanismHSS                          MechanismType = C.CKM_HSS
	MechanismVendorDefined                MechanismType = C.CKM_VENDOR_DEFINED
)

func (MechanismType) String added in v0.3.0

func (m MechanismType) String() string

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module represents an opened shared library. By default, this package requests locking support from the module, but concurrent safety may depend on the underlying library.

func Open

func Open(path string, opt ...OpenOption) (*Module, error)

Open dlopens a shared library by path, initializing the module.

func (*Module) Close

func (m *Module) Close() error

Close finalizes the module and releases any resources associated with the shared library.

func (*Module) Info

func (m *Module) Info() *ModuleInfo

Info returns additional information about the module.

func (*Module) NewSession added in v0.2.0

func (m *Module) NewSession(id uint, opts ...SessionOption) (*Session, error)

NewSession creates a session with the given slot, by default read-only. Users must call Close to release the session.

The returned NewSession's behavior is undefined once the Module is closed.

func (*Module) SlotIDs

func (m *Module) SlotIDs() ([]uint, error)

SlotIDs returns the IDs of all slots associated with this module, including ones that haven't been initialized.

func (*Module) SlotInfo

func (m *Module) SlotInfo(id uint) (*SlotInfo, error)

SlotInfo queries for information about the slot, such as the label.

type ModuleInfo added in v0.1.6

type ModuleInfo struct {
	CryptokiVersion Version
	// Manufacturer of the implementation. When multiple PKCS #11 devices are
	// present this is used to differentiate devices.
	Manufacturer string
	// Version of the module.
	Version Version
	// Human readable description of the module.
	Description string
}

ModuleInfo holds global information about the module.

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object represents a single object stored within a slot. For example a key or certificate.

func (*Object) Certificate

func (o *Object) Certificate() (*Certificate, error)

Certificate parses the underlying object as a certificate. If the object isn't a certificate, this method fails.

func (*Object) Class

func (o *Object) Class() Class

Class returns the type of the object stored. For example, certificate, public key, or private key.

func (*Object) GetAttributes added in v0.3.0

func (o *Object) GetAttributes(attributes ...Value) error

func (*Object) Handle added in v0.1.3

func (o *Object) Handle() uint

func (*Object) ID

func (o *Object) ID() []byte

func (*Object) Label

func (o *Object) Label() string

Label returns a string value attached to an object, which can be used to identify or group sets of keys and certificates.

func (*Object) PrivateKey

func (o *Object) PrivateKey() (PrivateKey, error)

PrivateKey parses the underlying object as a private key. Both RSA and ECDSA keys are supported.

If the object isn't a public key, this method fails.

func (*Object) PublicKey

func (o *Object) PublicKey() (crypto.PublicKey, error)

PublicKey parses the underlying object as a public key. Both RSA and ECDSA keys are supported.

If the object isn't a public key, this method fails.

type OpenOption added in v0.2.3

type OpenOption func(o *openOptions)

type PrivateKey

type PrivateKey interface {
	Signer
	// KeyPair finds an adjacent public key in the same slot. If there is more than one public key found then
	// it returns one with the matching ID if the latter is present
	KeyPair(flags MatchFlags) (KeyPair, error)
	AddPublic(pub crypto.PublicKey) (KeyPair, error)
	Handle() uint
}

PrivateKey is a private key object without a corresponding public key. It implements Signer and optionally Decrypter interfaces (for RSA) but not crypto.Signer and crypto.Decrypter

type Scalar added in v0.3.0

type Scalar[T any] struct {
	Value T
	// contains filtered or unexported fields
}

func NewScalar added in v0.3.0

func NewScalar[T any](typ AttributeType) *Scalar[T]

func NewScalarV added in v0.3.0

func NewScalarV[T any](typ AttributeType, val T) *Scalar[T]

func (*Scalar[T]) IsNil added in v0.3.0

func (t *Scalar[T]) IsNil() bool

func (*Scalar[T]) String added in v0.3.0

func (t *Scalar[T]) String() string

func (*Scalar[T]) Type added in v0.3.0

func (t *Scalar[T]) Type() AttributeType

type Session added in v0.2.0

type Session struct {
	// contains filtered or unexported fields
}

Session represents a session to a slot.

A slot holds a listable set of objects, such as certificates and cryptographic keys.

func (*Session) Close added in v0.2.0

func (s *Session) Close() error

Close releases the slot session.

func (*Session) NewObject added in v0.2.0

func (s *Session) NewObject(h uint) (*Object, error)

func (*Session) Objects added in v0.2.0

func (s *Session) Objects(filter ...Value) (objs []*Object, err error)

Objects searches a slot for objects that match the given options, or all objects if no options are provided.

The returned objects behavior is undefined once the Session object is closed.

func (*Session) SlotID added in v0.2.0

func (s *Session) SlotID() uint

func (*Session) SlotInfo added in v0.2.0

func (s *Session) SlotInfo() (*SlotInfo, error)

type SessionOption added in v0.2.0

type SessionOption func(o *sessionOptions)

func OptPIN

func OptPIN(pin string) SessionOption

OptPIN sets PIN for logging into a slot

func OptSecurityOfficerPIN

func OptSecurityOfficerPIN(pin string) SessionOption

OptUserPIN is an alias for OptPIN + OptUserType(UserTypeSecurityOfficer)

func OptUserPIN

func OptUserPIN(pin string) SessionOption

OptUserPIN is an alias for OptPIN + OptUserType(UserTypeNormal)

func OptUserType

func OptUserType(ut UserType) SessionOption

OptPIN sets a user type for logging into a slot

type Signer

type Signer interface {
	Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error)
}

type SlotFlags added in v0.1.6

type SlotFlags uint
const (
	SlotTokenPresent    SlotFlags = C.CKF_TOKEN_PRESENT
	SlotRemovableDevice SlotFlags = C.CKF_REMOVABLE_DEVICE
	SlotHWSlot          SlotFlags = C.CKF_HW_SLOT
)

func (SlotFlags) String added in v0.2.0

func (s SlotFlags) String() string

type SlotInfo

type SlotInfo struct {
	Description     string
	Manufacturer    string
	Flags           SlotFlags
	HardwareVersion Version
	FirmwareVersion Version

	Token *TokenInfo
}

SlotInfo holds information about the slot and underlying token.

type String added in v0.3.0

type String []byte

func (String) String added in v0.3.0

func (s String) String() string

type StringValue added in v0.3.0

type StringValue = Array[String, byte]

func NewString added in v0.3.0

func NewString(typ AttributeType, src string) *StringValue

type TokenFlags added in v0.1.6

type TokenFlags uint
const (
	TokenRNG                         TokenFlags = C.CKF_RNG
	TokenWriteProtected              TokenFlags = C.CKF_WRITE_PROTECTED
	TokenLoginRequired               TokenFlags = C.CKF_LOGIN_REQUIRED
	TokenUserPinInitialized          TokenFlags = C.CKF_USER_PIN_INITIALIZED
	TokenRestoreKeyNotNeeded         TokenFlags = C.CKF_RESTORE_KEY_NOT_NEEDED
	TokenClockOnToken                TokenFlags = C.CKF_CLOCK_ON_TOKEN
	TokenProtectedAuthenticationPath TokenFlags = C.CKF_PROTECTED_AUTHENTICATION_PATH
	TokenDualCryptoOperations        TokenFlags = C.CKF_DUAL_CRYPTO_OPERATIONS
	TokenTokenInitialized            TokenFlags = C.CKF_TOKEN_INITIALIZED
	TokenSecondaryAuthentication     TokenFlags = C.CKF_SECONDARY_AUTHENTICATION
	TokenUserPinCountLow             TokenFlags = C.CKF_USER_PIN_COUNT_LOW
	TokenUserPinFinalTry             TokenFlags = C.CKF_USER_PIN_FINAL_TRY
	TokenUserPinLocked               TokenFlags = C.CKF_USER_PIN_LOCKED
	TokenUserPinToBeChanged          TokenFlags = C.CKF_USER_PIN_TO_BE_CHANGED
	TokenSOPinCountLow               TokenFlags = C.CKF_SO_PIN_COUNT_LOW
	TokenSOPinFinalTry               TokenFlags = C.CKF_SO_PIN_FINAL_TRY
	TokenSOPinLocked                 TokenFlags = C.CKF_SO_PIN_LOCKED
	TokenSOPinToBeChanged            TokenFlags = C.CKF_SO_PIN_TO_BE_CHANGED
	TokenErrorState                  TokenFlags = C.CKF_ERROR_STATE
)

func (TokenFlags) String added in v0.2.0

func (t TokenFlags) String() string

type TokenInfo added in v0.1.6

type TokenInfo struct {
	Label              string
	Manufacturer       string
	Model              string
	SerialNumber       string
	Flags              TokenFlags
	MaxSessionCount    uint
	SessionCount       uint
	MaxRwSessionCount  uint
	RwSessionCount     uint
	MaxPinLen          uint
	MinPinLen          uint
	TotalPublicMemory  uint
	FreePublicMemory   uint
	TotalPrivateMemory uint
	FreePrivateMemory  uint
	HardwareVersion    Version
	FirmwareVersion    Version
	UTCTime            time.Time
}

type Uint added in v0.3.0

type Uint C.CK_ULONG

func (Uint) String added in v0.3.0

func (u Uint) String() string

type UserType

type UserType uint

UserType represents a user type

func (UserType) String

func (u UserType) String() string

type Value added in v0.3.0

type Value interface {
	String() string
	IsNil() bool
	Type() AttributeType
	// contains filtered or unexported methods
}

func NewValue added in v0.3.0

func NewValue(t AttributeType) Value

type Version

type Version struct {
	Major uint8
	Minor uint8
}

Version holds a major and minor version.

func (Version) String added in v0.1.6

func (v Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL