pkcs11

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

pkcs11 provides helpers for working with certificates via PKCS#11 APIs provided by go-pkcs11

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHexString

func ParseHexString(str string) (i uint32, err error)

ParseHexString parses hexadecimal string into uint32

Types

type Key

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

Key is a wrapper around the pkcs11 module and uses it to implement signing-related methods.

func Cred

func Cred(pkcs11Module string, slotUint32Str string, label string, userPin string) (*Key, error)

Cred returns a Key wrapping the first valid certificate in the pkcs11 module matching a given slot and label.

func (*Key) CertificateChain

func (k *Key) CertificateChain() [][]byte

CertificateChain returns the credential as a raw X509 cert chain. This contains the public key.

func (*Key) Close

func (k *Key) Close()

Close releases resources held by the credential.

func (*Key) Decrypt added in v0.3.0

func (k *Key) Decrypt(msg []byte, opts crypto.DecrypterOpts) ([]byte, error)

Decrypt decrypts a ciphertext message digest using the private key. Here, we pass off the decryption to pkcs11 library.

func (*Key) Encrypt added in v0.3.0

func (k *Key) Encrypt(plaintext []byte, opts any) ([]byte, error)

Encrypt encrypts a plaintext message digest using the public key. Here, we use standard golang API.

func (*Key) Public

func (k *Key) Public() crypto.PublicKey

Public returns the corresponding public key for this Key.

func (*Key) Sign

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

Sign signs a message.

Jump to

Keyboard shortcuts

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