diff --git a/backend/crypt/cipher.go b/backend/crypt/cipher.go index 94f499781..11f330e5f 100644 --- a/backend/crypt/cipher.go +++ b/backend/crypt/cipher.go @@ -633,11 +633,8 @@ func (fh *encrypter) Read(p []byte) (n int, err error) { } // possibly err != nil here, but we will process the // data and the next call to ReadFull will return 0, err - // Write nonce to start of block - copy(fh.buf, fh.nonce[:]) // Encrypt the block using the nonce - block := fh.buf - secretbox.Seal(block[:0], readBuf[:n], fh.nonce.pointer(), &fh.c.dataKey) + secretbox.Seal(fh.buf[:0], readBuf[:n], fh.nonce.pointer(), &fh.c.dataKey) fh.bufIndex = 0 fh.bufSize = blockHeaderSize + n fh.nonce.increment() @@ -782,8 +779,7 @@ func (fh *decrypter) fillBuffer() (err error) { return ErrorEncryptedFileBadHeader } // Decrypt the block using the nonce - block := fh.buf - _, ok := secretbox.Open(block[:0], readBuf[:n], fh.nonce.pointer(), &fh.c.dataKey) + _, ok := secretbox.Open(fh.buf[:0], readBuf[:n], fh.nonce.pointer(), &fh.c.dataKey) if !ok { if err != nil { return err // return pending error as it is likely more accurate