Skip to content

Commit c888e3a

Browse files
alagoutteLekensteyn
authored andcommitted
QUIC: Update Retry secret and nonce (draft-29)
Ping-Bug: 13881 Change-Id: I86d647ca693652a4289dc6034d7469e316f37344 Reviewed-on: https://code.wireshark.org/review/37464 Petri-Dish: Alexis La Goutte <[email protected]> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <[email protected]>
1 parent 4015992 commit c888e3a

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

epan/dissectors/packet-quic.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,17 +1921,24 @@ quic_process_payload(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree _U_
19211921

19221922
#ifdef HAVE_LIBGCRYPT_AEAD
19231923
static void
1924-
quic_verify_retry_token(tvbuff_t *tvb, quic_packet_info_t *quic_packet, const quic_cid_t *odcid)
1924+
quic_verify_retry_token(tvbuff_t *tvb, quic_packet_info_t *quic_packet, const quic_cid_t *odcid, guint32 version)
19251925
{
19261926
/*
19271927
* Verify the Retry Integrity Tag using the fixed key from
1928-
* https://tools.ietf.org/html/draft-ietf-quic-tls-25#section-5.8
1928+
* https://tools.ietf.org/html/draft-ietf-quic-tls-29#section-5.8
19291929
*/
1930-
static const guint8 key[] = {
1930+
static const guint8 key_draft_29[] = {
1931+
0xcc, 0xce, 0x18, 0x7e, 0xd0, 0x9a, 0x09, 0xd0,
1932+
0x57, 0x28, 0x15, 0x5a, 0x6c, 0xb9, 0x6b, 0xe1
1933+
};
1934+
static const guint8 nonce_draft_29[] = {
1935+
0xe5, 0x49, 0x30, 0xf9, 0x7f, 0x21, 0x36, 0xf0, 0x53, 0x0a, 0x8c, 0x1c
1936+
};
1937+
static const guint8 key_draft_25[] = {
19311938
0x4d, 0x32, 0xec, 0xdb, 0x2a, 0x21, 0x33, 0xc8,
19321939
0x41, 0xe4, 0x04, 0x3d, 0xf2, 0x7d, 0x44, 0x30,
19331940
};
1934-
static const guint8 nonce[] = {
1941+
static const guint8 nonce_draft_25[] = {
19351942
0x4d, 0x16, 0x11, 0xd0, 0x55, 0x13, 0xa5, 0x52, 0xc5, 0x87, 0xd5, 0x75,
19361943
};
19371944
gcry_cipher_hd_t h = NULL;
@@ -1942,9 +1949,17 @@ quic_verify_retry_token(tvbuff_t *tvb, quic_packet_info_t *quic_packet, const qu
19421949

19431950
err = gcry_cipher_open(&h, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_GCM, 0);
19441951
DISSECTOR_ASSERT_HINT(err == 0, "create cipher");
1945-
err = gcry_cipher_setkey(h, key, sizeof(key));
1952+
if (is_quic_draft_max(version, 28)) {
1953+
err = gcry_cipher_setkey(h, key_draft_25, sizeof(key_draft_25));
1954+
} else {
1955+
err = gcry_cipher_setkey(h, key_draft_29, sizeof(key_draft_29));
1956+
}
19461957
DISSECTOR_ASSERT_HINT(err == 0, "set key");
1947-
err = gcry_cipher_setiv(h, nonce, sizeof(nonce));
1958+
if (is_quic_draft_max(version, 28)) {
1959+
err = gcry_cipher_setiv(h, nonce_draft_25, sizeof(nonce_draft_25));
1960+
} else {
1961+
err = gcry_cipher_setiv(h, nonce_draft_29, sizeof(nonce_draft_29));
1962+
}
19481963
DISSECTOR_ASSERT_HINT(err == 0, "set nonce");
19491964
G_STATIC_ASSERT(sizeof(odcid->len) == 1);
19501965
err = gcry_cipher_authenticate(h, odcid, 1 + odcid->len);
@@ -2080,7 +2095,7 @@ dissect_quic_retry_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tr
20802095
if (!PINFO_FD_VISITED(pinfo) && odcid) {
20812096
// Skip validation if the Initial Packet is unknown, for example due
20822097
// to packet loss in the capture file.
2083-
quic_verify_retry_token(tvb, quic_packet, odcid);
2098+
quic_verify_retry_token(tvb, quic_packet, odcid, version);
20842099
}
20852100
#else
20862101
(void)odcid;

0 commit comments

Comments
 (0)