QUIC: fixed computation of nonce with packet numbers beyond 2^32.

Prodded by Yu Zhu.
This commit is contained in:
Sergey Kandaurov 2022-11-25 15:56:33 +04:00
parent a7bda07bda
commit 6c843d19f2
1 changed files with 8 additions and 4 deletions

View File

@ -964,10 +964,14 @@ ngx_quic_parse_pn(u_char **pos, ngx_int_t len, u_char *mask,
static void
ngx_quic_compute_nonce(u_char *nonce, size_t len, uint64_t pn)
{
nonce[len - 4] ^= (pn & 0xff000000) >> 24;
nonce[len - 3] ^= (pn & 0x00ff0000) >> 16;
nonce[len - 2] ^= (pn & 0x0000ff00) >> 8;
nonce[len - 1] ^= (pn & 0x000000ff);
nonce[len - 8] ^= (pn >> 56) & 0x3f;
nonce[len - 7] ^= (pn >> 48) & 0xff;
nonce[len - 6] ^= (pn >> 40) & 0xff;
nonce[len - 5] ^= (pn >> 32) & 0xff;
nonce[len - 4] ^= (pn >> 24) & 0xff;
nonce[len - 3] ^= (pn >> 16) & 0xff;
nonce[len - 2] ^= (pn >> 8) & 0xff;
nonce[len - 1] ^= pn & 0xff;
}