crypto

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 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

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

Types

type Encrypter

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

func (*Encrypter) Decrypt

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

func (*Encrypter) Encrypt

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

func (*Encrypter) Generate

func (b *Encrypter) Generate()

func (*Encrypter) GetSharedSecret

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

type EncrypterMarshal

type EncrypterMarshal MarshalledKey

type EncryptionPrivKeyType

type EncryptionPrivKeyType = *ecdh.PrivateKey

type EncryptionPubKeyType

type EncryptionPubKeyType = *ecdh.PublicKey

type ISigner

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

type IncompatibleKeyPair added in v0.10.1

type IncompatibleKeyPair error

type MarshalledKey

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

type SecurityViolation added in v0.10.1

type SecurityViolation error

type SharedSecret

type SharedSecret []byte

func GetSharedSecret

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

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

func (b *Signer) MarshalPrivate() string

func (*Signer) MarshalPublic

func (b *Signer) MarshalPublic() string

func (*Signer) Sign

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

func (*Signer) UnmarshalPrivate

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

func (*Signer) UnmarshalPublic

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

func (*Signer) Verify

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

type SignerMarshal

type SignerMarshal MarshalledKey

func (*SignerMarshal) Decode

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

Takes the struct from Signer.Marshal

type SigningPrivKeyType

type SigningPrivKeyType = ed25519.PrivateKey

type SigningPubKeyType

type SigningPubKeyType = ed25519.PublicKey

type SymmetricEncryption

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