-fix (C) notices
[oweals/gnunet.git] / src / util / test_crypto_hash_context.c
1 /*
2   This file is part of GNUnet
3   Copyright (C) 2014 GNUnet e.V.
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
26 int 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