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:
23
sshkeys/rsa.go
Normal file
23
sshkeys/rsa.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package sshkeys
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
)
|
||||
|
||||
func (k *SSHPrivKey) generateRsa() error {
|
||||
if k.BitSize == 0 {
|
||||
k.BitSize = defRSABitSize
|
||||
}
|
||||
if k.Key != nil || k.PublicKey.Key != nil {
|
||||
return nil // A no-op; key already exists.
|
||||
}
|
||||
if sk, err := rsa.GenerateKey(rand.Reader, int(k.BitSize)); err != nil {
|
||||
return err
|
||||
} else {
|
||||
k.Key = sk // See https://golang.org/pkg/crypto/rsa/#PrivateKey
|
||||
k.PublicKey.KeyType = KeyRsa
|
||||
k.PublicKey.Key = k.Key.PublicKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user