diff options
Diffstat (limited to 'src/util/test_crypto_random.c')
-rw-r--r-- | src/util/test_crypto_random.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/util/test_crypto_random.c b/src/util/test_crypto_random.c index 11f87a25e..e0a8fb72a 100644 --- a/src/util/test_crypto_random.c +++ b/src/util/test_crypto_random.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | 28 | ||
29 | static int | 29 | static int |
30 | test(enum GNUNET_CRYPTO_Quality mode) | 30 | test (enum GNUNET_CRYPTO_Quality mode) |
31 | { | 31 | { |
32 | int buf[1024]; | 32 | int buf[1024]; |
33 | unsigned int *b2; | 33 | unsigned int *b2; |
@@ -35,34 +35,34 @@ test(enum GNUNET_CRYPTO_Quality mode) | |||
35 | unsigned long long n; | 35 | unsigned long long n; |
36 | 36 | ||
37 | for (i = 0; i < 1024; i++) | 37 | for (i = 0; i < 1024; i++) |
38 | GNUNET_break(1024 > (buf[i] = GNUNET_CRYPTO_random_u32(mode, 1024))); | 38 | GNUNET_break (1024 > (buf[i] = GNUNET_CRYPTO_random_u32 (mode, 1024))); |
39 | for (i = 0; i < 10; i++) | 39 | for (i = 0; i < 10; i++) |
40 | { | ||
41 | b2 = GNUNET_CRYPTO_random_permute (mode, 1024); | ||
42 | if (0 == memcmp (b2, buf, sizeof(buf))) | ||
40 | { | 43 | { |
41 | b2 = GNUNET_CRYPTO_random_permute(mode, 1024); | 44 | fprintf (stderr, "%s", "!"); |
42 | if (0 == memcmp(b2, buf, sizeof(buf))) | 45 | GNUNET_free (b2); |
43 | { | 46 | continue; |
44 | fprintf(stderr, "%s", "!"); | ||
45 | GNUNET_free(b2); | ||
46 | continue; | ||
47 | } | ||
48 | GNUNET_free(b2); | ||
49 | break; | ||
50 | } | 47 | } |
48 | GNUNET_free (b2); | ||
49 | break; | ||
50 | } | ||
51 | if (i == 10) | 51 | if (i == 10) |
52 | return 1; /* virtually impossible... */ | 52 | return 1; /* virtually impossible... */ |
53 | 53 | ||
54 | for (n = 10; n < 1024LL * 1024LL * 1024LL; n *= 10) | 54 | for (n = 10; n < 1024LL * 1024LL * 1024LL; n *= 10) |
55 | GNUNET_break(n > GNUNET_CRYPTO_random_u64(mode, n)); | 55 | GNUNET_break (n > GNUNET_CRYPTO_random_u64 (mode, n)); |
56 | return 0; | 56 | return 0; |
57 | } | 57 | } |
58 | 58 | ||
59 | int | 59 | int |
60 | main(int argc, char *argv[]) | 60 | main (int argc, char *argv[]) |
61 | { | 61 | { |
62 | GNUNET_log_setup("test-crypto-random", "WARNING", NULL); | 62 | GNUNET_log_setup ("test-crypto-random", "WARNING", NULL); |
63 | if (0 != test(GNUNET_CRYPTO_QUALITY_WEAK)) | 63 | if (0 != test (GNUNET_CRYPTO_QUALITY_WEAK)) |
64 | return 1; | 64 | return 1; |
65 | if (0 != test(GNUNET_CRYPTO_QUALITY_STRONG)) | 65 | if (0 != test (GNUNET_CRYPTO_QUALITY_STRONG)) |
66 | return 1; | 66 | return 1; |
67 | 67 | ||
68 | return 0; | 68 | return 0; |