aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-09-03 19:22:25 +0100
committerNiall Sheridan <nsheridan@gmail.com>2016-09-03 19:22:25 +0100
commit223b08a898d7fc2b6709f4507ed0831b1f74ee38 (patch)
tree763ef0d52ce936a5f352d879762507ce0119f318 /cmd
parent0af43a29b7cabb6710cd1cb335785ff60dbf758f (diff)
Add comments for exported types and functions
Diffstat (limited to 'cmd')
-rw-r--r--cmd/cashier/client/client.go2
-rw-r--r--cmd/cashier/client/config.go2
-rw-r--r--cmd/cashier/client/keys.go2
3 files changed, 6 insertions, 0 deletions
diff --git a/cmd/cashier/client/client.go b/cmd/cashier/client/client.go
index d8def27..ba5b900 100644
--- a/cmd/cashier/client/client.go
+++ b/cmd/cashier/client/client.go
@@ -78,12 +78,14 @@ func send(s []byte, token, ca string, ValidateTLSCertificate bool) (*lib.SignRes
return c, nil
}
+// Sign sends the public key to the CA to be signed.
func Sign(pub ssh.PublicKey, token string, conf *Config) (*ssh.Certificate, error) {
validity, err := time.ParseDuration(conf.Validity)
if err != nil {
return nil, err
}
marshaled := ssh.MarshalAuthorizedKey(pub)
+ // Remove the trailing newline.
marshaled = marshaled[:len(marshaled)-1]
s, err := json.Marshal(&lib.SignRequest{
Key: string(marshaled),
diff --git a/cmd/cashier/client/config.go b/cmd/cashier/client/config.go
index d4defef..1cc9401 100644
--- a/cmd/cashier/client/config.go
+++ b/cmd/cashier/client/config.go
@@ -5,6 +5,7 @@ import (
"github.com/spf13/viper"
)
+// Config holds the client configuration.
type Config struct {
CA string `mapstructure:"ca"`
Keytype string `mapstructure:"key_type"`
@@ -21,6 +22,7 @@ func setDefaults() {
viper.SetDefault("validateTLSCertificate", true)
}
+// ReadConfig reads the client configuration from a file into a Config struct.
func ReadConfig(path string) (*Config, error) {
setDefaults()
viper.SetConfigFile(path)
diff --git a/cmd/cashier/client/keys.go b/cmd/cashier/client/keys.go
index 877ff42..4b3b69e 100644
--- a/cmd/cashier/client/keys.go
+++ b/cmd/cashier/client/keys.go
@@ -11,6 +11,7 @@ import (
"golang.org/x/crypto/ssh"
)
+// Key is a private key.
type Key interface{}
type keyfunc func(int) (Key, ssh.PublicKey, error)
@@ -69,6 +70,7 @@ func generateECDSAKey(bits int) (Key, ssh.PublicKey, error) {
return k, pub, nil
}
+// GenerateKey generates a ssh key-pair according to the type and size specified.
func GenerateKey(keytype string, bits int) (Key, ssh.PublicKey, error) {
f, ok := keytypes[keytype]
if !ok {