Skip to content

x/crypto/ssh: prefer rsa-sha2-512 over rsa-sha2-256 for RSA SSH signatures #77585

@lonnywong

Description

@lonnywong

Proposal Details

RSA signature algorithms are currently ordered as:

func algorithmsForKeyFormat(keyFormat string) []string {
	switch keyFormat {
	case KeyAlgoRSA:
		return []string{KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoRSA}
	case CertAlgoRSAv01:
		return []string{CertAlgoRSASHA256v01, CertAlgoRSASHA512v01, CertAlgoRSAv01}
	default:
		return []string{keyFormat}
	}
}

This causes rsa-sha2-256 to be negotiated before rsa-sha2-512 when both are supported.

OpenSSH prefers rsa-sha2-512 over rsa-sha2-256 in its default signature algorithm ordering and negotiates rsa-sha2-512 when possible.

Suggested change

Prefer SHA-512 when available:

case KeyAlgoRSA:
	return []string{KeyAlgoRSASHA512, KeyAlgoRSASHA256, KeyAlgoRSA}
case CertAlgoRSAv01:
	return []string{CertAlgoRSASHA512v01, CertAlgoRSASHA256v01, CertAlgoRSAv01}

This aligns Go's SSH behavior with OpenSSH while remaining fully backward compatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions