Skip to content

x/crypto/ssh: implement CryptoPublicKey on sk keys #62518

@maraino

Description

@maraino

The public keys in the x/crypto/ssh package implement the following interface:

type CryptoPublicKey interface {
	CryptoPublicKey() crypto.PublicKey
}

These methods return the underlying key for RSA, ECDSA, Ed25519, and DSA public keys. However, the ecdsa-sk and ed25519-sk keys do not implement that interface, forcing a user to unmarshal the serialized data to a struct to be able to get the underlying keys.

As the skECDSAPublicKey and skEd25519PublicKey already contain the key, the implementation would look like this:

func (k *skECDSAPublicKey) CryptoPublicKey() crypto.PublicKey {
	return &k.PublicKey
}

func (k *skEd25519PublicKey) CryptoPublicKey() crypto.PublicKey {
	return k.PublicKey
}

To be consistent with the rest of the CryptoPublicKey implementations, these methods will return the actual key, instead of a copy of it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions