SSHSecure/sshkeys/func.go

52 lines
1.0 KiB
Go
Raw Normal View History

package sshkeys
2020-09-12 00:58:58 -04:00
import (
"errors"
2020-09-12 01:25:44 -04:00
"r00t2.io/goutils/checks"
)
2020-09-12 00:58:58 -04:00
2020-09-12 01:25:44 -04:00
func genPrivKey(cipherAlgo string, kdf string, salt []byte, rounds uint32, passphrase string) ([]byte, error) {
2020-09-12 00:58:58 -04:00
return nil, nil
}
func genPubKey(privKey *[]byte) ([]byte, error) {
2020-09-12 01:25:44 -04:00
if *privKey == nil {
return nil, errors.New("must generate private key before public key")
}
2020-09-12 00:58:58 -04:00
return nil, nil
}
func (k *EncryptedSSHKeyV1) GeneratePrivate(force bool) error {
if k.Passphrase == "" {
return errors.New("cannot use encrypted key with empty passphrase")
}
if k.PrivateKeys != nil && !force {
return nil // Already generated.
}
return nil
}
2020-09-12 00:58:58 -04:00
func (k *EncryptedSSHKeyV1) GeneratePublic(force bool) error {
if err := k.GeneratePrivate(force); err != nil {
return err
}
2020-09-12 00:58:58 -04:00
return nil
}
2020-09-12 00:58:58 -04:00
func (k *SSHKeyV1) GeneratePrivate(force bool) error {
if k.PrivateKeys != nil && !force {
return nil // Already generated.
}
return nil
}
2020-09-12 00:58:58 -04:00
func (k *SSHKeyV1) GeneratePublic(force bool) error {
if err := k.GeneratePrivate(force); err != nil {
return err
}
return nil
}