-info: add contentEncryption
Example: $ ./gocryptfs -info ./tests/example_filesystems/v2.2-xchacha/ Creator: gocryptfs v2.1-27-gabaa129-dirty.xchacha FeatureFlags: HKDF XChaCha20Poly1305 DirIV EMENames LongNames Raw64 EncryptedKey: 64B ScryptObject: Salt=32B N=1024 R=8 P=1 KeyLen=32 contentEncryption: XChaCha20-Poly1305
This commit is contained in:
parent
db1824a23a
commit
c8996d2664
24
info.go
24
info.go
@ -1,44 +1,30 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/v2/internal/configfile"
|
"github.com/rfjakob/gocryptfs/v2/internal/configfile"
|
||||||
"github.com/rfjakob/gocryptfs/v2/internal/contentenc"
|
|
||||||
"github.com/rfjakob/gocryptfs/v2/internal/exitcodes"
|
"github.com/rfjakob/gocryptfs/v2/internal/exitcodes"
|
||||||
"github.com/rfjakob/gocryptfs/v2/internal/tlog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// info pretty-prints the contents of the config file at "filename" for human
|
// info pretty-prints the contents of the config file at "filename" for human
|
||||||
// consumption, stripping out sensitive data.
|
// consumption, stripping out sensitive data.
|
||||||
// This is called when you pass the "-info" option.
|
// This is called when you pass the "-info" option.
|
||||||
func info(filename string) {
|
func info(filename string) {
|
||||||
// Read from disk
|
cf, err := configfile.Load(filename)
|
||||||
js, err := ioutil.ReadFile(filename)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Printf("Reading config file failed: %v", err)
|
fmt.Printf("Loading config file failed: %v\n", err)
|
||||||
os.Exit(exitcodes.LoadConf)
|
|
||||||
}
|
|
||||||
// Unmarshal
|
|
||||||
var cf configfile.ConfFile
|
|
||||||
err = json.Unmarshal(js, &cf)
|
|
||||||
if err != nil {
|
|
||||||
tlog.Fatal.Printf("Failed to unmarshal config file")
|
|
||||||
os.Exit(exitcodes.LoadConf)
|
|
||||||
}
|
|
||||||
if cf.Version != contentenc.CurrentVersion {
|
|
||||||
tlog.Fatal.Printf("Unsupported on-disk format %d", cf.Version)
|
|
||||||
os.Exit(exitcodes.LoadConf)
|
os.Exit(exitcodes.LoadConf)
|
||||||
}
|
}
|
||||||
|
s := cf.ScryptObject
|
||||||
|
algo, _ := cf.ContentEncryption()
|
||||||
// Pretty-print
|
// Pretty-print
|
||||||
fmt.Printf("Creator: %s\n", cf.Creator)
|
fmt.Printf("Creator: %s\n", cf.Creator)
|
||||||
fmt.Printf("FeatureFlags: %s\n", strings.Join(cf.FeatureFlags, " "))
|
fmt.Printf("FeatureFlags: %s\n", strings.Join(cf.FeatureFlags, " "))
|
||||||
fmt.Printf("EncryptedKey: %dB\n", len(cf.EncryptedKey))
|
fmt.Printf("EncryptedKey: %dB\n", len(cf.EncryptedKey))
|
||||||
s := cf.ScryptObject
|
|
||||||
fmt.Printf("ScryptObject: Salt=%dB N=%d R=%d P=%d KeyLen=%d\n",
|
fmt.Printf("ScryptObject: Salt=%dB N=%d R=%d P=%d KeyLen=%d\n",
|
||||||
len(s.Salt), s.N, s.R, s.P, s.KeyLen)
|
len(s.Salt), s.N, s.R, s.P, s.KeyLen)
|
||||||
|
fmt.Printf("contentEncryption: %s\n", algo.Algo) // lowercase because not in JSON
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user