checking in for the night.
key generation should be done, need to finish packing/formatting. also need to start on moduli generation.
This commit is contained in:
24
sshkeys/ed25519.go
Normal file
24
sshkeys/ed25519.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package sshkeys
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
)
|
||||
|
||||
func (k *SSHPrivKey) generateEd25519() error {
|
||||
if k.Key != nil || k.PublicKey.Key != nil {
|
||||
return nil // Just no-op; already generated.
|
||||
}
|
||||
// We cast "pk" (public key) to _ because it's an interface{} that we can't seem to
|
||||
// assert to []byte. I've tried iterating, a type assertion, initializing,... nada.
|
||||
// Luckily it's at a fixed half of the secret key.
|
||||
if _, s, err := ed25519.GenerateKey(nil); err != nil {
|
||||
return err
|
||||
} else {
|
||||
k.Key = s
|
||||
ks := len(s) - ed25519.PublicKeySize
|
||||
k.PublicKey.Key = s[ks:]
|
||||
k.BitSize = ed25519Len
|
||||
k.PublicKey.KeyType = KeyEd25519
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user