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