aboutsummaryrefslogtreecommitdiff
path: root/internal/contentenc/content_api.go
blob: 4c6aa00df9fdb06c8cd0fabbd739a3c3a70925ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package contentenc

import "github.com/rfjakob/gocryptfs/internal/cryptocore"

const (
	// Default plaintext block size
	DefaultBS = 4096
)

type ContentEnc struct {
	// Cryptographic primitives
	cryptoCore *cryptocore.CryptoCore
	// Plaintext block size
	plainBS     uint64
	// Ciphertext block size
	cipherBS    uint64
	// All-zero block of size cipherBS, for fast compares
	allZeroBlock []byte
}

func New(cc *cryptocore.CryptoCore, plainBS uint64) *ContentEnc {

	cipherBS := plainBS + uint64(cc.IVLen) + cryptocore.AuthTagLen

	return &ContentEnc{
		cryptoCore: cc,
		plainBS: plainBS,
		cipherBS: cipherBS,
		allZeroBlock: make([]byte, cipherBS),
	}
}


func (be *ContentEnc) PlainBS() uint64 {
	return be.plainBS
}