MCPcopy Index your code
hub / github.com/coder/coder / Generate

Function Generate

coderd/gitsshkey/gitsshkey.go:66–77  ·  view source on GitHub ↗

Generate creates a private key in the OpenSSH PEM format and public key in the authorized key format.

(algo Algorithm)

Source from the content-addressed store, hash-verified

64// Generate creates a private key in the OpenSSH PEM format and public key in
65// the authorized key format.
66func 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.
80func ed25519KeyGen() (privateKey string, publicKey string, err error) {

Callers 5

CreateUserMethod · 0.92
regenerateGitSSHKeyMethod · 0.92
TestGitSSHKeysFunction · 0.92
BenchmarkGenerateFunction · 0.92

Calls 4

ed25519KeyGenFunction · 0.85
ecdsaKeyGenFunction · 0.85
rsa4096KeyGenFunction · 0.85
ErrorfMethod · 0.45

Tested by 2

TestGitSSHKeysFunction · 0.74
BenchmarkGenerateFunction · 0.74