@@ -475,33 +475,18 @@ static int quic_change_cipher_state(SSL *s, int which)
475475 }
476476 hashlen = (size_t )hashleni ;
477477
478- if (is_handshake )
479- level = ssl_encryption_handshake ;
480- else
481- level = ssl_encryption_application ;
482-
483478 if (is_client_read || is_server_write ) {
484479 if (is_handshake ) {
485480 level = ssl_encryption_handshake ;
486481
487482 if (!tls13_hkdf_expand (s , md , s -> handshake_secret , client_handshake_traffic ,
488483 sizeof (client_handshake_traffic )- 1 , hash , hashlen ,
489- s -> client_hand_traffic_secret , hashlen , 1 )) {
490- /* SSLfatal() already called */
491- goto err ;
492- }
493- if (!ssl_log_secret (s , CLIENT_HANDSHAKE_LABEL , s -> client_hand_traffic_secret , hashlen )) {
494- /* SSLfatal() already called */
495- goto err ;
496- }
497-
498- if (!tls13_hkdf_expand (s , md , s -> handshake_secret , server_handshake_traffic ,
499- sizeof (server_handshake_traffic )- 1 , hash , hashlen ,
500- s -> server_hand_traffic_secret , hashlen , 1 )) {
501- /* SSLfatal() already called */
502- goto err ;
503- }
504- if (!ssl_log_secret (s , SERVER_HANDSHAKE_LABEL , s -> server_hand_traffic_secret , hashlen )) {
484+ s -> client_hand_traffic_secret , hashlen , 1 )
485+ || !ssl_log_secret (s , CLIENT_HANDSHAKE_LABEL , s -> client_hand_traffic_secret , hashlen )
486+ || !tls13_hkdf_expand (s , md , s -> handshake_secret , server_handshake_traffic ,
487+ sizeof (server_handshake_traffic )- 1 , hash , hashlen ,
488+ s -> server_hand_traffic_secret , hashlen , 1 )
489+ || !ssl_log_secret (s , SERVER_HANDSHAKE_LABEL , s -> server_hand_traffic_secret , hashlen )) {
505490 /* SSLfatal() already called */
506491 goto err ;
507492 }
@@ -510,26 +495,20 @@ static int quic_change_cipher_state(SSL *s, int which)
510495
511496 if (!tls13_hkdf_expand (s , md , s -> master_secret , client_application_traffic ,
512497 sizeof (client_application_traffic )- 1 , hash , hashlen ,
513- s -> client_app_traffic_secret , hashlen , 1 )) {
514- /* SSLfatal() already called */
515- goto err ;
516- }
517- if (!ssl_log_secret (s , CLIENT_APPLICATION_LABEL , s -> client_app_traffic_secret , hashlen )) {
518- /* SSLfatal() already called */
519- goto err ;
520- }
521-
522- if (!tls13_hkdf_expand (s , md , s -> master_secret , server_application_traffic ,
523- sizeof (server_application_traffic )- 1 , hash , hashlen ,
524- s -> server_app_traffic_secret , hashlen , 1 )) {
525- /* SSLfatal() already called */
526- goto err ;
527- }
528- if (!ssl_log_secret (s , SERVER_APPLICATION_LABEL , s -> server_app_traffic_secret , hashlen )) {
498+ s -> client_app_traffic_secret , hashlen , 1 )
499+ || !ssl_log_secret (s , CLIENT_APPLICATION_LABEL , s -> client_app_traffic_secret , hashlen )
500+ || !tls13_hkdf_expand (s , md , s -> master_secret , server_application_traffic ,
501+ sizeof (server_application_traffic )- 1 , hash , hashlen ,
502+ s -> server_app_traffic_secret , hashlen , 1 )
503+ || !ssl_log_secret (s , SERVER_APPLICATION_LABEL , s -> server_app_traffic_secret , hashlen )) {
529504 /* SSLfatal() already called */
530505 goto err ;
531506 }
532507 }
508+ if (!quic_set_encryption_secrets (s , level )) {
509+ /* SSLfatal() already called */
510+ goto err ;
511+ }
533512 if (s -> server )
534513 s -> quic_write_level = level ;
535514 else
@@ -540,24 +519,24 @@ static int quic_change_cipher_state(SSL *s, int which)
540519
541520 if (!tls13_hkdf_expand (s , md , s -> early_secret , client_early_traffic ,
542521 sizeof (client_early_traffic )- 1 , hash , hashlen ,
543- s -> client_early_traffic_secret , hashlen , 1 )) {
544- /* SSLfatal() already called */
545- goto err ;
546- }
547- if (!ssl_log_secret (s , CLIENT_EARLY_LABEL , s -> client_early_traffic_secret , hashlen )) {
522+ s -> client_early_traffic_secret , hashlen , 1 )
523+ || !ssl_log_secret (s , CLIENT_EARLY_LABEL , s -> client_early_traffic_secret , hashlen )
524+ || !quic_set_encryption_secrets (s , level )) {
548525 /* SSLfatal() already called */
549526 goto err ;
550527 }
528+ } else if (is_handshake ) {
529+ level = ssl_encryption_handshake ;
530+ } else {
531+ level = ssl_encryption_application ;
551532 }
533+
552534 if (s -> server )
553535 s -> quic_read_level = level ;
554536 else
555537 s -> quic_write_level = level ;
556538 }
557539
558- if (level != ssl_encryption_initial && !quic_set_encryption_secrets (s , level ))
559- goto err ;
560-
561540 ret = 1 ;
562541 err :
563542 return ret ;
0 commit comments