Remaster tls parser for quic crypto

This commit is contained in:
Vadim Vetrov
2025-01-02 19:02:21 +03:00
parent fa7fe5294d
commit e5153e9186
6 changed files with 368 additions and 127 deletions

View File

@@ -41,6 +41,9 @@
#define QUIC_RETRY_TYPE_V2 0b00
#define quic_convtype_v2(type) (((type) + 1) & 0b11)
#define QUIC_FRAME_CRYPTO 0x06
#define QUIC_FRAME_PADDING 0x00
#define QUIC_V1 1 // RFC 9000
#define QUIC_V2 0x6b3343cf // RFC 9369
@@ -130,6 +133,8 @@ int quic_parse_data(const uint8_t *raw_payload, uint32_t raw_payload_len,
*
* \mlen Used to signal about variable length and validate left length
* in the buffer.
*
* On error/buffer overflow mlen set to 0, otherwise it is higher
*/
uint64_t quic_parse_varlength(const uint8_t *variable, uint64_t *mlen);
@@ -161,6 +166,18 @@ int64_t quic_get_version(const struct quic_lhdr *qch);
*/
int quic_check_is_initial(const struct quic_lhdr *qch);
struct quic_frame_crypto {
uint64_t offset;
uint64_t payload_length;
const uint8_t *payload;
};
/**
* Parses quic crypto frame
* Returns parsed size or -EINVAL on error
*/
ssize_t quic_parse_crypto(struct quic_frame_crypto *crypto_frame,
const uint8_t *frame, uint64_t flen);
/**
* Parses QUIC initial message header.