# HG changeset patch # User Sergey Kandaurov # Date 1693347778 -14400 # Node ID e1059682aeefea25ce61030ee1429b38280b6e63 # Parent 2a0a6035a1af4f4836d5e71d337e5f34d21a4dfa Tests: fixed ClientHello with resending Initial QUIC packets. Previously it was rebuilt each time using distinct ClientHello.random resulting in different CRYPTO payload. As such, it led to TLS digest hash and derived secrets mismatch when resending Initial packet. Now ClientHello is built once and reused when resending Initial packets. Additionally, this required to preserve a generated secret value used in shared secret calculation as part of TLS key schedule. Previously it was regenerated when receiving a Retry packet, but this won't work with reused ClientHello as the resulting shared secrets won't match. diff --git a/lib/Test/Nginx/HTTP3.pm b/lib/Test/Nginx/HTTP3.pm --- a/lib/Test/Nginx/HTTP3.pm +++ b/lib/Test/Nginx/HTTP3.pm @@ -59,6 +59,7 @@ sub new { $self->{buf} = ''; $self->init(); + $self->init_key_schedule(); $self->retry(%extra) or return; return $self; @@ -100,7 +101,6 @@ sub retry { $self->set_traffic_keys('tls13 client in', 'SHA256', 32, 0, 'w', $prk); $self->set_traffic_keys('tls13 server in', 'SHA256', 32, 0, 'r', $prk); - $self->init_key_schedule(); $self->initial(); return $self if $extra{probe}; $self->handshake() or return; @@ -134,7 +134,7 @@ sub init_key_schedule { sub initial { my ($self) = @_; - $self->{tlsm}{ch} = $self->build_tls_client_hello(); + $self->{tlsm}{ch} ||= $self->build_tls_client_hello(); my $ch = $self->{tlsm}{ch}; my $crypto = build_crypto($ch); my $padding = 1200 - length($crypto);