kex

package
v0.0.0-...-cceba45 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2014 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package kex wraps the go.crypto Curve25519 primitive for ease of use.

Index

Constants

View Source
const (
	// PublicKeySize is the size of a Curve25519 public key in bytes.
	PublicKeySize = 32

	// PrivateKeySize is the size of a Curve25519 private key in bytes.
	PrivateKeySize = 32

	// SharedSecretSize is the size of a Curve25519 shared secret in bytes.
	SharedSecretSize = 32
)

Variables

View Source
var ErrInvalidPublicKey = errors.New("kex: invalid raw public key")

ErrInvalidPublicKey is the error returned when a public key is invalid.

Functions

func GenerateKey

func GenerateKey(random io.Reader) (priv *PrivateKey, pub *PublicKey, err error)

GenerateKey creates a new public/private key pair using a given source of entropy.

Types

type PrivateKey

type PrivateKey [PrivateKeySize]byte

PrivateKey is a wrapper type around a private key.

func (*PrivateKey) KeyExchange

func (p *PrivateKey) KeyExchange(pub *PublicKey) *SharedSecret

KeyExchange calculates the shared secret based on a private key and separate public key.

func (*PrivateKey) Obliterate

func (p *PrivateKey) Obliterate()

Obliterate clears the private key.

type PublicKey

type PublicKey [PublicKeySize]byte

PublicKey is a wrapper type around a public key.

func NewPublicKey

func NewPublicKey(raw []byte) (pub *PublicKey, err error)

NewPublicKey creates a PublicKey from the raw key material.

func (*PublicKey) Bytes

func (p *PublicKey) Bytes() []byte

Bytes returns the raw public key as a byte slice.

type SharedSecret

type SharedSecret [SharedSecretSize]byte

SharedSecret is a wrapper type around a shared secret.

func (*SharedSecret) Bytes

func (s *SharedSecret) Bytes() []byte

Bytes returns the raw shared secret as a byte slice.

func (*SharedSecret) Obliterate

func (s *SharedSecret) Obliterate()

Obliterate clears the shared secret.

Jump to

Keyboard shortcuts

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