mirror of https://github.com/hashicorp/packer
This allows us to store more information about the key pair. In particular, we can query the private key for its bits of entropy - avoiding the possibility of hardcoding the wrong value.pull/7287/head
parent
d7510ecdf7
commit
4b649f7ce4
@ -0,0 +1,38 @@
|
||||
package ssh
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type ecdsaKeyPair struct {
|
||||
privateKey *ecdsa.PrivateKey
|
||||
publicKey gossh.PublicKey
|
||||
name string
|
||||
privatePemBlock []byte
|
||||
}
|
||||
|
||||
func (o ecdsaKeyPair) Type() KeyPairType {
|
||||
return Ecdsa
|
||||
}
|
||||
|
||||
func (o ecdsaKeyPair) Bits() int {
|
||||
return o.privateKey.Curve.Params().BitSize
|
||||
}
|
||||
|
||||
func (o ecdsaKeyPair) Name() string {
|
||||
return o.name
|
||||
}
|
||||
|
||||
func (o ecdsaKeyPair) Description() string {
|
||||
return description(o)
|
||||
}
|
||||
|
||||
func (o ecdsaKeyPair) PrivateKeyPemBlock() []byte {
|
||||
return o.privatePemBlock
|
||||
}
|
||||
|
||||
func (o ecdsaKeyPair) PublicKeyAuthorizedKeysLine(nl NewLineOption) []byte {
|
||||
return publicKeyAuthorizedKeysLine(o.publicKey, o.name, nl)
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package ssh
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type rsaKeyPair struct {
|
||||
privateKey *rsa.PrivateKey
|
||||
publicKey gossh.PublicKey
|
||||
name string
|
||||
privatePemBlock []byte
|
||||
}
|
||||
|
||||
func (o rsaKeyPair) Type() KeyPairType {
|
||||
return Rsa
|
||||
}
|
||||
|
||||
func (o rsaKeyPair) Bits() int {
|
||||
return o.privateKey.N.BitLen()
|
||||
}
|
||||
|
||||
func (o rsaKeyPair) Name() string {
|
||||
return o.name
|
||||
}
|
||||
|
||||
func (o rsaKeyPair) Description() string {
|
||||
return description(o)
|
||||
}
|
||||
|
||||
func (o rsaKeyPair) PrivateKeyPemBlock() []byte {
|
||||
return o.privatePemBlock
|
||||
}
|
||||
|
||||
func (o rsaKeyPair) PublicKeyAuthorizedKeysLine(nl NewLineOption) []byte {
|
||||
return publicKeyAuthorizedKeysLine(o.publicKey, o.name, nl)
|
||||
}
|
||||
Loading…
Reference in new issue