Skip to content

Commit cfbc8de

Browse files
lukacanPavel Siska
authored andcommitted
QUIC: Version 2 added
1 parent b3f4d2f commit cfbc8de

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

process/quic.cpp

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ QUICPlugin::QUICPlugin()
155155
quic_ptr = nullptr;
156156

157157

158-
can_parse = false;
159158

160159
is_version2 = false;
161160

@@ -531,9 +530,19 @@ bool QUICPlugin::quic_derive_secrets(uint8_t *secret)
531530

532531

533532
// expand label for other initial secrets
534-
expand_label("tls13 ", "quic key", NULL, 0, 16, quic_key, len_quic_key);
535-
expand_label("tls13 ", "quic iv", NULL, 0, 12, quic_iv, len_quic_iv);
536-
expand_label("tls13 ", "quic hp", NULL, 0, 16, quic_hp, len_quic_hp);
533+
if(!is_version2)
534+
{
535+
expand_label("tls13 ", "quic key", NULL, 0, 16, quic_key, len_quic_key);
536+
expand_label("tls13 ", "quic iv", NULL, 0, 12, quic_iv, len_quic_iv);
537+
expand_label("tls13 ", "quic hp", NULL, 0, 16, quic_hp, len_quic_hp);
538+
}
539+
else if (is_version2)
540+
{
541+
expand_label("tls13 ", "quicv2 key", NULL, 0, 16, quic_key, len_quic_key);
542+
expand_label("tls13 ", "quicv2 iv", NULL, 0, 12, quic_iv, len_quic_iv);
543+
expand_label("tls13 ", "quicv2 hp", NULL, 0, 16, quic_hp, len_quic_hp);
544+
}
545+
537546

538547

539548
// use HKDF-Expand to derive other secrets
@@ -1008,7 +1017,7 @@ bool QUICPlugin::handle_version(RecordExtQUIC * rec)
10081017
uint32_t version = quic_h1->version;
10091018
version = ntohl(version);
10101019
rec->quic_version = version;
1011-
DEBUG_MSG("version %d\n",version);
1020+
DEBUG_MSG("version %02x\n",version);
10121021

10131022

10141023

@@ -1072,30 +1081,22 @@ static const uint8_t hanshake_salt_draft_t51[SALT_LENGTH] = {
10721081
if (version == 0x00000000) {
10731082
DEBUG_MSG("Error, version negotiation\n");
10741083
return false;
1075-
} else if (version == 0x00000001 && !is_version2){
1084+
} else if (!is_version2 && version == 0x00000001){
10761085
salt = handshake_salt_v1;
1077-
can_parse = true;
1078-
} else if (quic_check_version(version, 9) && !is_version2) {
1086+
} else if (!is_version2 && quic_check_version(version, 9)) {
10791087
salt = handshake_salt_draft_7;
1080-
can_parse = true;
1081-
} else if (quic_check_version(version, 16) && !is_version2) {
1088+
} else if (!is_version2 && quic_check_version(version, 16)) {
10821089
salt = handshake_salt_draft_10;
1083-
can_parse = true;
1084-
} else if (quic_check_version(version, 20) && !is_version2) {
1090+
} else if (!is_version2 && quic_check_version(version, 20)) {
10851091
salt = handshake_salt_draft_17;
1086-
can_parse = true;
1087-
} else if (quic_check_version(version, 22) && !is_version2) {
1092+
} else if (!is_version2 && quic_check_version(version, 22)) {
10881093
salt = handshake_salt_draft_21;
1089-
can_parse = true;
1090-
} else if (quic_check_version(version, 28) && !is_version2) {
1094+
} else if (!is_version2 && quic_check_version(version, 28)) {
10911095
salt = handshake_salt_draft_23;
1092-
can_parse = true;
1093-
} else if (quic_check_version(version, 32) && !is_version2) {
1096+
} else if (!is_version2 && quic_check_version(version, 32)) {
10941097
salt = handshake_salt_draft_29;
1095-
can_parse = true;
1096-
} else if (quic_check_version(version, 100) && is_version2) {
1098+
} else if (is_version2 && quic_check_version(version, 100)) {
10971099
salt = handshake_salt_v2;
1098-
can_parse = true;
10991100
} else {
11001101
DEBUG_MSG("Error, version not supported\n");
11011102
return false;
@@ -1249,6 +1250,7 @@ bool QUICPlugin::quic_check_initial(uint8_t packet0)
12491250
}
12501251
else
12511252
{
1253+
// udp does not carry quic initial version 1 or version 2
12521254
return false;
12531255
}
12541256

@@ -1290,12 +1292,12 @@ bool QUICPlugin::process_quic(RecordExtQUIC *quic_data, const Packet &pkt)
12901292
DEBUG_MSG("Error, payload decryption failed (client side)\n");
12911293
return false;
12921294
}
1293-
if (can_parse && !quic_assemble())
1295+
if (!quic_assemble())
12941296
{
12951297
DEBUG_MSG("Error, reassembling of crypto frames failed (client side)\n");
12961298
return false;
12971299
}
1298-
if (can_parse && !parse_tls(quic_data))
1300+
if (!parse_tls(quic_data))
12991301
{
13001302
DEBUG_MSG("SNI and User Agent Extraction failed\n");
13011303
return false;

process/quic.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ class QUICPlugin : public ProcessPlugin
317317
Initial_Secrets initial_secrets;
318318

319319

320-
bool can_parse;
321320
bool is_version2;
322321
};
323322

0 commit comments

Comments
 (0)