48 parse_line(
const char *line,
char **p,
const int n,
const char *file,
49 const int line_num,
int msglevel,
struct gc_arena *gc)
60 const char *label,
size_t label_size,
61 void *ekm,
size_t ekm_size)
69 return "dummy print_link_socket_actual from unit test";
78 "-----BEGIN OpenVPN Static key V1-----\n"
79 "37268ea8f95d7f71f9fb8fc03770c460\n"
80 "daf714a483d815c013ce0a537efc18f2\n"
81 "8f4f172669d9e6a413bac6741d8ea054\n"
82 "00f49b7fd6326470f23798c606bf53d4\n"
83 "de63ebc64ec59d57ce5d04d5b62e68b5\n"
84 "3ca6e5354351097fa370446c4d269f18\n"
85 "7bb6ae54af2dc70ff7317fe2f8754b82\n"
86 "82aad4202f9fa42c8640245d883e2c54\n"
87 "a0c1c489a036cf3a8964d8d289c1583b\n"
88 "9447c262b1da5fd167a5d27bd5ac5143\n"
89 "17bc2343a31a2efc38dd920d910375f5\n"
90 "1c2e27f3afd36c49269da079f7ce466e\n"
91 "bb0f9ad13e9bbb4665974e6bc24b513c\n"
92 "5700393bf4a3e7f967e2f384069ac8a8\n"
93 "e78b18b15604993fd16515cce9c0f3e4\n"
94 "2b4126b999005ade802797b0eeb8b9e6\n"
95 "-----END OpenVPN Static key V1-----\n"
99 { 0x38, 0x68, 0x91, 0x92, 0x3f, 0xa3, 0x10, 0x34,
100 0x37, 0x00, 0x00, 0x00, 0x00, 0x00 };
103 { 0x38, 0xde, 0x69, 0x4c, 0x5c, 0x7b, 0xfb, 0xa2,
104 0x74, 0x93, 0x53, 0x7c, 0x1d, 0xed, 0x4e, 0x78,
105 0x15, 0x29, 0xae, 0x7c, 0xfe, 0x4b, 0x8c, 0x6d,
106 0x6b, 0x2b, 0x51, 0xf0, 0x5a, 0x00, 0x00, 0x00,
107 0x01, 0x61, 0xd3, 0xbf, 0x6c, 0x00, 0x00, 0x00,
111 {0x38, 0xf4, 0x19, 0xcb, 0x12, 0xd1, 0xf9, 0xe4,
112 0x8f, 0x00, 0x00, 0x00, 0x01, 0x61, 0xd3, 0xf8,
113 0xe1, 0x33, 0x02, 0x06, 0xf5, 0x68, 0x02, 0xbe,
114 0x44, 0xfb, 0xed, 0x90, 0x50, 0x64, 0xe3, 0xdb,
115 0x43, 0x41, 0x6b, 0xec, 0x5e, 0x52, 0x67, 0x19,
116 0x46, 0x2b, 0x7e, 0xb9, 0x0c, 0x96, 0xde, 0xfc,
117 0x9b, 0x05, 0xc4, 0x48, 0x79, 0xf7};
121 0x20, 0x14, 0x01, 0x4e, 0xbc, 0x80, 0xc6, 0x14,
122 0x2b, 0x7b, 0xc8, 0x76, 0xfb, 0xc5, 0x2e, 0x27,
123 0xb1, 0xc5, 0x07, 0x35, 0x5b, 0xb6, 0x00, 0x6b,
124 0xae, 0x71, 0xba, 0x4e, 0x38, 0x00, 0x00, 0x00,
125 0x03, 0x61, 0xd3, 0xff, 0x53, 0x00, 0x00, 0x00,
126 0x00, 0x01, 0x16, 0x03, 0x01, 0x01, 0x0c, 0x01,
127 0x00, 0x01, 0x08, 0x03, 0x03, 0x8c, 0xaa, 0xac,
128 0x3a, 0x1a, 0x07, 0xbd, 0xe7, 0xb7, 0x50, 0x06,
129 0x9b, 0x94, 0x0c, 0x34, 0x4b, 0x5a, 0x35, 0xca,
130 0xc4, 0x79, 0xbd, 0xc9, 0x09, 0xb0, 0x7b, 0xd9,
131 0xee, 0xbb, 0x7d, 0xe7, 0x25, 0x20, 0x39, 0x38,
132 0xe2, 0x18, 0x33, 0x36, 0x14, 0x9f, 0x34, 0xf0,
133 0x44, 0x59, 0x96, 0x8d, 0x0e, 0xd2, 0x47, 0x76,
134 0x64, 0x88, 0x59, 0xe9, 0x38, 0x03, 0x97, 0x96,
135 0x98, 0x45, 0xfb, 0xf5, 0xff, 0x23, 0x00, 0x32,
136 0x13, 0x02, 0x13, 0x03, 0x13, 0x01, 0xc0, 0x2c,
137 0xc0, 0x30, 0x00, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8,
138 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f, 0x00, 0x9e,
139 0xc0, 0x24, 0xc0, 0x28, 0x00, 0x6b, 0xc0, 0x23,
140 0xc0, 0x27, 0x00, 0x67, 0xc0, 0x0a, 0xc0, 0x14,
141 0x00, 0x39, 0xc0, 0x09, 0xc0, 0x13, 0x00, 0x33,
142 0x00, 0xff, 0x01, 0x00, 0x00, 0x8d, 0x00, 0x0b,
143 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a,
144 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x1d, 0x00, 0x17,
145 0x00, 0x1e, 0x00, 0x19, 0x00, 0x18, 0x00, 0x16,
146 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x0d,
147 0x00, 0x30, 0x00, 0x2e, 0x04, 0x03, 0x05, 0x03,
148 0x06, 0x03, 0x08, 0x07, 0x08, 0x08, 0x08, 0x09,
149 0x08, 0x0a, 0x08, 0x0b, 0x08, 0x04, 0x08, 0x05,
150 0x08, 0x06, 0x04, 0x01, 0x05, 0x01, 0x06, 0x01,
151 0x03, 0x03, 0x02, 0x03, 0x03, 0x01, 0x02, 0x01,
152 0x03, 0x02, 0x02, 0x02, 0x04, 0x02, 0x05, 0x02,
153 0x06, 0x02, 0x00, 0x2b, 0x00, 0x05, 0x04, 0x03,
154 0x04, 0x03, 0x03, 0x00, 0x2d, 0x00, 0x02, 0x01,
155 0x01, 0x00, 0x33, 0x00, 0x26, 0x00, 0x24, 0x00,
156 0x1d, 0x00, 0x20, 0x0e, 0xc9, 0x7a, 0xff, 0x58,
157 0xdb, 0x56, 0xf6, 0x40, 0xd1, 0xed, 0xdb, 0x91,
158 0x81, 0xd6, 0xef, 0x83, 0x86, 0x8a, 0xb2, 0x3d,
159 0x88, 0x92, 0x3f, 0xd8, 0x51, 0x9c, 0xd6, 0x26,
166 0x20, 0x78, 0x19, 0xbf, 0x2e, 0xbc, 0xd1, 0x9a,
167 0x45, 0x01, 0x00, 0x00, 0x00, 0x00, 0xea,
168 0xfe, 0xbf, 0xa4, 0x41, 0x8a, 0xe3, 0x1b,
169 0x00, 0x00, 0x00, 0x01, 0x16, 0x03, 0x01
173 0x28, 0xae, 0xb9, 0xaf, 0xe1, 0xf0, 0x1d, 0x79,
174 0xc8, 0x01, 0x00, 0x00, 0x00, 0x00, 0xdd,
175 0x85, 0xdb, 0x53, 0x56, 0x23, 0xb0, 0x2e
194 "Control Channel Authentication",
"tls-auth",
261 BPTR(&buf)[i] = 0x23;
316 BPTR(&buf)[20] = 0x23;
397 assert_int_equal(ack.
len, 1);
400 struct session_id expected_id = { .
id = {0xea, 0xfe, 0xbf, 0xa4, 0x41, 0x8a, 0xe3, 0x1b }};
401 assert_memory_equal(&sid, &expected_id,
SID_SIZE);
411 assert_int_equal(ack.
len, 1);
414 struct session_id expected_id2 = { .
id = {0xdd, 0x85, 0xdb, 0x53, 0x56, 0x23, 0xb0, 0x2e }};
415 assert_memory_equal(&sid, &expected_id2,
SID_SIZE);
503 static const int handwindow = 100;
507 addr.addr.in4.sin_family = AF_INET;
508 addr.addr.in4.sin_addr.s_addr = ntohl(0xff000ff);
509 addr.addr.in4.sin_port = ntohs(1195);
511 struct session_id client_id = { {0, 1, 2, 3, 4, 5, 6, 7}};
517 struct session_id expected_server_id = {{0x84, 0x73, 0x52, 0x2b, 0x5b, 0xa9, 0x2a, 0x70}};
522 if (
sizeof(addr.
addr.
in4.sin_family) ==
sizeof(
unsigned short int)
523 && ntohs(AF_INET) != AF_INET)
525 struct session_id linuxle = {{0x8b, 0xeb, 0x3d, 0x20, 0x14, 0x53, 0xbe, 0x0a }};
526 expected_server_id = linuxle;
528 assert_memory_equal(expected_server_id.
id, server_id.
id,
SID_SIZE);
534 assert_memory_not_equal(expected_server_id.
id, server_id_m1.
id,
SID_SIZE);
535 assert_memory_not_equal(expected_server_id.
id, server_id_p1.
id,
SID_SIZE);
546 assert_memory_equal(server_id2_m2.
id, server_id_m1.
id,
SID_SIZE);
547 assert_memory_equal(server_id2_m1.
id, expected_server_id.
id,
SID_SIZE);
548 assert_memory_equal(server_id2.
id, server_id_p1.
id,
SID_SIZE);
549 assert_memory_equal(server_id2_p1.
id, server_id_p2.
id,
SID_SIZE);
562 struct session_id client_id = {{0, 1, 2, 3, 4, 5, 6, 7}};
563 struct session_id server_id = {{8, 9, 0, 9, 8, 7, 6, 2}};
583 assert_int_equal(
BLEN(&buf),
BLEN(&buf2));
584 assert_memory_equal(
BPTR(&buf),
BPTR(&buf2),
BLEN(&buf));
601 struct session_id client_id = {{0xab, 1, 2, 3, 4, 5, 6, 0xcd}};
602 struct session_id server_id = {{8, 9, 0xa, 0xc, 8, 7, 6, 2}};
618 assert_int_equal(
BLEN(&buf),
BLEN(&buf2));
619 assert_memory_equal(
BPTR(&buf),
BPTR(&buf2),
BLEN(&buf));
633 const struct CMUnitTest tests[] = {
645 #if defined(ENABLE_CRYPTO_OPENSSL)
646 OpenSSL_add_all_algorithms();
649 int ret = cmocka_run_group_tests_name(
"pkt tests", tests, NULL, NULL);
651 #if defined(ENABLE_CRYPTO_OPENSSL)