diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2019-05-11 16:30:24 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2019-05-11 16:30:24 +0000 |
commit | 8418aabe4f347e87b8918a840afc2e37638b61a4 (patch) | |
tree | 089751860d2b180bbc48d257841bb0bde2e10884 /regress | |
parent | 30ce14364c76e910724541dd41455566ceb351e5 (diff) |
Add support for IKEv2 Message Fragmentation as defined in RFC 7383.
ok sthen@
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sbin/iked/parser/common.c | 7 | ||||
-rw-r--r-- | regress/sbin/iked/parser/test_parser_fuzz.c | 65 |
2 files changed, 70 insertions, 2 deletions
diff --git a/regress/sbin/iked/parser/common.c b/regress/sbin/iked/parser/common.c index 904af476b3f..b0066e41683 100644 --- a/regress/sbin/iked/parser/common.c +++ b/regress/sbin/iked/parser/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.1 2017/05/29 20:59:28 markus Exp $ */ +/* $OpenBSD: common.c,v 1.2 2019/05/11 16:30:23 patrick Exp $ */ /* * A bunch of stub functions so we can compile and link ikev2_pld.c * in a standalone program for testing purposes. @@ -166,6 +166,11 @@ config_add_proposal(struct iked_proposals *head, u_int id, u_int proto) return (NULL); } +void config_free_fragments(struct iked_frag *frag) +{ + return; +} + int ikev2_send_informational(struct iked *env, struct iked_message *msg) { diff --git a/regress/sbin/iked/parser/test_parser_fuzz.c b/regress/sbin/iked/parser/test_parser_fuzz.c index 3d0d86c6263..2c85e8b3906 100644 --- a/regress/sbin/iked/parser/test_parser_fuzz.c +++ b/regress/sbin/iked/parser/test_parser_fuzz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_parser_fuzz.c,v 1.2 2018/03/22 21:11:49 patrick Exp $ */ +/* $OpenBSD: test_parser_fuzz.c,v 1.3 2019/05/11 16:30:23 patrick Exp $ */ /* * Fuzz tests for payload parsing * @@ -183,6 +183,50 @@ u_int8_t ts_pld[] = { 0xac, 0x28, 0x7d, 0x00, 0xac, 0x28, 0x7d, 0xff }; +uint8_t skf_1of1_pld[] = { + 0x21, 0x00, 0x01, 0x98, 0x00, 0x01, 0x00, 0x01, 0x14, 0x77, + 0x25, 0x7b, 0x82, 0xc0, 0xdb, 0x0b, 0x24, 0x36, 0x36, 0x13, + 0x36, 0xe4, 0x99, 0xad, 0xf5, 0xaf, 0x26, 0x6f, 0x47, 0xd2, + 0x0d, 0x65, 0xe1, 0xa8, 0xcb, 0x35, 0x1e, 0x53, 0xce, 0x6d, + 0x8e, 0xf9, 0xe4, 0x51, 0xe3, 0x27, 0x10, 0x43, 0x38, 0x84, + 0x54, 0x1d, 0x7a, 0x1a, 0x89, 0x34, 0x06, 0xb3, 0x62, 0x86, + 0x98, 0x3b, 0x39, 0x91, 0x6e, 0xe8, 0x65, 0x3e, 0x31, 0xa8, + 0x08, 0xfe, 0x83, 0x56, 0x30, 0xd3, 0xe0, 0xfd, 0x73, 0x92, + 0x85, 0x2d, 0xae, 0x1d, 0x7d, 0xdb, 0x47, 0x05, 0x57, 0xe7, + 0x8e, 0xc5, 0xa5, 0x1b, 0x0e, 0x85, 0x1f, 0x12, 0x6d, 0xe6, + 0xdb, 0x3a, 0x3e, 0x99, 0xd1, 0x23, 0x41, 0xa4, 0x1c, 0x46, + 0x38, 0xd1, 0xa8, 0x84, 0x96, 0x13, 0xdb, 0x2a, 0x1d, 0x3b, + 0xb8, 0xd2, 0x04, 0xb3, 0x0d, 0xb4, 0x71, 0x90, 0xdb, 0xf6, + 0x2d, 0x60, 0x01, 0xc2, 0xb2, 0x89, 0xbd, 0xe9, 0x95, 0x7b, + 0x53, 0xa4, 0x94, 0x7e, 0x12, 0xe9, 0x5f, 0xfc, 0x51, 0x17, + 0x94, 0x3e, 0xba, 0xc2, 0xa5, 0x4d, 0x3a, 0x4d, 0x4b, 0x95, + 0x6d, 0x91, 0xc2, 0xb0, 0x2d, 0xb7, 0x24, 0xe8, 0x3b, 0xbd, + 0xe0, 0xc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, 0xbe, 0x6a, 0x3d, 0x76, 0xb6, 0xe2, 0xa5, 0xa7, + 0x96, 0x68, 0xeb, 0x91, 0xee, 0x02, 0xfc, 0xe4, 0x01, 0xc3, + 0x24, 0xda, 0x4c, 0xff, 0x10, 0x27, 0x78, 0xb0, 0x0b, 0x55, + 0x5c, 0xce, 0x62, 0x7d, 0x33, 0x2b, 0x25, 0x99, 0xaa, 0x99, + 0xea, 0xa3, 0x1d, 0xd8, 0x2b, 0x57, 0xb5, 0xe4, 0x04, 0x21, + 0x75, 0xd9, 0xc4, 0xd0, 0x3d, 0xa1, 0xa5, 0x8f +}; + u_int8_t sk_pld[] = { 0x21, 0x00, 0x01, 0x94, 0x14, 0x77, 0x25, 0x7b, 0x82, 0xc0, 0xdb, 0x0b, 0x24, 0x36, 0x36, 0x13, 0x36, 0xe4, 0x99, 0xad, @@ -454,6 +498,25 @@ parser_fuzz_tests(void) perform_test(fuzz); TEST_DONE(); + TEST_START("fuzz skf_1of1 payload"); + ASSERT_PTR_NE(data = ibuf_new(cookies, sizeof(cookies)), NULL); + ASSERT_INT_EQ(ibuf_add(data, genhdr, sizeof(genhdr)), 0); + ASSERT_INT_EQ(ibuf_add(data, skf_1of1_pld, sizeof(skf_1of1_pld)), 0); + set_length(ibuf_data(data), ibuf_size(data)); + set_nextpayload(ibuf_data(data), IKEV2_PAYLOAD_SKF); + print_hex(ibuf_data(data), 0, ibuf_size(data)); + prepare_header(&hdr, data); + prepare_message(&msg, data); + ASSERT_INT_EQ(ikev2_pld_parse(NULL, &hdr, &msg, 0), 0); + fuzz = fuzz_begin(FUZZ_1_BIT_FLIP | FUZZ_2_BIT_FLIP | + FUZZ_1_BYTE_FLIP | FUZZ_2_BYTE_FLIP | + FUZZ_TRUNCATE_START | FUZZ_TRUNCATE_END | + FUZZ_BASE64, + ibuf_data(data), ibuf_size(data)); + ibuf_free(data); + perform_test(fuzz); + TEST_DONE(); + TEST_START("fuzz sa payload"); ASSERT_PTR_NE(data = ibuf_new(cookies, sizeof(cookies)), NULL); ASSERT_INT_EQ(ibuf_add(data, genhdr, sizeof(genhdr)), 0); |