hecdsa

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ECP224 = "P-224"
	ECP256 = "P-256"
	ECP384 = "P-384"
	ECP521 = "P-521"
)

Variables

View Source
var ErrCurveNotSupported = errors.New("curve not supported")
View Source
var ErrEmptyKeyPath = errors.New("invalid keyPath - keyPath empty")
View Source
var ErrInvalidSignature = [...]error{
	errors.New("invalid signature - garbage follows signature"),
	errors.New("invalid signature - signature's R value should not be nil"),
	errors.New("invalid signature - signature's S value should not be nil"),
	errors.New("invalid signature - signature's R value should be positive except zero"),
	errors.New("invalid signature - signature's S value should be positive except zero"),
}
View Source
var ErrKeyType = errors.New("invalid key type - key type should be heimdall.PRIVATEKEY or heimdall.PUBLICKEY")
View Source
var ErrMultiplePriKey = errors.New("private key in directory should be one")
View Source
var ErrWrongKeyID = errors.New("wrong key id - failed to find key using key ID")

Functions

func GenerateKey

func GenerateKey(keyGenOpt heimdall.KeyGenOpts) (heimdall.PriKey, error)

func LoadPriKey added in v0.2.4

func LoadPriKey(keyDirPath, pwd string) (heimdall.PriKey, error)

LoadPriKey loads private key with password.

func LoadPriKeyWithoutPwd added in v0.2.4

func LoadPriKeyWithoutPwd(keyDirPath string) (heimdall.PriKey, error)

func LoadPubKey added in v0.2.4

func LoadPubKey(keyId heimdall.KeyID, keyDirPath string) (heimdall.PubKey, error)

LoadPubKey loads public key by key ID.

func NewPriKey

func NewPriKey(internalPriKey *ecdsa.PrivateKey) heimdall.PriKey

func NewPubKey

func NewPubKey(internalPubKey *ecdsa.PublicKey) heimdall.PubKey

func Sign

func Sign(pri heimdall.PriKey, message []byte, opts heimdall.SignerOpts) ([]byte, error)

Sign generates signature for a data using private key.

func SignWithKeyInLocal

func SignWithKeyInLocal(keyDirPath string, message []byte, signerOpt heimdall.SignerOpts) ([]byte, error)

func StorePriKey added in v0.2.4

func StorePriKey(key heimdall.PriKey, pwd, keyDirPath string, encOpt *encryption.Opts, kdfOpt *kdf.Opts) error

StorePriKey stores private key with password.

func StorePriKeyWithoutPwd added in v0.2.4

func StorePriKeyWithoutPwd(key heimdall.PriKey, keyDirPath string) error

func StorePubKey added in v0.2.4

func StorePubKey(key heimdall.PubKey, keyDirPath string) error

StorePubKey stores public key.

func Verify

func Verify(pub heimdall.PubKey, signature, message []byte, opts heimdall.SignerOpts) (bool, error)

Verify verifies the signature using pubKey(public key) and digest of original message, then returns boolean value.

func VerifyWithCert

func VerifyWithCert(cert *x509.Certificate, signature, message []byte, opts heimdall.SignerOpts) (bool, error)

VerifyWithCert verify a signature with certificate.

Types

type EncryptionHints added in v0.2.4

type EncryptionHints struct {
	EncOpt  *encryption.Opts
	KDFOpt  *kdf.Opts
	KDFSalt []byte
}

struct for providing hints of encryption and key derivation function.

type KeyFile added in v0.2.4

type KeyFile struct {
	SKI          []byte
	EncryptedKey string
	Hints        *EncryptionHints
}

struct for encrypted key's file format.

type KeyGenOpt

type KeyGenOpt struct {
	Curve elliptic.Curve
}

func NewKeyGenOpt

func NewKeyGenOpt(strCurve string) (*KeyGenOpt, error)

func (*KeyGenOpt) KeySize

func (opt *KeyGenOpt) KeySize() int

func (*KeyGenOpt) ToString

func (opt *KeyGenOpt) ToString() string

type KeyRecoverer

type KeyRecoverer struct {
}

func (*KeyRecoverer) RecoverKeyFromByte

func (recoverer *KeyRecoverer) RecoverKeyFromByte(keyBytes []byte, isPrivate bool) (heimdall.Key, error)

type PriKey

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

PriKey is an implementation of heimdall PriKey for using ECDSA private key

func (*PriKey) Clear

func (priKey *PriKey) Clear()

func (*PriKey) ID

func (priKey *PriKey) ID() heimdall.KeyID

func (*PriKey) IsPrivate

func (priKey *PriKey) IsPrivate() bool

func (*PriKey) KeyGenOpt

func (priKey *PriKey) KeyGenOpt() heimdall.KeyGenOpts

func (*PriKey) PublicKey

func (priKey *PriKey) PublicKey() heimdall.PubKey

func (*PriKey) SKI

func (priKey *PriKey) SKI() []byte

func (*PriKey) ToByte

func (priKey *PriKey) ToByte() ([]byte, error)

type PubKey

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

PubKey is an implementation of heimdall PubKey for using ECDSA public key

func (*PubKey) ID

func (pubKey *PubKey) ID() heimdall.KeyID

func (*PubKey) IsPrivate

func (pubKey *PubKey) IsPrivate() bool

func (*PubKey) KeyGenOpt

func (pubKey *PubKey) KeyGenOpt() heimdall.KeyGenOpts

func (*PubKey) SKI

func (pubKey *PubKey) SKI() []byte

func (*PubKey) ToByte

func (pubKey *PubKey) ToByte() ([]byte, error)

type SignerOpts

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

func NewSignerOpts

func NewSignerOpts(hashOpt *hashing.HashOpt) *SignerOpts

func (*SignerOpts) Algorithm

func (signerOpt *SignerOpts) Algorithm() string

func (*SignerOpts) HashOpt

func (signerOpt *SignerOpts) HashOpt() *hashing.HashOpt

Jump to

Keyboard shortcuts

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