crypto

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignatureSize  = ed25519.SignatureSize
	PublicKeySize  = ed25519.PublicKeySize
	PrivateKeySize = ed25519.SeedSize
)

Variables

This section is empty.

Functions

func InitCipher added in v0.6.8

func InitCipher(secret SharedSecret) (cipher.Block, error)

Types

type Encrypter added in v0.6.8

type Encrypter struct {
	// Do not use this outside of Marshalling!
	Private ecdh.PrivateKey
	Public  ecdh.PublicKey
}

func (*Encrypter) Decrypt added in v0.6.8

func (b *Encrypter) Decrypt(other *Encrypter, ciphertext []byte) ([]byte, error)

func (*Encrypter) Encode added in v0.6.8

func (b *Encrypter) Encode() SignerMarshal

Returns a struct for optimized marshalling as base64 strings

func (*Encrypter) Encrypt added in v0.6.8

func (b *Encrypter) Encrypt(other *Encrypter, plain []byte) ([]byte, error)

func (*Encrypter) Generate added in v0.6.8

func (b *Encrypter) Generate()

func (*Encrypter) GetSharedSecret added in v0.6.8

func (b *Encrypter) GetSharedSecret(other *Encrypter) ([]byte, error)

func (*Encrypter) MarshalPrivate added in v0.6.8

func (b *Encrypter) MarshalPrivate() string

func (*Encrypter) MarshalPublic added in v0.6.8

func (b *Encrypter) MarshalPublic() string

func (*Encrypter) UnmarshalPrivate added in v0.6.8

func (b *Encrypter) UnmarshalPrivate(marshalled string) (SigningPrivKeyType, error)

func (*Encrypter) UnmarshalPublic added in v0.6.8

func (b *Encrypter) UnmarshalPublic(marshalled string) (SigningPubKeyType, error)

type EncrypterMarshal added in v0.6.8

type EncrypterMarshal MarshalledKey

func (*EncrypterMarshal) Decode added in v0.6.8

func (b *EncrypterMarshal) Decode() (*Signer, error)

Takes the struct from Signer.Marshal

type ISigner added in v0.6.8

type ISigner interface {
	Sign([]byte) ([]byte, error)
	Verify([]byte) (bool, error)
	Public() []byte
}

type MarshalledKey added in v0.6.8

type MarshalledKey struct {
	Private string `toml:",omitemtpy" json:",omitempty" yaml:",omitempty"`
	Public  string `toml:",omitempty" json:",omitempty" yaml:",omitempty"`
}

type SharedSecret added in v0.6.6

type SharedSecret []byte

func GetSharedSecret added in v0.6.8

func GetSharedSecret(me *Encrypter, other *Encrypter) (SharedSecret, error)

type Signature

type Signature []byte

type Signer

type Signer struct {
	// Do not use this for Marshalling!
	Private SigningPrivKeyType
	Public  SigningPubKeyType
}

func (*Signer) Encode added in v0.6.8

func (b *Signer) Encode() SignerMarshal

Returns a struct for optimized marshalling as base64 strings

func (*Signer) Generate

func (b *Signer) Generate() *Signer

func (*Signer) MarshalPrivate added in v0.6.8

func (b *Signer) MarshalPrivate() string

func (*Signer) MarshalPublic added in v0.6.8

func (b *Signer) MarshalPublic() string

func (*Signer) Sign

func (b *Signer) Sign(data []byte) (Signature, error)

func (*Signer) UnmarshalPrivate added in v0.6.8

func (b *Signer) UnmarshalPrivate(marshalled string) (SigningPrivKeyType, error)

func (*Signer) UnmarshalPublic added in v0.6.8

func (b *Signer) UnmarshalPublic(marshalled string) (SigningPubKeyType, error)

func (*Signer) Verify

func (b *Signer) Verify(data []byte, signature Signature) bool

type SignerMarshal added in v0.6.8

type SignerMarshal MarshalledKey

func (*SignerMarshal) Decode added in v0.6.8

func (b *SignerMarshal) Decode() (*Signer, error)

Takes the struct from Signer.Marshal

type SigningPrivKeyType added in v0.6.8

type SigningPrivKeyType = ed25519.PrivateKey

type SigningPubKeyType added in v0.6.8

type SigningPubKeyType = ed25519.PublicKey

type SymmetricEncryption added in v0.6.8

type SymmetricEncryption interface {
	Encrypt(secret SharedSecret, date []byte) ([]byte, error)
	Decrypt(secret SharedSecret, data []byte) ([]byte, error)
}

Jump to

Keyboard shortcuts

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