changeset 8218:33feac1e57ac quic

Fixed header protection application with pn length > 1.
author Sergey Kandaurov <pluknet@nginx.com>
date Sat, 14 Mar 2020 03:15:09 +0300
parents a5a1b3fad834
children 1307308c3cf1
files src/event/ngx_event_quic.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/ngx_event_quic.c
+++ b/src/event/ngx_event_quic.c
@@ -1637,7 +1637,10 @@ ngx_quic_decrypt(ngx_connection_t *c, ng
 
     ngx_memcpy(ad.data, pkt->data, ad.len);
     ad.data[0] = clearflags;
-    ad.data[ad.len - pnl] = (u_char) pn;
+
+    do {
+        ad.data[ad.len - pnl] = pn >> (8 * (pnl - 1)) % 256;
+    } while (--pnl);
 
     nonce = ngx_pstrdup(c->pool, &pkt->secret->iv);
     nonce[11] ^= pn;