MCPcopy Create free account
hub / github.com/XTLS/Go / handleKeyUpdate

Method handleKeyUpdate

conn.go:1491–1517  ·  view source on GitHub ↗
(keyUpdate *keyUpdateMsg)

Source from the content-addressed store, hash-verified

1489}
1490
1491func (c *Conn) handleKeyUpdate(keyUpdate *keyUpdateMsg) error {
1492 cipherSuite := cipherSuiteTLS13ByID(c.cipherSuite)
1493 if cipherSuite == nil {
1494 return c.in.setErrorLocked(c.sendAlert(alertInternalError))
1495 }
1496
1497 newSecret := cipherSuite.nextTrafficSecret(c.in.trafficSecret)
1498 c.in.setTrafficSecret(cipherSuite, newSecret)
1499
1500 if keyUpdate.updateRequested {
1501 c.out.Lock()
1502 defer c.out.Unlock()
1503
1504 msg := &keyUpdateMsg{}
1505 _, err := c.writeRecordLocked(recordTypeHandshake, msg.marshal())
1506 if err != nil {
1507 // Surface the error at the next write.
1508 c.out.setErrorLocked(err)
1509 return nil
1510 }
1511
1512 newSecret := cipherSuite.nextTrafficSecret(c.out.trafficSecret)
1513 c.out.setTrafficSecret(cipherSuite, newSecret)
1514 }
1515
1516 return nil
1517}
1518
1519// Read reads data from the connection.
1520//

Callers 1

Calls 7

sendAlertMethod · 0.95
writeRecordLockedMethod · 0.95
marshalMethod · 0.95
cipherSuiteTLS13ByIDFunction · 0.85
setErrorLockedMethod · 0.80
nextTrafficSecretMethod · 0.80
setTrafficSecretMethod · 0.80

Tested by

no test coverage detected