Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / testsuite / base64-test.c
blobb2388aee372beb7010a0fcd0d852087aeb9482af
1 #include "testutils.h"
2 #include "base64.h"
4 void
5 test_main(void)
7 ASSERT(BASE64_ENCODE_LENGTH(0) == 0); /* At most 4 bits */
8 ASSERT(BASE64_ENCODE_LENGTH(1) == 2); /* At most 12 bits */
9 ASSERT(BASE64_ENCODE_LENGTH(2) == 3); /* At most 20 bits */
10 ASSERT(BASE64_ENCODE_LENGTH(3) == 4); /* At most 28 bits */
11 ASSERT(BASE64_ENCODE_LENGTH(4) == 6); /* At most 36 bits */
12 ASSERT(BASE64_ENCODE_LENGTH(5) == 7); /* At most 44 bits */
13 ASSERT(BASE64_ENCODE_LENGTH(12) == 16); /* At most 100 bits */
14 ASSERT(BASE64_ENCODE_LENGTH(13) == 18); /* At most 108 bits */
16 ASSERT(BASE64_DECODE_LENGTH(0) == 0); /* At most 6 bits */
17 ASSERT(BASE64_DECODE_LENGTH(1) == 1); /* At most 12 bits */
18 ASSERT(BASE64_DECODE_LENGTH(2) == 2); /* At most 18 bits */
19 ASSERT(BASE64_DECODE_LENGTH(3) == 3); /* At most 24 bits */
20 ASSERT(BASE64_DECODE_LENGTH(4) == 3); /* At most 30 bits */
22 test_armor(&nettle_base64, 0, "", "");
23 test_armor(&nettle_base64, 1, "H", "SA==");
24 test_armor(&nettle_base64, 2, "He", "SGU=");
25 test_armor(&nettle_base64, 3, "Hel", "SGVs");
26 test_armor(&nettle_base64, 4, "Hell", "SGVsbA==");
27 test_armor(&nettle_base64, 5, "Hello", "SGVsbG8=");
28 test_armor(&nettle_base64, 6, "Hello", "SGVsbG8A");
29 test_armor(&nettle_base64, 4, "\xff\xff\xff\xff", "/////w==");
32 /* Test overlapping areas */
33 uint8_t buffer[] = "Helloxxxx";
34 struct base64_decode_ctx ctx;
35 unsigned dst_length;
37 ASSERT(BASE64_ENCODE_RAW_LENGTH(5) == 8);
38 base64_encode_raw(buffer, 5, buffer);
39 ASSERT(MEMEQ(9, buffer, "SGVsbG8=x"));
41 base64_decode_init(&ctx);
42 dst_length = 8;
43 ASSERT(base64_decode_update(&ctx, &dst_length, buffer, 8, buffer));
44 ASSERT(dst_length == 5);
46 ASSERT(MEMEQ(9, buffer, "HelloG8=x"));