fixes
authorChristian Grothoff <christian@grothoff.org>
Tue, 8 Sep 2009 08:10:18 +0000 (08:10 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 8 Sep 2009 08:10:18 +0000 (08:10 +0000)
16 files changed:
src/datastore/perf_datastore_api.c
src/fs/Makefile.am
src/fs/test_fs_collection.c
src/fs/test_fs_directory.c
src/hostlist/test_gnunet_daemon_hostlist.c
src/include/gnunet_crypto_lib.h
src/testing/test_testing.c
src/util/crypto_aes.c
src/util/crypto_crc.c
src/util/crypto_hash.c
src/util/crypto_random.c
src/util/crypto_rsa.c
src/util/test_container_bloomfilter.c
src/util/test_crypto_hash.c
src/util/test_crypto_ksk.c
src/util/test_pseudonym.c

index 0df55f878860fea12cda88cf1fbf45396a4244c5..626fbcf73d848bba2776581d3a8a67d7ffaa5c0a 100644 (file)
@@ -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;
 }
 
index f2bcab615a643ed642ef406840c3c7bb3cf1cbbf..abc3d989ba0235b6287c0cb560e9cae5debb912d 100644 (file)
@@ -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
index 6857dfc25e0efb8a1ffc79acfbe7a199cba8c9a9..dc93bbfb5ae07d9ccbeb279a5a20c2e39879aeda 100644 (file)
@@ -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;
index 22dfa22cfee1c7f7ed0345b90ae13eb077920b6e..9d0101078850dc0df46732bc0ceb136f047cb995 100644 (file)
@@ -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;
index e99b486cc645ce96e95a692178bc81027bb6b956..006c6b1d897f278804f4d88700ef4e5dd84c9e94 100644 (file)
@@ -174,5 +174,7 @@ main (int argc, char *argv[])
 #endif
                     NULL);
   ret = check ();
-  return 0
+  return ret
 }
+
+/* end of test_gnunet_daemon_hostlist.c */
index 396f47355722c2ab00f76830733c8eb7fa6ba769..9303aa98c5fe5302593dd5ead09bf0bcece007a0 100644 (file)
@@ -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);
 
 
 /**
index cbedf60fb0d933024dcce5a16866ef7610a3d455..b273eeef5d4de2549538f156f71c77329599fad9 100644 (file)
@@ -109,7 +109,7 @@ main (int argc, char *argv[])
 #endif
                     NULL);
   ret = check ();
-
+  GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
   return ret;
 }
 
index 8fa935d9f7ce90a22fc5e95716e9d221b9546ba8..6db932b5bd71353716c8aabce0f0578f245cc8ea 100644 (file)
@@ -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,
index 35d1e257689dc6b698bdc32a32d0a9c505aa3704..a89b059c5cc029cb9f2ee46ef7603d15c1720582 100644 (file)
@@ -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 */
index fce93ceaf2740fb03b8a1c9790846859c468ade2..4f8482c4cdac35df2ab3d0d89cd3f58a89a73ecb 100644 (file)
@@ -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 */
index 3f7ac4dd386c64d7e32af3e83736dac6c8f2f36c..0ad1364cb592cdf6e6426acb79d0eafb52221930 100644 (file)
 /**
  * @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
index edf1b2bdf1b306d53f38510ae43650d0ac21ed70..bb14f36c9acae8a8f13c94fe14d198050859ec86 100644 (file)
@@ -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;
index ccaea45aec72450b40895962b337c69cca61b58d..012d3f954144e413d4701e846713b438ca7d0f2d 100644 (file)
@@ -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
index e10aee9b1c11ebb531a537b1cfe7cd68a080efb4..97ef4ec885baf12a69c0f3a39a1b67026bfe415d 100644 (file)
@@ -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;
index 8bcb105ea8d158269da38e9b536221753809fdce..943e9792bdeb0a5a39a41f3298d3f2634345466c 100644 (file)
@@ -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)
     {
index d358c8210aae1e9564ebfdc74712e9ba6f293940..daa4c31689d94bb71fc4ae48d28849e090717592 100644 (file)
@@ -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);