Lines Matching refs:hdr
189 QUIC_PKT_HDR *hdr, in ossl_quic_wire_decode_pkt_hdr() argument
207 hdr->partial = partial; in ossl_quic_wire_decode_pkt_hdr()
208 hdr->unused = 0; in ossl_quic_wire_decode_pkt_hdr()
209 hdr->reserved = 0; in ossl_quic_wire_decode_pkt_hdr()
220 hdr->type = QUIC_PKT_TYPE_1RTT; in ossl_quic_wire_decode_pkt_hdr()
221 hdr->fixed = 1; in ossl_quic_wire_decode_pkt_hdr()
222 hdr->spin_bit = (b0 & 0x20) != 0; in ossl_quic_wire_decode_pkt_hdr()
224 hdr->key_phase = 0; /* protected, zero for now */ in ossl_quic_wire_decode_pkt_hdr()
225 hdr->pn_len = 0; /* protected, zero for now */ in ossl_quic_wire_decode_pkt_hdr()
226 hdr->reserved = 0; /* protected, zero for now */ in ossl_quic_wire_decode_pkt_hdr()
228 hdr->key_phase = (b0 & 0x04) != 0; in ossl_quic_wire_decode_pkt_hdr()
229 hdr->pn_len = (b0 & 0x03) + 1; in ossl_quic_wire_decode_pkt_hdr()
230 hdr->reserved = (b0 & 0x18) >> 3; in ossl_quic_wire_decode_pkt_hdr()
234 if (!PACKET_copy_bytes(pkt, hdr->dst_conn_id.id, short_conn_id_len)) in ossl_quic_wire_decode_pkt_hdr()
237 hdr->dst_conn_id.id_len = (unsigned char)short_conn_id_len; in ossl_quic_wire_decode_pkt_hdr()
245 memset(hdr->pn, 0, sizeof(hdr->pn)); in ossl_quic_wire_decode_pkt_hdr()
248 if (!PACKET_forward(pkt, sizeof(hdr->pn))) in ossl_quic_wire_decode_pkt_hdr()
251 if (!PACKET_copy_bytes(pkt, hdr->pn, hdr->pn_len)) in ossl_quic_wire_decode_pkt_hdr()
256 hdr->version = 0; in ossl_quic_wire_decode_pkt_hdr()
257 hdr->src_conn_id.id_len = 0; in ossl_quic_wire_decode_pkt_hdr()
258 hdr->token = NULL; in ossl_quic_wire_decode_pkt_hdr()
259 hdr->token_len = 0; in ossl_quic_wire_decode_pkt_hdr()
265 hdr->len = PACKET_remaining(pkt); in ossl_quic_wire_decode_pkt_hdr()
266 hdr->data = PACKET_data(pkt); in ossl_quic_wire_decode_pkt_hdr()
273 if (!PACKET_forward(pkt, hdr->len)) in ossl_quic_wire_decode_pkt_hdr()
292 || !PACKET_copy_bytes(pkt, hdr->dst_conn_id.id, dst_conn_id_len) in ossl_quic_wire_decode_pkt_hdr()
295 || !PACKET_copy_bytes(pkt, hdr->src_conn_id.id, src_conn_id_len)) in ossl_quic_wire_decode_pkt_hdr()
298 hdr->version = (uint32_t)version; in ossl_quic_wire_decode_pkt_hdr()
299 hdr->dst_conn_id.id_len = (unsigned char)dst_conn_id_len; in ossl_quic_wire_decode_pkt_hdr()
300 hdr->src_conn_id.id_len = (unsigned char)src_conn_id_len; in ossl_quic_wire_decode_pkt_hdr()
308 hdr->type = QUIC_PKT_TYPE_VERSION_NEG; in ossl_quic_wire_decode_pkt_hdr()
309 hdr->fixed = (b0 & 0x40) != 0; in ossl_quic_wire_decode_pkt_hdr()
311 hdr->data = PACKET_data(pkt); in ossl_quic_wire_decode_pkt_hdr()
312 hdr->len = PACKET_remaining(pkt); in ossl_quic_wire_decode_pkt_hdr()
318 if ((hdr->len % 4) != 0) in ossl_quic_wire_decode_pkt_hdr()
322 hdr->partial = 0; in ossl_quic_wire_decode_pkt_hdr()
325 hdr->pn_len = 0; in ossl_quic_wire_decode_pkt_hdr()
326 hdr->spin_bit = 0; in ossl_quic_wire_decode_pkt_hdr()
327 hdr->key_phase = 0; in ossl_quic_wire_decode_pkt_hdr()
328 hdr->token = NULL; in ossl_quic_wire_decode_pkt_hdr()
329 hdr->token_len = 0; in ossl_quic_wire_decode_pkt_hdr()
330 memset(hdr->pn, 0, sizeof(hdr->pn)); in ossl_quic_wire_decode_pkt_hdr()
332 if (!PACKET_forward(pkt, hdr->len)) in ossl_quic_wire_decode_pkt_hdr()
346 hdr->type = QUIC_PKT_TYPE_INITIAL; in ossl_quic_wire_decode_pkt_hdr()
349 hdr->type = QUIC_PKT_TYPE_0RTT; in ossl_quic_wire_decode_pkt_hdr()
352 hdr->type = QUIC_PKT_TYPE_HANDSHAKE; in ossl_quic_wire_decode_pkt_hdr()
355 hdr->type = QUIC_PKT_TYPE_RETRY; in ossl_quic_wire_decode_pkt_hdr()
359 hdr->pn_len = 0; in ossl_quic_wire_decode_pkt_hdr()
360 hdr->fixed = 1; in ossl_quic_wire_decode_pkt_hdr()
363 hdr->spin_bit = 0; in ossl_quic_wire_decode_pkt_hdr()
364 hdr->key_phase = 0; in ossl_quic_wire_decode_pkt_hdr()
366 if (hdr->type == QUIC_PKT_TYPE_INITIAL) { in ossl_quic_wire_decode_pkt_hdr()
372 || !PACKET_get_bytes(pkt, &hdr->token, (size_t)token_len)) in ossl_quic_wire_decode_pkt_hdr()
375 hdr->token_len = (size_t)token_len; in ossl_quic_wire_decode_pkt_hdr()
377 hdr->token = NULL; in ossl_quic_wire_decode_pkt_hdr()
379 hdr->token = NULL; in ossl_quic_wire_decode_pkt_hdr()
380 hdr->token_len = 0; in ossl_quic_wire_decode_pkt_hdr()
383 if (hdr->type == QUIC_PKT_TYPE_RETRY) { in ossl_quic_wire_decode_pkt_hdr()
385 hdr->data = PACKET_data(pkt); in ossl_quic_wire_decode_pkt_hdr()
386 hdr->len = PACKET_remaining(pkt); in ossl_quic_wire_decode_pkt_hdr()
389 hdr->partial = 0; in ossl_quic_wire_decode_pkt_hdr()
392 hdr->unused = b0 & 0x0f; in ossl_quic_wire_decode_pkt_hdr()
395 memset(hdr->pn, 0, sizeof(hdr->pn)); in ossl_quic_wire_decode_pkt_hdr()
397 if (!PACKET_forward(pkt, hdr->len)) in ossl_quic_wire_decode_pkt_hdr()
403 hdr->pn_len = partial ? 0 : ((b0 & 0x03) + 1); in ossl_quic_wire_decode_pkt_hdr()
404 hdr->reserved = partial ? 0 : ((b0 & 0x0C) >> 2); in ossl_quic_wire_decode_pkt_hdr()
407 || len < sizeof(hdr->pn)) in ossl_quic_wire_decode_pkt_hdr()
420 memset(hdr->pn, 0, sizeof(hdr->pn)); in ossl_quic_wire_decode_pkt_hdr()
422 if (!PACKET_forward(pkt, sizeof(hdr->pn))) in ossl_quic_wire_decode_pkt_hdr()
425 hdr->len = (size_t)(len - sizeof(hdr->pn)); in ossl_quic_wire_decode_pkt_hdr()
427 if (!PACKET_copy_bytes(pkt, hdr->pn, hdr->pn_len)) in ossl_quic_wire_decode_pkt_hdr()
430 hdr->len = (size_t)(len - hdr->pn_len); in ossl_quic_wire_decode_pkt_hdr()
434 hdr->data = NULL; in ossl_quic_wire_decode_pkt_hdr()
436 hdr->data = PACKET_data(pkt); in ossl_quic_wire_decode_pkt_hdr()
439 if (!PACKET_forward(pkt, hdr->len)) in ossl_quic_wire_decode_pkt_hdr()
459 const QUIC_PKT_HDR *hdr, in ossl_quic_wire_encode_pkt_hdr() argument
480 if (hdr->partial in ossl_quic_wire_encode_pkt_hdr()
481 || (hdr->type == QUIC_PKT_TYPE_1RTT in ossl_quic_wire_encode_pkt_hdr()
482 && hdr->dst_conn_id.id_len != short_conn_id_len)) in ossl_quic_wire_encode_pkt_hdr()
485 if (hdr->type == QUIC_PKT_TYPE_1RTT) { in ossl_quic_wire_encode_pkt_hdr()
492 if (hdr->dst_conn_id.id_len != short_conn_id_len in ossl_quic_wire_encode_pkt_hdr()
494 || hdr->pn_len < 1 || hdr->pn_len > 4) in ossl_quic_wire_encode_pkt_hdr()
497 b0 = (hdr->spin_bit << 5) in ossl_quic_wire_encode_pkt_hdr()
498 | (hdr->key_phase << 2) in ossl_quic_wire_encode_pkt_hdr()
499 | (hdr->pn_len - 1) in ossl_quic_wire_encode_pkt_hdr()
500 | (hdr->reserved << 3) in ossl_quic_wire_encode_pkt_hdr()
504 || !WPACKET_memcpy(pkt, hdr->dst_conn_id.id, short_conn_id_len) in ossl_quic_wire_encode_pkt_hdr()
506 || !WPACKET_memcpy(pkt, hdr->pn, hdr->pn_len)) in ossl_quic_wire_encode_pkt_hdr()
512 if (hdr->dst_conn_id.id_len > QUIC_MAX_CONN_ID_LEN in ossl_quic_wire_encode_pkt_hdr()
513 || hdr->src_conn_id.id_len > QUIC_MAX_CONN_ID_LEN) in ossl_quic_wire_encode_pkt_hdr()
516 if (ossl_quic_pkt_type_has_pn(hdr->type) in ossl_quic_wire_encode_pkt_hdr()
517 && (hdr->pn_len < 1 || hdr->pn_len > 4)) in ossl_quic_wire_encode_pkt_hdr()
520 switch (hdr->type) { in ossl_quic_wire_encode_pkt_hdr()
522 if (hdr->version != 0) in ossl_quic_wire_encode_pkt_hdr()
538 if (hdr->type != QUIC_PKT_TYPE_VERSION_NEG || hdr->fixed) in ossl_quic_wire_encode_pkt_hdr()
540 if (ossl_quic_pkt_type_has_pn(hdr->type)) { in ossl_quic_wire_encode_pkt_hdr()
541 b0 |= hdr->pn_len - 1; in ossl_quic_wire_encode_pkt_hdr()
542 b0 |= (hdr->reserved << 2); in ossl_quic_wire_encode_pkt_hdr()
544 if (hdr->type == QUIC_PKT_TYPE_RETRY) in ossl_quic_wire_encode_pkt_hdr()
545 b0 |= hdr->unused; in ossl_quic_wire_encode_pkt_hdr()
548 || !WPACKET_put_bytes_u32(pkt, hdr->version) in ossl_quic_wire_encode_pkt_hdr()
549 || !WPACKET_put_bytes_u8(pkt, hdr->dst_conn_id.id_len) in ossl_quic_wire_encode_pkt_hdr()
550 || !WPACKET_memcpy(pkt, hdr->dst_conn_id.id, in ossl_quic_wire_encode_pkt_hdr()
551 hdr->dst_conn_id.id_len) in ossl_quic_wire_encode_pkt_hdr()
552 || !WPACKET_put_bytes_u8(pkt, hdr->src_conn_id.id_len) in ossl_quic_wire_encode_pkt_hdr()
553 || !WPACKET_memcpy(pkt, hdr->src_conn_id.id, in ossl_quic_wire_encode_pkt_hdr()
554 hdr->src_conn_id.id_len)) in ossl_quic_wire_encode_pkt_hdr()
557 if (hdr->type == QUIC_PKT_TYPE_VERSION_NEG in ossl_quic_wire_encode_pkt_hdr()
558 || hdr->type == QUIC_PKT_TYPE_RETRY) { in ossl_quic_wire_encode_pkt_hdr()
559 if (hdr->len > 0 && !WPACKET_reserve_bytes(pkt, hdr->len, NULL)) in ossl_quic_wire_encode_pkt_hdr()
565 if (hdr->type == QUIC_PKT_TYPE_INITIAL) { in ossl_quic_wire_encode_pkt_hdr()
566 if (!WPACKET_quic_write_vlint(pkt, hdr->token_len) in ossl_quic_wire_encode_pkt_hdr()
567 || !WPACKET_memcpy(pkt, hdr->token, hdr->token_len)) in ossl_quic_wire_encode_pkt_hdr()
571 if (!WPACKET_quic_write_vlint(pkt, hdr->len + hdr->pn_len) in ossl_quic_wire_encode_pkt_hdr()
573 || !WPACKET_memcpy(pkt, hdr->pn, hdr->pn_len)) in ossl_quic_wire_encode_pkt_hdr()
577 if (hdr->len > 0 && !WPACKET_reserve_bytes(pkt, hdr->len, NULL)) in ossl_quic_wire_encode_pkt_hdr()
586 = WPACKET_get_curr(pkt) + hdr->len - ptrs->raw_sample; in ossl_quic_wire_encode_pkt_hdr()
594 const QUIC_PKT_HDR *hdr) in ossl_quic_wire_get_encoded_pkt_hdr_len() argument
599 if (hdr->partial in ossl_quic_wire_get_encoded_pkt_hdr_len()
600 || (hdr->type == QUIC_PKT_TYPE_1RTT in ossl_quic_wire_get_encoded_pkt_hdr_len()
601 && hdr->dst_conn_id.id_len != short_conn_id_len)) in ossl_quic_wire_get_encoded_pkt_hdr_len()
604 if (hdr->type == QUIC_PKT_TYPE_1RTT) { in ossl_quic_wire_get_encoded_pkt_hdr_len()
611 if (hdr->dst_conn_id.id_len != short_conn_id_len in ossl_quic_wire_get_encoded_pkt_hdr_len()
613 || hdr->pn_len < 1 || hdr->pn_len > 4) in ossl_quic_wire_get_encoded_pkt_hdr_len()
616 return 1 + short_conn_id_len + hdr->pn_len; in ossl_quic_wire_get_encoded_pkt_hdr_len()
619 if (hdr->dst_conn_id.id_len > QUIC_MAX_CONN_ID_LEN in ossl_quic_wire_get_encoded_pkt_hdr_len()
620 || hdr->src_conn_id.id_len > QUIC_MAX_CONN_ID_LEN) in ossl_quic_wire_get_encoded_pkt_hdr_len()
624 + 1 + hdr->dst_conn_id.id_len /* DCID Len, DCID */ in ossl_quic_wire_get_encoded_pkt_hdr_len()
625 + 1 + hdr->src_conn_id.id_len /* SCID Len, SCID */ in ossl_quic_wire_get_encoded_pkt_hdr_len()
628 if (ossl_quic_pkt_type_has_pn(hdr->type)) { in ossl_quic_wire_get_encoded_pkt_hdr_len()
629 if (hdr->pn_len < 1 || hdr->pn_len > 4) in ossl_quic_wire_get_encoded_pkt_hdr_len()
632 len += hdr->pn_len; in ossl_quic_wire_get_encoded_pkt_hdr_len()
635 if (hdr->type == QUIC_PKT_TYPE_INITIAL) { in ossl_quic_wire_get_encoded_pkt_hdr_len()
636 enclen = ossl_quic_vlint_encode_len(hdr->token_len); in ossl_quic_wire_get_encoded_pkt_hdr_len()
640 len += enclen + hdr->token_len; in ossl_quic_wire_get_encoded_pkt_hdr_len()
643 if (!ossl_quic_pkt_type_must_be_last(hdr->type)) { in ossl_quic_wire_get_encoded_pkt_hdr_len()
644 enclen = ossl_quic_vlint_encode_len(hdr->len + hdr->pn_len); in ossl_quic_wire_get_encoded_pkt_hdr_len()
804 const QUIC_PKT_HDR *hdr, in ossl_quic_validate_retry_integrity_tag() argument
810 if (hdr == NULL || hdr->len < QUIC_RETRY_INTEGRITY_TAG_LEN) in ossl_quic_validate_retry_integrity_tag()
814 hdr, client_initial_dcid, in ossl_quic_validate_retry_integrity_tag()
818 actual_tag = hdr->data + hdr->len - QUIC_RETRY_INTEGRITY_TAG_LEN; in ossl_quic_validate_retry_integrity_tag()
837 const QUIC_PKT_HDR *hdr, in ossl_quic_calculate_retry_integrity_tag() argument
850 if (hdr->type != QUIC_PKT_TYPE_RETRY || hdr->version == 0 in ossl_quic_calculate_retry_integrity_tag()
851 || hdr->len < QUIC_RETRY_INTEGRITY_TAG_LEN in ossl_quic_calculate_retry_integrity_tag()
852 || hdr->data == NULL in ossl_quic_calculate_retry_integrity_tag()
864 hdr2 = *hdr; in ossl_quic_calculate_retry_integrity_tag()
918 if (EVP_CipherUpdate(cctx, NULL, &l, hdr->data, in ossl_quic_calculate_retry_integrity_tag()
919 hdr->len - QUIC_RETRY_INTEGRITY_TAG_LEN) != 1) { in ossl_quic_calculate_retry_integrity_tag()