MCPcopy
hub / github.com/XTLS/REALITY / typeAndHashFromSignatureScheme

Function typeAndHashFromSignatureScheme

auth.go:99–127  ·  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

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

Callers 10

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…