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)
| 131 | // the sigType (for earlier TLS versions). For Ed25519 signatures, which don't |
| 132 | // do pre-hashing, it returns the concatenation of the slices. |
| 133 | func 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 |
no test coverage detected
searching dependent graphs…