gchacha20

package
v0.0.0-...-04ff805 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChaCha20

type ChaCha20 struct{}

func NewChaCha20

func NewChaCha20() *ChaCha20

func (*ChaCha20) CodecWithKey

func (c *ChaCha20) CodecWithKey(key []byte, version gcrypto.Cipher) (*ChaCha20Cipher, error)

CodecWithKey creates ChaCha20 codec with bytes key.

func (*ChaCha20) CodecWithPassphrase

func (c *ChaCha20) CodecWithPassphrase(passphrase string, version gcrypto.Cipher) (*ChaCha20Cipher, error)

CodecWithPassphrase creates ChaCha20 codec with string passphrase.

func (*ChaCha20) MakerWithKey

func (c *ChaCha20) MakerWithKey(key []byte, version gcrypto.Cipher) (gcrypto.CipherRWCMaker, error)

MakerWithKey creates ChaCha20 stream codec with bytes key.

func (*ChaCha20) MakerWithPassphrase

func (c *ChaCha20) MakerWithPassphrase(passphrase string, version gcrypto.Cipher) (gcrypto.CipherRWCMaker, error)

MakerWithPassphrase creates ChaCha20 stream codec with string passphrase.

type ChaCha20Cipher

type ChaCha20Cipher struct {
	// contains filtered or unexported fields
}

ChaCha20Cipher is chacha20 encoder and decoder.

func (ChaCha20Cipher) Decrypt

func (c ChaCha20Cipher) Decrypt(b []byte) ([]byte, error)

Decrypt decrypts the given encrypted data using ChaCha20-Poly1305 with the given passphrase. The passphrase can be a user provided value, and is hashed using scrypt before being used. It implements `VarLenCipher` interface.

Will return error if an empty passphrase or data is provided.

func (ChaCha20Cipher) Encrypt

func (c ChaCha20Cipher) Encrypt(b []byte) ([]byte, error)

Encrypt encrypts the given data using ChaCha20-Poly1305 with the given passphrase. The passphrase can be a user provided value, and is hashed using scrypt before being used. It implements `VarLenCipher` interface.

Will return error if an empty passphrase or data is provided.

type ChaCha20Maker

type ChaCha20Maker struct {
	// contains filtered or unexported fields
}

ChaCha20Maker is a stream style ChaCha20 codec generator.

func (*ChaCha20Maker) Make

func (m *ChaCha20Maker) Make(rwc io.ReadWriteCloser, genNonce bool, timeout *time.Duration, nonceCodec gcrypto.EqLenCipher) (gcrypto.CipherRWC, error)

Make wraps io.ReadWriteCloser and generate a CipherRWC. genNonce: true: generate random nonce and write to other side false: read nonce from other side timeout: it is recommended, used to avoid unexpected block of reader `rwc`.

func (*ChaCha20Maker) NonceSize

func (m *ChaCha20Maker) NonceSize() int

type ChaCha20RWC

type ChaCha20RWC struct {
	// contains filtered or unexported fields
}

ChaCha20RWC is a stream style ChaCha20 codec.

func (*ChaCha20RWC) Close

func (s *ChaCha20RWC) Close() error

func (*ChaCha20RWC) Read

func (s *ChaCha20RWC) Read(b []byte) (int, error)

Read decrypts cipher data and write plain data into output buffer.

func (*ChaCha20RWC) Write

func (s *ChaCha20RWC) Write(b []byte) (int, error)

Write encrypts plain data and write cipher data into CipherStreamWriter.

Jump to

Keyboard shortcuts

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