sshutil

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RFC8832SSHPublicKey

type RFC8832SSHPublicKey struct {
	// contains filtered or unexported fields
}

RFC8832SSHPublicKey implements ssh.PublicKey with the rsa-sha2-512 and rsa-sha2-256 public key algorithms, as defined in RFC 8332.

At time of writing, the golang.org/x/crypto/ssh library provides a function to convert from rsa.PublicKey to ssh.PublicKey. Unfortunately, it will hardcode the "key type" of all rsa keys to ssh-rsa.

ssh-rsa uses SHA1 as the signature hash algorithm which is vulnerable to chosen-prefix collisions and is considered cryptographically broken as a result.

ssh-rsa was disabled by default in OpenSSH 8.8 (2021), so we have to provide our own implementation of ssh.PublicKey to use the correct public key algorithms.

func New256

func New256(pubKey *rsa.PublicKey) *RFC8832SSHPublicKey

New256 creates an ssh.PublicKey from an rsa.PublicKey with a type of rsa-sha2-256

func New512

func New512(pubKey *rsa.PublicKey) *RFC8832SSHPublicKey

New512 creates an ssh.PublicKey from an rsa.PublicKey with a type of rsa-sha2-512

func (RFC8832SSHPublicKey) Marshal

func (r RFC8832SSHPublicKey) Marshal() []byte

Marshal serializes the RFC8332SSHPublicKey into the ssh wire format, defined in RFC 4251 section 5

func (RFC8832SSHPublicKey) Type

func (r RFC8832SSHPublicKey) Type() string

Type returns the public key algorithm, defined in [RFC 8332]

func (RFC8832SSHPublicKey) Verify

func (r RFC8832SSHPublicKey) Verify(data []byte, sig *ssh.Signature) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL