cipher

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SaltLen    = 32
	KeyLen     = uint32(32)
	KeyTime    = uint32(5)
	KeyMemory  = uint32(64 * 1024)
	KeyThreads = uint8(4)
)
View Source
const BEE_AEAD_DATA = "*21!)4!"

Variables

This section is empty.

Functions

func DecryptBytes

func DecryptBytes(encryptedBytes, key, salt []byte) (decryptedBytes []byte, err error)

func EncryptBytes

func EncryptBytes(inputBytes, key []byte) (encryptedBytes, salt []byte, err error)

Types

type ChachaCipher

type ChachaCipher struct {
	ChunkSize  int
	DerivedKey []byte
	Salt       []byte

	BytesWritten int
	BytesRead    int
	// contains filtered or unexported fields
}

func NewChaChaCipherFromSalt

func NewChaChaCipherFromSalt(key, salt []byte, chunkSize int) (*ChachaCipher, error)

func NewChaChaCipherRandomSalt

func NewChaChaCipherRandomSalt(key []byte, chunkSize int) (*ChachaCipher, error)

func (*ChachaCipher) Decrypt

func (c *ChachaCipher) Decrypt(r io.Reader, w io.Writer) (int, error)

func (*ChachaCipher) Encrypt

func (c *ChachaCipher) Encrypt(r io.Reader, w io.Writer) (int, error)

func (*ChachaCipher) GetBytesRead

func (c *ChachaCipher) GetBytesRead() int

func (*ChachaCipher) GetBytesWritten

func (c *ChachaCipher) GetBytesWritten() int

func (*ChachaCipher) GetChunkSize

func (c *ChachaCipher) GetChunkSize() int

func (*ChachaCipher) GetDerivedKey

func (c *ChachaCipher) GetDerivedKey() []byte

func (*ChachaCipher) GetSalt

func (c *ChachaCipher) GetSalt() []byte

type Cipher

type Cipher interface {
	GetBytesRead() int
	GetBytesWritten() int
	GetChunkSize() int
	GetDerivedKey() []byte
	GetSalt() []byte
	Decrypt(r io.Reader, w io.Writer) (int, error)
	Encrypt(r io.Reader, w io.Writer) (int, error)
}

func NewKPCipherDecrypter

func NewKPCipherDecrypter(receiverSeed []byte, senderPubKey string) (Cipher, error)

NewKPCipherDecoder initializes an nkey encoding set

func NewKPCipherEncrypter

func NewKPCipherEncrypter(receiverPubKey string, senderSeed []byte) (Cipher, error)

NewKPCipherEncoder initializes an nkey decoding set

func NewSymmetricCipher

func NewSymmetricCipher(key []byte, chunkSize int) (Cipher, error)

NewSymmetricCipher would be called for encrypting when the salt needs to be derived.

func NewSymmetricCipherFromSalt

func NewSymmetricCipherFromSalt(key, salt []byte, chunkSize int) (Cipher, error)

NewSymmetricCipherFromSalt would be called for decrypting when the salt was previously derived.

type NKeysCipher

type NKeysCipher struct {
	ReceiverKP     nkeys.KeyPair
	ReceiverPubKey string
	SenderKP       nkeys.KeyPair
	SenderPubKey   string
	BytesRead      int
	BytesWritten   int
}

func NewNKeysCipherDecrypter

func NewNKeysCipherDecrypter(receiverSeed []byte, senderPubKey string) (*NKeysCipher, error)

func NewNKeysCipherEncrypter

func NewNKeysCipherEncrypter(receiverPubKey string, senderSeed []byte) (*NKeysCipher, error)

func (*NKeysCipher) Decrypt

func (nk *NKeysCipher) Decrypt(r io.Reader, w io.Writer) (int, error)

func (*NKeysCipher) Encrypt

func (nk *NKeysCipher) Encrypt(r io.Reader, w io.Writer) (int, error)

func (*NKeysCipher) GetBytesRead

func (nk *NKeysCipher) GetBytesRead() int

func (*NKeysCipher) GetBytesWritten

func (nk *NKeysCipher) GetBytesWritten() int

func (*NKeysCipher) GetChunkSize

func (nk *NKeysCipher) GetChunkSize() int

func (*NKeysCipher) GetDerivedKey

func (nk *NKeysCipher) GetDerivedKey() []byte

func (*NKeysCipher) GetSalt

func (nk *NKeysCipher) GetSalt() []byte

func (*NKeysCipher) Wipe

func (nk *NKeysCipher) Wipe()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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