aboutsummaryrefslogtreecommitdiff
path: root/flags.go
diff options
context:
space:
mode:
authorGibheer <gibheer@gmail.com>2015-02-19 20:50:06 +0100
committerGibheer <gibheer@gmail.com>2015-02-19 20:50:06 +0100
commitf80f34d89cdb678e53c3ea68e4c42adfa0268568 (patch)
tree39c73c9feb7ec3297e66cf1b97ccd3882d5ec8a1 /flags.go
parent579435cfbb5a294a620126ee7b77289eca69ebac (diff)
add message signing again
This adds again the possibility to sign messages through the API.
Diffstat (limited to 'flags.go')
-rw-r--r--flags.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/flags.go b/flags.go
index 6c0a76d..9af8371 100644
--- a/flags.go
+++ b/flags.go
@@ -41,6 +41,7 @@ type (
// a container go gather all incoming flags for further processing
paramContainer struct {
outputPath string // path to output whatever is generated
+ inputPath string // path to an input resource
cryptType string // type of something (private key)
length int // the length of something (private key)
privateKeyPath string // path to the private key
@@ -53,6 +54,7 @@ type (
flagSet struct {
PrivateKey pki.PrivateKey
Output io.WriteCloser
+ Input io.ReadCloser
// private key specific stuff
PrivateKeyGenerationFlags privateKeyGenerationFlags
@@ -124,6 +126,7 @@ func (f *Flags) AddPrivateKey() {
// check the private key flag and load the private key
func (f *Flags) parsePrivateKey() error {
+ if f.flag_container.privateKeyPath == "" { return fmt.Errorf("No private key given!") }
// check permissions of private key file
info, err := os.Stat(f.flag_container.privateKeyPath)
if err != nil { return fmt.Errorf("Error reading private key: %s", err) }
@@ -159,6 +162,24 @@ func (f *Flags) parseOutput() error {
return nil
}
+// add the input parameter to load resources from
+func (f *Flags) AddInput() {
+ f.check_list = append(f.check_list, f.parseInput)
+ f.flagset.StringVar(&f.flag_container.inputPath, "input", "STDIN", "path to the input or STDIN")
+}
+
+// parse the input parameter and open the file handle
+func (f *Flags) parseInput() error {
+ if f.flag_container.inputPath == "STDIN" {
+ f.Flags.Input = os.Stdin
+ return nil
+ }
+ var err error
+ f.Flags.Input, err = os.Open(f.flag_container.inputPath)
+ if err != nil { return err }
+ return nil
+}
+
// This function adds the private key generation flags.
func (f *Flags) AddPrivateKeyGenerationFlags() {
f.check_list = append(f.check_list, f.parsePrivateKeyGenerationFlags)