-/* $OpenBSD: common.c,v 1.12 2022/03/15 13:07:33 tobhe Exp $ */
+/* $OpenBSD: common.c,v 1.13 2022/12/03 22:34:35 tobhe Exp $ */
/*
* A bunch of stub functions so we can compile and link ikev2_pld.c
* in a standalone program for testing purposes.
struct iked_message *, void *, int);
int ikev2_msg_frompeer(struct iked_message *);
int ikev2_send_ike_e(struct iked *, struct iked_sa *, struct ibuf *,
- u_int8_t, u_int8_t, int);
+ uint8_t, uint8_t, int);
void ikev2_ikesa_recv_delete(struct iked *, struct iked_sa *);
struct iked_childsa *
- childsa_lookup(struct iked_sa *, u_int64_t, u_int8_t);
+ childsa_lookup(struct iked_sa *, uint64_t, uint8_t);
int ikev2_childsa_delete(struct iked *, struct iked_sa *,
- u_int8_t, u_int64_t, u_int64_t *, int);
+ uint8_t, uint64_t, uint64_t *, int);
int sa_stateok(const struct iked_sa *, int);
void sa_state(struct iked *, struct iked_sa *, int);
void ikev2_disable_rekeying(struct iked *, struct iked_sa *);
void ikev2_init_ike_sa(struct iked *, void *);
struct dh_group *
- group_get(u_int32_t);
+ group_get(uint32_t);
void timer_set(struct iked *, struct iked_timer *,
void (*)(struct iked *, void *), void *);
void timer_add(struct iked *, struct iked_timer *, int);
ssize_t ikev2_nat_detection(struct iked *, struct iked_message *,
void *, size_t, u_int, int);
int ca_setreq(struct iked *, struct iked_sa *, struct iked_static_id *,
- u_int8_t, u_int8_t, u_int8_t *, size_t, enum privsep_procid);
+ uint8_t, uint8_t, uint8_t *, size_t, enum privsep_procid);
int ikev2_print_id(struct iked_id *, char *, size_t);
int config_add_transform(struct iked_proposal *, u_int, u_int, u_int,
u_int);
int
ikev2_send_ike_e(struct iked *env, struct iked_sa *sa, struct ibuf *buf,
- u_int8_t firstpayload, u_int8_t exchange, int response)
+ uint8_t firstpayload, uint8_t exchange, int response)
{
return (0);
}
}
struct iked_childsa *
-childsa_lookup(struct iked_sa *a, u_int64_t b, u_int8_t c)
+childsa_lookup(struct iked_sa *a, uint64_t b, uint8_t c)
{
return (NULL);
}
int
-ikev2_childsa_delete(struct iked *a, struct iked_sa *b, u_int8_t c,
- u_int64_t d, u_int64_t *e , int f)
+ikev2_childsa_delete(struct iked *a, struct iked_sa *b, uint8_t c,
+ uint64_t d, uint64_t *e , int f)
{
return (0);
}
}
const struct group_id *
-group_getid(u_int32_t id)
+group_getid(uint32_t id)
{
return (NULL);
}
int
ca_setreq(struct iked *env, struct iked_sa *sh, struct iked_static_id *localid,
- u_int8_t type, u_int8_t more, u_int8_t *data, size_t len,
+ uint8_t type, uint8_t more, uint8_t *data, size_t len,
enum privsep_procid procid)
{
return (0);
-/* $OpenBSD: test_parser_fuzz.c,v 1.6 2022/02/22 13:47:21 claudio Exp $ */
+/* $OpenBSD: test_parser_fuzz.c,v 1.7 2022/12/03 22:34:35 tobhe Exp $ */
/*
* Fuzz tests for payload parsing
*
void parser_fuzz_tests(void);
-u_int8_t cookies[] = {
+uint8_t cookies[] = {
0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x00, 0x01, /* initator cookie */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* responder cookie */
};
-u_int8_t genhdr[] = {
+uint8_t genhdr[] = {
0x00, 0x20, 0x22, 0x08, /* next, major/minor, exchange type, flags */
0x00, 0x00, 0x00, 0x00, /* message ID */
0x00, 0x00, 0x00, 0x00 /* total length */
};
-u_int8_t sa_pld[] = {
+uint8_t sa_pld[] = {
0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x08, 0x01, 0x01, 0x00, 0x00
};
-u_int8_t saxform_pld[] = {
+uint8_t saxform_pld[] = {
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3c,
0x01, 0x01, 0x00, 0x06, 0x03, 0x00, 0x00, 0x08,
0x03, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x0c,
0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x01
};
-u_int8_t ke_pld[] = {
+uint8_t ke_pld[] = {
0x00, 0x00, 0x01, 0x08, 0x00, 0x0e, 0x00, 0x00, 0x16, 0xcb,
0x68, 0xaf, 0x63, 0xfe, 0xb0, 0x58, 0x49, 0x0e, 0x7f, 0x85,
0x60, 0x53, 0x80, 0xae, 0x3f, 0x82, 0xf3, 0x35, 0x21, 0xd5,
0x8e, 0x1f, 0xd8, 0x60
};
-u_int8_t nonce_pld[] = {
+uint8_t nonce_pld[] = {
0x00, 0x00, 0x00, 0x24, 0x5f, 0x61, 0x42, 0x72, 0x7d, 0xb2,
0xa8, 0xc1, 0xfe, 0xb1, 0x38, 0x2e, 0xb8, 0x75, 0xa7, 0xc1,
0x1d, 0x8a, 0xa7, 0xb7, 0x9b, 0x92, 0xe2, 0x0e, 0x3a, 0x18,
0x20, 0xb6, 0x16, 0xf3, 0x35, 0x67,
};
-u_int8_t notify_pld[] = {
+uint8_t notify_pld[] = {
0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x40, 0x04, 0xc7, 0xa0,
0x68, 0x68, 0x09, 0x0a, 0x7f, 0x12, 0x0b, 0x13, 0xd3, 0x2f,
0xde, 0x64, 0x8b, 0xf1, 0xc3, 0x3c, 0x79, 0x8f, 0x00, 0x00,
0xa8, 0xf9, 0xeb, 0xdf, 0x9f, 0x2c
};
-u_int8_t id_pld[] = {
+uint8_t id_pld[] = {
0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x00,
0xac, 0x12, 0x7d, 0x01
};
-u_int8_t cert_pld[] = {
+uint8_t cert_pld[] = {
0x00, 0x00, 0x01, 0x10, 0x0b, 0x00, 0x00, 0x00,
0x30, 0x82, 0x01, 0x0c, 0x02, 0x82, 0x01, 0x01, 0x00, 0x8a,
0x26, 0xf8, 0x9e, 0xe8, 0x09, 0x11, 0x6b, 0x3d, 0x00, 0xd3,
0x8e, 0xcf
};
-u_int8_t certreq_pld[] = {
+uint8_t certreq_pld[] = {
0x00, 0x00, 0x00, 0x05, 0x0b
};
-u_int8_t auth_pld[] = {
+uint8_t auth_pld[] = {
0x00, 0x00, 0x01, 0x08, 0x01, 0x00, 0x00, 0x00,
0x2a, 0x34, 0x80, 0x52, 0x3c, 0x86, 0x1c, 0xfa, 0x9a, 0x2b,
0x8b, 0xff, 0xbb, 0xb5, 0x0d, 0x6b, 0xa1, 0x62, 0x58, 0xd8,
0xba, 0x71, 0x77, 0xfe, 0x2c, 0x6d
};
-u_int8_t delete_pld[] = {
+uint8_t delete_pld[] = {
0x2a, 0x00, 0x00, 0x10, 0x01, 0x08, 0x00, 0x01, /* IKE SA */
0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xaf, 0xfe,
0x00, 0x00, 0x00, 0x10, 0x03, 0x04, 0x00, 0x02, /* ESP SA */
0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11
};
-u_int8_t vendor_pld[] = {
+uint8_t vendor_pld[] = {
0x00, 0x00, 0x00, 0x08, 0x11, 0x22, 0x33, 0x44
};
-u_int8_t ts_pld[] = {
+uint8_t ts_pld[] = {
0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x10, 0x00, 0x00, 0xff, 0xff,
0xac, 0x28, 0x7d, 0x00, 0xac, 0x28, 0x7d, 0xff
0x75, 0xd9, 0xc4, 0xd0, 0x3d, 0xa1, 0xa5, 0x8f
};
-u_int8_t sk_pld[] = {
+uint8_t sk_pld[] = {
0x21, 0x00, 0x01, 0x94, 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,
0x3d, 0xa1, 0xa5, 0x8f
};
-u_int8_t cp_pld[] = {
+uint8_t cp_pld[] = {
0x2f, 0x00, 0x00, 0x0c,
0x01, 0x00, 0x00, 0x00, /* REQUEST */
0x00, 0x01, 0x00, 0x00, /* INTERNAL_IP4_ADDRESS */
0x04, 0x00, 0x00, 0x00, /* ACK (empty) */
};
-u_int8_t eap_pld[] = {
+uint8_t eap_pld[] = {
0x30, 0x00, 0x00, 0x09,
0x01, 0x00, 0x00, 0x05, 0x01,
0x30, 0x00, 0x00, 0x0c,
};
/* Valid initator packet */
-u_int8_t valid_packet[] = {
+uint8_t valid_packet[] = {
0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x22, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x22, 0x00,
#define OFFSET_EXCHANGE (2 + sizeof(cookies))
#define OFFSET_LENGTH (8 + sizeof(cookies))
-static u_int8_t *
-get_icookie(u_int8_t *data)
+static uint8_t *
+get_icookie(uint8_t *data)
{
return &data[OFFSET_ICOOKIE];
}
-static u_int8_t *
-get_rcookie(u_int8_t *data)
+static uint8_t *
+get_rcookie(uint8_t *data)
{
return &data[OFFSET_RCOOKIE];
}
-static u_int8_t
-get_nextpayload(u_int8_t *data)
+static uint8_t
+get_nextpayload(uint8_t *data)
{
return data[OFFSET_NEXTPAYLOAD];
}
-static u_int8_t
-get_version(u_int8_t *data)
+static uint8_t
+get_version(uint8_t *data)
{
return data[OFFSET_VERSION];
}
-static u_int8_t
-get_exchange(u_int8_t *data)
+static uint8_t
+get_exchange(uint8_t *data)
{
return data[OFFSET_EXCHANGE];
}
-static u_int32_t
-get_length(u_int8_t *data)
+static uint32_t
+get_length(uint8_t *data)
{
- return *(u_int32_t *)&data[OFFSET_LENGTH];
+ return *(uint32_t *)&data[OFFSET_LENGTH];
}
static void
-set_length(u_int8_t *data, u_int32_t length)
+set_length(uint8_t *data, uint32_t length)
{
- u_int32_t *p;
+ uint32_t *p;
- p = (u_int32_t *)&data[OFFSET_LENGTH];
+ p = (uint32_t *)&data[OFFSET_LENGTH];
*p = htobe32(length);
}
static void
-set_nextpayload(u_int8_t *data, u_int8_t next)
+set_nextpayload(uint8_t *data, uint8_t next)
{
data[OFFSET_NEXTPAYLOAD] = next;
}
static char *
tohex(const void *_s, size_t l)
{
- u_int8_t *s = (u_int8_t *)_s;
+ uint8_t *s = (uint8_t *)_s;
size_t i, j;
const char *hex = "0123456789abcdef";
char *r = malloc((l * 2) + 1);
}
static int
-memvalcmp(const u_int8_t *s, u_char v, size_t l, size_t *where)
+memvalcmp(const uint8_t *s, u_char v, size_t l, size_t *where)
{
size_t i;
void
assert_u8(const char *file, int line, const char *a1, const char *a2,
- u_int8_t aa1, u_int8_t aa2, enum test_predicate pred)
+ uint8_t aa1, uint8_t aa2, enum test_predicate pred)
{
TEST_CHECK(aa1, aa2, pred);
test_header(file, line, a1, a2, "U8", pred);
void
assert_u16(const char *file, int line, const char *a1, const char *a2,
- u_int16_t aa1, u_int16_t aa2, enum test_predicate pred)
+ uint16_t aa1, uint16_t aa2, enum test_predicate pred)
{
TEST_CHECK(aa1, aa2, pred);
test_header(file, line, a1, a2, "U16", pred);
void
assert_u32(const char *file, int line, const char *a1, const char *a2,
- u_int32_t aa1, u_int32_t aa2, enum test_predicate pred)
+ uint32_t aa1, uint32_t aa2, enum test_predicate pred)
{
TEST_CHECK(aa1, aa2, pred);
test_header(file, line, a1, a2, "U32", pred);
void
assert_u64(const char *file, int line, const char *a1, const char *a2,
- u_int64_t aa1, u_int64_t aa2, enum test_predicate pred)
+ uint64_t aa1, uint64_t aa2, enum test_predicate pred)
{
TEST_CHECK(aa1, aa2, pred);
test_header(file, line, a1, a2, "U64", pred);