aboutsummaryrefslogtreecommitdiff
path: root/flags.go
diff options
context:
space:
mode:
authorGibheer <gibheer@gmail.com>2015-02-15 21:09:22 +0100
committerGibheer <gibheer@gmail.com>2015-02-15 21:09:22 +0100
commit02749d1d5e3e39bb04af296da4f9f6a14d4107d6 (patch)
tree2a451c39e131599480c45f0acf48a1a4c8db39b9 /flags.go
parent16eb14db9f9b228ef88bcf1beb09cf823256dac1 (diff)
make rsa check boundary
Diffstat (limited to 'flags.go')
-rw-r--r--flags.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/flags.go b/flags.go
index d7dc2ef..346486c 100644
--- a/flags.go
+++ b/flags.go
@@ -161,7 +161,13 @@ func (f *Flags) parsePrivateKeyGenerationFlags() error {
case 521: f.Flags.PrivateKeyGenerationFlags.Curve = elliptic.P521()
default: return fmt.Errorf("Curve %d unknown!", f.flag_container.length)
}
- case "rsa": f.Flags.PrivateKeyGenerationFlags.Size = f.flag_container.length
+ case "rsa":
+ size := f.flag_container.length
+ if RsaLowerLength <= size && size <= RsaUpperLength {
+ f.Flags.PrivateKeyGenerationFlags.Size = size
+ } else {
+ return fmt.Errorf("Length of %d is not allowed for rsa!", size)
+ }
default: return fmt.Errorf("Type %s is unknown!", pk_type)
}
return nil