test: condition out code that relies on CHACHA.

Run checker does a no-chacha build and tests fail because it can't be fetched.

Fixes #19363

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19366)
This commit is contained in:
Pauli 2022-10-10 09:01:42 +11:00 committed by Matt Caswell
parent 6e2f15ca93
commit 681c461910
2 changed files with 27 additions and 3 deletions

View File

@ -451,6 +451,7 @@ static int test_bio_dgram(int idx)
bio_dgram_cases[idx].local);
}
# if !defined(OPENSSL_NO_CHACHA)
static int random_data(const uint32_t *key, uint8_t *data, size_t data_len, size_t offset)
{
int ret = 0, outl;
@ -746,7 +747,7 @@ err:
BIO_ADDR_free(addr4);
return testresult;
}
# endif /* !defined(OPENSSL_NO_CHACHA) */
#endif /* !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK) */
int setup_tests(void)
@ -758,7 +759,9 @@ int setup_tests(void)
#if !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK)
ADD_ALL_TESTS(test_bio_dgram, OSSL_NELEM(bio_dgram_cases));
# if !defined(OPENSSL_NO_CHACHA)
ADD_TEST(test_bio_dgram_pair);
# endif
#endif
return 1;

View File

@ -167,6 +167,7 @@ static const struct rx_test_op rx_script_1[] = {
};
/* 2. RFC 9001 - A.5 ChaCha20-Poly1305 Short Header Packet */
#ifndef OPENSSL_NO_CHACHA
static const unsigned char rx_script_2_in[] = {
0x4c, 0xfe, 0x41, 0x89, 0x65, 0x5e, 0x5c, 0xd5, 0x5c, 0x41, 0xf6, 0x90,
0x80, 0x57, 0x5d, 0x79, 0x99, 0xc2, 0x5a, 0x5b, 0xfb
@ -199,6 +200,7 @@ static const struct rx_test_op rx_script_2[] = {
RX_OP_CHECK_NO_PKT()
RX_OP_END
};
#endif /* !defined(OPENSSL_NO_CHACHA) */
/* 3. Real World - Version Negotiation Response */
static const unsigned char rx_script_3_in[] = {
@ -1023,6 +1025,7 @@ static const struct rx_test_op rx_script_6[] = {
* 7. Real World - S2C Multiple Packets
* - Initial, Handshake, 1-RTT (ChaCha20-Poly1305)
*/
#ifndef OPENSSL_NO_CHACHA
static const QUIC_CONN_ID rx_script_7_c2s_init_dcid = {
4, {0xfa, 0x5d, 0xd6, 0x80}
};
@ -1375,6 +1378,7 @@ static const struct rx_test_op rx_script_7[] = {
RX_OP_END
};
#endif /* !defined(OPENSSL_NO_CHACHA) */
/*
* 8. Real World - S2C Multiple Packets with Peer Initiated Key Phase Update
@ -1651,12 +1655,16 @@ static const struct rx_test_op rx_script_8[] = {
static const struct rx_test_op *rx_scripts[] = {
rx_script_1,
#ifndef OPENSSL_NO_CHACHA
rx_script_2,
#endif
rx_script_3,
rx_script_4,
rx_script_5,
rx_script_6,
#ifndef OPENSSL_NO_CHACHA
rx_script_7,
#endif
rx_script_8
};
@ -2600,7 +2608,16 @@ static int test_wire_pkt_hdr_actual(int tidx, int repeat, int cipher,
hpr_key_len = 32;
break;
case 2:
/*
* In a build without CHACHA, we rerun the AES 256 tests.
* Removing all dependence on CHACHA is more difficult and these
* tests are fast enough.
*/
#ifndef OPENSSL_NO_CHACHA
hpr_cipher_id = QUIC_HDR_PROT_CIPHER_CHACHA;
#else
hpr_cipher_id = QUIC_HDR_PROT_CIPHER_AES_256;
#endif
hpr_key_len = 32;
break;
default:
@ -2770,9 +2787,9 @@ static int test_hdr_prot_stats(void)
*/
for (cipher = 0; cipher < HPR_CIPHER_COUNT; ++cipher)
for (i = 0; i < OSSL_NELEM(counts_u[0]); ++i) {
if (!TEST_true(counts_u[cipher][i]))
if (!TEST_uint_gt(counts_u[cipher][i], 0))
goto err;
if (!TEST_true(counts_c[cipher][i]))
if (!TEST_uint_gt(counts_c[cipher][i], 0))
goto err;
}
@ -3080,6 +3097,7 @@ static const struct tx_test_op tx_script_2[] = {
TX_OP_END
};
#ifndef OPENSSL_NO_CHACHA
/* 3. RFC 9001 - A.5 ChaCha20-Poly1305 Short Header Packet */
static const unsigned char tx_script_3_body[] = {
0x01
@ -3128,6 +3146,7 @@ static const struct tx_test_op tx_script_3[] = {
TX_OP_WRITE_CHECK(3)
TX_OP_END
};
#endif /* !defined(OPENSSL_NO_CHACHA) */
/* 4. Real World - AES-128-GCM Key Update */
static const unsigned char tx_script_4_secret[] = {
@ -3390,7 +3409,9 @@ static const struct tx_test_op tx_script_6[] = {
static const struct tx_test_op *const tx_scripts[] = {
tx_script_1,
tx_script_2,
#ifndef OPENSSL_NO_CHACHA
tx_script_3,
#endif
tx_script_4,
tx_script_5,
tx_script_6