[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r317 - in GNUnet: . src/util
From: |
grothoff |
Subject: |
[GNUnet-SVN] r317 - in GNUnet: . src/util |
Date: |
Fri, 25 Feb 2005 20:41:43 -0800 (PST) |
Author: grothoff
Date: 2005-02-25 20:41:42 -0800 (Fri, 25 Feb 2005)
New Revision: 317
Modified:
GNUnet/src/util/kblockkey.c
GNUnet/src/util/kblockkey_test.c
GNUnet/todo
Log:
fixing kblocks
Modified: GNUnet/src/util/kblockkey.c
===================================================================
--- GNUnet/src/util/kblockkey.c 2005-02-25 23:34:24 UTC (rev 316)
+++ GNUnet/src/util/kblockkey.c 2005-02-26 04:41:42 UTC (rev 317)
@@ -30,12 +30,6 @@
* @brief implementation of RSA-Key generation for KBlocks
* (do NOT use for pseudonyms or hostkeys!)
* @author Christian Grothoff
- *
- * Todo:
- * - testcase
- * - conversion to GNUnet's internal HOSTKEY format
- * - extend gnunet-util API accordingly
- * - link against GNU's GMP library (!)
*/
#include "platform.h"
@@ -164,7 +158,7 @@
unsigned int nbits;
nbits = get_nbits(a);
- while (nbits > 0)
+ while (nbits > n)
mpz_clrbit(a, nbits--);
mpz_setbit(a, n);
}
@@ -179,12 +173,20 @@
cnt = (nbits / sizeof(HashCode160) / 8) + 1;
tmp = MALLOC(sizeof(HashCode160) * cnt);
- for (i=0;i<cnt;i++) {
- hash(rnd,
+ tmp[0] = *rnd;
+ for (i=0;i<cnt-1;i++) {
+ hash(&tmp[i],
sizeof(HashCode160),
- &tmp[i]);
- *rnd = tmp[i];
+ &tmp[i+1]);
}
+ *rnd = tmp[cnt-1];
+ /*
+ printf("RND: ");
+ for (i=0;i<cnt * sizeof(HashCode160);i++)
+ printf("%02x", ((unsigned char*) tmp)[i]);
+ printf("\n");
+ */
+
mpz_import(n, cnt * sizeof(HashCode160) / sizeof(unsigned int),
1, sizeof(unsigned int), 1, 0, tmp);
FREE(tmp);
@@ -236,7 +238,7 @@
set_highbit(x, nbits-2 );
mpz_clrbit( x, nbits-2 );
}
- /* GNUNET_ASSERT( mpz_cmp( x, nminus1 ) < 0 && mpz_cmp_ui( x, 1 ) > 0 );
// this assertion from libgcrypt fails (always). Why? */
+ GNUNET_ASSERT( mpz_cmp( x, nminus1 ) < 0 && mpz_cmp_ui( x, 1 ) > 0 );
}
mpz_powm ( y, x, q, n);
if ( mpz_cmp_ui(y, 1) && mpz_cmp( y, nminus1 ) ) {
Modified: GNUnet/src/util/kblockkey_test.c
===================================================================
--- GNUnet/src/util/kblockkey_test.c 2005-02-25 23:34:24 UTC (rev 316)
+++ GNUnet/src/util/kblockkey_test.c 2005-02-26 04:41:42 UTC (rev 317)
@@ -12,6 +12,47 @@
#define MAX_TESTVAL 20
#define ITER 10
+
+static int testMultiKey(const char * word) {
+ HashCode160 in;
+ PrivateKey hostkey;
+ PublicKey pkey;
+ PublicKey pkey1;
+ int i;
+
+ fprintf(stderr,
+ "Testing KBlock key uniqueness (%s) ",
+ word);
+ hash(word, strlen(word), &in);
+ hostkey = makeKblockKey(&in);
+ if (hostkey == NULL) {
+ BREAK();
+ return SYSERR;
+ }
+ getPublicKey(hostkey, &pkey);
+ freePrivateKey(hostkey);
+ for (i=0;i<6;i++) {
+ fprintf(stderr, ".");
+ hostkey = makeKblockKey(&in);
+ if (hostkey == NULL) {
+ BREAK();
+ fprintf(stderr, " ERROR\n");
+ return SYSERR;
+ }
+ getPublicKey(hostkey, &pkey1);
+ freePrivateKey(hostkey);
+ if (0 != memcmp(&pkey, &pkey1,
+ sizeof(PublicKey))) {
+ BREAK();
+ fprintf(stderr, " ERROR\n");
+ return SYSERR;
+ }
+ }
+ fprintf(stderr, " OK\n");
+ return OK;
+}
+
+
static int testEncryptDecrypt(PrivateKey hostkey) {
PublicKey pkey;
RSAEncryptedData target;
@@ -176,8 +217,12 @@
return 1;
}
- if (OK != testEncryptDecrypt(hostkey))
- failureCount++;
+ if (OK != testMultiKey("foo"))
+ failureCount++;
+ if (OK != testMultiKey("bar"))
+ failureCount++;
+ if (OK != testEncryptDecrypt(hostkey))
+ failureCount++;
if (OK != testSignVerify(hostkey))
failureCount++;
if (OK != testPrivateKeyEncoding(hostkey))
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-02-25 23:34:24 UTC (rev 316)
+++ GNUnet/todo 2005-02-26 04:41:42 UTC (rev 317)
@@ -10,9 +10,6 @@
0.7.0pre0 [3'05] (aka "pre-preview"):
- padding for insert/return requests: we're currently breaking
8-byte alignment!
-- Investigate KBlocks:
- generated public keys are fishy
- (far to many 0-values in N!)
- Need testing:
* ECRS upload/download: automated test: complete ecrstest.c testcode!
* ECRS-directories (build, iterate)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r317 - in GNUnet: . src/util,
grothoff <=