aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorGibheer <gibheer@gmail.com>2015-02-17 21:44:10 +0100
committerGibheer <gibheer@gmail.com>2015-02-17 21:44:10 +0100
commit470d21409b5f26d49fefd34d75b82197045d4811 (patch)
treef808e14913b6f73406e93c6250ae7826d8f2777c /main.go
parentb022e8ab4ce93bc429e5052dd806ae03a068a676 (diff)
add public key support
This adds all options to create and store a public key.
Diffstat (limited to 'main.go')
-rw-r--r--main.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/main.go b/main.go
index 56128ff..524f498 100644
--- a/main.go
+++ b/main.go
@@ -50,10 +50,10 @@ func create_private_key() {
err := fs.Parse(program_args())
if err != nil { crash_with_help(1, fmt.Sprintf("%s", err)) }
- var pk pkilib.Pemmer
+ var pk pki.Pemmer
switch fs.Flags.PrivateKeyGenerationFlags.Type {
- case "ecdsa": pk, err = pkilib.NewPrivateKeyEcdsa(fs.Flags.PrivateKeyGenerationFlags.Curve)
- case "rsa": pk, err = pkilib.NewPrivateKeyRsa(fs.Flags.PrivateKeyGenerationFlags.Size)
+ case "ecdsa": pk, err = pki.NewPrivateKeyEcdsa(fs.Flags.PrivateKeyGenerationFlags.Curve)
+ case "rsa": pk, err = pki.NewPrivateKeyRsa(fs.Flags.PrivateKeyGenerationFlags.Size)
}
if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) }
marsh_pem, err := pk.MarshalPem()
@@ -66,10 +66,16 @@ func create_private_key() {
func create_public_key() {
fs := NewFlags("create-public")
fs.AddPrivateKey()
+ fs.AddOutput()
err := fs.Parse(program_args())
if err != nil { crash_with_help(1, fmt.Sprintf("%s", err)) }
- fmt.Println(fs.Flags.PrivateKey.Public())
+ var pub_key pki.Pemmer
+ pub_key = fs.Flags.PrivateKey.Public()
+ marsh_pem, err := pub_key.MarshalPem()
+ if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) }
+ _, err = marsh_pem.WriteTo(fs.Flags.Output)
+ if err != nil { crash_with_help(2, fmt.Sprintf("%s", err)) }
}
// print the module help