diff options
author | Tomas Mraz <tomas@openssl.org> | 2023-05-05 17:40:55 +0200 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-05-17 14:04:18 +0100 |
commit | c301149ad43ee2c611e7b8d4f2826f524f3385aa (patch) | |
tree | 70f643f6eff5c47ba4d56ef46b411d76a821ebad /test | |
parent | eff046524b970243196d4622d20ffb8e0aeb208b (diff) |
Fix test cases using NEW_CONNECTION_ID frame
seq_id must be >= retire_prior_to.
Add negative testcase.
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20892)
Diffstat (limited to 'test')
-rw-r--r-- | test/quic_txp_test.c | 8 | ||||
-rw-r--r-- | test/quic_wire_test.c | 53 |
2 files changed, 54 insertions, 7 deletions
diff --git a/test/quic_txp_test.c b/test/quic_txp_test.c index e01156d156..3c9804d2ab 100644 --- a/test/quic_txp_test.c +++ b/test/quic_txp_test.c @@ -394,8 +394,8 @@ static int schedule_cfq_new_conn_id(struct helper *h) size_t l = 0; OSSL_QUIC_FRAME_NEW_CONN_ID ncid = {0}; - ncid.seq_num = 1234; - ncid.retire_prior_to = 2345; + ncid.seq_num = 2345; + ncid.retire_prior_to = 1234; ncid.conn_id = cid_1; memcpy(ncid.stateless_reset_token, reset_token_1, sizeof(reset_token_1)); @@ -432,8 +432,8 @@ err: static int check_cfq_new_conn_id(struct helper *h) { - if (!TEST_uint64_t_eq(h->frame.new_conn_id.seq_num, 1234) - || !TEST_uint64_t_eq(h->frame.new_conn_id.retire_prior_to, 2345) + if (!TEST_uint64_t_eq(h->frame.new_conn_id.seq_num, 2345) + || !TEST_uint64_t_eq(h->frame.new_conn_id.retire_prior_to, 1234) || !TEST_mem_eq(&h->frame.new_conn_id.conn_id, sizeof(cid_1), &cid_1, sizeof(cid_1)) || !TEST_mem_eq(&h->frame.new_conn_id.stateless_reset_token, diff --git a/test/quic_wire_test.c b/test/quic_wire_test.c index ceb273e7b6..d6eef296a3 100644 --- a/test/quic_wire_test.c +++ b/test/quic_wire_test.c @@ -714,8 +714,8 @@ static const unsigned char encode_case_16_conn_id[] = { }; static const OSSL_QUIC_FRAME_NEW_CONN_ID encode_case_16_f = { - 0x1234, 0x9781, + 0x1234, { 0x4, {0x33, 0x44, 0x55, 0x66} @@ -745,10 +745,10 @@ static int encode_case_16_dec(PACKET *pkt, ossl_ssize_t fail) if (fail >= 0) return 1; - if (!TEST_uint64_t_eq(f.seq_num, 0x1234)) + if (!TEST_uint64_t_eq(f.seq_num, 0x9781)) return 0; - if (!TEST_uint64_t_eq(f.retire_prior_to, 0x9781)) + if (!TEST_uint64_t_eq(f.retire_prior_to, 0x1234)) return 0; if (!TEST_uint64_t_eq(f.conn_id.id_len, sizeof(encode_case_16_conn_id))) @@ -769,6 +769,52 @@ static int encode_case_16_dec(PACKET *pkt, ossl_ssize_t fail) static const unsigned char encode_case_16_expect[] = { 0x18, /* Type */ + 0x80, 0x00, 0x97, 0x81, /* Sequence Number */ + 0x52, 0x34, /* Retire Prior To */ + 0x04, /* Connection ID Length */ + 0x33, 0x44, 0x55, 0x66, /* Connection ID */ + 0xde, 0x06, 0xcb, 0x76, 0x5d, 0xb1, 0xa7, 0x71, /* Stateless Reset Token */ + 0x78, 0x09, 0xbb, 0xe8, 0x50, 0x19, 0x12, 0x9a +}; + +/* 16b. NEW_CONNECTION_ID seq_num < retire_prior_to */ +static const OSSL_QUIC_FRAME_NEW_CONN_ID encode_case_16b_f = { + 0x1234, + 0x9781, + { + 0x4, + {0x33, 0x44, 0x55, 0x66} + }, + { + 0xde, 0x06, 0xcb, 0x76, 0x5d, 0xb1, 0xa7, 0x71, + 0x78, 0x09, 0xbb, 0xe8, 0x50, 0x19, 0x12, 0x9a + } +}; + +static int encode_case_16b_enc(WPACKET *pkt) +{ + if (!TEST_int_eq(ossl_quic_wire_encode_frame_new_conn_id(pkt, + &encode_case_16b_f), 1)) + return 0; + + return 1; +} + +static int encode_case_16b_dec(PACKET *pkt, ossl_ssize_t fail) +{ + OSSL_QUIC_FRAME_NEW_CONN_ID f = {0}; + + if (!TEST_int_eq(ossl_quic_wire_decode_frame_new_conn_id(pkt, &f), 0)) + return 0; + + if (!TEST_true(PACKET_forward(pkt, PACKET_remaining(pkt)))) + return 0; + + return 1; +} + +static const unsigned char encode_case_16b_expect[] = { + 0x18, /* Type */ 0x52, 0x34, /* Sequence Number */ 0x80, 0x00, 0x97, 0x81, /* Retire Prior To */ 0x04, /* Connection ID Length */ @@ -1137,6 +1183,7 @@ static const struct encode_test_case encode_cases[] = { ENCODE_CASE(14) ENCODE_CASE(15) ENCODE_CASE(16) + ENCODE_CASE(16b) ENCODE_CASE(17) ENCODE_CASE(18) ENCODE_CASE(19) |