diff options
author | Jakob Unterwurzacher | 2017-05-28 20:43:48 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-05-28 20:43:48 +0200 |
commit | e2341c93d5b113457905b338b414e41892113ec4 (patch) | |
tree | 7888288fd38ecc9b8ec14220ad486ce4670f31fb /internal/fusefrontend_reverse | |
parent | 1f5201da5ebb0180717f63d77bbe2338876bfd29 (diff) |
pathiv: move block IV algorithm into this package
This was implemented in fusefrontend_reverse, but we need it
in fusefrontend as well. Move the algorithm into pathiv.BlockIV().
Diffstat (limited to 'internal/fusefrontend_reverse')
-rw-r--r-- | internal/fusefrontend_reverse/rfile.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/internal/fusefrontend_reverse/rfile.go b/internal/fusefrontend_reverse/rfile.go index 530547a..742d697 100644 --- a/internal/fusefrontend_reverse/rfile.go +++ b/internal/fusefrontend_reverse/rfile.go @@ -2,7 +2,6 @@ package fusefrontend_reverse import ( "bytes" - "encoding/binary" "io" "os" "syscall" @@ -95,18 +94,13 @@ func (rf *reverseFile) GetAttr(*fuse.Attr) fuse.Status { // encryptBlocks - encrypt "plaintext" into a number of ciphertext blocks. // "plaintext" must already be block-aligned. func (rf *reverseFile) encryptBlocks(plaintext []byte, firstBlockNo uint64, fileID []byte, block0IV []byte) []byte { - nonce := make([]byte, len(block0IV)) - copy(nonce, block0IV) - block0IVlow := binary.BigEndian.Uint64(block0IV[8:]) - nonceLow := nonce[8:] - inBuf := bytes.NewBuffer(plaintext) var outBuf bytes.Buffer bs := int(rf.contentEnc.PlainBS()) for blockNo := firstBlockNo; inBuf.Len() > 0; blockNo++ { - binary.BigEndian.PutUint64(nonceLow, block0IVlow+blockNo) inBlock := inBuf.Next(bs) - outBlock := rf.contentEnc.EncryptBlockNonce(inBlock, blockNo, fileID, nonce) + iv := pathiv.BlockIV(block0IV, blockNo) + outBlock := rf.contentEnc.EncryptBlockNonce(inBlock, blockNo, fileID, iv) outBuf.Write(outBlock) } return outBuf.Bytes() |