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

Function hashForServerKeyExchange

key_agreement.go:133–153  ·  view source on GitHub ↗

hashForServerKeyExchange hashes the given slices and returns their digest using the given hash function (for TLS 1.2) or using a default based on the sigType (for earlier TLS versions). For Ed25519 signatures, which don't do pre-hashing, it returns the concatenation of the slices.

(sigType uint8, hashFunc crypto.Hash, version uint16, slices ...[]byte)

Source from the content-addressed store, hash-verified

131// the sigType (for earlier TLS versions). For Ed25519 signatures, which don't
132// do pre-hashing, it returns the concatenation of the slices.
133func hashForServerKeyExchange(sigType uint8, hashFunc crypto.Hash, version uint16, slices ...[]byte) []byte {
134 if sigType == signatureEd25519 {
135 var signed []byte
136 for _, slice := range slices {
137 signed = append(signed, slice...)
138 }
139 return signed
140 }
141 if version >= VersionTLS12 {
142 h := hashFunc.New()
143 for _, slice := range slices {
144 h.Write(slice)
145 }
146 digest := h.Sum(nil)
147 return digest
148 }
149 if sigType == signatureECDSA {
150 return sha1Hash(slices)
151 }
152 return md5SHA1Hash(slices)
153}
154
155// ecdheKeyAgreement implements a TLS key agreement where the server
156// generates an ephemeral EC public/private key pair and signs it. The

Callers 2

Calls 4

sha1HashFunction · 0.85
md5SHA1HashFunction · 0.85
WriteMethod · 0.65
SumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…