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";
73 "-----BEGIN OpenVPN Static key V1-----\n"
74 "37268ea8f95d7f71f9fb8fc03770c460\n"
75 "daf714a483d815c013ce0a537efc18f2\n"
76 "8f4f172669d9e6a413bac6741d8ea054\n"
77 "00f49b7fd6326470f23798c606bf53d4\n"
78 "de63ebc64ec59d57ce5d04d5b62e68b5\n"
79 "3ca6e5354351097fa370446c4d269f18\n"
80 "7bb6ae54af2dc70ff7317fe2f8754b82\n"
81 "82aad4202f9fa42c8640245d883e2c54\n"
82 "a0c1c489a036cf3a8964d8d289c1583b\n"
83 "9447c262b1da5fd167a5d27bd5ac5143\n"
84 "17bc2343a31a2efc38dd920d910375f5\n"
85 "1c2e27f3afd36c49269da079f7ce466e\n"
86 "bb0f9ad13e9bbb4665974e6bc24b513c\n"
87 "5700393bf4a3e7f967e2f384069ac8a8\n"
88 "e78b18b15604993fd16515cce9c0f3e4\n"
89 "2b4126b999005ade802797b0eeb8b9e6\n"
90 "-----END OpenVPN Static key V1-----\n"
94 { 0x38, 0x68, 0x91, 0x92, 0x3f, 0xa3, 0x10, 0x34,
95 0x37, 0x00, 0x00, 0x00, 0x00, 0x00 };
98 { 0x38, 0xde, 0x69, 0x4c, 0x5c, 0x7b, 0xfb, 0xa2,
99 0x74, 0x93, 0x53, 0x7c, 0x1d, 0xed, 0x4e, 0x78,
100 0x15, 0x29, 0xae, 0x7c, 0xfe, 0x4b, 0x8c, 0x6d,
101 0x6b, 0x2b, 0x51, 0xf0, 0x5a, 0x00, 0x00, 0x00,
102 0x01, 0x61, 0xd3, 0xbf, 0x6c, 0x00, 0x00, 0x00,
106 {0x38, 0xf4, 0x19, 0xcb, 0x12, 0xd1, 0xf9, 0xe4,
107 0x8f, 0x00, 0x00, 0x00, 0x01, 0x61, 0xd3, 0xf8,
108 0xe1, 0x33, 0x02, 0x06, 0xf5, 0x68, 0x02, 0xbe,
109 0x44, 0xfb, 0xed, 0x90, 0x50, 0x64, 0xe3, 0xdb,
110 0x43, 0x41, 0x6b, 0xec, 0x5e, 0x52, 0x67, 0x19,
111 0x46, 0x2b, 0x7e, 0xb9, 0x0c, 0x96, 0xde, 0xfc,
112 0x9b, 0x05, 0xc4, 0x48, 0x79, 0xf7};
116 0x20, 0x14, 0x01, 0x4e, 0xbc, 0x80, 0xc6, 0x14,
117 0x2b, 0x7b, 0xc8, 0x76, 0xfb, 0xc5, 0x2e, 0x27,
118 0xb1, 0xc5, 0x07, 0x35, 0x5b, 0xb6, 0x00, 0x6b,
119 0xae, 0x71, 0xba, 0x4e, 0x38, 0x00, 0x00, 0x00,
120 0x03, 0x61, 0xd3, 0xff, 0x53, 0x00, 0x00, 0x00,
121 0x00, 0x01, 0x16, 0x03, 0x01, 0x01, 0x0c, 0x01,
122 0x00, 0x01, 0x08, 0x03, 0x03, 0x8c, 0xaa, 0xac,
123 0x3a, 0x1a, 0x07, 0xbd, 0xe7, 0xb7, 0x50, 0x06,
124 0x9b, 0x94, 0x0c, 0x34, 0x4b, 0x5a, 0x35, 0xca,
125 0xc4, 0x79, 0xbd, 0xc9, 0x09, 0xb0, 0x7b, 0xd9,
126 0xee, 0xbb, 0x7d, 0xe7, 0x25, 0x20, 0x39, 0x38,
127 0xe2, 0x18, 0x33, 0x36, 0x14, 0x9f, 0x34, 0xf0,
128 0x44, 0x59, 0x96, 0x8d, 0x0e, 0xd2, 0x47, 0x76,
129 0x64, 0x88, 0x59, 0xe9, 0x38, 0x03, 0x97, 0x96,
130 0x98, 0x45, 0xfb, 0xf5, 0xff, 0x23, 0x00, 0x32,
131 0x13, 0x02, 0x13, 0x03, 0x13, 0x01, 0xc0, 0x2c,
132 0xc0, 0x30, 0x00, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8,
133 0xcc, 0xaa, 0xc0, 0x2b, 0xc0, 0x2f, 0x00, 0x9e,
134 0xc0, 0x24, 0xc0, 0x28, 0x00, 0x6b, 0xc0, 0x23,
135 0xc0, 0x27, 0x00, 0x67, 0xc0, 0x0a, 0xc0, 0x14,
136 0x00, 0x39, 0xc0, 0x09, 0xc0, 0x13, 0x00, 0x33,
137 0x00, 0xff, 0x01, 0x00, 0x00, 0x8d, 0x00, 0x0b,
138 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a,
139 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x1d, 0x00, 0x17,
140 0x00, 0x1e, 0x00, 0x19, 0x00, 0x18, 0x00, 0x16,
141 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x0d,
142 0x00, 0x30, 0x00, 0x2e, 0x04, 0x03, 0x05, 0x03,
143 0x06, 0x03, 0x08, 0x07, 0x08, 0x08, 0x08, 0x09,
144 0x08, 0x0a, 0x08, 0x0b, 0x08, 0x04, 0x08, 0x05,
145 0x08, 0x06, 0x04, 0x01, 0x05, 0x01, 0x06, 0x01,
146 0x03, 0x03, 0x02, 0x03, 0x03, 0x01, 0x02, 0x01,
147 0x03, 0x02, 0x02, 0x02, 0x04, 0x02, 0x05, 0x02,
148 0x06, 0x02, 0x00, 0x2b, 0x00, 0x05, 0x04, 0x03,
149 0x04, 0x03, 0x03, 0x00, 0x2d, 0x00, 0x02, 0x01,
150 0x01, 0x00, 0x33, 0x00, 0x26, 0x00, 0x24, 0x00,
151 0x1d, 0x00, 0x20, 0x0e, 0xc9, 0x7a, 0xff, 0x58,
152 0xdb, 0x56, 0xf6, 0x40, 0xd1, 0xed, 0xdb, 0x91,
153 0x81, 0xd6, 0xef, 0x83, 0x86, 0x8a, 0xb2, 0x3d,
154 0x88, 0x92, 0x3f, 0xd8, 0x51, 0x9c, 0xd6, 0x26,
161 0x20, 0x78, 0x19, 0xbf, 0x2e, 0xbc, 0xd1, 0x9a,
162 0x45, 0x01, 0x00, 0x00, 0x00, 0x00, 0xea,
163 0xfe, 0xbf, 0xa4, 0x41, 0x8a, 0xe3, 0x1b,
164 0x00, 0x00, 0x00, 0x01, 0x16, 0x03, 0x01
168 0x28, 0xae, 0xb9, 0xaf, 0xe1, 0xf0, 0x1d, 0x79,
169 0xc8, 0x01, 0x00, 0x00, 0x00, 0x00, 0xdd,
170 0x85, 0xdb, 0x53, 0x56, 0x23, 0xb0, 0x2e
189 "Control Channel Authentication",
"tls-auth",
256 BPTR(&buf)[i] = 0x23;
311 BPTR(&buf)[20] = 0x23;
392 assert_int_equal(ack.
len, 1);
395 struct session_id expected_id = { .
id = {0xea, 0xfe, 0xbf, 0xa4, 0x41, 0x8a, 0xe3, 0x1b }};
396 assert_memory_equal(&sid, &expected_id,
SID_SIZE);
406 assert_int_equal(ack.
len, 1);
409 struct session_id expected_id2 = { .
id = {0xdd, 0x85, 0xdb, 0x53, 0x56, 0x23, 0xb0, 0x2e }};
410 assert_memory_equal(&sid, &expected_id2,
SID_SIZE);
498 static const int handwindow = 100;
502 addr.addr.in4.sin_family = AF_INET;
503 addr.addr.in4.sin_addr.s_addr = ntohl(0xff000ff);
504 addr.addr.in4.sin_port = ntohs(1195);
506 struct session_id client_id = { {0, 1, 2, 3, 4, 5, 6, 7}};
512 struct session_id expected_server_id = {{0x84, 0x73, 0x52, 0x2b, 0x5b, 0xa9, 0x2a, 0x70}};
517 if (
sizeof(addr.
addr.
in4.sin_family) ==
sizeof(
unsigned short int)
518 && ntohs(AF_INET) != AF_INET)
520 struct session_id linuxle = {{0x8b, 0xeb, 0x3d, 0x20, 0x14, 0x53, 0xbe, 0x0a }};
521 expected_server_id = linuxle;
523 assert_memory_equal(expected_server_id.
id, server_id.
id,
SID_SIZE);
529 assert_memory_not_equal(expected_server_id.
id, server_id_m1.
id,
SID_SIZE);
530 assert_memory_not_equal(expected_server_id.
id, server_id_p1.
id,
SID_SIZE);
541 assert_memory_equal(server_id2_m2.
id, server_id_m1.
id,
SID_SIZE);
542 assert_memory_equal(server_id2_m1.
id, expected_server_id.
id,
SID_SIZE);
543 assert_memory_equal(server_id2.
id, server_id_p1.
id,
SID_SIZE);
544 assert_memory_equal(server_id2_p1.
id, server_id_p2.
id,
SID_SIZE);
557 struct session_id client_id = {{0, 1, 2, 3, 4, 5, 6, 7}};
558 struct session_id server_id = {{8, 9, 0, 9, 8, 7, 6, 2}};
578 assert_int_equal(
BLEN(&buf),
BLEN(&buf2));
579 assert_memory_equal(
BPTR(&buf),
BPTR(&buf2),
BLEN(&buf));
596 struct session_id client_id = {{0xab, 1, 2, 3, 4, 5, 6, 0xcd}};
597 struct session_id server_id = {{8, 9, 0xa, 0xc, 8, 7, 6, 2}};
613 assert_int_equal(
BLEN(&buf),
BLEN(&buf2));
614 assert_memory_equal(
BPTR(&buf),
BPTR(&buf2),
BLEN(&buf));
631 const char input[] =
"valid control message\r\n\0\0Invalid\r\none\0valid one again";
633 buf_write(&input_buf, input,
sizeof(input));
640 assert_string_equal(
BSTR(&cmd1),
"valid control message");
642 assert_int_equal(cmd2.
len, 1);
643 assert_string_equal(
BSTR(&cmd2),
"");
644 assert_int_equal(cmd3.
len, 0);
645 assert_string_equal(
BSTR(&cmd4),
"valid one again");
646 assert_int_equal(cmd5.
len, 0);
648 const uint8_t nonull[6] = {
'n',
'o',
' ',
'N',
'U',
'L'};
651 buf_write(&nonull_buf, nonull,
sizeof(nonull));
653 assert_int_equal(nonullcmd.
len, 0);
662 const struct CMUnitTest tests[] = {
675 #if defined(ENABLE_CRYPTO_OPENSSL)
676 OpenSSL_add_all_algorithms();
679 int ret = cmocka_run_group_tests_name(
"pkt tests", tests, NULL, NULL);
681 #if defined(ENABLE_CRYPTO_OPENSSL)