p11

package module
v0.0.0-...-7d57b76 Latest Latest
Warning

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

Go to latest
Published: May 4, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

README

p11

p11 provides a wrapper on miekg/pkcs11 by providing crypto implementations that meet the existing interfaces in the Go crypto standard library and/or x/crypto supplementary libraries.

The intent is to provide near-drop-in replacements for offloading symmetric cryptographic operations to Hardware Security Modules.

It is similar to https://github.com/thalesignite/crypto11 and https://github.com/letsencrypt/pkcs11key . The key difference is that those libraries offer implementations for the common assymmetric operations, while this library is for symmetric operations.

HSMs aren't often used for symmetric operations so this is really just for fun/proof-of-concept. As such, please don't use this in production.

Working

AES (ECB)

TODO

  • integrate miekg/pkcs11/p11 for the session and context management to reduce implementation fragmentation
  • implement CBC cipher.BlockMode interface
  • implement GCM cipher.AEAD interface
  • add AES ECB unit tests

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	HSM *pkcs11.Ctx

	// TODO: make this a concurrent-safe pool of sessions, default of size 1
	Session pkcs11.SessionHandle
}

func New

func New(lib string, pin string, sessionPoolSize int) (*Context, error)

TODO: make these an Options struct?

func (*Context) Destroy

func (c *Context) Destroy()

Destroy tears down the HSM session and context

func (*Context) FindObjectByID

func (c *Context) FindObjectByID(id string) (pkcs11.ObjectHandle, error)

FindObjectByID searches for a session or token object by CKA_ID and returns the object handle

func (*Context) FindObjectByLabel

func (c *Context) FindObjectByLabel(label string) (pkcs11.ObjectHandle, error)

FindObjectByLabel searches for a token object by CKA_LABEL and returns the object handle

func (*Context) FindObjectByTemplate

func (c *Context) FindObjectByTemplate(template []*pkcs11.Attribute) (pkcs11.ObjectHandle, error)

FindObjectByTemplate searches for a token object by the attribute template and returns the object handle

func (*Context) GetSession

func (c *Context) GetSession() pkcs11.SessionHandle

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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