Commit 0d865a79 authored by Karel Slaný's avatar Karel Slaný

Fixed DNS cookie test.

parent 468a1db7
......@@ -53,8 +53,8 @@ int main(int argc, char *argv[])
/* Client cookie hash algorithm. */
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(NULL, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie no input");
hash_len = knot_cc_alg_fnv64.gen_func(NULL, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 client cookie no input");
memset(&cc_in, 0, sizeof(cc_in));
cc_in.clnt_sockaddr = NULL;
......@@ -62,8 +62,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = NULL;
cc_in.secret_len = 0;
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie input no data");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 client cookie input no data");
memset(&cc_in, 0, sizeof(cc_in));
cc_in.clnt_sockaddr = (struct sockaddr *)&c4_sa;
......@@ -71,8 +71,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = NULL;
cc_in.secret_len = 0;
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie input no secret");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 client cookie input no secret");
memset(&cc_in, 0, sizeof(cc_in));
cc_in.clnt_sockaddr = NULL;
......@@ -80,17 +80,17 @@ int main(int argc, char *argv[])
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie input no socket");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 client cookie input no socket");
memset(&cc_in, 0, sizeof(cc_in));
cc_in.clnt_sockaddr = (struct sockaddr *)&c4_sa;
cc_in.srvr_sockaddr = (struct sockaddr *)&s4_sa;
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, NULL, NULL);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie output no hash");
hash_len = 0;
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, NULL, hash_len);
ok(hash_len == 0, "cookies: FNV64 client cookie output no hash");
memset(&cc_in, 0, sizeof(cc_in));
cc_in.clnt_sockaddr = (struct sockaddr *)&c4_sa;
......@@ -98,8 +98,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = 1;
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 client cookie hash no space");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 client cookie hash no space");
memset(&cc_in, 0, sizeof(cc_in));
cc_in.clnt_sockaddr = (struct sockaddr *)&c4_sa;
......@@ -107,8 +107,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EOK && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len != 0 && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
{
uint8_t expected[] = { 0x74, 0x31, 0xf9, 0xa8, 0x03, 0xef, 0x15, 0xb1 };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 client cookie content");
......@@ -120,8 +120,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EOK && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len != 0 && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
{
uint8_t expected[] = { 0x7c, 0x62, 0x25, 0xd2, 0x43, 0xdd, 0x09, 0xe7 };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 client cookie content");
......@@ -133,8 +133,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EOK && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len != 0 && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
{
uint8_t expected[] = { 0x7c, 0x62, 0x25, 0xd2, 0x43, 0xdd, 0x09, 0xe7 };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 client cookie content");
......@@ -146,8 +146,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EOK && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len != 0 && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
{
uint8_t expected[] = { 0x05, 0xa9, 0xd1, 0x08, 0x1b, 0x98, 0xe0, 0xaa };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 client cookie content");
......@@ -159,8 +159,8 @@ int main(int argc, char *argv[])
cc_in.secret_data = secret;
cc_in.secret_len = sizeof(secret);
hash_len = sizeof(hash);
ret = knot_cc_alg_fnv64.gen_func(&cc_in, hash, &hash_len);
ok(ret == KNOT_EOK && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
hash_len = knot_cc_alg_fnv64.gen_func(&cc_in, hash, hash_len);
ok(hash_len != 0 && hash_len == knot_cc_alg_fnv64.cc_size, "cookies: FNV64 client cookie output");
{
uint8_t expected[] = { 0x05, 0xa9, 0xd1, 0x08, 0x1b, 0x98, 0xe0, 0xaa };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 client cookie content");
......
......@@ -92,8 +92,8 @@ int main(int argc, char *argv[])
/* Server cookie hash algorithm. */
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(NULL, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie no input");
hash_len = knot_sc_alg_fnv64.hash_func(NULL, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie no input");
memset(&sc_in, 0, sizeof(sc_in));
sc_in.cc = NULL;
......@@ -102,8 +102,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = 0;
sc_in.srvr_data = NULL;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie input no data");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie input no data");
memset(&sc_in, 0, sizeof(sc_in));
srvr_data.clnt_sockaddr = NULL;
......@@ -115,8 +115,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = 0;
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie input no data");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie input no data");
memset(&sc_in, 0, sizeof(sc_in));
srvr_data.clnt_sockaddr = NULL;
......@@ -128,8 +128,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, NULL);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie output no socket");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie output no socket");
memset(&sc_in, 0, sizeof(sc_in));
srvr_data.clnt_sockaddr = (struct sockaddr *)&c4_sa;
......@@ -141,8 +141,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, NULL);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie output no secret");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie output no secret");
memset(&sc_in, 0, sizeof(sc_in));
sc_in.cc = cc;
......@@ -151,8 +151,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = NULL;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, NULL);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie output no server data");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie output no server data");
memset(&sc_in, 0, sizeof(sc_in));
srvr_data.clnt_sockaddr = (struct sockaddr *)&c4_sa;
......@@ -164,8 +164,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, NULL);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie output no hash");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, NULL, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie output no hash");
memset(&sc_in, 0, sizeof(sc_in));
srvr_data.clnt_sockaddr = (struct sockaddr *)&c4_sa;
......@@ -177,8 +177,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = 1;
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EINVAL, "cookies: FNV64 server cookie output hash no space ");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len == 0, "cookies: FNV64 server cookie output hash no space ");
memset(&sc_in, 0, sizeof(sc_in));
srvr_data.clnt_sockaddr = (struct sockaddr *)&c4_sa;
......@@ -190,8 +190,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie output");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len != 0, "cookies: FNV64 server cookie output");
{
uint8_t expected[] = { 0x75, 0x45, 0x7c, 0x9a, 0xe0, 0x13, 0xa8, 0xea };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 server cookie content");
......@@ -207,8 +207,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie output");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len != 0, "cookies: FNV64 server cookie output");
{
uint8_t expected[] = { 0xc0, 0xbd, 0xdb, 0xec, 0x19, 0x78, 0x88, 0x39 };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 server cookie content");
......@@ -224,8 +224,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = 0;
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie output");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len != 0, "cookies: FNV64 server cookie output");
{
uint8_t expected[] = { 0xe0, 0xd9, 0x95, 0x4e, 0xbc, 0xc3, 0x99, 0x19 };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 server cookie content");
......@@ -241,8 +241,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie output");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len != 0, "cookies: FNV64 server cookie output");
{
uint8_t expected[] = { 0x4d, 0xde, 0xfa, 0x22, 0xb9, 0x0a, 0xcc, 0xd8 };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 server cookie content");
......@@ -258,8 +258,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce);
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie output");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len != 0, "cookies: FNV64 server cookie output");
{
uint8_t expected[] = { 0xa0, 0x35, 0xe3, 0xe0, 0x78, 0x7a, 0x91, 0xaf };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 server cookie content");
......@@ -275,8 +275,8 @@ int main(int argc, char *argv[])
sc_in.nonce_len = sizeof(nonce) - 1;
sc_in.srvr_data = &srvr_data;
hash_len = sizeof(hash);
ret = knot_sc_alg_fnv64.hash_func(&sc_in, hash, &hash_len);
ok(ret == KNOT_EOK, "cookies: FNV64 server cookie output");
hash_len = knot_sc_alg_fnv64.hash_func(&sc_in, hash, hash_len);
ok(hash_len != 0, "cookies: FNV64 server cookie output");
{
uint8_t expected[] = { 0x8e, 0xa3, 0xf8, 0x97, 0x84, 0x0a, 0x3d, 0x8b };
ok(sizeof(expected) == hash_len && 0 == memcmp(expected, hash, hash_len), "cookies: FNV64 server cookie content");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment