crypto

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// P256 curve
	P256 string = "P-256"
	// P384 curve
	P384 string = "P-384"
	// P521 curve
	P521 string = "P-521"
)
View Source
const (
	ErrUnsupportedKeyAlgorithm = errors.Error("key algorithm not supported")
	ErrInvalidSignature        = errors.Error("invalid signature")
)
View Source
const (
	Ed25519Private KeyAlgorithm = 0x1300 // well known value
	Ed25519Public  KeyAlgorithm = 0xED   // well known value

	PeerKey     KeyUsage = 0x6E00 // codec code for nimona _peer_ key
	IdentityKey KeyUsage = 0x6E01 // codec code for nimona _identity_ key
)

Variables

View Source
var (
	EmptyPublicKey  = PublicKey{}
	EmptyPrivateKey = PrivateKey{}
)

Functions

func CalculateSharedKey added in v0.7.0

func CalculateSharedKey(
	priv PrivateKey,
	pub PublicKey,
) ([]byte, error)

CalculateSharedKey calculates a shared secret given a private an public key

func GenerateTLSCertificate added in v0.5.0

func GenerateTLSCertificate(privateKey PrivateKey) (*tls.Certificate, error)

GenerateTLSCertificate for TLS serverset

Types

type KeyAlgorithm added in v0.18.0

type KeyAlgorithm uint64

type KeyUsage added in v0.18.0

type KeyUsage uint64

type PrivateKey

type PrivateKey struct {
	Usage     KeyUsage
	Algorithm KeyAlgorithm
	RawKey    ed25519.PrivateKey
}

func CalculateEphemeralSharedKey added in v0.18.0

func CalculateEphemeralSharedKey(
	pub PublicKey,
) (PrivateKey, []byte, error)

CalculateEphemeralSharedKey creates a new ec25519 key pair, calculates a shared secret given a public key, and returns the created public key and secret

func NewEd25519PrivateKey added in v0.18.0

func NewEd25519PrivateKey(keyType KeyUsage) (PrivateKey, error)

func NewEd25519PrivateKeyFromSeed added in v0.18.0

func NewEd25519PrivateKeyFromSeed(
	seed []byte,
	keyType KeyUsage,
) PrivateKey

func NewSharedKey added in v0.15.4

func NewSharedKey(
	priv PrivateKey,
	pub PublicKey,
) (PrivateKey, []byte, error)

NewSharedKey calculates a shared secret given a private and a public key, and returns it

func (PrivateKey) IsEmpty added in v0.5.0

func (k PrivateKey) IsEmpty() bool

func (PrivateKey) MarshalJSON added in v0.18.0

func (k PrivateKey) MarshalJSON() ([]byte, error)

func (PrivateKey) MarshalString added in v0.18.0

func (k PrivateKey) MarshalString() (string, error)

func (PrivateKey) MarshalText added in v0.18.0

func (k PrivateKey) MarshalText() ([]byte, error)

func (PrivateKey) PublicKey

func (k PrivateKey) PublicKey() PublicKey

func (PrivateKey) Sign added in v0.5.0

func (k PrivateKey) Sign(message []byte) []byte

func (PrivateKey) String added in v0.5.0

func (k PrivateKey) String() string

func (*PrivateKey) UnmarshalJSON added in v0.18.0

func (k *PrivateKey) UnmarshalJSON(s []byte) error

func (*PrivateKey) UnmarshalString added in v0.18.0

func (k *PrivateKey) UnmarshalString(s string) error

func (*PrivateKey) UnmarshalText added in v0.18.0

func (k *PrivateKey) UnmarshalText(s []byte) error

type PublicKey

type PublicKey struct {
	Usage     KeyUsage
	Algorithm KeyAlgorithm
	RawKey    ed25519.PublicKey
}

func NewEd25519PublicKeyFromRaw added in v0.18.0

func NewEd25519PublicKeyFromRaw(
	raw ed25519.PublicKey,
	keyType KeyUsage,
) PublicKey

func (PublicKey) Equals added in v0.5.0

func (k PublicKey) Equals(w PublicKey) bool

func (PublicKey) IsEmpty added in v0.5.0

func (k PublicKey) IsEmpty() bool

func (PublicKey) MarshalJSON added in v0.18.0

func (k PublicKey) MarshalJSON() ([]byte, error)

func (PublicKey) MarshalString added in v0.18.0

func (k PublicKey) MarshalString() (string, error)

func (PublicKey) MarshalText added in v0.18.0

func (k PublicKey) MarshalText() ([]byte, error)

func (PublicKey) String added in v0.5.0

func (k PublicKey) String() string

func (*PublicKey) UnmarshalJSON added in v0.18.0

func (k *PublicKey) UnmarshalJSON(s []byte) error

func (*PublicKey) UnmarshalString added in v0.18.0

func (k *PublicKey) UnmarshalString(s string) error

func (*PublicKey) UnmarshalText added in v0.18.0

func (k *PublicKey) UnmarshalText(s []byte) error

func (PublicKey) Verify added in v0.5.0

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

Jump to

Keyboard shortcuts

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