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

Function hashForServerKeyExchange

key_agreement.go:131–151  ·  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

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

Callers 2

Calls 4

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…