(keyUpdate *keyUpdateMsg)
| 1399 | } |
| 1400 | |
| 1401 | func (c *Conn) handleKeyUpdate(keyUpdate *keyUpdateMsg) error { |
| 1402 | if c.quic != nil { |
| 1403 | c.sendAlert(alertUnexpectedMessage) |
| 1404 | return c.in.setErrorLocked(errors.New("tls: received unexpected key update message")) |
| 1405 | } |
| 1406 | |
| 1407 | cipherSuite := cipherSuiteTLS13ByID(c.cipherSuite) |
| 1408 | if cipherSuite == nil { |
| 1409 | return c.in.setErrorLocked(c.sendAlert(alertInternalError)) |
| 1410 | } |
| 1411 | |
| 1412 | newSecret := cipherSuite.nextTrafficSecret(c.in.trafficSecret) |
| 1413 | c.in.setTrafficSecret(cipherSuite, QUICEncryptionLevelInitial, newSecret) |
| 1414 | |
| 1415 | if keyUpdate.updateRequested { |
| 1416 | c.out.Lock() |
| 1417 | defer c.out.Unlock() |
| 1418 | |
| 1419 | msg := &keyUpdateMsg{} |
| 1420 | msgBytes, err := msg.marshal() |
| 1421 | if err != nil { |
| 1422 | return err |
| 1423 | } |
| 1424 | _, err = c.writeRecordLocked(recordTypeHandshake, msgBytes) |
| 1425 | if err != nil { |
| 1426 | // Surface the error at the next write. |
| 1427 | c.out.setErrorLocked(err) |
| 1428 | return nil |
| 1429 | } |
| 1430 | |
| 1431 | newSecret := cipherSuite.nextTrafficSecret(c.out.trafficSecret) |
| 1432 | c.out.setTrafficSecret(cipherSuite, QUICEncryptionLevelInitial, newSecret) |
| 1433 | } |
| 1434 | |
| 1435 | return nil |
| 1436 | } |
| 1437 | |
| 1438 | // Read reads data from the connection. |
| 1439 | // |
no test coverage detected