44 static const char testtext[] =
"Dummy text to test PEM encoding";
60 assert_true(
BLEN(&src_buf) <
BLEN(&pem_buf));
66 assert_int_equal(
BLEN(&src_buf),
BLEN(&dec_buf));
67 assert_memory_equal(
BPTR(&src_buf),
BPTR(&dec_buf),
BLEN(&src_buf));
85 assert_string_equal(kt_name, openvpn_name);
98 for (
int i = 0; i < strlen(ciphername); i++)
100 upper[i] = toupper(ciphername[i]);
101 lower[i] = tolower(ciphername[i]);
104 random_case[i] = upper[i];
108 random_case[i] = lower[i];
114 openvpn_name = upper;
140 static const char *
ipsumlorem =
"Lorem ipsum dolor sit amet, consectetur "
141 "adipisici elit, sed eiusmod tempor incidunt "
142 "ut labore et dolore magna aliqua.";
147 const char *seedstr =
"Quis aute iure reprehenderit in voluptate "
148 "velit esse cillum dolore";
149 const unsigned char *seed = (
const unsigned char *)seedstr;
150 const size_t seed_len = strlen(seedstr);
153 const unsigned char *secret = (
const unsigned char *)
ipsumlorem;
154 size_t secret_len = strlen((
const char *)secret);
158 bool ret =
ssl_tls1_PRF(seed, seed_len, secret, secret_len, out,
sizeof(out));
160 #if defined(LIBRESSL_VERSION_NUMBER) || defined(ENABLE_CRYPTO_WOLFSSL)
165 uint8_t good_prf[32] = {0xd9, 0x8c, 0x85, 0x18, 0xc8, 0x5e, 0x94, 0x69,
166 0x27, 0x91, 0x6a, 0xcf, 0xc2, 0xd5, 0x92, 0xfb,
167 0xb1, 0x56, 0x7e, 0x4b, 0x4b, 0x14, 0x59, 0xe6,
168 0xa9, 0x04, 0xac, 0x2d, 0xda, 0xb7, 0x2d, 0x67};
169 assert_memory_equal(good_prf, out,
sizeof(out));
174 static uint8_t
goodhash[20] = {0x58, 0xea, 0x5a, 0xf0, 0x42, 0x94, 0xe9, 0x17,
175 0xed, 0x84, 0xb9, 0xf0, 0x83, 0x30, 0x23, 0xae,
176 0x8b, 0xa7, 0x7e, 0xb8};
207 memset(
key, 0x55,
sizeof(
key));
238 assert_int_equal(linkmtu, 1400);
247 assert_int_equal(linkmtu, 1408);
253 assert_int_equal(linkmtu, 1440);
259 assert_int_equal(linkmtu, 1440);
265 assert_int_equal(linkmtu, 1444);
270 assert_int_equal(linkmtu, 1446);
274 #if defined(USE_COMP)
279 assert_int_equal(linkmtu, 1445);
281 #if defined(ENABLE_FRAGMENT)
285 assert_int_equal(linkmtu, 1449);
303 assert_int_equal(linkmtu, 1457);
309 assert_int_equal(linkmtu, 1457);
316 assert_int_equal(linkmtu, 1405);
322 assert_int_equal(linkmtu, 1449);
325 #if defined(USE_COMP) && defined(ENABLE_FRAGMENT)
331 assert_int_equal(linkmtu, 1454);
336 assert_int_equal(linkmtu, 1464);
363 assert_int_equal(
f.mss_fix, 952);
373 assert_int_equal(
f.mss_fix, 952);
380 for (
int i = 990; i <= 1010; i++)
389 assert_int_equal(
f.mss_fix, 911);
393 assert_int_equal(
f.mss_fix, 943);
397 assert_int_equal(
f.mss_fix, 927);
406 for (
int i = 990; i <= 1010; i++)
415 assert_int_equal(
f.mss_fix, 910);
419 assert_int_equal(
f.mss_fix, 942);
423 assert_int_equal(
f.mss_fix, 926);
437 for (
int i = 900; i <= 1200; i++)
445 assert_int_equal(
f.mss_fix, i - 4 - 4 - 16 - 40);
455 const struct CMUnitTest tests[] = {
464 #if defined(ENABLE_CRYPTO_OPENSSL)
465 OpenSSL_add_all_algorithms();
468 int ret = cmocka_run_group_tests_name(
"crypto tests", tests, NULL, NULL);
470 #if defined(ENABLE_CRYPTO_OPENSSL)