gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13281 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r13281 - gnunet/src/util
Date: Thu, 14 Oct 2010 11:51:29 +0200

Author: grothoff
Date: 2010-10-14 11:51:29 +0200 (Thu, 14 Oct 2010)
New Revision: 13281

Modified:
   gnunet/src/util/crypto_ksk.c
   gnunet/src/util/test_crypto_ksk.c
Log:
stuff

Modified: gnunet/src/util/crypto_ksk.c
===================================================================
--- gnunet/src/util/crypto_ksk.c        2010-10-14 09:42:42 UTC (rev 13280)
+++ gnunet/src/util/crypto_ksk.c        2010-10-14 09:51:29 UTC (rev 13281)
@@ -201,7 +201,23 @@
   return rc;
 }
 
+/**
+ * If target != size, move target bytes to the
+ * end of the size-sized buffer and zero out the
+ * first target-size bytes.
+ */
 static void
+adjust (unsigned char *buf, size_t size, size_t target)
+{
+  if (size < target)
+    {
+      memmove (&buf[target - size], buf, size);
+      memset (buf, 0, target - size);
+    }
+}
+
+
+static void
 gen_prime (gcry_mpi_t *ptest, unsigned int nbits, GNUNET_HashCode * hc)
 {
   /* Note: 2 is not included because it can be tested more easily by
@@ -334,6 +350,8 @@
                         gcry_mpi_print (GCRYMPI_FMT_USG, 
                                         (unsigned char*) &mods[i], written, 
&written, 
                                         tmp));
+         adjust ( (unsigned char*) &mods[i], written, sizeof (unsigned int));
+         mods[i] = ntohl (mods[i]);
        }
       /* Now try some primes starting with prime. */
       for (step = 0; step < 20000; step += 2)

Modified: gnunet/src/util/test_crypto_ksk.c
===================================================================
--- gnunet/src/util/test_crypto_ksk.c   2010-10-14 09:42:42 UTC (rev 13280)
+++ gnunet/src/util/test_crypto_ksk.c   2010-10-14 09:51:29 UTC (rev 13281)
@@ -38,7 +38,7 @@
 static int
 testCorrectKey ()
 {
-  const char *want = 
"010601000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b73c215f7a5e6b09bec55713c901786c09324a150980e014bdb0d04426934929c3b4971a9711af5455536cd6eeb8bfa004ee904972a737455f53c752987d8e5e1396e5e5a4ed694fb1d45e15ae68d8756e525cbaf6ab6ed0269ac402f2a6b8a73627e3797496b43a851271cb7d7b60b6acf4324ba72be5cafcef98dca8d71d1b01010000";
+  const char *want = 
"010601000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b73c215f7a5e6b09bec55713c901786c09324a150980e014bdb0d04426934929c3b4971a9711af5455536cd6eeb8bfa004ee904972a737455f53c752987d8c82b755bc02882b44950c4acdc1672ba74c3b94d81a4c1ea3d74e7700ae5594c3a4f3c559e4bff2df6844fac302e4b66175e14dc8bad3ce44281d2fec1a1abef06301010000";
   GNUNET_HashCode in;
   struct GNUNET_CRYPTO_RsaPrivateKey *hostkey;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
@@ -57,7 +57,7 @@
   GNUNET_CRYPTO_rsa_key_free (hostkey);
 #if 1
   for (i=0;i<sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);i++)
-    printf(out, sizeof (out), "%02x", ((unsigned char*) &pkey)[i]);
+    printf("%02x", ((unsigned char*) &pkey)[i]);
   printf ("\n");
 #endif
   for (i=0;i<sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);i++)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]