From 9ba6a88449e6297ea925e0c59e923c56e742983f Mon Sep 17 00:00:00 2001 From: Gibheer Date: Mon, 30 Mar 2015 21:34:05 +0200 Subject: split out all private key related functions This moves all private key related functions out into a separate file to get flags.go smaller. --- main.go | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index fff9e4d..a4eec3f 100644 --- a/main.go +++ b/main.go @@ -26,35 +26,6 @@ func main() { CmdRoot.Execute() } -// create a new private key -func create_private_key(cmd *Command, args []string) { - err := checkFlags(checkOutput, checkPrivateKeyGeneration) - if err != nil { - crash_with_help(cmd, ErrorFlagInput, "Flags invalid: %s", err) - } - - var pk pki.Pemmer - switch FlagPrivateKeyGeneration.Type { - case "ecdsa": - pk, err = pki.NewPrivateKeyEcdsa(FlagPrivateKeyGeneration.Curve) - case "rsa": - pk, err = pki.NewPrivateKeyRsa(FlagPrivateKeyGeneration.Size) - default: - crash_with_help(cmd, ErrorInput, "Unknown private key type '%s'", FlagPrivateKeyGeneration.Type) - } - if err != nil { - crash_with_help(cmd, ErrorProgram, "Error creating private key: %s", err) - } - marsh_pem, err := pk.MarshalPem() - if err != nil { - crash_with_help(cmd, ErrorProgram, "Error when marshalling to pem: %s", err) - } - _, err = marsh_pem.WriteTo(FlagOutput) - if err != nil { - crash_with_help(cmd, ErrorProgram, "Error when writing output: %s", err) - } -} - // create a public key derived from a private key func create_public_key(cmd *Command, args []string) { err := checkFlags(checkPrivateKey, checkOutput) -- cgit v1.2.3-70-g09d2