Commit a8dd1867 authored by Jan Včelák's avatar Jan Včelák 🚀

Merge 'Cookies API change'

* Replaced in/out buffer size parameters when generating cookie hashes, because they might be confusing.
* Added functions for basic input checks when generating cookies.
* Fix when building test with libedit in external location.

See merge request !552
parents 6d1572bd 7c857dfb
......@@ -49,22 +49,19 @@ static inline void update_hash(Fnv64_t *hash_val, const struct sockaddr *sa)
*
* \note At least one input address must be provided.
*
* \param[in] input Input parameters.
* \param[in] cc_out Buffer for computed client cookie.
* \param[in,out] cc_len Size of buffer/written data.
* \param input Input parameters.
* \param cc_out Buffer for computed client cookie.
* \param cc_len Buffer size.
*
* \return KNOT_EOK on success, error code else.
* \retval non-zero size of written data on successful return
* \retval 0 on error
*/
static int cc_gen_fnv64(const struct knot_cc_input *input,
uint8_t *cc_out, uint16_t *cc_len)
static uint16_t cc_gen_fnv64(const struct knot_cc_input *input,
uint8_t *cc_out, uint16_t cc_len)
{
if (!input || !cc_out || !cc_len || *cc_len < KNOT_OPT_COOKIE_CLNT) {
return KNOT_EINVAL;
}
if ((!input->clnt_sockaddr && !input->srvr_sockaddr) ||
!(input->secret_data && input->secret_len)) {
return KNOT_EINVAL;
if (!knot_cc_input_is_valid(input) ||
!cc_out || cc_len < KNOT_OPT_COOKIE_CLNT) {
return 0;
}
Fnv64_t hash_val = FNV1A_64_INIT;
......@@ -82,10 +79,10 @@ static int cc_gen_fnv64(const struct knot_cc_input *input,
assert(KNOT_OPT_COOKIE_CLNT == sizeof(hash_val));
*cc_len = KNOT_OPT_COOKIE_CLNT;
memcpy(cc_out, &hash_val, *cc_len);
cc_len = sizeof(hash_val);
memcpy(cc_out, &hash_val, cc_len);
return KNOT_EOK;
return cc_len;
}
#define SRVR_FNV64_HASH_SIZE 8
......@@ -97,23 +94,19 @@ static int cc_gen_fnv64(const struct knot_cc_input *input,
*
* \note This function computes only the hash value.
*
* \param[in] input Data to compute cookie from.
* \param[in] hash_out Buffer to write the resulting hash data into.
* \param[in,out] hash_len On input set to hash buffer size. On successful
* return contains size of written hash.
* \param input Data to compute cookie from.
* \param hash_out Buffer to write the resulting hash data into.
* \param hash_len Buffer size.
*
* \return KNOT_EOK or error code.
* \retval non-zero size of written data on successful return
* \retval 0 on error
*/
static int sc_gen_fnv64(const struct knot_sc_input *input,
uint8_t *hash_out, uint16_t *hash_len)
static uint16_t sc_gen_fnv64(const struct knot_sc_input *input,
uint8_t *hash_out, uint16_t hash_len)
{
if (!input || !hash_out || !hash_len || (*hash_len < SRVR_FNV64_HASH_SIZE)) {
return KNOT_EINVAL;
}
if (!input->cc || !input->cc_len || !input->srvr_data ||
!input->srvr_data->secret_data || !input->srvr_data->secret_len) {
return KNOT_EINVAL;
if (!knot_sc_input_is_valid(input) ||
!hash_out || hash_len < SRVR_FNV64_HASH_SIZE) {
return 0;
}
Fnv64_t hash_val = FNV1A_64_INIT;
......@@ -131,11 +124,12 @@ static int sc_gen_fnv64(const struct knot_sc_input *input,
hash_val = fnv_64a_buf((void *)input->srvr_data->secret_data,
input->srvr_data->secret_len, hash_val);
*hash_len = sizeof(hash_val);
memcpy(hash_out, &hash_val, *hash_len);
assert(SRVR_FNV64_HASH_SIZE == *hash_len);
assert(SRVR_FNV64_HASH_SIZE == sizeof(hash_val));
hash_len = sizeof(hash_val);
memcpy(hash_out, &hash_val, hash_len);
return KNOT_EOK;
return hash_len;
}
_public_
......
......@@ -21,12 +21,24 @@
#include "libknot/errcode.h"
#include "libknot/rrtype/opt-cookie.h"
_public_
bool knot_cc_input_is_valid(const struct knot_cc_input *input)
{
/*
* RFC7873 4.1 -- Client cookie should be generated from
* client IP address, server IP address and a secret quantity.
*/
return input && (input->clnt_sockaddr || input->srvr_sockaddr) &&
input->secret_data && input->secret_len > 0;
}
_public_
int knot_cc_check(const uint8_t *cc, uint16_t cc_len,
const struct knot_cc_input *input,
const struct knot_cc_alg *cc_alg)
{
if (!cc || !cc_len || !input ||
if (!cc || cc_len == 0 || !input ||
!cc_alg || !cc_alg->cc_size || !cc_alg->gen_func) {
return KNOT_EINVAL;
}
......@@ -38,16 +50,12 @@ int knot_cc_check(const uint8_t *cc, uint16_t cc_len,
uint8_t generated_cc[KNOT_OPT_COOKIE_CLNT] = { 0 };
uint16_t generated_cc_len = KNOT_OPT_COOKIE_CLNT;
int ret = cc_alg->gen_func(input, generated_cc, &generated_cc_len);
if (ret != KNOT_EOK) {
return ret;
}
generated_cc_len = cc_alg->gen_func(input, generated_cc, generated_cc_len);
if (generated_cc_len != cc_len) {
return KNOT_EINVAL;
}
ret = memcmp(cc, generated_cc, generated_cc_len);
int ret = memcmp(cc, generated_cc, generated_cc_len);
if (ret != 0) {
return KNOT_EINVAL;
}
......
......@@ -16,6 +16,7 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
......@@ -29,19 +30,28 @@ struct knot_cc_input {
size_t secret_len; /*!< Secret data length. */
};
/*!
* \brief Check client cookie input data for basic sanity.
*
* \param input Data which to generate the cookie from.
*
* \retval true if input contains at least one socket and secret data
* \retval false if input is insufficient or NULL pointer passed
*/
bool knot_cc_input_is_valid(const struct knot_cc_input *input);
/*!
* \brief Client cookie generator function type.
*
* \param[in] input Data which to generate the cookie from.
* \param[in] cc_out Buffer to write the resulting client cookie data into.
* \param[in,out] cc_len On input set to cookie buffer size. On successful
* return contains size of client cookie.
* \param input Data which to generate the cookie from.
* \param cc_out Buffer to write the resulting client cookie data into.
* \param cc_len Cookie buffer size.
*
* \retval KNOT_EOK
* \retval KNOT_EINVAL
* \retval non-zero size of written data on successful return
* \retval 0 on error
*/
typedef int (knot_cc_gen_t)(const struct knot_cc_input *input,
uint8_t *cc_out, uint16_t *cc_len);
typedef uint16_t (knot_cc_gen_t)(const struct knot_cc_input *input,
uint8_t *cc_out, uint16_t cc_len);
/*!
* \brief Holds description of the client cookie algorithm.
......
......@@ -21,6 +21,18 @@
#include "libknot/errcode.h"
#include "libknot/rrtype/opt-cookie.h"
_public_
bool knot_sc_input_is_valid(const struct knot_sc_input *input)
{
/*
* RFC7873 4.2 -- Server cookie should be generated from request
* source IP address, a secret quantity and request client cookie.
*/
return input && input->cc && input->cc_len > 0 && input->srvr_data &&
input->srvr_data->secret_data && input->srvr_data->secret_len > 0;
}
_public_
int knot_sc_parse(uint16_t nonce_len, const uint8_t *sc, uint16_t sc_len,
struct knot_sc_content *content)
......@@ -92,9 +104,9 @@ int knot_sc_check(uint16_t nonce_len, const struct knot_dns_cookies *cookies,
};
/* Generate a new hash. */
ret = sc_alg->hash_func(&sc_input, generated_hash, &generated_hash_len);
if (ret != KNOT_EOK) {
return ret;
generated_hash_len = sc_alg->hash_func(&sc_input, generated_hash, generated_hash_len);
if (generated_hash_len == 0) {
return KNOT_EINVAL;
}
/* Compare hashes. */
......
......@@ -16,6 +16,7 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
......@@ -66,6 +67,16 @@ struct knot_sc_input {
const struct knot_sc_private *srvr_data; /*!< Private data known to the server. */
};
/*!
* \brief Check server cookie input data for basic sanity.
*
* \param input Data which to generate the cookie from.
*
* \retval true if input contains client cookie and server secret data
* \retval false if input is insufficient or NULL pointer passed
*/
bool knot_sc_input_is_valid(const struct knot_sc_input *input);
/*!
* \brief Reads a server cookie that contains \a nonce_len bytes of data
* prefixed before the actual hash.
......@@ -90,16 +101,15 @@ int knot_sc_parse(uint16_t nonce_len, const uint8_t *sc, uint16_t sc_len,
* data prefixed before the actual hash value. Nonce data must be written
* by an external function into the server cookie.
*
* \param[in] input Data which to generate the cookie from.
* \param[in] hash_out Buffer to write the resulting hash data into.
* \param[in,out] hash_len On input set to hash buffer size. On successful
* return contains size of written hash.
* \param input Data which to generate the cookie from.
* \param hash_out Buffer to write the resulting hash data into.
* \param hash_len Hash buffer size.
*
* \retval KNOT_EOK
* \retval KNOT_EINVAL
* \retval non-zero size of written data on successful return
* \retval 0 on error
*/
typedef int (knot_sc_hash_t)(const struct knot_sc_input *input,
uint8_t *hash_out, uint16_t *hash_len);
typedef uint16_t (knot_sc_hash_t)(const struct knot_sc_input *input,
uint8_t *hash_out, uint16_t hash_len);
/*!
* \brief Holds description of the server cookie algorithm.
......
......@@ -73,6 +73,10 @@ check_PROGRAMS += \
zonedb \
ztree
utils_test_lookup_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(libedit_CFLAGS)
utils_test_lookup_LDADD = \
$(top_builddir)/libtap/libtap.la \
$(top_builddir)/src/libknotus.la \
......
......@@ -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