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

Method readServerFinished

handshake_client_tls13.go:497–541  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

495}
496
497func (hs *clientHandshakeStateTLS13) readServerFinished() error {
498 c := hs.c
499
500 msg, err := c.readHandshake()
501 if err != nil {
502 return err
503 }
504
505 finished, ok := msg.(*finishedMsg)
506 if !ok {
507 c.sendAlert(alertUnexpectedMessage)
508 return unexpectedMessageError(finished, msg)
509 }
510
511 expectedMAC := hs.suite.finishedHash(c.in.trafficSecret, hs.transcript)
512 if !hmac.Equal(expectedMAC, finished.verifyData) {
513 c.sendAlert(alertDecryptError)
514 return errors.New("tls: invalid server finished hash")
515 }
516
517 hs.transcript.Write(finished.marshal())
518
519 // Derive secrets that take context through the server Finished.
520
521 hs.trafficSecret = hs.suite.deriveSecret(hs.masterSecret,
522 clientApplicationTrafficLabel, hs.transcript)
523 serverSecret := hs.suite.deriveSecret(hs.masterSecret,
524 serverApplicationTrafficLabel, hs.transcript)
525 c.in.setTrafficSecret(hs.suite, serverSecret)
526
527 err = c.config.writeKeyLog(keyLogLabelClientTraffic, hs.hello.random, hs.trafficSecret)
528 if err != nil {
529 c.sendAlert(alertInternalError)
530 return err
531 }
532 err = c.config.writeKeyLog(keyLogLabelServerTraffic, hs.hello.random, serverSecret)
533 if err != nil {
534 c.sendAlert(alertInternalError)
535 return err
536 }
537
538 c.ekm = hs.suite.exportKeyingMaterial(hs.masterSecret, hs.transcript)
539
540 return nil
541}
542
543func (hs *clientHandshakeStateTLS13) sendClientCertificate() error {
544 c := hs.c

Callers 1

handshakeMethod · 0.95

Calls 10

unexpectedMessageErrorFunction · 0.85
readHandshakeMethod · 0.80
sendAlertMethod · 0.80
finishedHashMethod · 0.80
deriveSecretMethod · 0.80
setTrafficSecretMethod · 0.80
writeKeyLogMethod · 0.80
exportKeyingMaterialMethod · 0.80
marshalMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected