summaryrefslogtreecommitdiff
path: root/cryptfs/cryptfs_content.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-12-13 20:10:52 +0100
committerJakob Unterwurzacher2015-12-13 20:24:13 +0100
commit00a712b4d1e68bb3c156eb8f97fbb89d684a7e92 (patch)
treeabf6d8c1b4493542686b3e59aaa08602fbfd4ead /cryptfs/cryptfs_content.go
parent8518d6d7bde33fdc7ef5bcb7c3c7709404392ad8 (diff)
go fmt
...and minimal comment changes.
Diffstat (limited to 'cryptfs/cryptfs_content.go')
-rw-r--r--cryptfs/cryptfs_content.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/cryptfs/cryptfs_content.go b/cryptfs/cryptfs_content.go
index cfd488b..25293a7 100644
--- a/cryptfs/cryptfs_content.go
+++ b/cryptfs/cryptfs_content.go
@@ -86,7 +86,7 @@ func (be *CryptFS) DecryptBlock(ciphertext []byte, blockNo uint64, fileId []byte
}
// encryptBlock - Encrypt and add IV and MAC
-func (be *CryptFS) EncryptBlock(plaintext []byte, blockNo uint64, fileId []byte) []byte {
+func (be *CryptFS) EncryptBlock(plaintext []byte, blockNo uint64, fileID []byte) []byte {
// Empty block?
if len(plaintext) == 0 {
@@ -96,10 +96,12 @@ func (be *CryptFS) EncryptBlock(plaintext []byte, blockNo uint64, fileId []byte)
// Get fresh nonce
nonce := gcmNonce.Get()
- // Encrypt plaintext and append to nonce
+ // Authenticate block with block number and file ID
aData := make([]byte, 8)
binary.BigEndian.PutUint64(aData, blockNo)
- aData = append(aData, fileId...)
+ aData = append(aData, fileID...)
+
+ // Encrypt plaintext and append to nonce
ciphertext := be.gcm.Seal(nonce, nonce, plaintext, aData)
return ciphertext