pkcs11

package module
v0.0.0-...-6ee79d0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: BSD-2-Clause Imports: 14 Imported by: 1

README

PKCS11 wrapper

This library wraps the PKCS#11 libraray from miekg/pkcs11, it provides some helper functions when working with PKCS#11 libraries.

The package is currently in use by other projects and it could use a re-write or replaced with another package.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKey

func CreateKey(p *pkcs11.Ctx, s pkcs11.SessionHandle, k Key) (pub pkcs11.ObjectHandle, priv pkcs11.ObjectHandle, err error)

func CreateSession

func CreateSession(p *pkcs11.Ctx, slot uint, pw string, rw bool) (s pkcs11.SessionHandle, err error)

func FindLib

func FindLib(lib string) (file string, err error)

func GetCert

func GetCert(p *pkcs11.Ctx, s pkcs11.SessionHandle, ckaId []byte) (cert *x509.Certificate, id []byte, err error)

func ImportCert

func ImportCert(p *pkcs11.Ctx, s pkcs11.SessionHandle, cert *x509.Certificate, ckaId []byte, label string) (object pkcs11.ObjectHandle, err error)

func New

func New(module string) *pkcs11.Ctx

func SelectSlot

func SelectSlot(p *pkcs11.Ctx) (slot uint, err error)

func SlotInfo

func SlotInfo(p *pkcs11.Ctx, s uint, skipVerify bool) (err error)

Types

type Key

type Key struct {
	Type    string
	Label   string
	CKAID   string
	Public  PublicKeyTemplate
	Private PrivateKeyTemplate
}

type Object

type Object struct {
	Type string
	Id   pkcs11.ObjectHandle

	Value []byte
	Label string
	// contains filtered or unexported fields
}

func GetObjects

func GetObjects(p *pkcs11.Ctx, s pkcs11.SessionHandle, ot interface{}, ckaId []byte, limit int) (objs []Object, err error)

type PrivateKey

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

A PrivateKey represents an RSA key

func InitPrivateKey

func InitPrivateKey(p *pkcs11.Ctx, s pkcs11.SessionHandle, ckaId []byte) (*PrivateKey, error)

New returns a new private key object

func (*PrivateKey) Public

func (priv *PrivateKey) Public() crypto.PublicKey

Public returns the public key corresponding to priv.

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (sig []byte, err error)

Sign delegates the signing of 'msg' to the PKCS11 library.

type PrivateKeyTemplate

type PrivateKeyTemplate struct {
	Token       bool
	Private     bool
	Subject     string
	Sensitive   bool
	Extractable bool
	Decrypt     bool
	Sign        bool
	Unwrap      bool
}

type PublicKeyTemplate

type PublicKeyTemplate struct {
	Token       bool
	Encrypt     bool
	Verify      bool
	Wrap        bool
	ModulesBits int
	Exponent    *big.Int
	Curve       string
}

Jump to

Keyboard shortcuts

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