...

Package pkcs11

import "github.com/googleapis/enterprise-certificate-proxy/internal/signer/linux/pkcs11"
Overview
Index

Overview ▾

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

func ParseHexString

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

ParseHexString parses hexadecimal string into uint32

type Key

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

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

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

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

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.