aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-09 17:18:14 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-09 17:18:14 +0000
commit0931dc632a7bea6eb50cd1c7d1688fc6e757a502 (patch)
treee3799f8025374c2cb3565f6a2fb3c840545a3f3d /src/util
parent712767683a32140be3fd7d195b44be676853eb12 (diff)
downloadgnunet-0931dc632a7bea6eb50cd1c7d1688fc6e757a502.tar.gz
gnunet-0931dc632a7bea6eb50cd1c7d1688fc6e757a502.zip
moving hash_context testcase over as well
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Makefile.am6
-rw-r--r--src/util/test_crypto_hash_context.c45
2 files changed, 51 insertions, 0 deletions
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 87651e620..f4e39711b 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -227,6 +227,7 @@ check_PROGRAMS = \
227 test_crypto_eddsa \ 227 test_crypto_eddsa \
228 test_crypto_ecdhe \ 228 test_crypto_ecdhe \
229 test_crypto_hash \ 229 test_crypto_hash \
230 test_crypto_hash_context \
230 test_crypto_hkdf \ 231 test_crypto_hkdf \
231 test_crypto_paillier \ 232 test_crypto_paillier \
232 test_crypto_random \ 233 test_crypto_random \
@@ -390,6 +391,11 @@ test_crypto_hash_SOURCES = \
390test_crypto_hash_LDADD = \ 391test_crypto_hash_LDADD = \
391 libgnunetutil.la 392 libgnunetutil.la
392 393
394test_crypto_hash_context_SOURCES = \
395 test_crypto_hash_context.c
396test_crypto_hash_context_LDADD = \
397 libgnunetutil.la
398
393test_crypto_hkdf_SOURCES = \ 399test_crypto_hkdf_SOURCES = \
394 test_crypto_hkdf.c 400 test_crypto_hkdf.c
395test_crypto_hkdf_LDADD = \ 401test_crypto_hkdf_LDADD = \
diff --git a/src/util/test_crypto_hash_context.c b/src/util/test_crypto_hash_context.c
new file mode 100644
index 000000000..9794f838c
--- /dev/null
+++ b/src/util/test_crypto_hash_context.c
@@ -0,0 +1,45 @@
1/*
2 This file is part of GNUnet
3 (C) 2014 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/
16/**
17 * @file util/test_crypto_hash_context.c
18 * @brief test case for incremental hashing
19 * @author Florian Dold
20 */
21#include "platform.h"
22#include "gnunet_util_lib.h"
23
24#define LEN 1234
25
26int main()
27{
28 char data[1234];
29 struct GNUNET_HashCode hc1;
30 struct GNUNET_HashCode hc2;
31 struct GNUNET_HashContext *hctx;
32
33 memset (data, 42, LEN);
34
35 hctx = GNUNET_CRYPTO_hash_context_start ();
36 GNUNET_CRYPTO_hash_context_read (hctx, data, LEN);
37 GNUNET_CRYPTO_hash_context_finish (hctx, &hc1);
38
39 GNUNET_CRYPTO_hash (data, LEN, &hc2);
40
41 if (0 == memcmp (&hc1, &hc2, sizeof (struct GNUNET_HashCode)))
42 return 0;
43 return 1;
44}
45