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

Method sendServerFinished

handshake_server_tls13.go:644–690  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

642}
643
644func (hs *serverHandshakeStateTLS13) sendServerFinished() error {
645 c := hs.c
646
647 finished := &finishedMsg{
648 verifyData: hs.suite.finishedHash(c.out.trafficSecret, hs.transcript),
649 }
650
651 hs.transcript.Write(finished.marshal())
652 if _, err := c.writeRecord(recordTypeHandshake, finished.marshal()); err != nil {
653 return err
654 }
655
656 // Derive secrets that take context through the server Finished.
657
658 hs.masterSecret = hs.suite.extract(nil,
659 hs.suite.deriveSecret(hs.handshakeSecret, "derived", nil))
660
661 hs.trafficSecret = hs.suite.deriveSecret(hs.masterSecret,
662 clientApplicationTrafficLabel, hs.transcript)
663 serverSecret := hs.suite.deriveSecret(hs.masterSecret,
664 serverApplicationTrafficLabel, hs.transcript)
665 c.out.setTrafficSecret(hs.suite, serverSecret)
666
667 err := c.config.writeKeyLog(keyLogLabelClientTraffic, hs.clientHello.random, hs.trafficSecret)
668 if err != nil {
669 c.sendAlert(alertInternalError)
670 return err
671 }
672 err = c.config.writeKeyLog(keyLogLabelServerTraffic, hs.clientHello.random, serverSecret)
673 if err != nil {
674 c.sendAlert(alertInternalError)
675 return err
676 }
677
678 c.ekm = hs.suite.exportKeyingMaterial(hs.masterSecret, hs.transcript)
679
680 // If we did not request client certificates, at this point we can
681 // precompute the client finished and roll the transcript forward to send
682 // session tickets in our first flight.
683 if !hs.requestClientCert() {
684 if err := hs.sendSessionTickets(); err != nil {
685 return err
686 }
687 }
688
689 return nil
690}
691
692func (hs *serverHandshakeStateTLS13) shouldSendSessionTickets() bool {
693 if hs.c.config.SessionTicketsDisabled {

Callers 1

handshakeMethod · 0.95

Calls 12

marshalMethod · 0.95
requestClientCertMethod · 0.95
sendSessionTicketsMethod · 0.95
finishedHashMethod · 0.80
writeRecordMethod · 0.80
extractMethod · 0.80
deriveSecretMethod · 0.80
setTrafficSecretMethod · 0.80
writeKeyLogMethod · 0.80
sendAlertMethod · 0.80
exportKeyingMaterialMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected