pkcs11wrapper

package
v1.0.0-alpha5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright SecureKey Technologies Inc. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright SecureKey Technologies Inc. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCKACLASS

func DecodeCKACLASS(b byte) string

func FindSlotByLabel

func FindSlotByLabel(p *pkcs11.Ctx, slotLabel string) (slot uint, index int, err error)

Return the slotID of token label

func GetECParamMarshaled

func GetECParamMarshaled(namedCurve string) (ecParamMarshaled []byte, err error)

returns value for CKA_EC_PARAMS

Types

type EcdsaKey

type EcdsaKey struct {
	PubKey  *ecdsa.PublicKey
	PrivKey *ecdsa.PrivateKey
	SKI     SubjectKeyIdentifier
}

func (*EcdsaKey) DeriveSharedSecret

func (k *EcdsaKey) DeriveSharedSecret(anotherPublicKey *ecdsa.PublicKey) (secret []byte, err error)

func (*EcdsaKey) GenSKI

func (k *EcdsaKey) GenSKI() (ski []byte)

SKI returns the subject key identifier of this key.

func (*EcdsaKey) Generate

func (k *EcdsaKey) Generate(namedCurve string) (err error)

func (*EcdsaKey) ImportPrivKeyFromFile

func (k *EcdsaKey) ImportPrivKeyFromFile(file string) (err error)

func (*EcdsaKey) ImportPubKeyFromCertFile

func (k *EcdsaKey) ImportPubKeyFromCertFile(file string) (err error)

func (*EcdsaKey) SignMessage

func (k *EcdsaKey) SignMessage(message string) (signature string, err error)

func (*EcdsaKey) VerifySignature

func (k *EcdsaKey) VerifySignature(message string, signature string) (verified bool)

type Pkcs11Library

type Pkcs11Library struct {
	Path string
	Info pkcs11.Info
}

type Pkcs11Object

type Pkcs11Object struct {
	ObjectHandle pkcs11.ObjectHandle

	// Some human readable attributes
	Count     string
	CKA_CLASS string
	CKA_LABEL string
	CKA_ID    string
}

type Pkcs11Wrapper

type Pkcs11Wrapper struct {

	// Context
	Library Pkcs11Library
	Context *pkcs11.Ctx

	// Session Handler
	SlotLabel string
	Session   pkcs11.SessionHandle

	// Optional Slot Login
	SlotPin string
}

func (*Pkcs11Wrapper) CloseContext

func (p11w *Pkcs11Wrapper) CloseContext()

Perform all actions needed to close Context

func (*Pkcs11Wrapper) FindObjects

func (p11w *Pkcs11Wrapper) FindObjects(template []*pkcs11.Attribute, max int) (p11ObjHandlers []pkcs11.ObjectHandle, moreThanMax bool, err error)

This should return a list of object handlers and true if more than max

func (*Pkcs11Wrapper) ImportECKey

func (p11w *Pkcs11Wrapper) ImportECKey(ec EcdsaKey) (err error)

func (*Pkcs11Wrapper) ImportECKeyFromFile

func (p11w *Pkcs11Wrapper) ImportECKeyFromFile(file string) (err error)

func (*Pkcs11Wrapper) InitContext

func (p11w *Pkcs11Wrapper) InitContext() (err error)

Initialize pkcs11 context

func (*Pkcs11Wrapper) InitSession

func (p11w *Pkcs11Wrapper) InitSession() (err error)

Initialize Session to slot

func (*Pkcs11Wrapper) ListObjects

func (p11w *Pkcs11Wrapper) ListObjects(template []*pkcs11.Attribute, max int)

List content of slot

func (*Pkcs11Wrapper) Login

func (p11w *Pkcs11Wrapper) Login() (err error)

This will perform a login

func (*Pkcs11Wrapper) SignMessage

func (p11w *Pkcs11Wrapper) SignMessage(message string, key pkcs11.ObjectHandle) (signature string, err error)

func (*Pkcs11Wrapper) SignMessageAdvanced

func (p11w *Pkcs11Wrapper) SignMessageAdvanced(data []byte, key pkcs11.ObjectHandle, mechanism *pkcs11.Mechanism) (signature string, err error)

Advanced form of signing message, specify mechanism. Assume data is already prepared for mechanism (not altered in this function)

func (*Pkcs11Wrapper) VerifySignature

func (p11w *Pkcs11Wrapper) VerifySignature(message string, signature string, key pkcs11.ObjectHandle) (verified bool, err error)

type SubjectKeyIdentifier

type SubjectKeyIdentifier struct {
	Sha1        string
	Sha1Bytes   []byte
	Sha256      string
	Sha256Bytes []byte
}

Jump to

Keyboard shortcuts

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