@@ -27,7 +27,7 @@ use crate::log::{debug, trace, warn};
2727use crate :: msgs:: base:: { Payload , PayloadU8 } ;
2828use crate :: msgs:: ccs:: ChangeCipherSpecPayload ;
2929use crate :: msgs:: codec:: { Codec , Reader } ;
30- use crate :: msgs:: enums:: { ExtensionType , KeyUpdateRequest } ;
30+ use crate :: msgs:: enums:: { ExtensionType , KeyUpdateRequest , NamedGroup } ;
3131use crate :: msgs:: handshake:: {
3232 CERTIFICATE_MAX_SIZE_LIMIT , CertificatePayloadTls13 , ClientExtensions , EchConfigPayload ,
3333 HandshakeMessagePayload , HandshakePayload , KeyShareEntry , NewSessionTicketPayloadTls13 ,
@@ -216,12 +216,6 @@ pub(super) fn handle_server_hello(
216216 } ;
217217 }
218218
219- // Remember what KX group the server liked for next time.
220- config
221- . resumption
222- . store
223- . set_kx_hint ( server_name. clone ( ) , their_key_share. group ) ;
224-
225219 // If we change keying when a subsequent handshake message is being joined,
226220 // the two halves will have different record layer protections. Disallow this.
227221 cx. common . check_aligned_handshake ( ) ?;
@@ -246,6 +240,7 @@ pub(super) fn handle_server_hello(
246240 suite,
247241 transcript,
248242 key_schedule,
243+ kx_group : their_key_share. group ,
249244 hello,
250245 } ) )
251246}
@@ -481,6 +476,7 @@ struct ExpectEncryptedExtensions {
481476 suite : & ' static Tls13CipherSuite ,
482477 transcript : HandshakeHash ,
483478 key_schedule : KeyScheduleHandshake ,
479+ kx_group : NamedGroup ,
484480 hello : ClientHelloDetails ,
485481}
486482
@@ -592,6 +588,7 @@ impl State<ClientConnectionData> for ExpectEncryptedExtensions {
592588 suite : self . suite ,
593589 transcript : self . transcript ,
594590 key_schedule : self . key_schedule ,
591+ kx_group : self . kx_group ,
595592 client_auth : None ,
596593 cert_verified,
597594 sig_verified,
@@ -614,6 +611,7 @@ impl State<ClientConnectionData> for ExpectEncryptedExtensions {
614611 suite : self . suite ,
615612 transcript : self . transcript ,
616613 key_schedule : self . key_schedule ,
614+ kx_group : self . kx_group ,
617615 ech_retry_configs,
618616 } )
619617 } else {
@@ -624,6 +622,7 @@ impl State<ClientConnectionData> for ExpectEncryptedExtensions {
624622 suite : self . suite ,
625623 transcript : self . transcript ,
626624 key_schedule : self . key_schedule ,
625+ kx_group : self . kx_group ,
627626 ech_retry_configs,
628627 } )
629628 } )
@@ -643,6 +642,7 @@ struct ExpectCertificateOrCompressedCertificateOrCertReq {
643642 suite : & ' static Tls13CipherSuite ,
644643 transcript : HandshakeHash ,
645644 key_schedule : KeyScheduleHandshake ,
645+ kx_group : NamedGroup ,
646646 ech_retry_configs : Option < Vec < EchConfigPayload > > ,
647647}
648648
@@ -666,6 +666,7 @@ impl State<ClientConnectionData> for ExpectCertificateOrCompressedCertificateOrC
666666 suite : self . suite ,
667667 transcript : self . transcript ,
668668 key_schedule : self . key_schedule ,
669+ kx_group : self . kx_group ,
669670 client_auth : None ,
670671 message_already_in_transcript : false ,
671672 ech_retry_configs : self . ech_retry_configs ,
@@ -681,6 +682,7 @@ impl State<ClientConnectionData> for ExpectCertificateOrCompressedCertificateOrC
681682 suite : self . suite ,
682683 transcript : self . transcript ,
683684 key_schedule : self . key_schedule ,
685+ kx_group : self . kx_group ,
684686 client_auth : None ,
685687 ech_retry_configs : self . ech_retry_configs ,
686688 } )
@@ -695,6 +697,7 @@ impl State<ClientConnectionData> for ExpectCertificateOrCompressedCertificateOrC
695697 suite : self . suite ,
696698 transcript : self . transcript ,
697699 key_schedule : self . key_schedule ,
700+ kx_group : self . kx_group ,
698701 offered_cert_compression : true ,
699702 ech_retry_configs : self . ech_retry_configs ,
700703 } )
@@ -723,6 +726,7 @@ struct ExpectCertificateOrCompressedCertificate {
723726 suite : & ' static Tls13CipherSuite ,
724727 transcript : HandshakeHash ,
725728 key_schedule : KeyScheduleHandshake ,
729+ kx_group : NamedGroup ,
726730 client_auth : Option < ClientAuthDetails > ,
727731 ech_retry_configs : Option < Vec < EchConfigPayload > > ,
728732}
@@ -747,6 +751,7 @@ impl State<ClientConnectionData> for ExpectCertificateOrCompressedCertificate {
747751 suite : self . suite ,
748752 transcript : self . transcript ,
749753 key_schedule : self . key_schedule ,
754+ kx_group : self . kx_group ,
750755 client_auth : self . client_auth ,
751756 message_already_in_transcript : false ,
752757 ech_retry_configs : self . ech_retry_configs ,
@@ -762,6 +767,7 @@ impl State<ClientConnectionData> for ExpectCertificateOrCompressedCertificate {
762767 suite : self . suite ,
763768 transcript : self . transcript ,
764769 key_schedule : self . key_schedule ,
770+ kx_group : self . kx_group ,
765771 client_auth : self . client_auth ,
766772 ech_retry_configs : self . ech_retry_configs ,
767773 } )
@@ -789,6 +795,7 @@ struct ExpectCertificateOrCertReq {
789795 suite : & ' static Tls13CipherSuite ,
790796 transcript : HandshakeHash ,
791797 key_schedule : KeyScheduleHandshake ,
798+ kx_group : NamedGroup ,
792799 ech_retry_configs : Option < Vec < EchConfigPayload > > ,
793800}
794801
@@ -812,6 +819,7 @@ impl State<ClientConnectionData> for ExpectCertificateOrCertReq {
812819 suite : self . suite ,
813820 transcript : self . transcript ,
814821 key_schedule : self . key_schedule ,
822+ kx_group : self . kx_group ,
815823 client_auth : None ,
816824 message_already_in_transcript : false ,
817825 ech_retry_configs : self . ech_retry_configs ,
@@ -827,6 +835,7 @@ impl State<ClientConnectionData> for ExpectCertificateOrCertReq {
827835 suite : self . suite ,
828836 transcript : self . transcript ,
829837 key_schedule : self . key_schedule ,
838+ kx_group : self . kx_group ,
830839 offered_cert_compression : false ,
831840 ech_retry_configs : self . ech_retry_configs ,
832841 } )
@@ -857,6 +866,7 @@ struct ExpectCertificateRequest {
857866 suite : & ' static Tls13CipherSuite ,
858867 transcript : HandshakeHash ,
859868 key_schedule : KeyScheduleHandshake ,
869+ kx_group : NamedGroup ,
860870 offered_cert_compression : bool ,
861871 ech_retry_configs : Option < Vec < EchConfigPayload > > ,
862872}
@@ -940,6 +950,7 @@ impl State<ClientConnectionData> for ExpectCertificateRequest {
940950 suite : self . suite ,
941951 transcript : self . transcript ,
942952 key_schedule : self . key_schedule ,
953+ kx_group : self . kx_group ,
943954 client_auth : Some ( client_auth) ,
944955 ech_retry_configs : self . ech_retry_configs ,
945956 } )
@@ -951,6 +962,7 @@ impl State<ClientConnectionData> for ExpectCertificateRequest {
951962 suite : self . suite ,
952963 transcript : self . transcript ,
953964 key_schedule : self . key_schedule ,
965+ kx_group : self . kx_group ,
954966 client_auth : Some ( client_auth) ,
955967 message_already_in_transcript : false ,
956968 ech_retry_configs : self . ech_retry_configs ,
@@ -970,6 +982,7 @@ struct ExpectCompressedCertificate {
970982 suite : & ' static Tls13CipherSuite ,
971983 transcript : HandshakeHash ,
972984 key_schedule : KeyScheduleHandshake ,
985+ kx_group : NamedGroup ,
973986 client_auth : Option < ClientAuthDetails > ,
974987 ech_retry_configs : Option < Vec < EchConfigPayload > > ,
975988}
@@ -1054,6 +1067,7 @@ impl State<ClientConnectionData> for ExpectCompressedCertificate {
10541067 suite : self . suite ,
10551068 transcript : self . transcript ,
10561069 key_schedule : self . key_schedule ,
1070+ kx_group : self . kx_group ,
10571071 client_auth : self . client_auth ,
10581072 message_already_in_transcript : true ,
10591073 ech_retry_configs : self . ech_retry_configs ,
@@ -1073,6 +1087,7 @@ struct ExpectCertificate {
10731087 suite : & ' static Tls13CipherSuite ,
10741088 transcript : HandshakeHash ,
10751089 key_schedule : KeyScheduleHandshake ,
1090+ kx_group : NamedGroup ,
10761091 client_auth : Option < ClientAuthDetails > ,
10771092 message_already_in_transcript : bool ,
10781093 ech_retry_configs : Option < Vec < EchConfigPayload > > ,
@@ -1119,6 +1134,7 @@ impl State<ClientConnectionData> for ExpectCertificate {
11191134 suite : self . suite ,
11201135 transcript : self . transcript ,
11211136 key_schedule : self . key_schedule ,
1137+ kx_group : self . kx_group ,
11221138 server_cert,
11231139 client_auth : self . client_auth ,
11241140 ech_retry_configs : self . ech_retry_configs ,
@@ -1138,6 +1154,7 @@ struct ExpectCertificateVerify<'a> {
11381154 suite : & ' static Tls13CipherSuite ,
11391155 transcript : HandshakeHash ,
11401156 key_schedule : KeyScheduleHandshake ,
1157+ kx_group : NamedGroup ,
11411158 server_cert : ServerCertDetails < ' a > ,
11421159 client_auth : Option < ClientAuthDetails > ,
11431160 ech_retry_configs : Option < Vec < EchConfigPayload > > ,
@@ -1209,6 +1226,7 @@ impl State<ClientConnectionData> for ExpectCertificateVerify<'_> {
12091226 suite : self . suite ,
12101227 transcript : self . transcript ,
12111228 key_schedule : self . key_schedule ,
1229+ kx_group : self . kx_group ,
12121230 client_auth : self . client_auth ,
12131231 cert_verified,
12141232 sig_verified,
@@ -1224,6 +1242,7 @@ impl State<ClientConnectionData> for ExpectCertificateVerify<'_> {
12241242 suite : self . suite ,
12251243 transcript : self . transcript ,
12261244 key_schedule : self . key_schedule ,
1245+ kx_group : self . kx_group ,
12271246 server_cert : self . server_cert . into_owned ( ) ,
12281247 client_auth : self . client_auth ,
12291248 ech_retry_configs : self . ech_retry_configs ,
@@ -1316,6 +1335,7 @@ struct ExpectFinished {
13161335 suite : & ' static Tls13CipherSuite ,
13171336 transcript : HandshakeHash ,
13181337 key_schedule : KeyScheduleHandshake ,
1338+ kx_group : NamedGroup ,
13191339 client_auth : Option < ClientAuthDetails > ,
13201340 cert_verified : verify:: ServerCertVerified ,
13211341 sig_verified : verify:: HandshakeSignatureValid ,
@@ -1416,6 +1436,12 @@ impl State<ClientConnectionData> for ExpectFinished {
14161436 emit_finished_tls13 ( & mut flight, & verify_data) ;
14171437 flight. finish ( cx. common ) ;
14181438
1439+ // Remember what KX group the server liked for next time.
1440+ st. config
1441+ . resumption
1442+ . store
1443+ . set_kx_hint ( st. server_name . clone ( ) , st. kx_group ) ;
1444+
14191445 /* We're now sure this server supports TLS1.3. But if we run out of TLS1.3 tickets
14201446 * when connecting to it again, we definitely don't want to attempt a TLS1.2 resumption. */
14211447 st. config
0 commit comments