signkeys

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package signkeys implements key generation and verification methods for keys suitable for blind signature creation.

Index

Constants

View Source
const (
	// DefaultExpireTime is the duration for which a key is considered valid.
	DefaultExpireTime = 2592000 // one month
)
View Source
const (
	// KeyIDSize is the size of a keyID.
	KeyIDSize = sha256.Size
)

Variables

View Source
var (
	// ErrNoSigner is returned if a generator is missing a private key for
	// signing its keys.
	ErrNoSigner = errors.New("keygen: no signer")
)

Functions

This section is empty.

Types

type KeyGenerator

type KeyGenerator struct {
	Curve      *eccutil.Curve // Curve and hash for all keys
	ExpireTime int64          // Expire duration to set on generation
	Usage      string         // The key usage type
	PublicKey  *[ed25519.PublicKeySize]byte
	PrivateKey *[ed25519.PrivateKeySize]byte
}

KeyGenerator implements a signing key generator and a verifier.

func New

func New(curve func() elliptic.Curve, rand io.Reader, hash func([]byte) []byte) *KeyGenerator

New returns a new key generator. The Usage and URL of the generator must be explicitely set.

func (KeyGenerator) GenKey

func (kg KeyGenerator) GenKey() (*KeyPair, error)

GenKey generates a new key structure.

type KeyPair

type KeyPair struct {
	PublicKey  PublicKey
	PrivateKey []byte // Private key
}

KeyPair represents a keypair.

type PublicKey

type PublicKey struct {
	KeyID     [KeyIDSize]byte             // The KeyID (hash) of this key
	PublicKey eccutil.Point               // Public key of PrivateKey
	Expire    int64                       // Last unixtime for which this key is usable for verification
	Usage     string                      // The usage for the key
	Signer    [ed25519.PublicKeySize]byte // The signer
	Signature [ed25519.SignatureSize]byte // Signature of key
}

PublicKey represents the public components of a key.

func (*PublicKey) CalcKeyID

func (pk *PublicKey) CalcKeyID() [sha256.Size]byte

CalcKeyID returns the sha256 of the key components.

func (PublicKey) Marshal

func (pk PublicKey) Marshal() ([]byte, error)

Marshal a public key to ASN1.

func (*PublicKey) Unmarshal

func (pk *PublicKey) Unmarshal(d []byte) (*PublicKey, error)

Unmarshal fills the public key with d.

func (PublicKey) Verify

func (pk PublicKey) Verify(SignaturePublicKey *[ed25519.PublicKeySize]byte) bool

Verify verifies a public key using SignaturePublicKey.

type PublicKeyMarshal

type PublicKeyMarshal struct {
	KeyID                  []byte
	PublicKeyX, PublicKeyY []byte
	Expire                 int64
	Usage                  string
	Signer                 []byte
	Signature              []byte
}

PublicKeyMarshal is an intermediate representation of a public key to fix limitations of ASN1.

Jump to

Keyboard shortcuts

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