Generate creates a private key in the OpenSSH PEM format and public key in the authorized key format.
(algo Algorithm)
| 64 | // Generate creates a private key in the OpenSSH PEM format and public key in |
| 65 | // the authorized key format. |
| 66 | func Generate(algo Algorithm) (privateKey string, publicKey string, err error) { |
| 67 | switch algo { |
| 68 | case AlgorithmEd25519: |
| 69 | return ed25519KeyGen() |
| 70 | case AlgorithmECDSA: |
| 71 | return ecdsaKeyGen() |
| 72 | case AlgorithmRSA4096: |
| 73 | return rsa4096KeyGen() |
| 74 | default: |
| 75 | return "", "", xerrors.Errorf("invalid algorithm: %s", algo) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | // ed25519KeyGen returns an ED25519-based SSH private key. |
| 80 | func ed25519KeyGen() (privateKey string, publicKey string, err error) { |