[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4288 - in GNUnet: m4 src/applications/fs/ecrs src/include
From: |
grothoff |
Subject: |
[GNUnet-SVN] r4288 - in GNUnet: m4 src/applications/fs/ecrs src/include src/util/crypto |
Date: |
Thu, 11 Jan 2007 00:32:16 -0800 (PST) |
Author: grothoff
Date: 2007-01-11 00:32:12 -0800 (Thu, 11 Jan 2007)
New Revision: 4288
Modified:
GNUnet/m4/Makefile.in
GNUnet/src/applications/fs/ecrs/Makefile.am
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/ecrs/uritest.c
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/src/util/crypto/hashing.c
Log:
adding (crashing) testcase for location uris
Modified: GNUnet/m4/Makefile.in
===================================================================
--- GNUnet/m4/Makefile.in 2007-01-11 08:14:08 UTC (rev 4287)
+++ GNUnet/m4/Makefile.in 2007-01-11 08:32:12 UTC (rev 4288)
@@ -41,10 +41,10 @@
$(top_srcdir)/m4/gtk-2.0.m4 $(top_srcdir)/m4/iconv.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libcurl.m4 \
- $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/po.m4 \
- $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/libgcrypt.m4 $(top_srcdir)/m4/libxml2.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/pkg.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
Modified: GNUnet/src/applications/fs/ecrs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/ecrs/Makefile.am 2007-01-11 08:14:08 UTC (rev
4287)
+++ GNUnet/src/applications/fs/ecrs/Makefile.am 2007-01-11 08:32:12 UTC (rev
4288)
@@ -43,7 +43,8 @@
uritest_SOURCES = \
uritest.c
uritest_LDADD = \
- $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la
+ $(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
+ $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la
namespacetest_SOURCES = \
namespacetest.c
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2007-01-11 08:14:08 UTC (rev
4287)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2007-01-11 08:32:12 UTC (rev
4288)
@@ -1134,8 +1134,9 @@
unsigned short proto,
unsigned short sas,
unsigned int mtu,
- char * address,
- ECRS_SignFunction signer) {
+ const char * address,
+ ECRS_SignFunction signer,
+ void * signer_cls) {
struct ECRS_URI * uri;
P2P_hello_MESSAGE * hello;
@@ -1159,16 +1160,18 @@
uri->data.loc.address = NULL;
}
hello = ECRS_getHelloFromUri(uri);
- signer(&hello->senderIdentity,
+ signer(signer_cls,
P2P_hello_MESSAGE_size(hello)
- sizeof(Signature)
- sizeof(PublicKey)
- sizeof(MESSAGE_HEADER),
+ &hello->senderIdentity,
&uri->data.loc.helloSignature);
- signer(&uri->data.loc.fi,
+ signer(signer_cls,
sizeof(FileIdentifier) +
sizeof(PublicKey) +
sizeof(TIME_T),
+ &uri->data.loc.fi,
&uri->data.loc.contentSignature);
return uri;
}
Modified: GNUnet/src/applications/fs/ecrs/uritest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uritest.c 2007-01-11 08:14:08 UTC (rev
4287)
+++ GNUnet/src/applications/fs/ecrs/uritest.c 2007-01-11 08:32:12 UTC (rev
4288)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2003, 2004, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2003, 2004, 2006, 2007 Christian Grothoff (and other contributing
authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -26,6 +26,7 @@
#include "platform.h"
#include "gnunet_util.h"
+#include "gnunet_util_crypto.h"
#include "gnunet_ecrs_lib.h"
#include "ecrs.h"
@@ -56,6 +57,68 @@
return 0;
}
+static int testLocation() {
+ struct ECRS_URI * uri;
+ char * uric;
+ struct ECRS_URI * uri2;
+ PublicKey pk;
+ struct PrivateKey * hk;
+ struct ECRS_URI * baseURI;
+
+ baseURI = ECRS_stringToUri(NULL,
"gnunet://ecrs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42");
+ hk = makePrivateKey();
+ getPublicKey(hk,
+ &pk);
+ uri = ECRS_uriFromLocation(baseURI,
+ &pk,
+ TIME(NULL) + 60,
+ 42, /* PROTO */
+ 4, /* SAS */
+ 1500, /* MTU */
+ "GNU!", /* location */
+ (ECRS_SignFunction) &sign,
+ hk);
+ freePrivateKey(hk);
+ if (uri == NULL) {
+ ECRS_freeUri(baseURI);
+ return 1;
+ }
+ if (! ECRS_isLocationUri(uri)) {
+ ECRS_freeUri(uri);
+ ECRS_freeUri(baseURI);
+ return 1;
+ }
+ uri2 = ECRS_getContentUri(uri);
+ if (! ECRS_equalsUri(baseURI,
+ uri2)) {
+ ECRS_freeUri(uri);
+ ECRS_freeUri(uri2);
+ ECRS_freeUri(baseURI);
+ return 1;
+ }
+ ECRS_freeUri(baseURI);
+ uric = ECRS_uriToString(uri);
+#if 1
+ /* not for the faint of heart: */
+ printf("URI: `%s'\n", uric);
+#endif
+ uri2 = ECRS_stringToUri(NULL, uric);
+ FREE(uric);
+ if (uri2 == NULL) {
+ ECRS_freeUri(uri);
+ return 1;
+ }
+ if (YES != ECRS_equalsUri(uri,
+ uri2)) {
+ ECRS_freeUri(uri);
+ ECRS_freeUri(uri2);
+ return 1;
+ }
+ ECRS_freeUri(uri2);
+ ECRS_freeUri(uri);
+ return 0;
+}
+
static int testNamespace(int i) {
char * uri;
struct ECRS_URI * ret;
@@ -100,7 +163,7 @@
ABORT();
if (ECRS_isNamespaceUri(ret))
ABORT();
- if (ntohll(ret->data.chk.file_length) != 42)
+ if (ntohll(ret->data.fi.file_length) != 42)
ABORT();
uri = ECRS_uriToString(ret);
@@ -118,6 +181,7 @@
int i;
failureCount += testKeyword();
+ failureCount += testLocation();
for (i=0;i<255;i++) {
failureCount += testNamespace(i);
failureCount += testFile(i);
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2007-01-11 08:14:08 UTC (rev
4287)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2007-01-11 08:32:12 UTC (rev
4288)
@@ -269,13 +269,15 @@
* Convert a NULL-terminated array of keywords
* to an ECRS URI.
*/
-struct ECRS_URI * ECRS_keywordsToUri(const char * keyword[]);
+struct ECRS_URI *
+ECRS_keywordsToUri(const char * keyword[]);
/**
* Convert a UTF-8 String to a URI.
*/
-struct ECRS_URI * ECRS_stringToUri(struct GE_Context * ectx,
- const char * uri);
+struct ECRS_URI *
+ECRS_stringToUri(struct GE_Context * ectx,
+ const char * uri);
/**
* Free URI.
@@ -324,8 +326,9 @@
* Function that produces a signature for
* a particular piece of content.
*/
-typedef int (*ECRS_SignFunction)(const void * data,
+typedef int (*ECRS_SignFunction)(void * cls,
unsigned short size,
+ const void * data,
Signature * result);
/**
@@ -348,8 +351,9 @@
unsigned short proto,
unsigned short sas,
unsigned int mtu,
- char * address,
- ECRS_SignFunction signer);
+ const char * address,
+ ECRS_SignFunction signer,
+ void * signer_cls);
/**
@@ -362,7 +366,8 @@
* adding the current date (YYYY-MM-DD) after each
* keyword.
*/
-struct ECRS_URI * ECRS_dateExpandKeywordUri(const struct ECRS_URI * uri);
+struct ECRS_URI *
+ECRS_dateExpandKeywordUri(const struct ECRS_URI * uri);
/**
* Create an ECRS URI from a single user-supplied string of keywords.
Modified: GNUnet/src/util/crypto/hashing.c
===================================================================
--- GNUnet/src/util/crypto/hashing.c 2007-01-11 08:14:08 UTC (rev 4287)
+++ GNUnet/src/util/crypto/hashing.c 2007-01-11 08:32:12 UTC (rev 4288)
@@ -437,7 +437,7 @@
vbit += 8;
}
if (vbit < 5) {
- bits = bits << (5 - vbit); /* zero-padding */
+ bits <<= (5 - vbit); /* zero-padding */
GE_ASSERT(NULL, vbit == 2); /* padding by 3: 512+3 mod 5 == 0 */
vbit = 5;
}
@@ -478,7 +478,7 @@
if (vbit >= 8) {
((unsigned char*)result)[--wpos]
= (unsigned char) bits;
- bits = bits >> 8;
+ bits >>= 8;
vbit -= 8;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4288 - in GNUnet: m4 src/applications/fs/ecrs src/include src/util/crypto,
grothoff <=