okp

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Curve25519KeySize is the size of both Curve25519 public and private keys
	Curve25519KeySize = 32

	// Ed25519KeySize is the size of both Ed25519 public and private keys
	Ed25519KeySize = 32
)

Variables

View Source
var (
	// ErrKeyMissing s thrown when a required key (public or private) is missing
	ErrKeyMissing = errors.New("no public or private key is specified")
)

Functions

func ValidateCurve25519

func ValidateCurve25519(pub, priv []byte) error

ValidateCurve25519 validates that a Curve25519 private/public key pair matches

func ValidateEd25519

func ValidateEd25519(pub, priv []byte) error

ValidateEd25519 validates that a Ed25519 private/public key pair matches

Types

type Curve25519

type Curve25519 struct{ OctetKeyPairBase }

Curve25519 represents a Curve25519 Key Pair

func GenerateCurve25519

func GenerateCurve25519(rand io.Reader) (Curve25519, error)

GenerateCurve25519 Generates a new X25519 CurveOctetKeyPair

func NewCurve25519

func NewCurve25519(pub, priv []byte) Curve25519

NewCurve25519 Creates a new Curve25519 CurveOctetKeyPair

func (Curve25519) Algorithm

func (c Curve25519) Algorithm() string

Algorithm is the algorithm used in conjunction with the curve

func (Curve25519) Curve

func (c Curve25519) Curve() string

Curve is the name of the elliptic curve

type Curve448

type Curve448 struct{ OctetKeyPairBase }

Curve448 represents a Curve448 Key Pair

func NewCurve448

func NewCurve448(pub, priv []byte) Curve448

NewCurve448 Creates a new Curve448 CurveOctetKeyPair

func (Curve448) Algorithm

func (c Curve448) Algorithm() string

Algorithm is the algorithm used in conjunction with the curve

func (Curve448) Curve

func (c Curve448) Curve() string

Curve is the name of the elliptic curve

type CurveOctetKeyPair

type CurveOctetKeyPair interface {
	OctetKeyPair
	CurveSpec
}

CurveOctetKeyPair is a combination of an OctetKeyPair and CurveSpec.

func CurveExtractPublic

func CurveExtractPublic(okp CurveOctetKeyPair) (CurveOctetKeyPair, error)

CurveExtractPublic creates a new CurveOctetKeyPair out of an existing one, removing the private key and keeping only the public key.

func NewCurveOKP

func NewCurveOKP(curve string, pubKey []byte, privKey []byte) (CurveOctetKeyPair, error)

NewCurveOKP creates a new CurveOctetKeyPair with the specified curve

type CurveSpec

type CurveSpec interface {
	// Curve is the name of the elliptic curve.
	// This should be the standard name used in JWA.
	// (See RFCs: 7518, 8037)
	Curve() string

	// Algorithm is the algorithm used in conjunction with the curve,
	// as specified in JWA.
	// (See RFCs: 7518, 8037)
	Algorithm() string
}

CurveSpec exposes a named elliptic curve

type Ed25519

type Ed25519 struct{ OctetKeyPairBase }

Ed25519 represents an Ed25519 Key Pair

func GenerateEd25519

func GenerateEd25519(rand io.Reader) (Ed25519, error)

GenerateEd25519 Generates a new Ed25519 CurveOctetKeyPair

func NewEd25519

func NewEd25519(pub, priv []byte) Ed25519

NewEd25519 Creates a new Ed25519 CurveOctetKeyPair

func (Ed25519) Algorithm

func (c Ed25519) Algorithm() string

Algorithm is the algorithm used in conjunction with the curve

func (Ed25519) Curve

func (c Ed25519) Curve() string

Curve is the name of the elliptic curve

type Ed448

type Ed448 struct{ OctetKeyPairBase }

Ed448 represents an Ed448 Key Pair

func NewEd448

func NewEd448(pub, priv []byte) Ed448

NewEd448 Creates a new Ed448 CurveOctetKeyPair

func (Ed448) Algorithm

func (c Ed448) Algorithm() string

Algorithm is the algorithm used in conjunction with the curve

func (Ed448) Curve

func (c Ed448) Curve() string

Curve is the name of the elliptic curve

type OctetKeyPair

type OctetKeyPair interface {
	// PrivateKey is the bytes specifying the private key.
	PrivateKey() []byte

	// PublicKey is the bytes specifying the public key
	PublicKey() []byte
}

OctetKeyPair specifies an octet key pair, as specified by RFC 8037.

type OctetKeyPairBase

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

OctetKeyPairBase is a common type for implementing OctetKeyPairs

func (OctetKeyPairBase) PrivateKey

func (okp OctetKeyPairBase) PrivateKey() []byte

PrivateKey is the bytes specifying the private key.

func (OctetKeyPairBase) PublicKey

func (okp OctetKeyPairBase) PublicKey() []byte

PublicKey is the bytes specifying the public key

Jump to

Keyboard shortcuts

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