* https://www.openssl.org/source/license.html
*/
+#include "internal/common.h"
#include "internal/quic_wire_pkt.h"
int ossl_quic_hdr_protector_init(QUIC_HDR_PROTECTOR *hpr,
return 0;
if (ptrs != NULL) {
+ /* ptrs would not be stable on non-static WPACKET */
+ if (!ossl_assert(pkt->staticbuf != NULL))
+ return 0;
ptrs->raw_start = NULL;
ptrs->raw_sample = NULL;
ptrs->raw_sample_len = 0;
static unsigned int counts_u[HPR_CIPHER_COUNT][37] = {0};
static unsigned int counts_c[HPR_CIPHER_COUNT][37] = {0};
+#define TEST_PKT_BUF_LEN 20000
+
static int test_wire_pkt_hdr_actual(int tidx, int repeat, int cipher,
size_t trunc_len)
{
QUIC_PKT_HDR_PTRS ptrs = {0}, wptrs = {0};
PACKET pkt = {0};
WPACKET wpkt = {0};
- BUF_MEM *buf = NULL;
+ unsigned char *buf = NULL;
size_t l = 0, i, j;
QUIC_HDR_PROTECTOR hpr = {0};
unsigned char hpr_key[32] = {0,1,2,3,4,5,6,7};
goto err;
}
- if (!TEST_ptr(buf = BUF_MEM_new()))
+ if (!TEST_ptr(buf = OPENSSL_malloc(TEST_PKT_BUF_LEN)))
goto err;
- if (!TEST_true(WPACKET_init(&wpkt, buf)))
+ if (!TEST_true(WPACKET_init_static_len(&wpkt, buf, TEST_PKT_BUF_LEN, 0)))
goto err;
if (!TEST_true(PACKET_buf_init(&pkt, t->expected, trunc_len)))
if (!TEST_true(WPACKET_get_total_written(&wpkt, &l)))
goto err;
- if (!TEST_mem_eq(buf->data, l, t->expected, t->expected_len))
+ if (!TEST_mem_eq(buf, l, t->expected, t->expected_len))
goto err;
/* Test header protection. */
if (have_hpr)
ossl_quic_hdr_protector_cleanup(&hpr);
WPACKET_finish(&wpkt);
- BUF_MEM_free(buf);
+ OPENSSL_free(buf);
OPENSSL_free(hbuf);
return testresult;
}