Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
ValidateCurve25519 validates that a Curve25519 private/public key pair matches
func ValidateEd25519 ¶
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 ¶
NewCurve448 Creates a new Curve448 CurveOctetKeyPair
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 ¶
GenerateEd25519 Generates a new Ed25519 CurveOctetKeyPair
func NewEd25519 ¶
NewEd25519 Creates a new Ed25519 CurveOctetKeyPair
type Ed448 ¶
type Ed448 struct{ OctetKeyPairBase }
Ed448 represents an Ed448 Key Pair
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