summaryrefslogtreecommitdiff
path: root/internal/contentenc
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-07-02 00:12:36 +0200
committerJakob Unterwurzacher2016-07-02 00:12:36 +0200
commit7b22b426b9f5e68a0ff51799e04f193dc74586d0 (patch)
treeba30788cce61ca58608d669b75b07296df9b9422 /internal/contentenc
parentf2b4d57068d13b6dc3de2ccc6550675d11d34cfa (diff)
contentenc: rename PlaintextRange and CiphertextRange
The name could be misunderstood and actually caused a bug: doWrite used to always preallocate 4128 instead of the actual data length.
Diffstat (limited to 'internal/contentenc')
-rw-r--r--internal/contentenc/content.go6
-rw-r--r--internal/contentenc/intrablock.go14
2 files changed, 12 insertions, 8 deletions
diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go
index 2298c5e..6ac766f 100644
--- a/internal/contentenc/content.go
+++ b/internal/contentenc/content.go
@@ -40,10 +40,16 @@ func New(cc *cryptocore.CryptoCore, plainBS uint64) *ContentEnc {
}
}
+// PlainBS returns the plaintext block size
func (be *ContentEnc) PlainBS() uint64 {
return be.plainBS
}
+// CipherBS returns the ciphertext block size
+func (be *ContentEnc) CipherBS() uint64 {
+ return be.cipherBS
+}
+
// DecryptBlocks - Decrypt a number of blocks
func (be *ContentEnc) DecryptBlocks(ciphertext []byte, firstBlockNo uint64, fileId []byte) ([]byte, error) {
cBuf := bytes.NewBuffer(ciphertext)
diff --git a/internal/contentenc/intrablock.go b/internal/contentenc/intrablock.go
index 330b980..ec9562d 100644
--- a/internal/contentenc/intrablock.go
+++ b/internal/contentenc/intrablock.go
@@ -16,16 +16,14 @@ func (ib *intraBlock) IsPartial() bool {
return false
}
-// CiphertextRange - get byte range in ciphertext file corresponding to BlockNo
-// (complete block)
-func (ib *intraBlock) CiphertextRange() (offset uint64, length uint64) {
- return ib.fs.BlockNoToCipherOff(ib.BlockNo), ib.fs.cipherBS
+// BlockCipherOff returns the ciphertext offset corresponding to BlockNo
+func (ib *intraBlock) BlockCipherOff() (offset uint64) {
+ return ib.fs.BlockNoToCipherOff(ib.BlockNo)
}
-// PlaintextRange - get byte range in plaintext corresponding to BlockNo
-// (complete block)
-func (ib *intraBlock) PlaintextRange() (offset uint64, length uint64) {
- return ib.fs.BlockNoToPlainOff(ib.BlockNo), ib.fs.plainBS
+// BlockPlainOff returns the plaintext offset corresponding to BlockNo
+func (ib *intraBlock) BlockPlainOff() (offset uint64) {
+ return ib.fs.BlockNoToPlainOff(ib.BlockNo)
}
// CropBlock - crop a potentially larger plaintext block down to the relevant part