openssh

package
v0.0.0-...-88eb583 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: BSD-3-Clause, BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//	KeyAlgoECDSA256   string = "ecdsa-sha2-nistp256"
	//	KeyAlgoSKECDSA256 string = "sk-ecdsa-sha2-nistp256@openssh.com"
	KeyAlgoECDSA384 string = "ecdsa-sha2-nistp384"
	KeyAlgoECDSA521 string = "ecdsa-sha2-nistp521"
)
View Source
const (
	KeyAlgoED25519   string = "ssh-ed25519"
	KeyAlgoSKED25519 string = "sk-ssh-ed25519@openssh.com"
)
View Source
const (
	KeyAlgoRSA string = "ssh-rsa"

	//	KeyAlgoRSASHA256 			string = "rsa-sha2-256"
	KeyAlgoRSASHA512 string = "rsa-sha2-512"
)
View Source
const (
	CertAlgoRSAv01 string = "ssh-rsa-cert-v01@openssh.com"
	//	CertAlgoECDSA256v01   		string = "ecdsa-sha2-nistp256-cert-v01@openssh.com"
	CertAlgoECDSA384v01 string = "ecdsa-sha2-nistp384-cert-v01@openssh.com"
	CertAlgoECDSA521v01 string = "ecdsa-sha2-nistp521-cert-v01@openssh.com"
	//	CertAlgoSKECDSA256v01 		string = "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com"
	CertAlgoED25519v01   string = "ssh-ed25519-cert-v01@openssh.com"
	CertAlgoSKED25519v01 string = "sk-ssh-ed25519-cert-v01@openssh.com"

	// CertAlgoRSASHA256v01 and CertAlgoRSASHA512v01 can't appear as a
	// Certificate.Type (or PublicKey.Type), but only in
	// ClientConfig.HostKeyAlgorithms.
	//	CertAlgoRSASHA256v01 		string = "rsa-sha2-256-cert-v01@openssh.com"
	CertAlgoRSASHA512v01 string = "rsa-sha2-512-cert-v01@openssh.com"
)
View Source
const (
	// Deprecated: use CertAlgoRSAv01.
	//	CertSigAlgoRSAv01 			string = CertAlgoRSAv01
	// Deprecated: use CertAlgoRSASHA256v01.
	//	CertSigAlgoRSASHA2256v01 	string = CertAlgoRSASHA256v01
	// Deprecated: use CertAlgoRSASHA512v01.
	CertSigAlgoRSASHA2512v01 string = CertAlgoRSASHA512v01
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(msg interface{}) []byte

Marshal serializes the message in msg to SSH wire format. The msg argument should be a struct or pointer to struct. If the first member has the "sshtype" tag set to a number in decimal, that number is prepended to the result. If the last of member has the "ssh" tag set to "rest", its contents are appended to the output.

func MarshalPrivateKey

func MarshalPrivateKey(key crypto.PrivateKey, comment string) (*pem.Block, error)

MarshalPrivateKey returns a PEM block with the private key serialized in the OpenSSH format.

func MarshalPrivateKeyWithPassphrase

func MarshalPrivateKeyWithPassphrase(key crypto.PrivateKey, comment string, passphrase []byte) (*pem.Block, error)

MarshalPrivateKeyWithPassphrase returns a PEM block holding the encrypted private key serialized in the OpenSSH format.

func Unmarshal

func Unmarshal(data []byte, out interface{}) error

Unmarshal parses data in SSH wire format into a structure. The out argument should be a pointer to struct. If the first member of the struct has the "sshtype" tag set to a '|'-separated set of numbers in decimal, the packet must start with one of those numbers. In case of error, Unmarshal returns a ParseError or UnexpectedMessageError.

Types

type PublicKey

type PublicKey interface {
	// Type returns the key format name, e.g. "ssh-rsa".
	Type() string

	// Marshal returns the serialized key data in SSH wire format, with the name
	// prefix. To unmarshal the returned data, use the ParsePublicKey function.
	Marshal() []byte

	// Verify that sig is a signature on the given data using this key. This
	// method will hash the data appropriately first. sig.Format is allowed to
	// be any signature algorithm compatible with the key type, the caller
	// should check if it has more stringent requirements.
	Verify(data []byte, sig *Signature) error
}

PublicKey represents a public key using an unspecified algorithm.

Some PublicKeys provided by this package also implement CryptoPublicKey.

func NewPublicKey

func NewPublicKey(key interface{}) (PublicKey, error)

NewPublicKey takes an *rsa.PublicKey, *dsa.PublicKey, *ecdsa.PublicKey, or ed25519.PublicKey returns a corresponding PublicKey instance. ECDSA keys must use P-256, P-384 or P-521.

type Signature

type Signature struct {
	Format string
	Blob   []byte
	Rest   []byte `ssh:"rest"`
}

Signature represents a cryptographic signature.

Jump to

Keyboard shortcuts

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