cryptokit

package module
v0.0.0-...-b452821 Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: MIT Imports: 2 Imported by: 0

README

cryptokit

Golang crypto wrapper with pluggable providers

Documentation

Documentation

Index

Constants

View Source
const (
	AesKey  = 1
	DesKey  = 2
	TdesKey = 3
	RsaKey  = 3
	DsaKey  = 4
	RawKey  = 5
)
View Source
const (
	Encrypt = 0x1
	Decrypt = 0x2
	Wrap    = 0x4
	Unwrap  = 0x8
	Derive  = 0x10

	EncryptDecrypt  = Encrypt | Decrypt
	AllCapabilities = Encrypt | Decrypt | Wrap | Unwrap | Derive
)

Variables

This section is empty.

Functions

func RegisterProvider

func RegisterProvider(name string, factory ProviderFactory)

Types

type Aes

type Aes struct {
}

func (Aes) Name

func (m Aes) Name() string

type BlockCipher

type BlockCipher interface {
	BlockCipherUnderlying() Mechanism
	BlockCipherIV() []byte
}

type Cbc

type Cbc struct {
	Underlying Mechanism `cmd:",primary"`
	IV         []byte
}

func (Cbc) BlockCipherIV

func (c Cbc) BlockCipherIV() []byte

func (Cbc) BlockCipherUnderlying

func (c Cbc) BlockCipherUnderlying() Mechanism

func (Cbc) Name

func (c Cbc) Name() string

type Des

type Des struct {
}

func (Des) Name

func (m Des) Name() string

type Dukpt

type Dukpt struct {
	Ksn []byte `cmd:",primary"`
}

func (Dukpt) Name

func (m Dukpt) Name() string

type Ecb

type Ecb struct {
	Underlying Mechanism
	IV         []byte
}

func (Ecb) BlockCipherIV

func (c Ecb) BlockCipherIV() []byte

func (Ecb) BlockCipherUnderlying

func (c Ecb) BlockCipherUnderlying() Mechanism

func (Ecb) Name

func (c Ecb) Name() string

type FixedKey

type FixedKey struct {
	Key []byte `cmd:",primary"`
}

func (FixedKey) Name

func (m FixedKey) Name() string

type Gcm

type Gcm struct {
	Underlying     Mechanism `cmd:",primary"`
	Nonce          []byte    `cmd:"nonce"`
	AdditionalData []byte    `cmd:"additional-data"`
}

func (Gcm) Name

func (c Gcm) Name() string

type Hmac

type Hmac struct {
	Underlying Mechanism `cmd:",primary"`
}

func (Hmac) Name

func (m Hmac) Name() string

type Key

type Key interface {
	ID() string
	Type() KeyType
	Length() uint
	Attributes() KeyAttributes
	Extract() ([]byte, error)

	Session() Session
	Destroy() error
	Close() error
}

type KeyAttributes

type KeyAttributes struct {
	ID           string
	Type         KeyType
	Length       uint
	Permanent    bool
	Extractable  bool
	Capabilities KeyCapability
}

type KeyCapability

type KeyCapability uint

type KeyType

type KeyType uint

type Mechanism

type Mechanism interface {
	Name() string
}

type Provider

type Provider interface {
	OpenSession() (Session, error)
	Close() error
}

func Create

func Create(uri string) (Provider, error)

type ProviderFactory

type ProviderFactory func(*url.URL) (Provider, error)

type Random

type Random struct {
}

func (Random) Name

func (m Random) Name() string

type Session

type Session interface {
	ListKeys() ([]string, error)
	FindKey(id string) (Key, bool, error)

	Encrypt(mech Mechanism, key Key, in []byte) ([]byte, error)
	Decrypt(mech Mechanism, key Key, in []byte) ([]byte, error)
	Translate(mech Mechanism, inKey Key, in []byte, outKey Key) ([]byte, error)

	Wrap(mech Mechanism, kek, key Key) ([]byte, error)
	Unwrap(mech Mechanism, kek Key, key []byte, attributes KeyAttributes) (Key, error)

	Generate(mech Mechanism, attributes KeyAttributes) (Key, error)
	Derive(mech Mechanism, key Key, attributes KeyAttributes) (Key, error)

	Hash(mech Mechanism, in []byte) ([]byte, error)

	Close() error
}

type Sha1

type Sha1 struct {
}

func (Sha1) Name

func (m Sha1) Name() string

type Sha256

type Sha256 struct {
}

func (Sha256) Name

func (m Sha256) Name() string

type Sha512

type Sha512 struct {
}

func (Sha512) Name

func (m Sha512) Name() string

type Tdes

type Tdes struct {
}

func (Tdes) Name

func (m Tdes) Name() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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