aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_crypto_kdf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_crypto_kdf.c')
-rw-r--r--src/util/test_crypto_kdf.c71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/util/test_crypto_kdf.c b/src/util/test_crypto_kdf.c
deleted file mode 100644
index 7c33e0ba8..000000000
--- a/src/util/test_crypto_kdf.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 Copyright (c) 2010 Jeffrey Burdges
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22
23/**
24 * @file src/util/test_crypt_kdf.c
25 * @brief Testcases for KDF mod n
26 * @author Jeffrey Burdges <burdges@gnunet.org>
27 */
28
29#include <gcrypt.h>
30
31#include "platform.h"
32#include "gnunet_crypto_lib.h"
33
34
35int
36main ()
37{
38#define RND_BLK_SIZE 4096
39 unsigned char rnd_blk[RND_BLK_SIZE];
40 int i;
41 gcry_mpi_t r, n;
42
43 GNUNET_log_setup ("test-crypto-kdf", "WARNING", NULL);
44
45 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
46 rnd_blk,
47 RND_BLK_SIZE);
48
49 /* test full domain hash size */
50 for (i = 0; i < 100; i++)
51 {
52 gcry_mpi_scan (&n,
53 GCRYMPI_FMT_USG,
54 rnd_blk, RND_BLK_SIZE,
55 NULL);
56 GNUNET_CRYPTO_kdf_mod_mpi (&r, n,
57 "", 0,
58 "", 0,
59 "");
60 GNUNET_assert (0 > gcry_mpi_cmp (r, n));
61
62 /* Is it worth checking that it's not too small? */
63 /* GNUNET_assert (gcry_mpi_get_nbits(r) > 3*RND_BLK_SIZE/4); */
64 /* This test necessarily randomly fails with probability 2^(3 - RND_BLK_SIZE/4) */
65
66 gcry_mpi_release (n);
67 gcry_mpi_release (r);
68 }
69
70 return 0;
71}