Documentation ¶
Overview ¶
Package aeadstream implements streams on AEAD ciphers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AEADStream ¶
AEADStream is a wrapper of cipher.AEAD.
func NewAEADStream ¶
func NewAEADStream(c cipher.AEAD) *AEADStream
NewAEADStream creates an AEADStream based on c.
func (*AEADStream) StreamDecrypt ¶
func (as *AEADStream) StreamDecrypt(w io.Writer, r io.Reader, nonceSeed []byte, chunkSize int) (int64, error)
StreamDecrypt decrypts data from r and writes plain text to w. cipher.AEAD.Open is processed every chunkSize of data read. nonceSeed is the seed of nonce, must either be nil or the same size as NonceSize() of the AEAD cipher.
The number of bytes written to w is returned. If and only if the returned error is nil, either reading from r or writing to w met EOF. It is guaranteed that unauthorized data is never written to w.
func (*AEADStream) StreamEncrypt ¶
func (as *AEADStream) StreamEncrypt(w io.Writer, r io.Reader, nonceSeed []byte, chunkSize int) (int64, error)
StreamEncrypt encrypts data from r and writes cipher text to w. cipher.AEAD.Seal is processed every chunkSize of data read. nonceSeed is the seed of nonce, must either be nil or the same size as NonceSize() of the AEAD cipher.
The number of bytes written to w is returned. If and only if the returned error is nil, either reading from r or writing to w met EOF.