comparison src/event/quic/ngx_event_quic_openssl_compat.c @ 9126:29a6c0e11f75

QUIC: a new constant for AEAD tag length. Previously used constant EVP_GCM_TLS_TAG_LEN had misleading name since it was used not only with GCM, but also with CHACHAPOLY. Now a new constant NGX_QUIC_TAG_LEN introduced. Luckily all AEAD algorithms used by QUIC have the same tag length of 16.
author Roman Arutyunyan <arut@nginx.com>
date Fri, 09 Jun 2023 10:25:54 +0400
parents b4a57278bf24
children daf8f5ba23d8
comparison
equal deleted inserted replaced
9125:31c8c1a713bc 9126:29a6c0e11f75
443 ngx_quic_connection_t *qc; 443 ngx_quic_connection_t *qc;
444 ngx_quic_compat_record_t rec; 444 ngx_quic_compat_record_t rec;
445 u_char in[NGX_QUIC_COMPAT_RECORD_SIZE + 1]; 445 u_char in[NGX_QUIC_COMPAT_RECORD_SIZE + 1];
446 u_char out[NGX_QUIC_COMPAT_RECORD_SIZE + 1 446 u_char out[NGX_QUIC_COMPAT_RECORD_SIZE + 1
447 + SSL3_RT_HEADER_LENGTH 447 + SSL3_RT_HEADER_LENGTH
448 + EVP_GCM_TLS_TAG_LEN]; 448 + NGX_QUIC_TAG_LEN];
449 449
450 c = ngx_ssl_get_connection(ssl); 450 c = ngx_ssl_get_connection(ssl);
451 451
452 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic compat rx %s len:%uz", 452 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic compat rx %s len:%uz",
453 ngx_quic_level_name(level), len); 453 ngx_quic_level_name(level), len);
526 if (plain) { 526 if (plain) {
527 type = rec->type; 527 type = rec->type;
528 528
529 } else { 529 } else {
530 type = SSL3_RT_APPLICATION_DATA; 530 type = SSL3_RT_APPLICATION_DATA;
531 len += EVP_GCM_TLS_TAG_LEN; 531 len += NGX_QUIC_TAG_LEN;
532 } 532 }
533 533
534 out[0] = type; 534 out[0] = type;
535 out[1] = 0x03; 535 out[1] = 0x03;
536 out[2] = 0x03; 536 out[2] = 0x03;
550 u_char nonce[NGX_QUIC_IV_LEN]; 550 u_char nonce[NGX_QUIC_IV_LEN];
551 551
552 ad.data = res->data; 552 ad.data = res->data;
553 ad.len = ngx_quic_compat_create_header(rec, ad.data, 0); 553 ad.len = ngx_quic_compat_create_header(rec, ad.data, 0);
554 554
555 out.len = rec->payload.len + EVP_GCM_TLS_TAG_LEN; 555 out.len = rec->payload.len + NGX_QUIC_TAG_LEN;
556 out.data = res->data + ad.len; 556 out.data = res->data + ad.len;
557 557
558 #ifdef NGX_QUIC_DEBUG_CRYPTO 558 #ifdef NGX_QUIC_DEBUG_CRYPTO
559 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, rec->log, 0, 559 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, rec->log, 0,
560 "quic compat ad len:%uz %xV", ad.len, &ad); 560 "quic compat ad len:%uz %xV", ad.len, &ad);