2015-07-24 12:42:52 +02:00
|
|
|
// This package builds a binary which helps to generate
|
|
|
|
// private keys, public keys, certificates and also
|
|
|
|
// includes functionality to sign and verify messages.
|
2015-07-24 12:44:43 +02:00
|
|
|
package main
|
2015-07-24 12:42:52 +02:00
|
|
|
|
2014-10-27 21:55:43 +01:00
|
|
|
import (
|
2015-03-25 20:43:18 +01:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2014-10-27 21:55:43 +01:00
|
|
|
)
|
|
|
|
|
2015-03-21 18:50:55 +01:00
|
|
|
const (
|
2016-10-01 21:56:29 +02:00
|
|
|
COMMAND = "pkictl"
|
2014-10-27 21:55:43 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-01 21:56:29 +02:00
|
|
|
if len(os.Args) == 1 {
|
|
|
|
printHelp()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
command, args := os.Args[1], os.Args[2:]
|
|
|
|
var err error
|
|
|
|
switch command {
|
|
|
|
case "create-private":
|
|
|
|
err = CreatePrivateKey(args)
|
|
|
|
case "create-public":
|
|
|
|
err = CreatePublicKey(args)
|
|
|
|
case "sign-input":
|
|
|
|
err = SignInput(args)
|
|
|
|
case "verify-input":
|
|
|
|
err = VerifyInput(args)
|
|
|
|
case "create-sign-request":
|
|
|
|
err = CreateSignRequest(args)
|
|
|
|
case "create-cert":
|
|
|
|
err = CreateCert(args)
|
|
|
|
default:
|
|
|
|
printHelp()
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("error: %s\n", err)
|
|
|
|
os.Exit(2)
|
2015-03-25 20:43:18 +01:00
|
|
|
}
|
2015-02-19 20:50:06 +01:00
|
|
|
}
|
|
|
|
|
2016-10-01 21:56:29 +02:00
|
|
|
func printHelp() {
|
|
|
|
fmt.Printf(`Usage: %s command [flags]
|
|
|
|
|
|
|
|
where 'command' is one of:
|
|
|
|
create-private create a private key
|
|
|
|
create-public create a public key derived from a private key
|
|
|
|
sign-input sign a message using a private key
|
|
|
|
verify-input verify a message using a signature and a public key
|
|
|
|
create-sign-request create a certificate sign request
|
|
|
|
create-cert create a certificate from a certificate sign request
|
|
|
|
`, COMMAND)
|
2015-02-15 01:34:25 +01:00
|
|
|
}
|