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

Function ed25519KeyGen

coderd/gitsshkey/gitsshkey.go:80–98  ·  view source on GitHub ↗

ed25519KeyGen returns an ED25519-based SSH private key.

()

Source from the content-addressed store, hash-verified

78
79// ed25519KeyGen returns an ED25519-based SSH private key.
80func ed25519KeyGen() (privateKey string, publicKey string, err error) {
81 _, privateKeyRaw, err := ed25519.GenerateKey(entropy())
82 if err != nil {
83 return "", "", xerrors.Errorf("generate ed25519 private key: %w", err)
84 }
85
86 // NOTE: as of the time of writing, x/crypto/ssh is unable to marshal an ED25519 private key
87 // into the format expected by OpenSSH. See: https://github.com/golang/go/issues/37132
88 // Until this support is added, using a third-party implementation.
89 byt, err := MarshalED25519PrivateKey(privateKeyRaw)
90 if err != nil {
91 return "", "", xerrors.Errorf("marshal ed25519 private key: %w", err)
92 }
93
94 return generateKeys(pem.Block{
95 Type: "OPENSSH PRIVATE KEY",
96 Bytes: byt,
97 }, privateKeyRaw)
98}
99
100// ecdsaKeyGen returns an ECDSA-based SSH private key.
101func ecdsaKeyGen() (privateKey string, publicKey string, err error) {

Callers 1

GenerateFunction · 0.85

Calls 4

entropyFunction · 0.85
MarshalED25519PrivateKeyFunction · 0.85
generateKeysFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected