Skip to content

Commit

Permalink
[kvsp-enc] Add --bkey option
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed May 7, 2020
1 parent 6f2a4d3 commit 484ba81
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion kvsp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ func doEnc() error {
// Parse command-line arguments.
fs := flag.NewFlagSet("enc", flag.ExitOnError)
var (
keyFileName = fs.String("k", "", "Key file name")
keyFileName = fs.String("k", "", "Secret key file name")
bkeyFileName = fs.String("bkey", "", "Bootstrapping key file name")
inputFileName = fs.String("i", "", "Input file name (plain)")
outputFileName = fs.String("o", "", "Output file name (encrypted)")
)
Expand All @@ -557,9 +558,28 @@ func doEnc() error {
return err
}

// Generate bootstrapping key if not exist
if *bkeyFileName == "" {
bkeyFile, err := ioutil.TempFile("", "")
if err != nil {
return err
}
defer os.Remove(bkeyFile.Name())

*bkeyFileName = bkeyFile.Name()

_, err = runIyokanPacket("genbkey",
"--in", *keyFileName,
"--out", *bkeyFileName)
if err != nil {
return err
}
}

// Encrypt
_, err = runIyokanPacket("enc",
"--key", *keyFileName,
"--bkey", *bkeyFileName,
"--in", packedFile.Name(),
"--out", *outputFileName)
return err
Expand Down

0 comments on commit 484ba81

Please sign in to comment.