comparison src/event/quic/ngx_event_quic_protection.c @ 8894:de7b9af30fc6 quic

QUIC: refactored packet creation. The "min" and "max" arguments refer to UDP datagram size. Generating payload requires to account properly for header size, which is variable and depends on payload size and packet number.
author Vladimir Homutov <vl@nginx.com>
date Thu, 07 Oct 2021 13:48:29 +0300
parents 6d1488b62dc5
children 3341e4089c6c
comparison
equal deleted inserted replaced
8893:126a15530136 8894:de7b9af30fc6
834 ngx_uint_t i; 834 ngx_uint_t i;
835 ngx_quic_secret_t *secret; 835 ngx_quic_secret_t *secret;
836 ngx_quic_ciphers_t ciphers; 836 ngx_quic_ciphers_t ciphers;
837 u_char nonce[NGX_QUIC_IV_LEN], mask[NGX_QUIC_HP_LEN]; 837 u_char nonce[NGX_QUIC_IV_LEN], mask[NGX_QUIC_HP_LEN];
838 838
839 ad.data = res->data;
840 ad.len = ngx_quic_create_header(pkt, ad.data, &pnp);
841
839 out.len = pkt->payload.len + EVP_GCM_TLS_TAG_LEN; 842 out.len = pkt->payload.len + EVP_GCM_TLS_TAG_LEN;
840
841 ad.data = res->data;
842 ad.len = ngx_quic_create_header(pkt, ad.data, out.len, &pnp);
843
844 out.data = res->data + ad.len; 843 out.data = res->data + ad.len;
845 844
846 #ifdef NGX_QUIC_DEBUG_CRYPTO 845 #ifdef NGX_QUIC_DEBUG_CRYPTO
847 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0, 846 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pkt->log, 0,
848 "quic ad len:%uz %xV", ad.len, &ad); 847 "quic ad len:%uz %xV", ad.len, &ad);