writeHandshakeRecord writes a handshake message to the connection and updates the record layer state. If transcript is non-nil the marshaled message is written to it.
(msg handshakeMessage, transcript transcriptHash)
| 1089 | // the record layer state. If transcript is non-nil the marshaled message is |
| 1090 | // written to it. |
| 1091 | func (c *Conn) writeHandshakeRecord(msg handshakeMessage, transcript transcriptHash) (int, error) { |
| 1092 | c.out.Lock() |
| 1093 | defer c.out.Unlock() |
| 1094 | |
| 1095 | data, err := msg.marshal() |
| 1096 | if err != nil { |
| 1097 | return 0, err |
| 1098 | } |
| 1099 | if transcript != nil { |
| 1100 | transcript.Write(data) |
| 1101 | } |
| 1102 | |
| 1103 | if c.out.handshakeBuf != nil && len(data) > 0 && data[0] != typeServerHello { |
| 1104 | c.out.handshakeBuf = append(c.out.handshakeBuf, data...) |
| 1105 | if data[0] != typeFinished { |
| 1106 | return len(data), nil |
| 1107 | } |
| 1108 | data = c.out.handshakeBuf |
| 1109 | c.out.handshakeBuf = nil |
| 1110 | } |
| 1111 | |
| 1112 | return c.writeRecordLocked(recordTypeHandshake, data) |
| 1113 | } |
| 1114 | |
| 1115 | // writeRecord writes a TLS record with the given type and payload to the |
| 1116 | // connection and updates the record layer state. |
no test coverage detected