aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_random.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-03-04 11:25:16 +0000
committerChristian Grothoff <christian@grothoff.org>2014-03-04 11:25:16 +0000
commitaaa926133b701674bec880b813281fa197be7284 (patch)
tree5eec3d55057ee7661e8dc14e5293ff64eb1ad075 /src/util/crypto_random.c
parentb3e4bdd6d25ad08e7b592204d4f13f19bc73b668 (diff)
downloadgnunet-aaa926133b701674bec880b813281fa197be7284.tar.gz
gnunet-aaa926133b701674bec880b813281fa197be7284.zip
-doxygen
Diffstat (limited to 'src/util/crypto_random.c')
-rw-r--r--src/util/crypto_random.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c
index 89985c7ac..b477f8e2f 100644
--- a/src/util/crypto_random.c
+++ b/src/util/crypto_random.c
@@ -1,5 +1,5 @@
1/* 1/*
2 This file is part of GNUnet. (C) 2001-2013 Christian Grothoff 2 This file is part of GNUnet. (C) 2001-2014 Christian Grothoff
3 (and other contributing authors) 3 (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
@@ -84,7 +84,7 @@ get_weak_random ()
84 84
85 85
86/** 86/**
87 * Seed a weak random generator. Only GNUNET_CRYPTO_QUALITY_WEAK-mode generator 87 * Seed a weak random generator. Only #GNUNET_CRYPTO_QUALITY_WEAK-mode generator
88 * can be seeded. 88 * can be seeded.
89 * 89 *
90 * @param seed the seed to use 90 * @param seed the seed to use
@@ -138,14 +138,15 @@ GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, void *buffer, size_
138 138
139 139
140/** 140/**
141 * Produce a random value. 141 * Produce a random unsigned 32-bit number modulo @a i.
142 * 142 *
143 * @param mode desired quality of the random number 143 * @param mode desired quality of the random number
144 * @param i the upper limit (exclusive) for the random number 144 * @param i the upper limit (exclusive) for the random number
145 * @return a random value in the interval [0,i[. 145 * @return a random value in the interval [0,i[.
146 */ 146 */
147uint32_t 147uint32_t
148GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i) 148GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode,
149 uint32_t i)
149{ 150{
150#ifdef gcry_fast_random_poll 151#ifdef gcry_fast_random_poll
151 static unsigned int invokeCount; 152 static unsigned int invokeCount;
@@ -194,13 +195,14 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i)
194/** 195/**
195 * Get an array with a random permutation of the 196 * Get an array with a random permutation of the
196 * numbers 0...n-1. 197 * numbers 0...n-1.
197 * @param mode GNUNET_RANDOM_QUALITY_STRONG if the strong (but expensive) 198 * @param mode #GNUNET_RANDOM_QUALITY_STRONG if the strong (but expensive)
198 * PRNG should be used, GNUNET_RANDOM_QUALITY_WEAK otherwise 199 * PRNG should be used, #GNUNET_RANDOM_QUALITY_WEAK otherwise
199 * @param n the size of the array 200 * @param n the size of the array
200 * @return the permutation array (allocated from heap) 201 * @return the permutation array (allocated from heap)
201 */ 202 */
202unsigned int * 203unsigned int *
203GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n) 204GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode,
205 unsigned int n)
204{ 206{
205 unsigned int *ret; 207 unsigned int *ret;
206 unsigned int i; 208 unsigned int i;
@@ -223,8 +225,7 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n)
223 225
224 226
225/** 227/**
226 * Random on unsigned 64-bit values. 228 * Generate random unsigned 64-bit value.
227 *
228 * 229 *
229 * @param mode desired quality of the random number 230 * @param mode desired quality of the random number
230 * @param max value returned will be in range [0,max) (exclusive) 231 * @param max value returned will be in range [0,max) (exclusive)