@@ -475,33 +475,18 @@ static int quic_change_cipher_state(SSL *s, int which)
475
475
}
476
476
hashlen = (size_t )hashleni ;
477
477
478
- if (is_handshake )
479
- level = ssl_encryption_handshake ;
480
- else
481
- level = ssl_encryption_application ;
482
-
483
478
if (is_client_read || is_server_write ) {
484
479
if (is_handshake ) {
485
480
level = ssl_encryption_handshake ;
486
481
487
482
if (!tls13_hkdf_expand (s , md , s -> handshake_secret , client_handshake_traffic ,
488
483
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 )) {
505
490
/* SSLfatal() already called */
506
491
goto err ;
507
492
}
@@ -510,26 +495,20 @@ static int quic_change_cipher_state(SSL *s, int which)
510
495
511
496
if (!tls13_hkdf_expand (s , md , s -> master_secret , client_application_traffic ,
512
497
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 )) {
529
504
/* SSLfatal() already called */
530
505
goto err ;
531
506
}
532
507
}
508
+ if (!quic_set_encryption_secrets (s , level )) {
509
+ /* SSLfatal() already called */
510
+ goto err ;
511
+ }
533
512
if (s -> server )
534
513
s -> quic_write_level = level ;
535
514
else
@@ -540,24 +519,24 @@ static int quic_change_cipher_state(SSL *s, int which)
540
519
541
520
if (!tls13_hkdf_expand (s , md , s -> early_secret , client_early_traffic ,
542
521
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 )) {
548
525
/* SSLfatal() already called */
549
526
goto err ;
550
527
}
528
+ } else if (is_handshake ) {
529
+ level = ssl_encryption_handshake ;
530
+ } else {
531
+ level = ssl_encryption_application ;
551
532
}
533
+
552
534
if (s -> server )
553
535
s -> quic_read_level = level ;
554
536
else
555
537
s -> quic_write_level = level ;
556
538
}
557
539
558
- if (level != ssl_encryption_initial && !quic_set_encryption_secrets (s , level ))
559
- goto err ;
560
-
561
540
ret = 1 ;
562
541
err :
563
542
return ret ;
0 commit comments