summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-09-08 08:10:18 +0000
committerChristian Grothoff <christian@grothoff.org>2009-09-08 08:10:18 +0000
commitc2017c2ba13736ee1fe4dc9d811d49bee1641ca3 (patch)
tree93ae178521584311eeecdf1e5448a27925bfc681
parent3da5c316b7b992fcc33328043151cf8cb25bf640 (diff)
fixes
-rw-r--r--src/datastore/perf_datastore_api.c1
-rw-r--r--src/fs/Makefile.am4
-rw-r--r--src/fs/test_fs_collection.c11
-rw-r--r--src/fs/test_fs_directory.c24
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c4
-rw-r--r--src/include/gnunet_crypto_lib.h67
-rw-r--r--src/testing/test_testing.c2
-rw-r--r--src/util/crypto_aes.c13
-rw-r--r--src/util/crypto_crc.c6
-rw-r--r--src/util/crypto_hash.c51
-rw-r--r--src/util/crypto_random.c26
-rw-r--r--src/util/crypto_rsa.c7
-rw-r--r--src/util/test_container_bloomfilter.c2
-rw-r--r--src/util/test_crypto_hash.c4
-rw-r--r--src/util/test_crypto_ksk.c2
-rw-r--r--src/util/test_pseudonym.c4
16 files changed, 124 insertions, 104 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 0df55f878..626fbcf73 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -389,6 +389,7 @@ main (int argc, char *argv[])
#if REPORT_ID
fprintf (stderr, "\n");
#endif
+ GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-datastore");
return ret;
}
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index f2bcab615..abc3d989b 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -107,7 +107,9 @@ check_PROGRAMS = \
test_fs_getopt \
test_fs_uri
-TESTS = $(check_PROGRAMS)
+TESTS = test_fs_uri
+
+# $(check_PROGRAMS)
test_fs_collection_SOURCES = \
test_fs_collection.c
diff --git a/src/fs/test_fs_collection.c b/src/fs/test_fs_collection.c
index 6857dfc25..dc93bbfb5 100644
--- a/src/fs/test_fs_collection.c
+++ b/src/fs/test_fs_collection.c
@@ -52,7 +52,9 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
cfg,
"test-fs-collection",
&progress_cb,
- NULL);
+ NULL,
+ GNUNET_FS_FLAGS_NONE,
+ GNUNET_FS_OPTIONS_END);
GNUNET_assert (NULL != fsh);
GNUNET_FS_collection_stop (fsh);
GNUNET_assert (NULL == GNUNET_FS_collection_get (fsh));
@@ -76,7 +78,9 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
cfg,
"test-fs-collection",
&progress_cb,
- NULL);
+ NULL,
+ GNUNET_FS_FLAGS_NONE,
+ GNUNET_FS_OPTIONS_END);
have = GNUNET_FS_collection_get (fsh);
GNUNET_assert (NULL != have);
GNUNET_FS_namespace_delete (have, GNUNET_NO);
@@ -101,7 +105,8 @@ main (int argc, char *argv[])
NULL);
GNUNET_CRYPTO_random_disable_entropy_gathering ();
cfg = GNUNET_CONFIGURATION_create ();
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (cfg, "test_fs_collection_data.conf"))
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_parse (cfg,
+ "test_fs_collection_data.conf"))
{
GNUNET_CONFIGURATION_destroy (cfg);
return -1;
diff --git a/src/fs/test_fs_directory.c b/src/fs/test_fs_directory.c
index 22dfa22cf..9d0101078 100644
--- a/src/fs/test_fs_directory.c
+++ b/src/fs/test_fs_directory.c
@@ -67,8 +67,9 @@ processor (void *cls,
static int
testDirectory (unsigned int i)
{
+ struct GNUNET_FS_DirectoryBuilder *db;
char *data;
- unsigned long long dlen;
+ size_t dlen;
struct GNUNET_FS_Uri **uris;
struct GNUNET_CONTAINER_MetaData **mds;
struct GNUNET_CONTAINER_MetaData *meta;
@@ -96,7 +97,7 @@ testDirectory (unsigned int i)
}
GNUNET_snprintf (uri,
sizeof(uri),
- "gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
+ "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.%u",
p);
uris[p] = GNUNET_FS_uri_parse (uri, &emsg);
if (uris[p] == NULL)
@@ -115,19 +116,12 @@ testDirectory (unsigned int i)
meta = GNUNET_CONTAINER_meta_data_create ();
GNUNET_CONTAINER_meta_data_insert (meta, EXTRACTOR_TITLE, "A title");
GNUNET_CONTAINER_meta_data_insert (meta, EXTRACTOR_AUTHOR, "An author");
- if (GNUNET_OK !=
- GNUNET_FS_directory_create (&dlen, &data, i, uris, mds, meta))
- {
- GNUNET_CONTAINER_meta_data_destroy (meta);
- for (p = 0; p < i; p++)
- {
- GNUNET_CONTAINER_meta_data_destroy (mds[p]);
- GNUNET_FS_uri_destroy (uris[p]);
- }
- GNUNET_free (uris);
- GNUNET_free (mds);
- ABORT ();
- }
+ db = GNUNET_FS_directory_builder_create (meta);
+ for (p=0;p<i;p++)
+ GNUNET_FS_directory_builder_add (db, uris[i], mds[i], NULL);
+ GNUNET_FS_directory_builder_finish (db,
+ &dlen,
+ (void**) &data);
cls.pos = 0;
cls.uri = uris;
cls.md = mds;
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index e99b486cc..006c6b1d8 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -174,5 +174,7 @@ main (int argc, char *argv[])
#endif
NULL);
ret = check ();
- return 0;
+ return ret;
}
+
+/* end of test_gnunet_daemon_hostlist.c */
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 396f47355..9303aa98c 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -202,25 +202,31 @@ struct GNUNET_CRYPTO_AesInitializationVector
* @param len the length of the buffer in bytes
* @return the resulting CRC32 checksum
*/
-int GNUNET_CRYPTO_crc32_n (const void *buf, unsigned int len);
+int32_t GNUNET_CRYPTO_crc32_n (const void *buf,
+ size_t len);
/**
* Produce a random value.
*
+ * @param mode desired quality of the random number
* @param i the upper limit (exclusive) for the random number
- * @return a random value in the interval [0,i[.
+ * @return a random value in the interval [0,i) (exclusive).
*/
-unsigned int GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality,
- unsigned int i);
+uint32_t GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode,
+ uint32_t i);
/**
* Random on unsigned 64-bit values. We break them down into signed
* 32-bit values and reassemble the 64-bit random value bit-wise.
+ *
+ * @param mode desired quality of the random number
+ * @param max value returned will be in range [0,max) (exclusive)
+ * @return random 64-bit number
*/
-unsigned long long GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode,
- unsigned long long u);
+uint64_t GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode,
+ uint64_t max);
/**
@@ -261,13 +267,13 @@ int GNUNET_CRYPTO_aes_check_session_key (const struct
* for streams.
* @returns the size of the encrypted block, -1 for errors
*/
-int GNUNET_CRYPTO_aes_encrypt (const void *block,
- uint16_t len,
- const struct GNUNET_CRYPTO_AesSessionKey
- *sessionkey,
- const struct
- GNUNET_CRYPTO_AesInitializationVector *iv,
- void *result);
+ssize_t GNUNET_CRYPTO_aes_encrypt (const void *block,
+ size_t len,
+ const struct GNUNET_CRYPTO_AesSessionKey
+ *sessionkey,
+ const struct
+ GNUNET_CRYPTO_AesInitializationVector *iv,
+ void *result);
/**
@@ -280,10 +286,11 @@ int GNUNET_CRYPTO_aes_encrypt (const void *block,
* @param result address to store the result at
* @return -1 on failure, size of decrypted block on success
*/
-int GNUNET_CRYPTO_aes_decrypt (const void *block, uint16_t size,
- const struct GNUNET_CRYPTO_AesSessionKey *sessionkey,
- const struct GNUNET_CRYPTO_AesInitializationVector *iv,
- void *result);
+ssize_t GNUNET_CRYPTO_aes_decrypt (const void *block,
+ size_t size,
+ const struct GNUNET_CRYPTO_AesSessionKey *sessionkey,
+ const struct GNUNET_CRYPTO_AesInitializationVector *iv,
+ void *result);
/**
@@ -315,16 +322,19 @@ int GNUNET_CRYPTO_hash_from_string (const char *enc,
* result should be a positive number.
* @return number between 0 and 65536
*/
-unsigned int GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a,
- const GNUNET_HashCode * b);
+uint32_t GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a,
+ const GNUNET_HashCode * b);
/**
- * Hash block of given size.
- * @param block the data to GNUNET_CRYPTO_hash, length is given as a second argument
+ * Compute hash of a given block.
+ *
+ * @param block the data to hash
+ * @param size size of the block
* @param ret pointer to where to write the hashcode
*/
-void GNUNET_CRYPTO_hash (const void *block, unsigned int size,
+void GNUNET_CRYPTO_hash (const void *block,
+ size_t size,
GNUNET_HashCode * ret);
@@ -363,7 +373,8 @@ void GNUNET_CRYPTO_hash_file (struct GNUNET_SCHEDULER_Handle *sched,
/**
* Create a random hash code.
*/
-void GNUNET_CRYPTO_hash_create_random (GNUNET_HashCode * result);
+void GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode,
+ GNUNET_HashCode * result);
/**
@@ -491,7 +502,7 @@ void GNUNET_CRYPTO_rsa_key_get_public (const struct
* @returns GNUNET_SYSERR on error, GNUNET_OK if ok
*/
int GNUNET_CRYPTO_rsa_encrypt (const void *block,
- uint16_t size,
+ size_t size,
const struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
*publicKey,
@@ -507,9 +518,11 @@ int GNUNET_CRYPTO_rsa_encrypt (const void *block,
* @param size how many bytes of a result are expected? Must be exact.
* @returns the size of the decrypted block (that is, size) or -1 on error
*/
-int GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
- const struct GNUNET_CRYPTO_RsaEncryptedData
- *block, void *result, uint16_t size);
+ssize_t GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
+ const struct GNUNET_CRYPTO_RsaEncryptedData
+ *block,
+ void *result,
+ size_t size);
/**
diff --git a/src/testing/test_testing.c b/src/testing/test_testing.c
index cbedf60fb..b273eeef5 100644
--- a/src/testing/test_testing.c
+++ b/src/testing/test_testing.c
@@ -109,7 +109,7 @@ main (int argc, char *argv[])
#endif
NULL);
ret = check ();
-
+ GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
return ret;
}
diff --git a/src/util/crypto_aes.c b/src/util/crypto_aes.c
index 8fa935d9f..6db932b5b 100644
--- a/src/util/crypto_aes.c
+++ b/src/util/crypto_aes.c
@@ -72,9 +72,9 @@ GNUNET_CRYPTO_aes_check_session_key (const struct GNUNET_CRYPTO_AesSessionKey
* @param result the output parameter in which to store the encrypted result
* @returns the size of the encrypted block, -1 for errors
*/
-int
+ssize_t
GNUNET_CRYPTO_aes_encrypt (const void *block,
- uint16_t len,
+ size_t len,
const struct GNUNET_CRYPTO_AesSessionKey
*sessionkey,
const struct GNUNET_CRYPTO_AesInitializationVector
@@ -88,7 +88,7 @@ GNUNET_CRYPTO_aes_encrypt (const void *block,
(sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH)))
{
GNUNET_break (0);
- return GNUNET_SYSERR;
+ return -1;
}
GNUNET_assert (0 == gcry_cipher_open (&handle,
GCRY_CIPHER_AES256,
@@ -115,8 +115,9 @@ GNUNET_CRYPTO_aes_encrypt (const void *block,
* @param result address to store the result at
* @return -1 on failure, size of decrypted block on success
*/
-int
-GNUNET_CRYPTO_aes_decrypt (const void *block, uint16_t size,
+ssize_t
+GNUNET_CRYPTO_aes_decrypt (const void *block,
+ size_t size,
const struct GNUNET_CRYPTO_AesSessionKey
*sessionkey,
const struct GNUNET_CRYPTO_AesInitializationVector
@@ -130,7 +131,7 @@ GNUNET_CRYPTO_aes_decrypt (const void *block, uint16_t size,
(sessionkey, GNUNET_CRYPTO_AES_KEY_LENGTH)))
{
GNUNET_break (0);
- return GNUNET_SYSERR;
+ return -1;
}
GNUNET_assert (0 == gcry_cipher_open (&handle,
GCRY_CIPHER_AES256,
diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c
index 35d1e2576..a89b059c5 100644
--- a/src/util/crypto_crc.c
+++ b/src/util/crypto_crc.c
@@ -94,8 +94,8 @@ crc32 (uLong crc, const char *buf, size_t len)
* @param len the length of the buffer
* @return the resulting CRC32 checksum
*/
-int
-GNUNET_CRYPTO_crc32_n (const void *buf, unsigned int len)
+int32_t
+GNUNET_CRYPTO_crc32_n (const void *buf, size_t len)
{
uLong crc;
crc = crc32 (0L, Z_NULL, 0);
@@ -103,4 +103,4 @@ GNUNET_CRYPTO_crc32_n (const void *buf, unsigned int len)
return crc;
}
-/* end of crc32.c */
+/* end of crypto_crc.c */
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index fce93ceaf..4f8482c4c 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -359,7 +359,8 @@ sha512_final (struct sha512_ctx *sctx, unsigned char *hash)
* @param ret pointer to where to write the hashcode
*/
void
-GNUNET_CRYPTO_hash (const void *block, unsigned int size,
+GNUNET_CRYPTO_hash (const void *block,
+ size_t size,
GNUNET_HashCode * ret)
{
struct sha512_ctx ctx;
@@ -660,18 +661,18 @@ GNUNET_CRYPTO_hash_distance_u32 (const GNUNET_HashCode * a,
}
void
-GNUNET_CRYPTO_hash_create_random (GNUNET_HashCode * result)
+GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, GNUNET_HashCode * result)
{
int i;
- for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
+ for (i = (sizeof (GNUNET_HashCode) / sizeof (uint32_t)) - 1; i >= 0;
i--)
- result->bits[i] = rand ();
+ result->bits[i] = GNUNET_CRYPTO_random_u32 (mode, (uint32_t)-1);
}
void
GNUNET_CRYPTO_hash_difference (const GNUNET_HashCode * a,
- const GNUNET_HashCode * b,
- GNUNET_HashCode * result)
+ const GNUNET_HashCode * b,
+ GNUNET_HashCode * result)
{
int i;
for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
@@ -681,8 +682,8 @@ GNUNET_CRYPTO_hash_difference (const GNUNET_HashCode * a,
void
GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a,
- const GNUNET_HashCode * delta,
- GNUNET_HashCode * result)
+ const GNUNET_HashCode * delta,
+ GNUNET_HashCode * result)
{
int i;
for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
@@ -692,7 +693,7 @@ GNUNET_CRYPTO_hash_sum (const GNUNET_HashCode * a,
void
GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a,
- const GNUNET_HashCode * b, GNUNET_HashCode * result)
+ const GNUNET_HashCode * b, GNUNET_HashCode * result)
{
int i;
for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
@@ -705,18 +706,18 @@ GNUNET_CRYPTO_hash_xor (const GNUNET_HashCode * a,
*/
void
GNUNET_CRYPTO_hash_to_aes_key (const GNUNET_HashCode * hc,
- struct GNUNET_CRYPTO_AesSessionKey *skey,
- struct GNUNET_CRYPTO_AesInitializationVector
- *iv)
+ struct GNUNET_CRYPTO_AesSessionKey *skey,
+ struct GNUNET_CRYPTO_AesInitializationVector
+ *iv)
{
GNUNET_assert (sizeof (GNUNET_HashCode) >=
- GNUNET_CRYPTO_AES_KEY_LENGTH +
- sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
+ GNUNET_CRYPTO_AES_KEY_LENGTH +
+ sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
memcpy (skey, hc, GNUNET_CRYPTO_AES_KEY_LENGTH);
skey->crc32 =
htonl (GNUNET_CRYPTO_crc32_n (skey, GNUNET_CRYPTO_AES_KEY_LENGTH));
memcpy (iv, &((char *) hc)[GNUNET_CRYPTO_AES_KEY_LENGTH],
- sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
+ sizeof (struct GNUNET_CRYPTO_AesInitializationVector));
}
/**
@@ -739,21 +740,21 @@ GNUNET_CRYPTO_hash_get_bit (const GNUNET_HashCode * code, unsigned int bit)
*/
int
GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1,
- const GNUNET_HashCode * h2)
+ const GNUNET_HashCode * h2)
{
unsigned int *i1;
unsigned int *i2;
int i;
-
+
i1 = (unsigned int *) h1;
i2 = (unsigned int *) h2;
for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
i--)
{
if (i1[i] > i2[i])
- return 1;
+ return 1;
if (i1[i] < i2[i])
- return -1;
+ return -1;
}
return 0;
}
@@ -765,23 +766,23 @@ GNUNET_CRYPTO_hash_cmp (const GNUNET_HashCode * h1,
*/
int
GNUNET_CRYPTO_hash_xorcmp (const GNUNET_HashCode * h1,
- const GNUNET_HashCode * h2,
- const GNUNET_HashCode * target)
+ const GNUNET_HashCode * h2,
+ const GNUNET_HashCode * target)
{
int i;
unsigned int d1;
unsigned int d2;
-
+
for (i = sizeof (GNUNET_HashCode) / sizeof (unsigned int) - 1; i >= 0; i--)
{
d1 = ((unsigned int *) h1)[i] ^ ((unsigned int *) target)[i];
d2 = ((unsigned int *) h2)[i] ^ ((unsigned int *) target)[i];
if (d1 > d2)
- return 1;
+ return 1;
else if (d1 < d2)
- return -1;
+ return -1;
}
return 0;
}
-/* end of hashing.c */
+/* end of crypto_hash.c */
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c
index 3f7ac4dd3..0ad1364cb 100644
--- a/src/util/crypto_random.c
+++ b/src/util/crypto_random.c
@@ -32,13 +32,14 @@
/**
* @return a random value in the interval [0,i[.
*/
-unsigned int
-GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, unsigned int i)
+uint32_t
+GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode,
+ uint32_t i)
{
#ifdef gcry_fast_random_poll
static unsigned int invokeCount;
#endif
- unsigned int ret;
+ uint32_t ret;
GNUNET_assert (i > 0);
@@ -49,11 +50,9 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, unsigned int i)
if ((invokeCount++ % 256) == 0)
gcry_fast_random_poll ();
#endif
- ret = rand (); /* in case gcry_randomize fails,
- we at least get a pseudo-
- random number this way */
gcry_randomize ((unsigned char *) &ret,
- sizeof (unsigned int), GCRY_STRONG_RANDOM);
+ sizeof (uint32_t),
+ GCRY_STRONG_RANDOM);
return ret % i;
}
else
@@ -80,10 +79,10 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n)
unsigned int *ret;
unsigned int i;
unsigned int tmp;
- unsigned int x;
+ uint32_t x;
GNUNET_assert (n > 0);
- ret = GNUNET_malloc (n * sizeof (int));
+ ret = GNUNET_malloc (n * sizeof (unsigned int));
for (i = 0; i < n; i++)
ret[i] = i;
for (i = 0; i < n; i++)
@@ -99,17 +98,18 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n)
/**
* Random on unsigned 64-bit values.
*/
-unsigned long long
+uint64_t
GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode,
- unsigned long long u)
+ uint64_t u)
{
- unsigned long long ret;
+ uint64_t ret;
GNUNET_assert (u > 0);
if (mode == GNUNET_CRYPTO_QUALITY_STRONG)
{
gcry_randomize ((unsigned char *) &ret,
- sizeof (unsigned long long), GCRY_STRONG_RANDOM);
+ sizeof (uint64_t),
+ GCRY_STRONG_RANDOM);
return ret % u;
}
else
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index edf1b2bdf..bb14f36c9 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -751,7 +751,7 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename)
*/
int
GNUNET_CRYPTO_rsa_encrypt (const void *block,
- uint16_t size,
+ size_t size,
const struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey,
struct GNUNET_CRYPTO_RsaEncryptedData *target)
@@ -799,10 +799,11 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block,
* the decrypted block is bigger, an error is returned
* @returns the size of the decrypted block, -1 on error
*/
-int
+ssize_t
GNUNET_CRYPTO_rsa_decrypt (const struct GNUNET_CRYPTO_RsaPrivateKey *hostkey,
const struct GNUNET_CRYPTO_RsaEncryptedData *block,
- void *result, uint16_t max)
+ void *result,
+ size_t max)
{
gcry_sexp_t resultsexp;
gcry_sexp_t data;
diff --git a/src/util/test_container_bloomfilter.c b/src/util/test_container_bloomfilter.c
index ccaea45ae..012d3f954 100644
--- a/src/util/test_container_bloomfilter.c
+++ b/src/util/test_container_bloomfilter.c
@@ -38,7 +38,7 @@
static void
nextHC (GNUNET_HashCode * hc)
{
- GNUNET_CRYPTO_hash_create_random (hc);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, hc);
}
static int
diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c
index e10aee9b1..97ef4ec88 100644
--- a/src/util/test_crypto_hash.c
+++ b/src/util/test_crypto_hash.c
@@ -73,8 +73,8 @@ testArithmetic ()
struct GNUNET_CRYPTO_AesSessionKey skey;
struct GNUNET_CRYPTO_AesInitializationVector iv;
- GNUNET_CRYPTO_hash_create_random (&h1);
- GNUNET_CRYPTO_hash_create_random (&h2);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &h1);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &h2);
if (GNUNET_CRYPTO_hash_distance_u32 (&h1, &h2) !=
GNUNET_CRYPTO_hash_distance_u32 (&h2, &h1))
return 1;
diff --git a/src/util/test_crypto_ksk.c b/src/util/test_crypto_ksk.c
index 8bcb105ea..943e9792b 100644
--- a/src/util/test_crypto_ksk.c
+++ b/src/util/test_crypto_ksk.c
@@ -193,7 +193,7 @@ main (int argc, char *argv[])
struct GNUNET_CRYPTO_RsaPrivateKey *hostkey;
GNUNET_log_setup ("test-crypto-ksk", "WARNING", NULL);
- GNUNET_CRYPTO_hash_create_random (&in);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &in);
hostkey = GNUNET_CRYPTO_rsa_key_create_from_hash (&in);
if (hostkey == NULL)
{
diff --git a/src/util/test_pseudonym.c b/src/util/test_pseudonym.c
index d358c8210..daa4c3168 100644
--- a/src/util/test_pseudonym.c
+++ b/src/util/test_pseudonym.c
@@ -99,7 +99,7 @@ main (int argc, char *argv[])
old = GNUNET_PSEUDONYM_list_all (cfg, NULL, NULL);
meta = GNUNET_CONTAINER_meta_data_create ();
GNUNET_CONTAINER_meta_data_insert (meta, EXTRACTOR_TITLE, "test");
- GNUNET_CRYPTO_hash_create_random (&id1);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id1);
GNUNET_PSEUDONYM_add (cfg, &id1, meta);
CHECK (notiCount == 1);
GNUNET_PSEUDONYM_add (cfg, &id1, meta);
@@ -107,7 +107,7 @@ main (int argc, char *argv[])
newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok);
CHECK (old < newVal);
old = newVal;
- GNUNET_CRYPTO_hash_create_random (&id2);
+ GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &id2);
GNUNET_PSEUDONYM_add (cfg, &id2, meta);
CHECK (notiCount == 3);
newVal = GNUNET_PSEUDONYM_list_all (cfg, &iter, &ok);