From 70f92fd6b3baeede3c047d38f1dd7d6a9cb2661a Mon Sep 17 00:00:00 2001 From: Dan Hipschman Date: Fri, 9 Oct 2020 17:55:53 -0700 Subject: [PATCH] crypt: small simplification, no functionality change --- backend/crypt/cipher.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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