crypto

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: MIT Imports: 12 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 (
	EmptyPrivateKey = PrivateKey("")
	EmptyPublicKey  = PublicKey("")
)
View Source
const (
	EC             = "EC"  // Elliptic Curve
	InvalidKeyType = ""    // Invalid KeyType
	OctetSeq       = "oct" // Octet sequence (used to represent symmetric keys)
	RSA            = "RSA" // RSA
)

Supported values for KeyType

Variables

This section is empty.

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 PrivateKey

type PrivateKey string

func GenerateEd25519PrivateKey added in v0.5.0

func GenerateEd25519PrivateKey() (PrivateKey, error)

func NewEphemeralSharedKey added in v0.7.0

func NewEphemeralSharedKey(pub PublicKey) (*PrivateKey, []byte, error)

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

func NewPrivateKey

func NewPrivateKey(seed []byte) PrivateKey

func (PrivateKey) Bytes added in v0.5.0

func (i PrivateKey) Bytes() []byte

func (PrivateKey) IsEmpty added in v0.5.0

func (i PrivateKey) IsEmpty() bool

func (PrivateKey) PublicKey

func (i PrivateKey) PublicKey() PublicKey

func (PrivateKey) Sign added in v0.5.0

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

func (PrivateKey) String added in v0.5.0

func (i PrivateKey) String() string

type PublicKey

type PublicKey string

func NewPublicKey

func NewPublicKey(publicKey ed25519.PublicKey) PublicKey

func (PublicKey) Address added in v0.5.0

func (r PublicKey) Address() string

func (PublicKey) Bytes added in v0.5.0

func (r PublicKey) Bytes() []byte

func (PublicKey) Equals added in v0.5.0

func (r PublicKey) Equals(w PublicKey) bool

func (PublicKey) IsEmpty added in v0.5.0

func (r PublicKey) IsEmpty() bool

func (PublicKey) String added in v0.5.0

func (r PublicKey) String() string

func (PublicKey) Verify added in v0.5.0

func (r 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