Rename nametransform, contentenc source files
Let's have shorter names, and merge *_api.go into the "main" file. No code changes.
This commit is contained in:
parent
6c3f97399a
commit
7e92ebe16a
@ -8,9 +8,42 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
||||
"github.com/rfjakob/gocryptfs/internal/tlog"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// DecryptBlocks - Decrypt a number of blocks
|
||||
func (be *ContentEnc) DecryptBlocks(ciphertext []byte, firstBlockNo uint64, fileId []byte) ([]byte, error) {
|
||||
cBuf := bytes.NewBuffer(ciphertext)
|
||||
|
@ -1,35 +0,0 @@
|
||||
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
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package nametransform
|
||||
|
||||
import "github.com/rfjakob/gocryptfs/internal/cryptocore"
|
||||
|
||||
type NameTransform struct {
|
||||
cryptoCore *cryptocore.CryptoCore
|
||||
useEME bool
|
||||
longNames bool
|
||||
DirIVCache dirIVCache
|
||||
}
|
||||
|
||||
func New(c *cryptocore.CryptoCore, useEME bool, longNames bool) *NameTransform {
|
||||
return &NameTransform{
|
||||
cryptoCore: c,
|
||||
longNames: longNames,
|
||||
useEME: useEME,
|
||||
}
|
||||
}
|
@ -9,10 +9,28 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rfjakob/eme"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/internal/cryptocore"
|
||||
)
|
||||
|
||||
type NameTransform struct {
|
||||
cryptoCore *cryptocore.CryptoCore
|
||||
useEME bool
|
||||
longNames bool
|
||||
DirIVCache dirIVCache
|
||||
}
|
||||
|
||||
func New(c *cryptocore.CryptoCore, useEME bool, longNames bool) *NameTransform {
|
||||
return &NameTransform{
|
||||
cryptoCore: c,
|
||||
longNames: longNames,
|
||||
useEME: useEME,
|
||||
}
|
||||
}
|
||||
|
||||
// DecryptName - decrypt base64-encoded encrypted filename "cipherName"
|
||||
// The used encryption is either CBC or EME, depending on "useEME".
|
||||
// Used by DecryptPathDirIV().
|
||||
// The encryption is either CBC or EME, depending on "useEME".
|
||||
//
|
||||
// This function is exported because it allows for a very efficient readdir
|
||||
// implementation (read IV once, decrypt all names using this function).
|
||||
@ -43,11 +61,12 @@ func (n *NameTransform) DecryptName(cipherName string, iv []byte) (string, error
|
||||
return plain, err
|
||||
}
|
||||
|
||||
// encryptName - encrypt "plainName", return base64-encoded "cipherName64"
|
||||
// The used encryption is either CBC or EME, depending on "useEME".
|
||||
// encryptName - encrypt "plainName", return base64-encoded "cipherName64".
|
||||
// Used internally by EncryptPathDirIV().
|
||||
// The encryption is either CBC or EME, depending on "useEME".
|
||||
//
|
||||
// This function is exported because fusefrontend needs access to the full (not hashed)
|
||||
// name if longname is used
|
||||
// name if longname is used. Otherwise you should use EncryptPathDirIV()
|
||||
func (n *NameTransform) EncryptName(plainName string, iv []byte) (cipherName64 string) {
|
||||
|
||||
bin := []byte(plainName)
|
Loading…
Reference in New Issue
Block a user