ecc

package
v0.0.0-...-bb554c2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.

Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.

Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.

Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.

Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.

Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.

Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.

Index

Constants

This section is empty.

Variables

View Source
var Curves = []CurveInfo{
	{

		GenName: "P256",
		Oid:     encoding.NewOID([]byte{0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07}),
		Curve:   NewGenericCurve(elliptic.P256()),
	},
	{

		GenName: "P384",
		Oid:     encoding.NewOID([]byte{0x2B, 0x81, 0x04, 0x00, 0x22}),
		Curve:   NewGenericCurve(elliptic.P384()),
	},
	{

		GenName: "P521",
		Oid:     encoding.NewOID([]byte{0x2B, 0x81, 0x04, 0x00, 0x23}),
		Curve:   NewGenericCurve(elliptic.P521()),
	},
	{

		GenName: "SecP256k1",
		Oid:     encoding.NewOID([]byte{0x2B, 0x81, 0x04, 0x00, 0x0A}),
		Curve:   NewGenericCurve(bitcurves.S256()),
	},
	{

		GenName: "Curve25519",
		Oid:     encoding.NewOID([]byte{0x2B, 0x06, 0x01, 0x04, 0x01, 0x97, 0x55, 0x01, 0x05, 0x01}),
		Curve:   NewCurve25519(),
	},
	{

		GenName: "Curve448",
		Oid:     encoding.NewOID([]byte{0x2B, 0x65, 0x6F}),
		Curve:   NewX448(),
	},
	{

		GenName: "Curve25519",
		Oid:     encoding.NewOID([]byte{0x2B, 0x06, 0x01, 0x04, 0x01, 0xDA, 0x47, 0x0F, 0x01}),
		Curve:   NewEd25519(),
	},
	{

		GenName: "Curve448",
		Oid:     encoding.NewOID([]byte{0x2B, 0x65, 0x71}),
		Curve:   NewEd448(),
	},
	{

		GenName: "BrainpoolP256",
		Oid:     encoding.NewOID([]byte{0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x07}),
		Curve:   NewGenericCurve(brainpool.P256r1()),
	},
	{

		GenName: "BrainpoolP384",
		Oid:     encoding.NewOID([]byte{0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0B}),
		Curve:   NewGenericCurve(brainpool.P384r1()),
	},
	{

		GenName: "BrainpoolP512",
		Oid:     encoding.NewOID([]byte{0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0D}),
		Curve:   NewGenericCurve(brainpool.P512r1()),
	},
}

Functions

func NewCurve25519

func NewCurve25519() *curve25519

func NewEd25519

func NewEd25519() *ed25519

func NewEd448

func NewEd448() *ed448

func NewGenericCurve

func NewGenericCurve(c elliptic.Curve) *genericCurve

func NewX448

func NewX448() *x448

Types

type Curve

type Curve interface {
	GetCurveName() string
}

type CurveInfo

type CurveInfo struct {
	GenName string
	Oid     *encoding.OID
	Curve   Curve
}

func FindByCurve

func FindByCurve(curve Curve) *CurveInfo

func FindByOid

func FindByOid(oid encoding.Field) *CurveInfo

type ECDHCurve

type ECDHCurve interface {
	Curve
	MarshalBytePoint([]byte) (encoded []byte)
	UnmarshalBytePoint(encoded []byte) []byte
	MarshalByteSecret(d []byte) []byte
	UnmarshalByteSecret(d []byte) []byte
	GenerateECDH(rand io.Reader) (point []byte, secret []byte, err error)
	Encaps(rand io.Reader, point []byte) (ephemeral, sharedSecret []byte, err error)
	Decaps(ephemeral, secret []byte) (sharedSecret []byte, err error)
	ValidateECDH(public []byte, secret []byte) error
}

func FindECDHByGenName

func FindECDHByGenName(curveGenName string) ECDHCurve

type ECDSACurve

type ECDSACurve interface {
	Curve
	MarshalIntegerPoint(x, y *big.Int) []byte
	UnmarshalIntegerPoint([]byte) (x, y *big.Int)
	MarshalIntegerSecret(d *big.Int) []byte
	UnmarshalIntegerSecret(d []byte) *big.Int
	GenerateECDSA(rand io.Reader) (x, y, secret *big.Int, err error)
	Sign(rand io.Reader, x, y, d *big.Int, hash []byte) (r, s *big.Int, err error)
	Verify(x, y *big.Int, hash []byte, r, s *big.Int) bool
	ValidateECDSA(x, y *big.Int, secret []byte) error
}

func FindECDSAByGenName

func FindECDSAByGenName(curveGenName string) ECDSACurve

type EdDSACurve

type EdDSACurve interface {
	Curve
	MarshalBytePoint(x []byte) []byte
	UnmarshalBytePoint([]byte) (x []byte)
	MarshalByteSecret(d []byte) []byte
	UnmarshalByteSecret(d []byte) []byte
	MarshalSignature(sig []byte) (r, s []byte)
	UnmarshalSignature(r, s []byte) (sig []byte)
	GenerateEdDSA(rand io.Reader) (pub, priv []byte, err error)
	Sign(publicKey, privateKey, message []byte) (sig []byte, err error)
	Verify(publicKey, message, sig []byte) bool
	ValidateEdDSA(publicKey, privateKey []byte) (err error)
}

func FindEdDSAByGenName

func FindEdDSAByGenName(curveGenName string) EdDSACurve

Jump to

Keyboard shortcuts

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