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

Function typeAndHashFromSignatureScheme

auth.go:98–126  ·  view source on GitHub ↗

typeAndHashFromSignatureScheme returns the corresponding signature type and crypto.Hash for a given TLS SignatureScheme.

(signatureAlgorithm SignatureScheme)

Source from the content-addressed store, hash-verified

96// typeAndHashFromSignatureScheme returns the corresponding signature type and
97// crypto.Hash for a given TLS SignatureScheme.
98func typeAndHashFromSignatureScheme(signatureAlgorithm SignatureScheme) (sigType uint8, hash crypto.Hash, err error) {
99 switch signatureAlgorithm {
100 case PKCS1WithSHA1, PKCS1WithSHA256, PKCS1WithSHA384, PKCS1WithSHA512:
101 sigType = signaturePKCS1v15
102 case PSSWithSHA256, PSSWithSHA384, PSSWithSHA512:
103 sigType = signatureRSAPSS
104 case ECDSAWithSHA1, ECDSAWithP256AndSHA256, ECDSAWithP384AndSHA384, ECDSAWithP521AndSHA512:
105 sigType = signatureECDSA
106 case Ed25519:
107 sigType = signatureEd25519
108 default:
109 return 0, 0, fmt.Errorf("unsupported signature algorithm: %v", signatureAlgorithm)
110 }
111 switch signatureAlgorithm {
112 case PKCS1WithSHA1, ECDSAWithSHA1:
113 hash = crypto.SHA1
114 case PKCS1WithSHA256, PSSWithSHA256, ECDSAWithP256AndSHA256:
115 hash = crypto.SHA256
116 case PKCS1WithSHA384, PSSWithSHA384, ECDSAWithP384AndSHA384:
117 hash = crypto.SHA384
118 case PKCS1WithSHA512, PSSWithSHA512, ECDSAWithP521AndSHA512:
119 hash = crypto.SHA512
120 case Ed25519:
121 hash = directSigning
122 default:
123 return 0, 0, fmt.Errorf("unsupported signature algorithm: %v", signatureAlgorithm)
124 }
125 return sigType, hash, nil
126}
127
128// legacyTypeAndHashFromPublicKey returns the fixed signature type and crypto.Hash for
129// a given public key used with TLS 1.0 and 1.1, before the introduction of

Callers 9

doFullHandshakeMethod · 0.85
readServerCertificateMethod · 0.85
sendClientCertificateMethod · 0.85
sendServerCertificateMethod · 0.85
readClientCertificateMethod · 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…