2 Copyright (c) 2010 Jeffrey Burdges
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:
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
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
24 * @file src/util/test_crypt_kdf.c
25 * @brief Testcases for KDF mod n
26 * @author Jeffrey Burdges <burdges@gnunet.org>
32 #include "gnunet_crypto_lib.h"
38 #define RND_BLK_SIZE 4096
39 unsigned char rnd_blk[RND_BLK_SIZE];
43 GNUNET_log_setup ("test-crypto-kdf", "WARNING", NULL);
45 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
49 /* test full domain hash size */
50 for (i=0; i<100; i++) {
53 rnd_blk, RND_BLK_SIZE,
55 GNUNET_CRYPTO_kdf_mod_mpi (&r, n,
59 GNUNET_assert( 0 > gcry_mpi_cmp(r,n) );
61 /* Is it worth checking that it's not too small? */
62 /* GNUNET_assert (gcry_mpi_get_nbits(r) > 3*RND_BLK_SIZE/4); */
63 /* This test necessarily randomly fails with probability 2^(3 - RND_BLK_SIZE/4) */