Commit 1edb85330e for openssl.org
commit 1edb85330e6f7add4a2c3615d0a2a1d999980646
Author: Andrew Dinh <andrewd@openssl.org>
Date: Mon Aug 31 22:13:34 2026 +0700
Migrate script_55 to script_59
Assisted-by: Claude:claude-sonnet-5
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Merge-date: Tue Sep 15 08:55:48 2026
Merged-from: https://github.com/openssl/openssl/pull/32619
diff --git a/test/quic_multistream_test.c b/test/quic_multistream_test.c
index 20d4554970..4039d58b30 100644
--- a/test/quic_multistream_test.c
+++ b/test/quic_multistream_test.c
@@ -2406,93 +2406,6 @@ static const struct script_op script_38[] = {
};
/* 39. Fault injection - NEW_CONN_ID with zero-len CID */
-static int script_39_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
- unsigned char *buf, size_t len)
-{
- int ok = 0;
- WPACKET wpkt;
- unsigned char frame_buf[64];
- size_t i, written;
- uint64_t seq_no = 0, retire_prior_to = 0;
- QUIC_CONN_ID new_cid = { 0 };
- QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(h->s_priv);
-
- if (hdr->type != QUIC_PKT_TYPE_1RTT)
- return 1;
-
- switch (h->inject_word1) {
- case 0:
- return 1;
- case 1:
- new_cid.id_len = 0;
- break;
- case 2:
- new_cid.id_len = 21;
- break;
- case 3:
- new_cid.id_len = 1;
- new_cid.id[0] = 0x55;
-
- seq_no = 0;
- retire_prior_to = 1;
- break;
- case 4:
- /* Use our actual CID so we don't break connectivity. */
- ossl_quic_channel_get_diag_local_cid(ch, &new_cid);
-
- seq_no = 2;
- retire_prior_to = 2;
- break;
- case 5:
- /*
- * Use a bogus CID which will need to be ignored if connectivity is to
- * be continued.
- */
- new_cid.id_len = 8;
- new_cid.id[0] = 0x55;
-
- seq_no = 1;
- retire_prior_to = 1;
- break;
- }
-
- if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
- sizeof(frame_buf), 0)))
- return 0;
-
- if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID))
- || !TEST_true(WPACKET_quic_write_vlint(&wpkt, seq_no)) /* seq no */
- || !TEST_true(WPACKET_quic_write_vlint(&wpkt, retire_prior_to)) /* retire prior to */
- || !TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id_len))) /* len */
- goto err;
-
- for (i = 0; i < new_cid.id_len && i < OSSL_NELEM(new_cid.id); ++i)
- if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id[i])))
- goto err;
-
- for (; i < new_cid.id_len; ++i)
- if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x55)))
- goto err;
-
- for (i = 0; i < QUIC_STATELESS_RESET_TOKEN_LEN; ++i)
- if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
- goto err;
-
- if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
- goto err;
-
- if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
- goto err;
-
- ok = 1;
-err:
- if (ok)
- WPACKET_finish(&wpkt);
- else
- WPACKET_cleanup(&wpkt);
- return ok;
-}
-
static const struct script_op script_39[] = {
/* test moved to test/radix/quic_tests.c */
OP_END
@@ -2590,155 +2503,31 @@ static const struct script_op script_54[] = {
/* 55. Fault injection - NEW_CONN_ID with >20 byte CID */
static const struct script_op script_55[] = {
- OP_S_SET_INJECT_PLAIN(script_39_inject_plain),
- OP_C_SET_ALPN("ossltest"),
- OP_C_CONNECT_WAIT(),
- OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE),
-
- OP_C_NEW_STREAM_BIDI(a, C_BIDI_ID(0)),
- OP_C_WRITE(a, "apple", 5),
- OP_S_BIND_STREAM_ID(a, C_BIDI_ID(0)),
- OP_S_READ_EXPECT(a, "apple", 5),
-
- OP_SET_INJECT_WORD(0, 2),
- OP_S_WRITE(a, "orange", 5),
-
- OP_C_EXPECT_CONN_CLOSE_INFO(OSSL_QUIC_ERR_FRAME_ENCODING_ERROR, 0, 0),
-
+ /* test moved to test/radix/quic_tests.c */
OP_END
};
/* 56. Fault injection - NEW_CONN_ID with seq no < retire prior to */
static const struct script_op script_56[] = {
- OP_S_SET_INJECT_PLAIN(script_39_inject_plain),
- OP_C_SET_ALPN("ossltest"),
- OP_C_CONNECT_WAIT(),
- OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE),
-
- OP_C_NEW_STREAM_BIDI(a, C_BIDI_ID(0)),
- OP_C_WRITE(a, "apple", 5),
- OP_S_BIND_STREAM_ID(a, C_BIDI_ID(0)),
- OP_S_READ_EXPECT(a, "apple", 5),
-
- OP_SET_INJECT_WORD(0, 3),
- OP_S_WRITE(a, "orange", 5),
-
- OP_C_EXPECT_CONN_CLOSE_INFO(OSSL_QUIC_ERR_FRAME_ENCODING_ERROR, 0, 0),
-
+ /* test moved to test/radix/quic_tests.c */
OP_END
};
/* 57. Fault injection - NEW_CONN_ID with lower seq so ignored */
static const struct script_op script_57[] = {
- OP_S_SET_INJECT_PLAIN(script_39_inject_plain),
- OP_C_SET_ALPN("ossltest"),
- OP_C_CONNECT_WAIT(),
- OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE),
-
- OP_C_NEW_STREAM_BIDI(a, C_BIDI_ID(0)),
- OP_C_WRITE(a, "apple", 5),
- OP_S_BIND_STREAM_ID(a, C_BIDI_ID(0)),
- OP_S_READ_EXPECT(a, "apple", 5),
-
- OP_SET_INJECT_WORD(0, 4),
- OP_S_WRITE(a, "orange", 5),
- OP_C_READ_EXPECT(a, "orange", 5),
-
- OP_C_WRITE(a, "Strawberry", 10),
- OP_S_READ_EXPECT(a, "Strawberry", 10),
-
- /*
- * Now we send a NEW_CONN_ID with a bogus CID. However the sequence number
- * is old so it should be ignored and we should still be able to
- * communicate.
- */
- OP_SET_INJECT_WORD(0, 5),
- OP_S_WRITE(a, "raspberry", 9),
- OP_C_READ_EXPECT(a, "raspberry", 9),
-
- OP_C_WRITE(a, "peach", 5),
- OP_S_READ_EXPECT(a, "peach", 5),
-
+ /* test moved to test/radix/quic_tests.c */
OP_END
};
/* 58. Fault injection - repeated HANDSHAKE_DONE */
-static int script_58_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
- unsigned char *buf, size_t len)
-{
- int ok = 0;
- unsigned char frame_buf[64];
- size_t written;
- WPACKET wpkt;
-
- if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
- return 1;
-
- if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
- sizeof(frame_buf), 0)))
- return 0;
-
- if (h->inject_word0 == 1) {
- if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE)))
- goto err;
- } else {
- /* Needless multi-byte encoding */
- if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x40))
- || !TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x1E)))
- goto err;
- }
-
- if (!TEST_true(WPACKET_get_total_written(&wpkt, &written)))
- goto err;
-
- if (!qtest_fault_prepend_frame(h->qtf, frame_buf, written))
- goto err;
-
- ok = 1;
-err:
- if (ok)
- WPACKET_finish(&wpkt);
- else
- WPACKET_cleanup(&wpkt);
- return ok;
-}
-
static const struct script_op script_58[] = {
- OP_S_SET_INJECT_PLAIN(script_58_inject_plain),
- OP_C_SET_ALPN("ossltest"),
- OP_C_CONNECT_WAIT(),
-
- OP_C_WRITE(DEFAULT, "apple", 5),
- OP_S_BIND_STREAM_ID(a, C_BIDI_ID(0)),
- OP_S_READ_EXPECT(a, "apple", 5),
-
- OP_SET_INJECT_WORD(1, 0),
-
- OP_S_WRITE(a, "orange", 6),
- OP_C_READ_EXPECT(DEFAULT, "orange", 6),
-
- OP_C_WRITE(DEFAULT, "Strawberry", 10),
- OP_S_READ_EXPECT(a, "Strawberry", 10),
-
+ /* test moved to test/radix/quic_tests.c */
OP_END
};
/* 59. Fault injection - multi-byte frame encoding */
static const struct script_op script_59[] = {
- OP_S_SET_INJECT_PLAIN(script_58_inject_plain),
- OP_C_SET_ALPN("ossltest"),
- OP_C_CONNECT_WAIT(),
-
- OP_C_WRITE(DEFAULT, "apple", 5),
- OP_S_BIND_STREAM_ID(a, C_BIDI_ID(0)),
- OP_S_READ_EXPECT(a, "apple", 5),
-
- OP_SET_INJECT_WORD(2, 0),
-
- OP_S_WRITE(a, "orange", 6),
-
- OP_C_EXPECT_CONN_CLOSE_INFO(OSSL_QUIC_ERR_PROTOCOL_VIOLATION, 0, 0),
-
+ /* test moved to test/radix/quic_tests.c */
OP_END
};
diff --git a/test/radix/quic_tests.c b/test/radix/quic_tests.c
index 8ecf6299b0..7791d9c28a 100644
--- a/test/radix/quic_tests.c
+++ b/test/radix/quic_tests.c
@@ -3372,24 +3372,163 @@ DEF_SCRIPT(script_54, "Fault injection - corrupted crypto stream data")
OP_EXPECT_CONN_CLOSE_INFO(C, OSSL_QUIC_ERR_CRYPTO_UNEXPECTED_MESSAGE, 0, 0);
}
-DEF_SCRIPT(script_55, "place holder for multistrem script_55")
+/* 55. Fault injection - NEW_CONN_ID with >20 byte CID */
+DEF_SCRIPT(script_55, "Fault injection - NEW_CONN_ID with >20 byte CID")
{
+ OP_SIMPLE_PAIR_CONN_ND();
+ OP_ACCEPT_CONN_WAIT_ND(L, S, 0);
+
+ OP_SET_INJECT_PLAIN(S, inject_new_conn_id_plain);
+
+ OP_NEW_STREAM(C, Ca, 0 /* bidirectional */);
+ OP_WRITE(Ca, "apple", 5);
+ OP_ACCEPT_STREAM_WAIT(S, Sa, 0);
+ OP_READ_EXPECT(Sa, "apple", 5);
+
+ OP_ENGINE_TICK_DISABLE(S);
+ OP_SET_INJECT_WORD(0, 2);
+ OP_WRITE(Sa, "orange", 5);
+ OP_ENGINE_TICK_ENABLE(S);
+
+ OP_EXPECT_CONN_CLOSE_INFO(C, OSSL_QUIC_ERR_FRAME_ENCODING_ERROR, 0, 0);
+}
+
+/* 56. Fault injection - NEW_CONN_ID with seq no < retire prior to */
+DEF_SCRIPT(script_56, "Fault injection - NEW_CONN_ID with seq no < retire prior to")
+{
+ OP_SIMPLE_PAIR_CONN_ND();
+ OP_ACCEPT_CONN_WAIT_ND(L, S, 0);
+
+ OP_SET_INJECT_PLAIN(S, inject_new_conn_id_plain);
+
+ OP_NEW_STREAM(C, Ca, 0 /* bidirectional */);
+ OP_WRITE(Ca, "apple", 5);
+ OP_ACCEPT_STREAM_WAIT(S, Sa, 0);
+ OP_READ_EXPECT(Sa, "apple", 5);
+
+ OP_ENGINE_TICK_DISABLE(S);
+ OP_SET_INJECT_WORD(0, 3);
+ OP_WRITE(Sa, "orange", 5);
+ OP_ENGINE_TICK_ENABLE(S);
+
+ OP_EXPECT_CONN_CLOSE_INFO(C, OSSL_QUIC_ERR_FRAME_ENCODING_ERROR, 0, 0);
}
-DEF_SCRIPT(script_56, "place holder for multistrem script_56")
+/* 57. Fault injection - NEW_CONN_ID with lower seq so ignored */
+DEF_SCRIPT(script_57, "Fault injection - NEW_CONN_ID with lower seq so ignored")
{
+ OP_SIMPLE_PAIR_CONN_ND();
+ OP_ACCEPT_CONN_WAIT_ND(L, S, 0);
+
+ OP_SET_INJECT_PLAIN(S, inject_new_conn_id_plain);
+
+ OP_NEW_STREAM(C, Ca, 0 /* bidirectional */);
+ OP_WRITE(Ca, "apple", 5);
+ OP_ACCEPT_STREAM_WAIT(S, Sa, 0);
+ OP_READ_EXPECT(Sa, "apple", 5);
+
+ OP_ENGINE_TICK_DISABLE(S);
+ OP_SET_INJECT_WORD(0, 4);
+ OP_WRITE(Sa, "orange", 5);
+ OP_ENGINE_TICK_ENABLE(S);
+ OP_READ_EXPECT(Ca, "orange", 5);
+
+ OP_WRITE(Ca, "Strawberry", 10);
+ OP_READ_EXPECT(Sa, "Strawberry", 10);
+
+ /*
+ * Now we send a NEW_CONN_ID with a bogus CID. However the sequence number
+ * is old so it should be ignored and we should still be able to
+ * communicate.
+ */
+ OP_ENGINE_TICK_DISABLE(S);
+ OP_SET_INJECT_WORD(0, 5);
+ OP_WRITE(Sa, "raspberry", 9);
+ OP_ENGINE_TICK_ENABLE(S);
+ OP_READ_EXPECT(Ca, "raspberry", 9);
+
+ OP_WRITE(Ca, "peach", 5);
+ OP_READ_EXPECT(Sa, "peach", 5);
}
-DEF_SCRIPT(script_57, "place holder for multistrem script_57")
+/* 58. Fault injection - repeated HANDSHAKE_DONE */
+static int script_58_inject_plain(RADIX_FAULT *fault, QUIC_PKT_HDR *hdr,
+ unsigned char *buf, size_t len)
{
+ int ok = 0;
+ unsigned char frame_buf[64];
+ size_t written;
+ WPACKET wpkt;
+
+ if (fault->word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
+ return 1;
+
+ if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
+ sizeof(frame_buf), 0)))
+ return 0;
+
+ if (fault->word0 == 1) {
+ if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE)))
+ goto err;
+ } else {
+ /* Needless multi-byte encoding */
+ if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x40))
+ || !TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x1E)))
+ goto err;
+ }
+
+ if (!TEST_true(WPACKET_get_total_written(&wpkt, &written))
+ || !radix_fault_prepend_frame(fault, frame_buf, written))
+ goto err;
+
+ ok = 1;
+err:
+ if (ok)
+ WPACKET_finish(&wpkt);
+ else
+ WPACKET_cleanup(&wpkt);
+ return ok;
}
-DEF_SCRIPT(script_58, "place holder for multistrem script_58")
+DEF_SCRIPT(script_58, "Fault injection - repeated HANDSHAKE_DONE")
{
+ OP_SIMPLE_PAIR_CONN();
+ OP_ACCEPT_CONN_WAIT(L, S, 0);
+
+ OP_SET_INJECT_PLAIN(S, script_58_inject_plain);
+
+ OP_WRITE(C, "apple", 5);
+ OP_ACCEPT_STREAM_WAIT(S, Sa, 0);
+ OP_READ_EXPECT(Sa, "apple", 5);
+
+ OP_ENGINE_TICK_DISABLE(S);
+ OP_SET_INJECT_WORD(1, 0);
+ OP_WRITE(Sa, "orange", 6);
+ OP_ENGINE_TICK_ENABLE(S);
+ OP_READ_EXPECT(C, "orange", 6);
+
+ OP_WRITE(C, "Strawberry", 10);
+ OP_READ_EXPECT(Sa, "Strawberry", 10);
}
-DEF_SCRIPT(script_59, "place holder for multistrem script_59")
+/* 59. Fault injection - multi-byte frame encoding */
+DEF_SCRIPT(script_59, "Fault injection - multi-byte frame encoding")
{
+ OP_SIMPLE_PAIR_CONN();
+ OP_ACCEPT_CONN_WAIT(L, S, 0);
+
+ OP_SET_INJECT_PLAIN(S, script_58_inject_plain);
+
+ OP_WRITE(C, "apple", 5);
+ OP_ACCEPT_STREAM_WAIT(S, Sa, 0);
+ OP_READ_EXPECT(Sa, "apple", 5);
+
+ OP_ENGINE_TICK_DISABLE(S);
+ OP_SET_INJECT_WORD(2, 0);
+ OP_WRITE(Sa, "orange", 6);
+ OP_ENGINE_TICK_ENABLE(S);
+
+ OP_EXPECT_CONN_CLOSE_INFO(C, OSSL_QUIC_ERR_PROTOCOL_VIOLATION, 0, 0);
}
DEF_SCRIPT(script_60, "place holder for multistrem script_60")