diff options
author | Jakob Unterwurzacher | 2017-05-28 20:43:48 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-05-30 17:04:46 +0200 |
commit | 9a217ce786581ee7ec18b27e46f0096763c85f9e (patch) | |
tree | 973b358e56e0df5a7749f8d714748b0c0710aaca /internal/fusefrontend_reverse/rfile.go | |
parent | e43eb36da3e72cd0f59ac978cf76a94fa87ca7cd (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/rfile.go')
-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() |