Documentation ¶
Overview ¶
Package pkcs11 implements logic for using PKCS #11 shared libraries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) 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 int
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 = iota + 1 CertificateUnknown )
Certificate types supported by this package.
type Class ¶
type Class int
Class is the primary object type. Such as a certificate, public key, or private key.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is returned for cryptokit specific API codes.
type Filter ¶
Filter hold options for returning a subset of objects from a slot.
The returned object will match all provided parameters. For example, if Class=ClassPrivateKey and Label="foo", the returned object must be a private key with label "foo".
type Info ¶
type Info struct { // 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 }
Info holds global information about the module.
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 (*Module) Close ¶
Close finalizes the module and releases any resources associated with the shared library.
func (*Module) Slot ¶
Slot creates a session with the given slot, by default read-only. Users must call Close to release the session.
The returned Slot's behavior is undefined once the Module is closed.
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 ¶
Class returns the type of the object stored. For example, certificate, public key, or private key.
func (Object) Label ¶
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 ¶
PrivateKey parses the underlying object as a private key. Both RSA and ECDSA keys are supported.
The returned PrivateKey implements crypto.Signer and optionally crypto.Decrypter depending on the supported mechanisms.
If the object isn't a public key, this method fails.
type Options ¶
type Options struct { PIN string AdminPIN string // ReadWrite indicates that the slot should be opened with write capabilities, // such as generating keys or importing certificates. // // By default, sessions can access objects and perform signing requests. ReadWrite bool }
Options holds configuration options for the slot session.
type Slot ¶
type Slot struct {
// contains filtered or unexported fields
}
Slot represents a session to a slot.
A slot holds a listable set of objects, such as certificates and cryptographic keys.