changeset 8313:c625bde6cb77 quic

Fixed computing nonce again, by properly shifting packet number.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 03 Apr 2020 13:49:40 +0300
parents 053fa468b044
children de8981bf2dd5
files src/event/ngx_event_quic_protection.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/ngx_event_quic_protection.c
+++ b/src/event/ngx_event_quic_protection.c
@@ -787,10 +787,10 @@ ngx_quic_parse_pn(u_char **pos, ngx_int_
 static void
 ngx_quic_compute_nonce(u_char *nonce, size_t len, uint64_t pn)
 {
-    nonce[len - 4] ^= pn & 0xff000000;
-    nonce[len - 3] ^= pn & 0x00ff0000;
-    nonce[len - 2] ^= pn & 0x0000ff00;
-    nonce[len - 1] ^= pn & 0x000000ff;
+    nonce[len - 4] ^= (pn & 0xff000000) >> 24;
+    nonce[len - 3] ^= (pn & 0x00ff0000) >> 16;
+    nonce[len - 2] ^= (pn & 0x0000ff00) >> 8;
+    nonce[len - 1] ^= (pn & 0x000000ff);
 }