SSHSecure/sshkeys/func.go

52 lines
1.0 KiB
Go

package sshkeys
import (
"errors"
"r00t2.io/goutils/checks"
)
func genPrivKey(cipherAlgo string, kdf string, salt []byte, rounds uint32, passphrase string) ([]byte, error) {
return nil, nil
}
func genPubKey(privKey *[]byte) ([]byte, error) {
if *privKey == nil {
return nil, errors.New("must generate private key before public key")
}
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
}
func (k *EncryptedSSHKeyV1) GeneratePublic(force bool) error {
if err := k.GeneratePrivate(force); err != nil {
return err
}
return nil
}
func (k *SSHKeyV1) GeneratePrivate(force bool) error {
if k.PrivateKeys != nil && !force {
return nil // Already generated.
}
return nil
}
func (k *SSHKeyV1) GeneratePublic(force bool) error {
if err := k.GeneratePrivate(force); err != nil {
return err
}
return nil
}