diff options
author | Gibheer <gibheer@gmail.com> | 2015-03-30 21:34:05 +0200 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2015-03-30 21:34:05 +0200 |
commit | 9ba6a88449e6297ea925e0c59e923c56e742983f (patch) | |
tree | 75972e862ac1d7295fa422ea90d4c34342b5148f /main.go | |
parent | 8e2db6f6c9ebaea1ca072b4880a63d4a3bda2da9 (diff) |
split out all private key related functions
This moves all private key related functions out into a separate file to
get flags.go smaller.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 29 |
1 files changed, 0 insertions, 29 deletions
@@ -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) |