MCPcopy Index your code
hub / github.com/XTLS/Go / legacyTypeAndHashFromPublicKey

Function legacyTypeAndHashFromPublicKey

auth.go:131–146  ·  view source on GitHub ↗

legacyTypeAndHashFromPublicKey returns the fixed signature type and crypto.Hash for a given public key used with TLS 1.0 and 1.1, before the introduction of signature algorithm negotiation.

(pub crypto.PublicKey)

Source from the content-addressed store, hash-verified

129// a given public key used with TLS 1.0 and 1.1, before the introduction of
130// signature algorithm negotiation.
131func legacyTypeAndHashFromPublicKey(pub crypto.PublicKey) (sigType uint8, hash crypto.Hash, err error) {
132 switch pub.(type) {
133 case *rsa.PublicKey:
134 return signaturePKCS1v15, crypto.MD5SHA1, nil
135 case *ecdsa.PublicKey:
136 return signatureECDSA, crypto.SHA1, nil
137 case ed25519.PublicKey:
138 // RFC 8422 specifies support for Ed25519 in TLS 1.0 and 1.1,
139 // but it requires holding on to a handshake transcript to do a
140 // full signature, and not even OpenSSL bothers with the
141 // complexity, so we can't even test it properly.
142 return 0, 0, fmt.Errorf("tls: Ed25519 public keys are not supported before TLS 1.2")
143 default:
144 return 0, 0, fmt.Errorf("tls: unsupported public key: %T", pub)
145 }
146}
147
148var rsaSignatureSchemes = []struct {
149 scheme SignatureScheme

Callers 4

doFullHandshakeMethod · 0.85
doFullHandshakeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…