diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-09 17:18:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-09 17:18:14 +0000 |
commit | 0931dc632a7bea6eb50cd1c7d1688fc6e757a502 (patch) | |
tree | e3799f8025374c2cb3565f6a2fb3c840545a3f3d /src/util/test_crypto_hash_context.c | |
parent | 712767683a32140be3fd7d195b44be676853eb12 (diff) | |
download | gnunet-0931dc632a7bea6eb50cd1c7d1688fc6e757a502.tar.gz gnunet-0931dc632a7bea6eb50cd1c7d1688fc6e757a502.zip |
moving hash_context testcase over as well
Diffstat (limited to 'src/util/test_crypto_hash_context.c')
-rw-r--r-- | src/util/test_crypto_hash_context.c | 45 |
1 files changed, 45 insertions, 0 deletions
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 | |||
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 | |||