Commit 8987731a authored by Mark Karpilovskij's avatar Mark Karpilovskij Committed by Daniel Salzman

tests: added unit test for Siphash

parent 5446ee1f
......@@ -498,6 +498,7 @@ tests/contrib/test_hhash.c
tests/contrib/test_net.c
tests/contrib/test_net_shortwrite.c
tests/contrib/test_qp-trie.c
tests/contrib/test_siphash.c
tests/contrib/test_sockaddr.c
tests/contrib/test_string.c
tests/contrib/test_strtonum.c
......
......@@ -11,6 +11,7 @@
/contrib/test_net
/contrib/test_net_shortwrite
/contrib/test_qp-trie
/contrib/test_siphash
/contrib/test_sockaddr
/contrib/test_string
/contrib/test_strtonum
......
......@@ -21,6 +21,7 @@ check_PROGRAMS = \
contrib/test_net \
contrib/test_net_shortwrite \
contrib/test_qp-trie \
contrib/test_siphash \
contrib/test_sockaddr \
contrib/test_string \
contrib/test_strtonum \
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <tap/basic.h>
#include "contrib/openbsd/siphash.h"
int main(void)
{
plan_lazy();
SIPHASH_KEY key = {
0x0706050403020100,
0x0f0e0d0c0b0a0908
};
const char *data = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e";
size_t data_len = 15;
uint64_t ret = SipHash24(&key, data, data_len);
ok(ret == 0xa129ca6149be45e5, "siphash: correct hash result");
return 0;
}
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