ecc

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 18 Imported by: 0

README

ecc Go Reference Release Tests Go Report Card License

Elliptic Curve Cryptography with curve25519 using only the golang standard library. Requires Go 1.22 or later.

Installation

go get github.com/malivvan/ecc@latest

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Organization = "ECC"

	CertValidity = func() (time.Time, time.Time) {
		now := time.Now().In(time.UTC)
		notBefore := time.Date(now.Year()-(now.Year()%10), time.January, 1, 0, 0, 0, 0, time.UTC)
		notAfter := time.Date(now.Year()-(now.Year()%10)+9, time.December, 31, 23, 59, 59, 0, time.UTC)
		return notBefore, notAfter
	}

	CertifyValidity = func() (time.Time, time.Time) {
		now := time.Now().In(time.UTC)
		notBefore := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC)
		notAfter := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, time.UTC)
		return notBefore, notAfter
	}
)
View Source
var Base91 = newBase91Encoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_-{|}~'")

Base91 is a binary-to-text encoding scheme with a 91-character alphabet. Of the 95 printable ASCII characters, the following four are omitted: quotation mark (0x22), space (0x20), backtick (0x60) and backslash (0x5c).

Functions

func Cert added in v1.1.0

func Cert(privateKey any) ([]byte, error)

func Certify

func Certify(privateKey any, host string) ([]byte, []byte, error)

func Exchange

func Exchange(privateKey, publicKey any) ([]byte, error)

func Register added in v1.1.0

func Register(fn any)

func Sign

func Sign(privateKey any, message []byte) ([]byte, error)

func Verify

func Verify(publicKey any, message, signature []byte) error

Types

type PrivateKey

type PrivateKey [32]byte

func Private

func Private(privateKey any) (*PrivateKey, error)

func (*PrivateKey) Bytes

func (priv *PrivateKey) Bytes() []byte

func (*PrivateKey) Cert added in v1.1.0

func (priv *PrivateKey) Cert() ([]byte, error)

func (*PrivateKey) Certify

func (priv *PrivateKey) Certify(host string) ([]byte, []byte, error)

func (*PrivateKey) ED25519 added in v1.1.0

func (priv *PrivateKey) ED25519() []byte

func (*PrivateKey) Equals

func (priv *PrivateKey) Equals(other *PrivateKey) bool

func (*PrivateKey) Exchange

func (priv *PrivateKey) Exchange(publicKey any) ([]byte, error)

func (*PrivateKey) PEM

func (priv *PrivateKey) PEM() []byte

func (*PrivateKey) Public

func (priv *PrivateKey) Public() *PublicKey

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(message []byte) ([]byte, error)

func (*PrivateKey) String

func (priv *PrivateKey) String() string

func (*PrivateKey) X25519 added in v1.1.0

func (priv *PrivateKey) X25519() []byte

type PublicKey

type PublicKey [32]byte

func Public

func Public(publicKey any) (*PublicKey, error)

func (*PublicKey) Bytes

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

func (*PublicKey) ED25519 added in v1.1.0

func (pub *PublicKey) ED25519() []byte

func (*PublicKey) Equals

func (pub *PublicKey) Equals(other *PublicKey) bool

func (*PublicKey) Exchange

func (pub *PublicKey) Exchange(privateKey any) ([]byte, error)

func (*PublicKey) PEM

func (pub *PublicKey) PEM() []byte

func (*PublicKey) String

func (pub *PublicKey) String() string

func (*PublicKey) Verify

func (pub *PublicKey) Verify(message []byte, signature []byte) error

func (*PublicKey) X25519 added in v1.1.0

func (pub *PublicKey) X25519() []byte

Jump to

Keyboard shortcuts

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