Documentation ¶
Index ¶
- type ChaCha20
- func (c *ChaCha20) CodecWithKey(key []byte, version gcrypto.Cipher) (*ChaCha20Cipher, error)
- func (c *ChaCha20) CodecWithPassphrase(passphrase string, version gcrypto.Cipher) (*ChaCha20Cipher, error)
- func (c *ChaCha20) MakerWithKey(key []byte, version gcrypto.Cipher) (gcrypto.CipherRWCMaker, error)
- func (c *ChaCha20) MakerWithPassphrase(passphrase string, version gcrypto.Cipher) (gcrypto.CipherRWCMaker, error)
- type ChaCha20Cipher
- type ChaCha20Maker
- type ChaCha20RWC
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 ¶
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 ¶
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