<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><p style="margin:0;"># HG changeset patch</p><p style="margin:0;"># User Yu Zhu <lishu.zy@alibaba-inc.com></p><p style="margin:0;"># Date 1668789115 -28800</p><p style="margin:0;">#      Sat Nov 19 00:31:55 2022 +0800</p><p style="margin:0;"># Branch quic</p><p style="margin:0;"># Node ID 1a320805265db14904ca9deaae8330f4979619ce</p><p style="margin:0;"># Parent  6cf8ed15fd00668b7efa0226c06f47d7238f26e8</p><p style="margin:0;">QUIC: fixed computation of nonce</p><p style="margin:0;"><br></p><p style="margin:0;">RFC 9001, 5.3. AEAD Usage</p><p style="margin:0;">The nonce, N, is formed by combining the packet protection IV with the packet number. The 62 bits of the reconstructed QUIC packet number in network byte order are left-padded with zeros to the size of the IV. The exclusive OR of the padded packet number and the IV forms the AEAD nonce.</p><p style="margin:0;"><br></p><p style="margin:0;">diff -r 6cf8ed15fd00 -r 1a320805265d src/event/quic/ngx_event_quic_protection.c</p><p style="margin:0;">--- a/src/event/quic/ngx_event_quic_protection.c        Tue Nov 01 17:00:35 2022 +0400</p><p style="margin:0;">+++ b/src/event/quic/ngx_event_quic_protection.c        Sat Nov 19 00:31:55 2022 +0800</p><p style="margin:0;">@@ -969,10 +969,11 @@</p><p style="margin:0;"> static void</p><p style="margin:0;"> ngx_quic_compute_nonce(u_char *nonce, size_t len, uint64_t pn)</p><p style="margin:0;"> {</p><p style="margin:0;">-    nonce[len - 4] ^= (pn & 0xff000000) >> 24;</p><p style="margin:0;">-    nonce[len - 3] ^= (pn & 0x00ff0000) >> 16;</p><p style="margin:0;">-    nonce[len - 2] ^= (pn & 0x0000ff00) >> 8;</p><p style="margin:0;">-    nonce[len - 1] ^= (pn & 0x000000ff);</p><p style="margin:0;">+    size_t  i;</p><p style="margin:0;">+</p><p style="margin:0;">+    for (i = 0; i < 8; i++) {</p><p style="margin:0;">+        nonce[len - 8 + i] ^= (pn >> (8 - i - 1) * 8) & 0xff;</p><p style="margin:0;">+    }</p><p style="margin:0;"> }</p></div>