[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r366 - in GNUnet: . src/applications/advertising src/applic
From: |
grothoff |
Subject: |
[GNUnet-SVN] r366 - in GNUnet: . src/applications/advertising src/applications/chat src/applications/datastore src/applications/dht/module src/applications/dht/tools src/applications/fragmentation src/applications/fs src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/lib src/applications/fs/module src/applications/fs/tools src/applications/gap src/applications/sqstore_mysql src/applications/sqstore_sqlite src/applications/tracekit src/applications/traffic src/conf src/include src/server src/transports src/util |
Date: |
Fri, 4 Mar 2005 21:37:04 -0800 (PST) |
Author: grothoff
Date: 2005-03-04 21:37:01 -0800 (Fri, 04 Mar 2005)
New Revision: 366
Modified:
GNUnet/AUTHORS
GNUnet/ChangeLog
GNUnet/src/applications/advertising/advertising.c
GNUnet/src/applications/chat/chat.c
GNUnet/src/applications/datastore/datastore.c
GNUnet/src/applications/datastore/filter.c
GNUnet/src/applications/datastore/filter.h
GNUnet/src/applications/datastore/prefetch.c
GNUnet/src/applications/datastore/prefetch.h
GNUnet/src/applications/dht/module/cs.c
GNUnet/src/applications/dht/module/datastore_dht_master.c
GNUnet/src/applications/dht/module/datastore_memory.c
GNUnet/src/applications/dht/module/datastore_memory_test.c
GNUnet/src/applications/dht/module/dht.c
GNUnet/src/applications/dht/tools/dht-join.c
GNUnet/src/applications/dht/tools/dht-query.c
GNUnet/src/applications/dht/tools/dht_api.c
GNUnet/src/applications/fragmentation/fragmentation.c
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/ecrs/ecrs.c
GNUnet/src/applications/fs/ecrs/ecrs.h
GNUnet/src/applications/fs/ecrs/ecrstest.c
GNUnet/src/applications/fs/ecrs/keyspace.c
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/ecrs/unindex.c
GNUnet/src/applications/fs/ecrs/upload.c
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/ecrs_core.c
GNUnet/src/applications/fs/fsui/collection.c
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/fsui/fsui.h
GNUnet/src/applications/fs/fsui/namespace_info.c
GNUnet/src/applications/fs/fsui/search.c
GNUnet/src/applications/fs/lib/fslib.c
GNUnet/src/applications/fs/lib/fslibtest.c
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/fs/module/migration.c
GNUnet/src/applications/fs/module/ondemand.c
GNUnet/src/applications/fs/module/ondemand.h
GNUnet/src/applications/fs/module/querymanager.c
GNUnet/src/applications/fs/module/querymanager.h
GNUnet/src/applications/fs/tools/gnunet-directory.c
GNUnet/src/applications/fs/tools/gnunet-insert.c
GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
GNUnet/src/applications/gap/gap.c
GNUnet/src/applications/sqstore_mysql/mysql.c
GNUnet/src/applications/sqstore_mysql/mysqltest.c
GNUnet/src/applications/sqstore_sqlite/sqlite.c
GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
GNUnet/src/applications/tracekit/gnunet-tracekit.c
GNUnet/src/applications/tracekit/tracekit.c
GNUnet/src/applications/traffic/traffic.c
GNUnet/src/conf/gnunet-win-tool.c
GNUnet/src/include/ecrs_core.h
GNUnet/src/include/fs.h
GNUnet/src/include/gnunet_blockstore.h
GNUnet/src/include/gnunet_datastore_service.h
GNUnet/src/include/gnunet_dht.h
GNUnet/src/include/gnunet_dht_lib.h
GNUnet/src/include/gnunet_dht_service.h
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/src/include/gnunet_fs_lib.h
GNUnet/src/include/gnunet_fsui_lib.h
GNUnet/src/include/gnunet_gap_service.h
GNUnet/src/include/gnunet_sqstore_service.h
GNUnet/src/include/gnunet_util.h
GNUnet/src/server/connection.c
GNUnet/src/server/connection.h
GNUnet/src/server/version.c
GNUnet/src/transports/nat.c
GNUnet/src/util/Makefile.am
GNUnet/src/util/bloomfilter.c
GNUnet/src/util/bloomtest.c
GNUnet/src/util/hashing.c
GNUnet/src/util/hashingtest.c
GNUnet/src/util/hashtest.c
GNUnet/src/util/hostkey_gcrypt.c
GNUnet/src/util/hostkey_openssl.c
GNUnet/src/util/hostkeytest.c
GNUnet/src/util/kblockkey.c
GNUnet/src/util/kblockkey_test.c
GNUnet/src/util/storagetest.c
GNUnet/src/util/symcipher_gcrypt.c
GNUnet/src/util/symcipher_openssl.c
GNUnet/todo
Log:
changing ciphers
Modified: GNUnet/AUTHORS
===================================================================
--- GNUnet/AUTHORS 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/AUTHORS 2005-03-05 05:37:01 UTC (rev 366)
@@ -24,7 +24,11 @@
Uli Luckas <address@hidden>
Werner Koch <address@hidden> [original code of libgcrypt]
Kevin Vandersloot <address@hidden> [original code of gnome-system-monitor]
+Jean-Luc Cooke <address@hidden> [ SHA-512]
+Andrew McDonald <address@hidden> [ SHA-512]
+Kyle McMartin <address@hidden> [ SHA-512]
+
Original RPC and DHT-module were contributed by:
Marko R�ih�
Risto Saarelma
Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/ChangeLog 2005-03-05 05:37:01 UTC (rev 366)
@@ -1,3 +1,7 @@
+Sat Mar 5 00:33:51 EST 2005
+ Changing hash algorithm to SHA-512.
+ Changing symcipher algorithm to AES-256.
+
Sun Feb 27 21:59:31 EST 2005
All unit testcases pass. Releasing 0.7.0pre0.
Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/advertising/advertising.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -139,7 +139,7 @@
return SYSERR;
identity->getPeerIdentity(&msg->publicKey,
&foreignId);
- if (!equalsHashCode160(&msg->senderIdentity.hashPubKey,
+ if (!equalsHashCode512(&msg->senderIdentity.hashPubKey,
&foreignId.hashPubKey))
return SYSERR; /* public key and host hash do not match */
if (SYSERR == verifySig(&msg->senderIdentity,
Modified: GNUnet/src/applications/chat/chat.c
===================================================================
--- GNUnet/src/applications/chat/chat.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/applications/chat/chat.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -37,16 +37,16 @@
static ClientHandle clients[MAX_CLIENTS];
static int clientCount;
-static HashCode160 lastMsgs[MAX_LAST_MESSAGES];
+static HashCode512 lastMsgs[MAX_LAST_MESSAGES];
static int ringIndex;
static Mutex chatMutex;
-static void markSeen(HashCode160 * hc) {
+static void markSeen(HashCode512 * hc) {
if (++ringIndex >= MAX_LAST_MESSAGES)
ringIndex = 0;
memcpy(&lastMsgs[ringIndex],
hc,
- sizeof(HashCode160));
+ sizeof(HashCode512));
}
typedef struct {
@@ -80,7 +80,7 @@
int j;
CHAT_CS_MESSAGE * cmsg;
CHAT_p2p_MESSAGE * pmsg;
- HashCode160 hc;
+ HashCode512 hc;
if (ntohs(message->size) != sizeof(CHAT_p2p_MESSAGE)) {
LOG(LOG_WARNING,
@@ -97,7 +97,7 @@
j = -1;
MUTEX_LOCK(&chatMutex);
for (i=0;i<MAX_LAST_MESSAGES;i++)
- if (equalsHashCode160(&hc, &lastMsgs[i]))
+ if (equalsHashCode512(&hc, &lastMsgs[i]))
j = i;
if (j == -1) {
/* we have not seen it before, send to all TCP clients
@@ -126,7 +126,7 @@
int j;
CHAT_CS_MESSAGE * cmsg;
CHAT_p2p_MESSAGE * pmsg;
- HashCode160 hc;
+ HashCode512 hc;
if (ntohs(message->size) != sizeof(CHAT_CS_MESSAGE)) {
LOG(LOG_WARNING,
Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/datastore/datastore.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -66,7 +66,7 @@
return sq->getSize();
}
-static int get(const HashCode160 * query,
+static int get(const HashCode512 * query,
unsigned int type,
Datum_Iterator iter,
void * closure) {
@@ -93,7 +93,7 @@
/**
* Explicitly remove some content from the database.
*/
-static int del(const HashCode160 * query,
+static int del(const HashCode512 * query,
const Datastore_Value * value) {
int ok;
EncName enc;
@@ -141,7 +141,7 @@
* to justify removing something else, SYSERR on
* other serious error (i.e. IO permission denied)
*/
-static int put(const HashCode160 * key,
+static int put(const HashCode512 * key,
const Datastore_Value * value) {
int ok;
@@ -169,7 +169,7 @@
Datastore_Value * existing;
} CE;
-static int checkExists(const HashCode160 * key,
+static int checkExists(const HashCode512 * key,
const Datastore_Value * value,
CE * ce) {
ce->existing = MALLOC(ntohl(value->size));
@@ -190,7 +190,7 @@
* to justify removing something else, SYSERR on
* other serious error (i.e. IO permission denied)
*/
-static int putUpdate(const HashCode160 * key,
+static int putUpdate(const HashCode512 * key,
const Datastore_Value * value) {
CE cls;
int ok;
@@ -240,7 +240,7 @@
return ok;
}
-static int freeSpaceExpired(const HashCode160 * key,
+static int freeSpaceExpired(const HashCode512 * key,
const Datastore_Value * value,
void * closure) {
int ret;
@@ -255,7 +255,7 @@
return OK;
}
-static int freeSpaceLow(const HashCode160 * key,
+static int freeSpaceLow(const HashCode512 * key,
const Datastore_Value * value,
void * closure) {
int ret;
@@ -350,7 +350,7 @@
* Callback that adds all element of the SQStore to the
* bloomfilter.
*/
-static int filterAddAll(const HashCode160 * key,
+static int filterAddAll(const HashCode512 * key,
const Datastore_Value * value,
void * closure) {
makeAvailable(key);
Modified: GNUnet/src/applications/datastore/filter.c
===================================================================
--- GNUnet/src/applications/datastore/filter.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/datastore/filter.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -84,15 +84,15 @@
FREE(fn);
}
-void makeAvailable(const HashCode160 * key) {
+void makeAvailable(const HashCode512 * key) {
addToBloomfilter(filter, key);
}
-void makeUnavailable(const HashCode160 * key) {
+void makeUnavailable(const HashCode512 * key) {
delFromBloomfilter(filter, key);
}
-int testAvailable(const HashCode160 * key) {
+int testAvailable(const HashCode512 * key) {
return testBloomfilter(filter,
key);
}
Modified: GNUnet/src/applications/datastore/filter.h
===================================================================
--- GNUnet/src/applications/datastore/filter.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/datastore/filter.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -32,10 +32,10 @@
void deleteFilter();
-void makeAvailable(const HashCode160 * key);
+void makeAvailable(const HashCode512 * key);
-void makeUnavailable(const HashCode160 * key);
+void makeUnavailable(const HashCode512 * key);
-int testAvailable(const HashCode160 * key);
+int testAvailable(const HashCode512 * key);
#endif
Modified: GNUnet/src/applications/datastore/prefetch.c
===================================================================
--- GNUnet/src/applications/datastore/prefetch.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/datastore/prefetch.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -38,7 +38,7 @@
* Buffer with pre-fetched, encoded random content for migration.
*/
typedef struct {
- HashCode160 key;
+ HashCode512 key;
Datastore_Value * value;
} ContentBuffer;
@@ -71,7 +71,7 @@
static PTHREAD_T gather_thread;
-static int aquire(const HashCode160 * key,
+static int aquire(const HashCode512 * key,
const Datastore_Value * value,
void * closure) {
int load;
@@ -134,9 +134,9 @@
*
* @return SYSERR if the RCB is empty
*/
-int getRandom(const HashCode160 * receiver,
+int getRandom(const HashCode512 * receiver,
unsigned int sizeLimit,
- HashCode160 * key,
+ HashCode512 * key,
Datastore_Value ** value,
unsigned int type) {
unsigned int dist;
@@ -151,7 +151,7 @@
if ( (type != ntohl(randomContentBuffer[i].value->type)) ||
(sizeLimit < ntohl(randomContentBuffer[i].value->size)) )
continue;
- dist = distanceHashCode160(&randomContentBuffer[i].key,
+ dist = distanceHashCode512(&randomContentBuffer[i].key,
receiver);
if (dist < minDist) {
minIdx = i;
Modified: GNUnet/src/applications/datastore/prefetch.h
===================================================================
--- GNUnet/src/applications/datastore/prefetch.h 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/datastore/prefetch.h 2005-03-05 05:37:01 UTC
(rev 366)
@@ -48,9 +48,9 @@
* for any type.
* @return OK if a value was found, SYSERR if not
*/
-int getRandom(const HashCode160 * receiver,
+int getRandom(const HashCode512 * receiver,
unsigned int sizeLimit,
- HashCode160 * key,
+ HashCode512 * key,
Datastore_Value ** value,
unsigned int type);
Modified: GNUnet/src/applications/dht/module/cs.c
===================================================================
--- GNUnet/src/applications/dht/module/cs.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/dht/module/cs.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -163,7 +163,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
DataProcessor resultCallback,
void * resCallbackClosure) {
DHT_CS_REQUEST_GET * req;
@@ -179,10 +179,10 @@
handlers->resultCallbackClosure = resCallbackClosure;
handlers->status = 0;
size = sizeof(DHT_CS_REQUEST_GET) +
- (keyCount-1) * sizeof(HashCode160);
+ (keyCount-1) * sizeof(HashCode512);
if (((unsigned int)size)
!= sizeof(DHT_CS_REQUEST_GET) +
- (keyCount-1) * sizeof(HashCode160)) {
+ (keyCount-1) * sizeof(HashCode512)) {
SEMAPHORE_UP(handlers->prerequest);
return SYSERR; /* too many keys, size > rangeof(short) */
}
@@ -194,7 +194,7 @@
req->table = handlers->table;
memcpy(&req->keys,
keys,
- sizeof(HashCode160) * keyCount);
+ sizeof(HashCode512) * keyCount);
req->timeout = htonll(0);
if (OK != coreAPI->sendToClient(handlers->handler,
&req->header)) {
@@ -218,7 +218,7 @@
* @return OK if the value could be stored, SYSERR if not (i.e. out of space)
*/
static int tcp_put(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value,
unsigned int prio) {
DHT_CS_REQUEST_PUT * req;
@@ -265,7 +265,7 @@
* @return OK if the value could be removed, SYSERR if not (i.e. not present)
*/
static int tcp_del(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value) {
DHT_CS_REQUEST_REMOVE * req;
CS_TableHandlers * handlers = closure;
@@ -412,7 +412,7 @@
MUTEX_LOCK(&csLock);
for (i=0;i<csHandlersCount;i++) {
- if ( (equalsHashCode160(&csHandlers[i]->table,
+ if ( (equalsHashCode512(&csHandlers[i]->table,
&req->table)) ) {
if (OK != dhtAPI->leave(&req->table,
ntohll(req->timeout))) {
@@ -651,7 +651,7 @@
-static int cs_get_result_callback(const HashCode160 * key,
+static int cs_get_result_callback(const HashCode512 * key,
const DataContainer * value,
CS_GET_RECORD * record) {
DHT_CS_REPLY_RESULTS * msg;
@@ -736,7 +736,7 @@
req = cpc->message;
FREE(cpc);
- keyCount = 1 + ((ntohs(req->header.size) - sizeof(DHT_CS_REQUEST_GET)) /
sizeof(HashCode160));
+ keyCount = 1 + ((ntohs(req->header.size) - sizeof(DHT_CS_REQUEST_GET)) /
sizeof(HashCode512));
ptr = MALLOC(sizeof(CS_GET_RECORD));
ptr->client = client;
ptr->count = 0;
@@ -804,7 +804,7 @@
MUTEX_LOCK(&csLock);
for (i=0;i<csHandlersCount;i++) {
if ( (csHandlers[i]->handler == client) &&
- (equalsHashCode160(&csHandlers[i]->table,
+ (equalsHashCode512(&csHandlers[i]->table,
&req->table)) ) {
SEMAPHORE_DOWN(ptr->postreply);
ptr = csHandlers[i];
@@ -849,7 +849,7 @@
MUTEX_LOCK(&csLock);
for (i=0;i<csHandlersCount;i++) {
if ( (csHandlers[i]->handler == client) &&
- (equalsHashCode160(&csHandlers[i]->table,
+ (equalsHashCode512(&csHandlers[i]->table,
&req->table)) ) {
ptr = csHandlers[i];
SEMAPHORE_DOWN(ptr->postreply);
Modified: GNUnet/src/applications/dht/module/datastore_dht_master.c
===================================================================
--- GNUnet/src/applications/dht/module/datastore_dht_master.c 2005-03-04
19:31:22 UTC (rev 365)
+++ GNUnet/src/applications/dht/module/datastore_dht_master.c 2005-03-05
05:37:01 UTC (rev 366)
@@ -41,7 +41,7 @@
#include "datastore_dht_master.h"
typedef struct {
- HashCode160 hash;
+ HashCode512 hash;
cron_t lastRefreshTime;
} MasterEntry;
@@ -50,7 +50,7 @@
*/
typedef struct HT_Entry_t {
struct HT_Entry_t * next;
- HashCode160 key;
+ HashCode512 key;
unsigned int count;
MasterEntry * values;
} HT_Entry;
@@ -77,7 +77,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
DataProcessor resultCallback,
void * resCallbackClosure) {
MemoryDatastore * ds = (MemoryDatastore*) closure;
@@ -92,7 +92,7 @@
MUTEX_LOCK(&ds->lock);
pos = ds->first;
while (pos != NULL) {
- if (equalsHashCode160(&keys[0], &pos->key)) {
+ if (equalsHashCode512(&keys[0], &pos->key)) {
int * perm;
if (pos->count > prio)
@@ -111,12 +111,12 @@
else
j = perm[i];
data = MALLOC(sizeof(DataContainer) +
- sizeof(HashCode160));
+ sizeof(HashCode512));
data->size = htonl(sizeof(DataContainer) +
- sizeof(HashCode160));
+ sizeof(HashCode512));
memcpy(&data[1],
&pos->values[j].hash,
- sizeof(HashCode160));
+ sizeof(HashCode512));
resultCallback(NULL,
data,
resCallbackClosure);
@@ -136,13 +136,13 @@
* Store an item in the datastore.
*
* @param key the key of the item
- * @param value the value to store, must be of size HashCode160 for
+ * @param value the value to store, must be of size HashCode512 for
* the master table!
* @return OK if the value could be stored, SYSERR if not,
* NO for out of space)
*/
static int store(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value,
unsigned int prio) {
MemoryDatastore * ds = (MemoryDatastore*) closure;
@@ -152,16 +152,16 @@
if ( (ds == NULL) || (value == NULL) )
return SYSERR;
if (ntohl(value->size) - sizeof(DataContainer)
- != sizeof(HashCode160))
+ != sizeof(HashCode512))
return SYSERR;
MUTEX_LOCK(&ds->lock);
pos = ds->first;
while (pos != NULL) {
- if (equalsHashCode160(key, &pos->key)) {
+ if (equalsHashCode512(key, &pos->key)) {
for (i=0;i<pos->count;i++)
- if (equalsHashCode160(&pos->values[i].hash,
- (HashCode160*)&value[1])) {
+ if (equalsHashCode512(&pos->values[i].hash,
+ (HashCode512*)&value[1])) {
pos->values[i].lastRefreshTime = cronTime(NULL);
MUTEX_UNLOCK(&ds->lock);
return OK; /* already present */
@@ -177,7 +177,7 @@
pos->values[pos->count-1].lastRefreshTime = cronTime(NULL);
memcpy(&pos->values[pos->count-1].hash,
&value[1],
- sizeof(HashCode160));
+ sizeof(HashCode512));
MUTEX_UNLOCK(&ds->lock);
return OK;
} /* end key match */
@@ -195,7 +195,7 @@
pos->values = MALLOC(sizeof(MasterEntry));
memcpy(&pos->values[0].hash,
&value[1],
- sizeof(HashCode160));
+ sizeof(HashCode512));
pos->values[0].lastRefreshTime = cronTime(NULL);
pos->next = ds->first;
ds->first = pos;
@@ -210,7 +210,7 @@
* @return OK if the value could be removed, SYSERR if not (i.e. not present)
*/
static int ds_remove(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value) {
MemoryDatastore * ds = (MemoryDatastore*) closure;
HT_Entry * pos;
@@ -221,19 +221,19 @@
return SYSERR;
if ( (value != NULL) &&
(ntohl(value->size) - sizeof(DataContainer)
- != sizeof(HashCode160)) )
+ != sizeof(HashCode512)) )
return SYSERR;
MUTEX_LOCK(&ds->lock);
prev = NULL;
pos = ds->first;
while (pos != NULL) {
- if (equalsHashCode160(key, &pos->key)) {
+ if (equalsHashCode512(key, &pos->key)) {
if (value != NULL) {
for (i=0;i<pos->count;i++) {
if (0 == memcmp(&pos->values[i].hash,
&value[1],
- sizeof(HashCode160))) {
+ sizeof(HashCode512))) {
pos->values[i] = pos->values[pos->count-1];
GROW(pos->values,
pos->count,
@@ -297,15 +297,15 @@
MUTEX_LOCK(&ds->lock);
pos = ds->first;
ret = 0;
- cont = MALLOC(sizeof(HashCode160) + sizeof(DataContainer));
- cont->size = htonl(sizeof(HashCode160) + sizeof(DataContainer));
+ cont = MALLOC(sizeof(HashCode512) + sizeof(DataContainer));
+ cont->size = htonl(sizeof(HashCode512) + sizeof(DataContainer));
while (pos != NULL) {
for (i=0;i<pos->count;i++) {
ret++;
if (processor != NULL) {
memcpy(&cont[1],
&pos->values[i].hash,
- sizeof(HashCode160));
+ sizeof(HashCode512));
if (OK != processor(&pos->key,
cont,
cls)) {
Modified: GNUnet/src/applications/dht/module/datastore_memory.c
===================================================================
--- GNUnet/src/applications/dht/module/datastore_memory.c 2005-03-04
19:31:22 UTC (rev 365)
+++ GNUnet/src/applications/dht/module/datastore_memory.c 2005-03-05
05:37:01 UTC (rev 366)
@@ -39,7 +39,7 @@
*/
typedef struct HT_Entry_t {
struct HT_Entry_t * next;
- HashCode160 key;
+ HashCode512 key;
unsigned int count;
DataContainer ** values;
} HT_Entry;
@@ -72,7 +72,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
DataProcessor resultCallback,
void * resCallbackClosure) {
MemoryDatastore * ds = (MemoryDatastore*) closure;
@@ -84,7 +84,7 @@
MUTEX_LOCK(&ds->lock);
pos = ds->first;
while (pos != NULL) {
- if (equalsHashCode160(&keys[0], &pos->key)) {
+ if (equalsHashCode512(&keys[0], &pos->key)) {
for (i=0;i<pos->count;i++)
if (OK != resultCallback(&pos->key,
pos->values[i],
@@ -110,7 +110,7 @@
* @return OK if the value could be stored, DHT_ERRORCODE or SYSERR if not
(i.e. out of space)
*/
static int store(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value,
unsigned int prio) {
MemoryDatastore * ds = (MemoryDatastore*) closure;
@@ -124,7 +124,7 @@
MUTEX_LOCK(&ds->lock);
pos = ds->first;
while (pos != NULL) {
- if (equalsHashCode160(key, &pos->key)) {
+ if (equalsHashCode512(key, &pos->key)) {
if (ds->max_memory < size) {
MUTEX_UNLOCK(&ds->lock);
return NO;
@@ -171,7 +171,7 @@
* @return OK if the value could be removed, SYSERR if not (i.e. not present)
*/
static int ds_remove(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value) {
MemoryDatastore * ds = closure;
HT_Entry * pos;
@@ -186,7 +186,7 @@
prev = NULL;
pos = ds->first;
while (pos != NULL) {
- if (equalsHashCode160(key, &pos->key)) {
+ if (equalsHashCode512(key, &pos->key)) {
if (value != NULL) {
for (i=0;i<pos->count;i++) {
if ( (pos->values[i]->size == value->size) &&
Modified: GNUnet/src/applications/dht/module/datastore_memory_test.c
===================================================================
--- GNUnet/src/applications/dht/module/datastore_memory_test.c 2005-03-04
19:31:22 UTC (rev 365)
+++ GNUnet/src/applications/dht/module/datastore_memory_test.c 2005-03-05
05:37:01 UTC (rev 366)
@@ -35,7 +35,7 @@
static int store(Blockstore * s,
char * key,
char * val) {
- HashCode160 hc;
+ HashCode512 hc;
DataContainer * cont;
cont = MALLOC(sizeof(DataContainer) + strlen(val));
@@ -61,7 +61,7 @@
static int rem(Blockstore * s,
char * key,
char * val) {
- HashCode160 hc;
+ HashCode512 hc;
DataContainer * cont;
if (val == NULL) {
@@ -87,7 +87,7 @@
return 0;
}
-static int resCB(const HashCode160 * key,
+static int resCB(const HashCode512 * key,
const DataContainer * val,
void * cls) {
DataContainer ** trg = cls;
@@ -101,7 +101,7 @@
static int load(Blockstore * s,
char * key,
char * val) {
- HashCode160 hc;
+ HashCode512 hc;
DataContainer * cont;
cont = NULL;
@@ -169,7 +169,7 @@
return OK;
}
-int main(int args,
+int main(int argc,
char * argv[]) {
Blockstore * s;
int i;
Modified: GNUnet/src/applications/dht/module/dht.c
===================================================================
--- GNUnet/src/applications/dht/module/dht.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/dht/module/dht.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -204,7 +204,7 @@
/**
* Towards which key are we routing?
*/
- HashCode160 key;
+ HashCode512 key;
/**
* In what table are we searching?
@@ -225,7 +225,7 @@
/**
* Best k matches found so far. Of size ALPHA.
*/
- HashCode160 * matches;
+ HashCode512 * matches;
/**
* Number of RPCs transmitted so far (if it reaches
@@ -278,7 +278,7 @@
/**
* Towards which key are we routing?
*/
- HashCode160 key;
+ HashCode512 key;
/**
* In what table are we searching?
@@ -361,7 +361,7 @@
/**
* What are the keys?
*/
- HashCode160 * keys;
+ HashCode512 * keys;
DataProcessor resultCallback;
@@ -412,7 +412,7 @@
/**
* What is the key?
*/
- HashCode160 key;
+ HashCode512 key;
DataContainer * value;
@@ -468,7 +468,7 @@
/**
* What is the key?
*/
- HashCode160 key;
+ HashCode512 key;
/**
* Which value should be removed?
@@ -624,7 +624,7 @@
FindNodesContext * fnc);
static FindKNodesContext * findKNodes_start(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
unsigned int k,
NodeFoundCallback callback,
@@ -658,7 +658,7 @@
/**
* The ID of the master table.
*/
-static HashCode160 masterTableId;
+static HashCode512 masterTableId;
/**
* List of the tables that this peer participates in.
@@ -784,7 +784,7 @@
static LocalTableData * getLocalTableData(const DHT_TableId * id) {
int i;
for (i=tablesCount-1;i>=0;i--)
- if (equalsHashCode160(id,
+ if (equalsHashCode512(id,
&tables[i].id))
return &tables[i];
return NULL;
@@ -797,7 +797,7 @@
*/
static int isNotCloserThanMe(const DHT_TableId * table,
const PeerIdentity * peer,
- const HashCode160 * key) {
+ const HashCode512 * key) {
if (NULL == getLocalTableData(table))
return NO;
if (-1 == hashCodeCompareDistance(&peer->hashPubKey,
@@ -820,8 +820,8 @@
EncName enc2;
#endif
- index = sizeof(HashCode160)*8;
- for (i = sizeof(HashCode160)*8 - 1; i >= 0; --i) {
+ index = sizeof(HashCode512)*8;
+ for (i = sizeof(HashCode512)*8 - 1; i >= 0; --i) {
diff = getHashCodeBit(&peer->hashPubKey, i) -
getHashCodeBit(&coreAPI->myIdentity->hashPubKey, i);
if (diff != 0) {
index = i;
@@ -870,16 +870,16 @@
*/
static void k_best_insert(unsigned int limit,
int * k,
- const HashCode160 * key,
- HashCode160 * kbest,
- const HashCode160 * newValue) {
+ const HashCode512 * key,
+ HashCode512 * kbest,
+ const HashCode512 * newValue) {
int replace;
int m;
if ((*k) < limit) {
memcpy(&kbest[*k],
newValue,
- sizeof(HashCode160));
+ sizeof(HashCode512));
(*k)++;
} else {
replace = -1;
@@ -895,7 +895,7 @@
if (replace != -1) {
memcpy(&kbest[replace],
newValue,
- sizeof(HashCode160));
+ sizeof(HashCode512));
}
}
}
@@ -914,7 +914,7 @@
return NULL;
pos = vectorGetFirst(bucket->peers);
while (pos != NULL) {
- if (equalsHashCode160(&peer->hashPubKey,
+ if (equalsHashCode512(&peer->hashPubKey,
&pos->id.hashPubKey))
return pos;
pos = vectorGetNext(bucket->peers);
@@ -1197,7 +1197,7 @@
cronTime(&now);
param = RPC_paramNew();
MUTEX_LOCK(&fnc->lock);
- if (equalsHashCode160(&fnc->key,
+ if (equalsHashCode512(&fnc->key,
&coreAPI->myIdentity->hashPubKey)) {
table = getLocalTableData(&fnc->table);
if (table != NULL)
@@ -1210,7 +1210,7 @@
RPC_paramAdd(param,
"key",
- sizeof(HashCode160),
+ sizeof(HashCode512),
&fnc->key);
GROW(fnc->rpc,
fnc->rpcRepliesExpected,
@@ -1254,10 +1254,10 @@
return;
/* does the peer support the table in question? */
- if (! equalsHashCode160(&fnc->table,
+ if (! equalsHashCode512(&fnc->table,
&masterTableId)) {
for (i=tableCount-1;i>=0;i--)
- if (equalsHashCode160(&fnc->table,
+ if (equalsHashCode512(&fnc->table,
&tables[i]))
break;
if (i == -1)
@@ -1354,7 +1354,7 @@
* @return number of hosts found
*/
static unsigned int findLocalNodes(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
PeerIdentity * hosts,
unsigned int k) {
int i;
@@ -1381,7 +1381,7 @@
pos = vectorGetFirst(bucket->peers);
while (pos != NULL) {
for (j=pos->tableCount-1;j>=0;j--) {
- if (equalsHashCode160(&pos->tables[j],
+ if (equalsHashCode512(&pos->tables[j],
table)) {
#if DEBUG_DHT
EncName enc;
@@ -1396,7 +1396,7 @@
k_best_insert(k,
&ret,
key,
- (HashCode160*) hosts,
+ (HashCode512*) hosts,
&pos->id.hashPubKey);
}
}
@@ -1504,7 +1504,7 @@
&record->table);
RPC_paramAdd(param,
"keys",
- sizeof(HashCode160) * record->keyCount,
+ sizeof(HashCode512) * record->keyCount,
&record->keys);
RPC_paramAdd(param,
"timeout",
@@ -1535,11 +1535,11 @@
* callback with the results found locally.
* A DataProcessor.
*/
-static int getLocalResultCallback(const HashCode160 * key,
+static int getLocalResultCallback(const HashCode512 * key,
const DataContainer * val,
DHT_GET_RECORD * rec) {
int ret;
- if ( (equalsHashCode160(&rec->table,
+ if ( (equalsHashCode512(&rec->table,
&masterTableId)) &&
((ntohl(val->size) - sizeof(DataContainer)) % sizeof(PeerIdentity) !=
0) )
BREAK(); /* assertion failed: entry in master table malformed! */
@@ -1569,7 +1569,7 @@
dht_get_async_start(const DHT_TableId * table,
unsigned int type,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
cron_t timeout,
DataProcessor resultCallback,
void * cls,
@@ -1609,10 +1609,10 @@
ret->timeout = cronTime(NULL) + timeout;
ret->type = type;
ret->keyCount = keyCount;
- ret->keys = MALLOC(keyCount * sizeof(HashCode160));
+ ret->keys = MALLOC(keyCount * sizeof(HashCode512));
memcpy(ret->keys,
keys,
- keyCount * sizeof(HashCode160));
+ keyCount * sizeof(HashCode512));
ret->table = *table;
ret->resultCallback = resultCallback;
ret->resultClosure = cls;
@@ -1649,7 +1649,7 @@
k_best_insert(ALPHA,
&count,
&keys[0],
- (HashCode160*) hosts,
+ (HashCode512*) hosts,
&coreAPI->myIdentity->hashPubKey);
if (count == 0) {
BREAK();
@@ -1773,7 +1773,7 @@
* looking for; pass those Helos to the core *and* try to ping them.
*/
static int
-findnodes_dht_master_get_callback(const HashCode160 * key,
+findnodes_dht_master_get_callback(const HashCode512 * key,
const DataContainer * cont,
FindNodesContext * fnc) {
unsigned int dataLength;
@@ -1836,7 +1836,7 @@
* @return context for findNodes_stop
*/
static FindNodesContext * findNodes_start(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout) {
FindNodesContext * fnc;
int i;
@@ -1856,7 +1856,7 @@
fnc->key = *key;
fnc->table = *table;
fnc->k = 0;
- fnc->matches = MALLOC(sizeof(HashCode160) * ALPHA);
+ fnc->matches = MALLOC(sizeof(HashCode512) * ALPHA);
fnc->signal = SEMAPHORE_NEW(0);
fnc->timeout = cronTime(NULL) + timeout;
fnc->rpcRepliesExpected = 0;
@@ -1887,7 +1887,7 @@
/* also search for more peers for this table? */
fnc->async_handle = NULL;
if (fnc->k < ALPHA) {
- if (equalsHashCode160(table,
+ if (equalsHashCode512(table,
&masterTableId)) {
#if DEBUG_DHT
LOG(LOG_DEBUG,
@@ -1975,7 +1975,7 @@
* looking for; pass those Helos to the core *and* to the callback
* as peers supporting the table.
*/
-static void find_k_nodes_dht_master_get_callback(const HashCode160 * key,
+static void find_k_nodes_dht_master_get_callback(const HashCode512 * key,
const DataContainer * cont,
FindKNodesContext * fnc) {
unsigned int pos;
@@ -2058,7 +2058,7 @@
* @return context for findKNodes_stop
*/
static FindKNodesContext * findKNodes_start(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
unsigned int k,
NodeFoundCallback callback,
@@ -2119,7 +2119,7 @@
/* also do 'get' to find for more peers for this table */
fnc->async_handle = NULL;
- if (equalsHashCode160(table,
+ if (equalsHashCode512(table,
&masterTableId)) {
BREAK();
/* findKNodes_start called for masterTable. That should not happen! */
@@ -2263,7 +2263,7 @@
&record->table);
RPC_paramAdd(param,
"key",
- sizeof(HashCode160),
+ sizeof(HashCode512),
&record->key);
RPC_paramAdd(param,
"timeout",
@@ -2304,7 +2304,7 @@
*/
static struct DHT_PUT_RECORD *
dht_put_async_start(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
const DataContainer * value,
DHT_OP_Complete callback,
@@ -2381,7 +2381,7 @@
k_best_insert(ALPHA,
&count,
key,
- (HashCode160*) hosts,
+ (HashCode512*) hosts,
&coreAPI->myIdentity->hashPubKey);
if (count == 0) {
BREAK();
@@ -2543,7 +2543,7 @@
&record->table);
RPC_paramAdd(param,
"key",
- sizeof(HashCode160),
+ sizeof(HashCode512),
&record->key);
RPC_paramAdd(param,
"timeout",
@@ -2584,7 +2584,7 @@
*/
static struct DHT_REMOVE_RECORD *
dht_remove_async_start(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
const DataContainer * value,
DHT_OP_Complete callback,
@@ -2637,7 +2637,7 @@
k_best_insert(ALPHA,
&count,
key,
- (HashCode160*) hosts,
+ (HashCode512*) hosts,
&coreAPI->myIdentity->hashPubKey);
if (count == 0) {
BREAK();
@@ -2744,7 +2744,7 @@
/**
* Callback function to migrate content to other peers.
*/
-static int dht_migrate(const HashCode160 * key,
+static int dht_migrate(const HashCode512 * key,
const DataContainer * value,
MigrationClosure * cls) {
ENTER();
@@ -2810,7 +2810,7 @@
tablesCount,
tablesCount-1);
MUTEX_UNLOCK(lock);
- if (! equalsHashCode160(&masterTableId,
+ if (! equalsHashCode512(&masterTableId,
table)) {
/* issue dht_remove to remove this peer
from the master table for this table;
@@ -2908,7 +2908,7 @@
static void rpc_DHT_findNode(const PeerIdentity * sender,
RPC_Param * arguments,
RPC_Param * results) {
- HashCode160 * key;
+ HashCode512 * key;
DHT_TableId * table;
unsigned int dataLength;
unsigned int count;
@@ -2923,7 +2923,7 @@
"key",
&dataLength,
(void**) &key)) ||
- (dataLength != sizeof(HashCode160)) ||
+ (dataLength != sizeof(HashCode512)) ||
(OK != RPC_paramValueByName(arguments,
"table",
&dataLength,
@@ -2989,7 +2989,7 @@
* been accumulated this will also stop the cron-job and trigger
* sending the cummulative reply via RPC.
*/
-static int rpc_dht_findValue_callback(const HashCode160 * key,
+static int rpc_dht_findValue_callback(const HashCode512 * key,
const DataContainer * value,
RPC_DHT_FindValue_Context * fw) {
ENTER();
@@ -3027,7 +3027,7 @@
RPC_Param * arguments,
Async_RPC_Complete_Callback callback,
struct CallInstance * rpc_context) {
- HashCode160 * keys;
+ HashCode512 * keys;
DHT_TableId * table;
unsigned long long * timeout;
unsigned int * type;
@@ -3042,7 +3042,7 @@
"keys",
&keysLength,
(void**) &keys)) ||
- (0 != (keysLength % sizeof(HashCode160))) ||
+ (0 != (keysLength % sizeof(HashCode512))) ||
(OK != RPC_paramValueByName(arguments,
"table",
&dataLength,
@@ -3080,7 +3080,7 @@
fw_context->get_record
= dht_get_async_start(table,
ntohl(*type),
- keysLength / sizeof(HashCode160),
+ keysLength / sizeof(HashCode512),
keys,
ntohll(*timeout),
(DataProcessor) &rpc_dht_findValue_callback,
@@ -3146,7 +3146,7 @@
RPC_Param * arguments,
Async_RPC_Complete_Callback callback,
struct CallInstance * rpc_context) {
- HashCode160 * key;
+ HashCode512 * key;
DHT_TableId * table;
unsigned int dataLength;
DataContainer * value;
@@ -3161,7 +3161,7 @@
"key",
&dataLength,
(void**) &key)) ||
- (dataLength != sizeof(HashCode160)) ||
+ (dataLength != sizeof(HashCode512)) ||
(OK != RPC_paramValueByName(arguments,
"table",
&dataLength,
@@ -3274,7 +3274,7 @@
RPC_Param * arguments,
Async_RPC_Complete_Callback callback,
struct CallInstance * rpc_context) {
- HashCode160 * key;
+ HashCode512 * key;
DHT_TableId * table;
unsigned int dataLength;
DataContainer * value;
@@ -3289,7 +3289,7 @@
"key",
&dataLength,
(void**) &key)) ||
- (dataLength != sizeof(HashCode160)) ||
+ (dataLength != sizeof(HashCode512)) ||
(OK != RPC_paramValueByName(arguments,
"table",
&dataLength,
@@ -3449,7 +3449,7 @@
for (i=0;i<tablesCount;i++) {
if (tables[i].lastMasterAdvertisement + DHT_MAINTAIN_BUCKET_FREQUENCY <
now) {
tables[i].lastMasterAdvertisement = now;
- if (equalsHashCode160(&tables[i].id,
+ if (equalsHashCode512(&tables[i].id,
&masterTableId))
continue;
GROW(putRecords,
@@ -3616,7 +3616,7 @@
api.remove_start = &dht_remove_async_start;
api.remove_stop = &dht_remove_async_stop;
- memset(&masterTableId, 0, sizeof(HashCode160));
+ memset(&masterTableId, 0, sizeof(HashCode512));
/* join the master table */
i = getConfigurationInt("DHT",
"MASTER-TABLE-SIZE");
Modified: GNUnet/src/applications/dht/tools/dht-join.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-join.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/dht/tools/dht-join.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -152,7 +152,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
DataProcessor processor,
void * pclosure) {
int ret;
@@ -170,7 +170,7 @@
}
static int store(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value,
unsigned int prio) {
int ret;
@@ -186,7 +186,7 @@
}
static int removeDS(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value) {
int ret;
Blockstore * cls = (Blockstore*) closure;
@@ -215,7 +215,7 @@
char **argv) {
char * tableName;
unsigned int mem;
- HashCode160 table;
+ HashCode512 table;
Blockstore myStore;
if (SYSERR == initUtil(argc, argv, &parseOptions))
Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/dht/tools/dht-query.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -112,7 +112,7 @@
return OK;
}
-static int printCallback(const HashCode160 * hash,
+static int printCallback(const HashCode512 * hash,
const DataContainer * data,
char * key) {
printf("%s(%s): '%.*s'\n",
@@ -126,7 +126,7 @@
static void do_get(GNUNET_TCP_SOCKET * sock,
const char * key) {
int ret;
- HashCode160 hc;
+ HashCode512 hc;
hash(key,
strlen(key),
@@ -153,7 +153,7 @@
const char * key,
char * value) {
DataContainer * dc;
- HashCode160 hc;
+ HashCode512 hc;
hash(key, strlen(key), &hc);
dc = MALLOC(sizeof(DataContainer)
@@ -185,7 +185,7 @@
const char * key,
char * value) {
DataContainer * dc;
- HashCode160 hc;
+ HashCode512 hc;
hash(key, strlen(key), &hc);
dc = MALLOC(sizeof(DataContainer)
Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -106,14 +106,14 @@
&msg.header);
}
-static int sendAllResults(const HashCode160 * key,
+static int sendAllResults(const HashCode512 * key,
const DataContainer * value,
void * cls) {
TableList * list = (TableList*) cls;
DHT_CS_REPLY_RESULTS * reply;
- reply = MALLOC(sizeof(DHT_CS_REPLY_RESULTS) + ntohl(value->size) +
sizeof(HashCode160));
- reply->header.size = htons(sizeof(DHT_CS_REPLY_RESULTS) + ntohl(value->size)
+ sizeof(HashCode160));
+ reply = MALLOC(sizeof(DHT_CS_REPLY_RESULTS) + ntohl(value->size) +
sizeof(HashCode512));
+ reply->header.size = htons(sizeof(DHT_CS_REPLY_RESULTS) + ntohl(value->size)
+ sizeof(HashCode512));
reply->header.type = htons(DHT_CS_PROTO_REPLY_GET);
reply->totalResults = htonl(1);
reply->table = list->table;
@@ -208,7 +208,7 @@
FREE(buffer);
}
req = (DHT_CS_REQUEST_GET*) buffer;
- if (! equalsHashCode160(&req->table,
+ if (! equalsHashCode512(&req->table,
&list->table)) {
LOG(LOG_ERROR,
_("Received invalid '%s' request (wrong table)\n"),
@@ -220,7 +220,7 @@
break;
}
- keyCount = 1 + ( (ntohs(req->header.size) - sizeof(DHT_CS_REQUEST_GET))
/ sizeof(HashCode160));
+ keyCount = 1 + ( (ntohs(req->header.size) - sizeof(DHT_CS_REQUEST_GET))
/ sizeof(HashCode512));
resCount = list->store->get(list->store->closure,
ntohl(req->type),
ntohl(req->priority),
@@ -260,7 +260,7 @@
break;
}
req = (DHT_CS_REQUEST_PUT*) buffer;
- if (! equalsHashCode160(&req->table,
+ if (! equalsHashCode512(&req->table,
&list->table)) {
LOG(LOG_ERROR,
_("Received invalid '%s' request (wrong table)\n"),
@@ -314,7 +314,7 @@
break;
}
req = (DHT_CS_REQUEST_REMOVE*) buffer;
- if (! equalsHashCode160(&req->table,
+ if (! equalsHashCode512(&req->table,
&list->table)) {
LOG(LOG_ERROR,
_("Received invalid '%s' request (wrong table)\n"),
@@ -426,7 +426,7 @@
MUTEX_LOCK(&lock);
for (i=0;i<tableCount;i++)
- if (equalsHashCode160(&tables[i]->table,
+ if (equalsHashCode512(&tables[i]->table,
table)) {
LOG(LOG_WARNING,
_("This client already participates in the given DHT!\n"));
@@ -489,7 +489,7 @@
list = NULL;
MUTEX_LOCK(&lock);
for (i=0;i<tableCount;i++) {
- if (equalsHashCode160(&tables[i]->table,
+ if (equalsHashCode512(&tables[i]->table,
table)) {
list = tables[i];
tables[i] = tables[tableCount-1];
@@ -576,7 +576,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
cron_t timeout,
DataProcessor processor,
void * closure) {
@@ -593,9 +593,9 @@
return SYSERR;
req = MALLOC(sizeof(DHT_CS_REQUEST_GET) +
- (keyCount-1) * sizeof(HashCode160));
+ (keyCount-1) * sizeof(HashCode512));
req->header.size = htons(sizeof(DHT_CS_REQUEST_GET) +
- (keyCount-1) * sizeof(HashCode160));
+ (keyCount-1) * sizeof(HashCode512));
req->header.type = htons(DHT_CS_PROTO_REQUEST_GET);
req->type = htonl(type);
req->timeout = htonll(timeout);
@@ -603,7 +603,7 @@
req->priority = htonl(prio);
memcpy(&req->keys,
keys,
- keyCount * sizeof(HashCode160));
+ keyCount * sizeof(HashCode512));
if (OK != writeToSocket(sock,
&req->header)) {
releaseClientSocket(sock);
@@ -665,7 +665,7 @@
* @return OK on success, SYSERR on error (or timeout)
*/
int DHT_LIB_put(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
unsigned int prio,
cron_t timeout,
const DataContainer * value) {
@@ -724,7 +724,7 @@
* @return OK on success, SYSERR on error (or timeout)
*/
int DHT_LIB_remove(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
const DataContainer * value) {
GNUNET_TCP_SOCKET * sock;
Modified: GNUnet/src/applications/fragmentation/fragmentation.c
===================================================================
--- GNUnet/src/applications/fragmentation/fragmentation.c 2005-03-04
19:31:22 UTC (rev 365)
+++ GNUnet/src/applications/fragmentation/fragmentation.c 2005-03-05
05:37:01 UTC (rev 366)
@@ -390,7 +390,7 @@
return SYSERR;
MUTEX_LOCK(&defragCacheLock);
- hash = sender->hashPubKey.a % DEFRAG_BUCKET_COUNT;
+ hash = sender->hashPubKey.bits[0] % DEFRAG_BUCKET_COUNT;
smf = defragmentationCache[hash];
while (smf != NULL) {
if (OK == tryJoin(smf, sender, (FRAGMENT_Message*) frag)) {
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/download.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -386,7 +386,7 @@
} RequestManager;
-static int nodeReceive(const HashCode160 * query,
+static int nodeReceive(const HashCode512 * query,
const Datastore_Value * reply,
NodeClosure * node);
@@ -730,12 +730,12 @@
data,
size);
if (res == size) {
- HashCode160 hc;
+ HashCode512 hc;
hash(data,
size,
&hc);
- if (equalsHashCode160(&hc,
+ if (equalsHashCode512(&hc,
&node->chk.key)) {
updateProgress(node, data, size);
if (node->level > 0)
@@ -809,7 +809,7 @@
*/
static int decryptContent(const char * data,
unsigned int size,
- const HashCode160 * hashcode,
+ const HashCode512 * hashcode,
char * result){
INITVECTOR iv;
SESSIONKEY skey;
@@ -836,10 +836,10 @@
* @param reply the reply
* @return OK if the reply was valid, SYSERR on error
*/
-static int nodeReceive(const HashCode160 * query,
+static int nodeReceive(const HashCode512 * query,
const Datastore_Value * reply,
NodeClosure * node) {
- HashCode160 hc;
+ HashCode512 hc;
unsigned int size;
int i;
char * data;
@@ -852,7 +852,7 @@
"Receiving reply to query %s\n",
&enc);
- GNUNET_ASSERT(equalsHashCode160(query,
+ GNUNET_ASSERT(equalsHashCode512(query,
&node->chk.query));
size = ntohl(reply->size) - sizeof(Datastore_Value);
if ( (size <= sizeof(DBlock)) ||
@@ -876,7 +876,7 @@
hash(data,
size,
&hc);
- if (!equalsHashCode160(&hc,
+ if (!equalsHashCode512(&hc,
&node->chk.key)) {
FREE(data);
BREAK();
Modified: GNUnet/src/applications/fs/ecrs/ecrs.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/ecrs.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -29,7 +29,7 @@
#include "platform.h"
#include "ecrs.h"
-void ECRS_encryptInPlace(const HashCode160 * hc,
+void ECRS_encryptInPlace(const HashCode512 * hc,
void * data,
unsigned int len) {
char * tmp;
@@ -48,7 +48,7 @@
FREE(tmp);
}
-void ECRS_decryptInPlace(const HashCode160 * hc,
+void ECRS_decryptInPlace(const HashCode512 * hc,
void * data,
unsigned int len) {
char * tmp;
Modified: GNUnet/src/applications/fs/ecrs/ecrs.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/ecrs.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -44,8 +44,8 @@
typedef struct Location {
PeerIdentity peer;
- HashCode160 query;
- HashCode160 key;
+ HashCode512 query;
+ HashCode512 key;
unsigned int type;
unsigned long long size;
} Location;
@@ -60,8 +60,8 @@
unsigned int keywordCount;
} ksk;
struct {
- HashCode160 namespace;
- HashCode160 identifier;
+ HashCode512 namespace;
+ HashCode512 identifier;
} sks;
FileIdentifier chk;
Location loc;
@@ -82,11 +82,11 @@
} MetaData;
-void ECRS_encryptInPlace(const HashCode160 * hc,
+void ECRS_encryptInPlace(const HashCode512 * hc,
void * data,
unsigned int len);
-void ECRS_decryptInPlace(const HashCode160 * hc,
+void ECRS_decryptInPlace(const HashCode512 * hc,
void * data,
unsigned int len);
Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -81,10 +81,10 @@
fd = OPEN(name, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
buf = MALLOC(size);
memset(buf, size + size / 253, size);
- for (i=0;i<(int) (size - 42 - sizeof(HashCode160));i+=sizeof(HashCode160))
- hash(&buf[i+sizeof(HashCode160)],
+ for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
+ hash(&buf[i+sizeof(HashCode512)],
42,
- (HashCode160*) &buf[i]);
+ (HashCode512*) &buf[i]);
write(fd, buf, size);
FREE(buf);
CLOSE(fd);
@@ -130,7 +130,7 @@
}
static int searchCB(const ECRS_FileInfo * fi,
- const HashCode160 * key,
+ const HashCode512 * key,
void * closure) {
struct ECRS_URI ** my = closure;
char * tmp;
@@ -199,10 +199,10 @@
buf = MALLOC(size);
in = MALLOC(size);
memset(buf, size + size / 253, size);
- for (i=0;i<(int) (size - 42 - sizeof(HashCode160));i+=sizeof(HashCode160))
- hash(&buf[i+sizeof(HashCode160)],
+ for (i=0;i<(int) (size - 42 - sizeof(HashCode512));i+=sizeof(HashCode512))
+ hash(&buf[i+sizeof(HashCode512)],
42,
- (HashCode160*) &buf[i]);
+ (HashCode512*) &buf[i]);
if (size != read(fd, in, size))
ret = SYSERR;
else if (0 == memcmp(buf,
Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -60,7 +60,7 @@
unsigned int size;
unsigned int mdsize;
struct PrivateKey * pk;
- HashCode160 hc;
+ HashCode512 hc;
char * dstURI;
KBlock * kb;
char ** keywords;
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -98,7 +98,7 @@
unsigned int priority,
cron_t expiration,
const struct ECRS_URI * advertisementURI,
- const HashCode160 * rootEntry,
+ const HashCode512 * rootEntry,
struct ECRS_URI ** rootURI) {
char * fileName;
char tmp;
@@ -106,7 +106,7 @@
PrivateKeyEncoded * hke;
char * dst;
unsigned short len;
- HashCode160 hc;
+ HashCode512 hc;
GNUNET_TCP_SOCKET * sock;
Datastore_Value * value;
Datastore_Value * knvalue;
@@ -187,7 +187,7 @@
ret = OK;
/* publish NBlock */
- memset(&nb->identifier, 0, sizeof(HashCode160));
+ memset(&nb->identifier, 0, sizeof(HashCode512));
getPublicKey(hk,
&nb->subspace);
hash(&nb->subspace,
@@ -201,7 +201,7 @@
nb->rootEntry = *rootEntry;
GNUNET_ASSERT(OK == sign(hk,
- mdsize + 3 * sizeof(HashCode160),
+ mdsize + 3 * sizeof(HashCode512),
&nb->identifier,
&nb->signature));
if (OK != FS_insert(sock, value))
@@ -265,13 +265,13 @@
* @return OK if the namespace exists, SYSERR if not
*/
int ECRS_testNamespaceExists(const char * name,
- const HashCode160 * hc) {
+ const HashCode512 * hc) {
struct PrivateKey * hk;
char * fileName;
PrivateKeyEncoded * hke;
char * dst;
unsigned short len;
- HashCode160 namespace;
+ HashCode512 namespace;
PublicKey pk;
/* FIRST: read and decrypt pseudonym! */
@@ -304,7 +304,7 @@
freePrivateKey(hk);
hash(&pk, sizeof(PublicKey), &namespace);
if ( (hc == NULL) ||
- (equalsHashCode160(hc,
+ (equalsHashCode512(hc,
&namespace)))
return OK;
else
@@ -326,8 +326,8 @@
cron_t expiration,
cron_t creationTime,
cron_t updateInterval,
- const HashCode160 * thisId,
- const HashCode160 * nextId,
+ const HashCode512 * thisId,
+ const HashCode512 * nextId,
const struct ECRS_URI * dstU,
const struct ECRS_MetaData * md,
struct ECRS_URI ** uri) {
@@ -338,13 +338,13 @@
unsigned int mdsize;
struct PrivateKey * hk;
SBlock * sb;
- HashCode160 namespace;
+ HashCode512 namespace;
char * dstURI;
char * fileName;
PrivateKeyEncoded * hke;
char * dst;
unsigned short len;
- HashCode160 hc;
+ HashCode512 hc;
/* FIRST: read and decrypt pseudonym! */
fileName = getPseudonymFileName(name);
@@ -424,7 +424,7 @@
nextId,
&sb->identifierIncrement);
hash(thisId,
- sizeof(HashCode160),
+ sizeof(HashCode512),
&hc);
getPublicKey(hk,
&sb->subspace);
@@ -445,7 +445,7 @@
size
- sizeof(Signature)
- sizeof(PublicKey)
- - sizeof(HashCode160));
+ - sizeof(HashCode512));
/* FINALLY: sign & publish SBlock */
GNUNET_ASSERT(OK == sign(hk,
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/search.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -68,12 +68,12 @@
/**
* The keys (for the search).
*/
- HashCode160 * keys;
+ HashCode512 * keys;
/**
* The key (for decryption)
*/
- HashCode160 decryptKey;
+ HashCode512 decryptKey;
} PendingSearch;
@@ -121,8 +121,8 @@
*/
static void addPS(unsigned int type,
unsigned int keyCount,
- const HashCode160 * keys,
- const HashCode160 * dkey,
+ const HashCode512 * keys,
+ const HashCode512 * dkey,
SendQueriesContext * sqc) {
PendingSearch * ps;
@@ -132,10 +132,10 @@
ps->priority = 5 + randomi(20);
ps->type = type;
ps->keyCount = keyCount;
- ps->keys = MALLOC(sizeof(HashCode160) * keyCount);
+ ps->keys = MALLOC(sizeof(HashCode512) * keyCount);
memcpy(ps->keys,
keys,
- sizeof(HashCode160) * keyCount);
+ sizeof(HashCode512) * keyCount);
ps->decryptKey = *dkey;
ps->handle = NULL;
MUTEX_LOCK(&sqc->lock);
@@ -158,11 +158,11 @@
_("CHK URI not allowed for search.\n"));
break;
case sks: {
- HashCode160 keys[2];
- HashCode160 hk; /* hk = hash(identifier) */
+ HashCode512 keys[2];
+ HashCode512 hk; /* hk = hash(identifier) */
hash(&uri->data.sks.identifier,
- sizeof(HashCode160),
+ sizeof(HashCode512),
&hk);
xorHashCodes(&hk,
&uri->data.sks.namespace,
@@ -176,8 +176,8 @@
break;
}
case ksk: {
- HashCode160 hc;
- HashCode160 query;
+ HashCode512 hc;
+ HashCode512 query;
struct PrivateKey * pk;
PublicKey pub;
int i;
@@ -228,15 +228,15 @@
*/
static int computeIdAtTime(const SBlock * sb,
cron_t now,
- HashCode160 * c) {
+ HashCode512 * c) {
cron_t pos;
- HashCode160 tmp;
+ HashCode512 tmp;
unsigned int iter;
if (ntohll(sb->updateInterval) == (cron_t) SBLOCK_UPDATE_SPORADIC) {
memcpy(c,
&sb->nextIdentifier,
- sizeof(HashCode160));
+ sizeof(HashCode512));
return OK;
}
if (ntohll(sb->updateInterval) == (cron_t) SBLOCK_UPDATE_NONE) {
@@ -272,7 +272,7 @@
* namespace advertisement.
*/
static int processNBlock(const NBlock * nb,
- const HashCode160 * key,
+ const HashCode512 * key,
unsigned int size,
SendQueriesContext * sqc) {
ECRS_FileInfo fi;
@@ -306,7 +306,7 @@
*
* @return SYSERR if the entry is malformed
*/
-static int receiveReplies(const HashCode160 * key,
+static int receiveReplies(const HashCode512 * key,
const Datastore_Value * value,
SendQueriesContext * sqc) {
unsigned int type;
@@ -334,14 +334,18 @@
case K_BLOCK: {
KBlock * kb;
char * dstURI;
+ EncName enc;
int j;
if (size < sizeof(KBlock))
return SYSERR;
kb = (KBlock*) &value[1];
+ IFLOG(LOG_DEBUG,
+ hash2enc(&ps->decryptKey,
+ &enc));
LOG(LOG_DEBUG,
- "Decrypting KBlock with key %u.\n",
- ps->decryptKey.a);
+ "Decrypting KBlock with key %s.\n",
+ &enc);
ECRS_decryptInPlace(&ps->decryptKey,
&kb[1],
size - sizeof(KBlock));
@@ -409,7 +413,7 @@
char * dstURI;
int j;
cron_t now;
- HashCode160 updateId;
+ HashCode512 updateId;
URI updateURI;
if (size < sizeof(SBlock))
@@ -420,7 +424,7 @@
size
- sizeof(Signature)
- sizeof(PublicKey)
- - sizeof(HashCode160));
+ - sizeof(HashCode512));
j = sizeof(SBlock);
while ( (j < size) &&
(((char*) &sb[1])[j] != '\0') )
@@ -457,7 +461,7 @@
cronTime(&now);
if (OK != computeIdAtTime(sb, now, &updateId))
return SYSERR;
- if (equalsHashCode160(&updateId,
+ if (equalsHashCode512(&updateId,
&ps->decryptKey))
return ret; /* have latest version */
if (ps->keyCount != 2) {
Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/unindex.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -117,13 +117,13 @@
* c) copy file, if fails restore symlink
*/
static int undoSymlinking(const char * fn,
- const HashCode160 * fileId,
+ const HashCode512 * fileId,
GNUNET_TCP_SOCKET * sock) {
EncName enc;
char * serverDir;
char * serverFN;
char * tmpName;
- HashCode160 serverFileId;
+ HashCode512 serverFileId;
struct stat buf;
int ret;
@@ -179,7 +179,7 @@
FREE(serverFN);
return SYSERR;
}
- if (! equalsHashCode160(&serverFileId,
+ if (! equalsHashCode512(&serverFileId,
fileId)) {
FREE(serverFN);
BREAK(); /* rather odd... */
@@ -239,7 +239,7 @@
DBlock * db;
Datastore_Value * value;
GNUNET_TCP_SOCKET * sock;
- HashCode160 fileId;
+ HashCode512 fileId;
CHK chk;
cron_t eta;
cron_t start;
Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/upload.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -118,13 +118,13 @@
* d) delete old file
*/
static void trySymlinking(const char * fn,
- const HashCode160 * fileId,
+ const HashCode512 * fileId,
GNUNET_TCP_SOCKET * sock) {
EncName enc;
char * serverDir;
char * serverFN;
char * tmpName;
- HashCode160 serverFileId;
+ HashCode512 serverFileId;
if (testConfigurationString("FS",
"DISABLE-SYMLINKING",
@@ -151,7 +151,7 @@
FREE(serverFN);
return;
}
- if (! equalsHashCode160(&serverFileId,
+ if (! equalsHashCode512(&serverFileId,
fileId)) {
BREAK(); /* rather odd... */
return;
@@ -226,7 +226,7 @@
DBlock * db;
Datastore_Value * value;
GNUNET_TCP_SOCKET * sock;
- HashCode160 fileId;
+ HashCode512 fileId;
CHK chk;
cron_t eta;
cron_t start;
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -114,8 +114,8 @@
/**
* Generate a subspace URI.
*/
-static char * createSubspaceURI(const HashCode160 * namespace,
- const HashCode160 * identifier) {
+static char * createSubspaceURI(const HashCode512 * namespace,
+ const HashCode512 * identifier) {
size_t n;
char * ret;
EncName ns;
@@ -253,8 +253,8 @@
* @return OK on success, SYSERR if this is not a namespace URI
*/
static int parseSubspaceURI(const char * uri,
- HashCode160 * namespace,
- HashCode160 * identifier) {
+ HashCode512 * namespace,
+ HashCode512 * identifier) {
unsigned int pos;
size_t slen;
char * up;
Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/ecrs_core.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -44,9 +44,9 @@
*/
int fileBlockEncode(const DBlock * data,
unsigned int len,
- const HashCode160 * query,
+ const HashCode512 * query,
Datastore_Value ** value) {
- HashCode160 hc;
+ HashCode512 hc;
SESSIONKEY skey;
INITVECTOR iv; /* initial value */
Datastore_Value * val;
@@ -75,7 +75,7 @@
hash(&db[1],
len - sizeof(DBlock),
&hc);
- if (equalsHashCode160(query,
+ if (equalsHashCode512(query,
&hc)) {
*value = val;
return OK;
@@ -93,7 +93,7 @@
*/
void fileBlockGetKey(const DBlock * data,
unsigned int len,
- HashCode160 * key) {
+ HashCode512 * key) {
GNUNET_ASSERT(len >= sizeof(DBlock));
hash(&data[1],
len - sizeof(DBlock),
@@ -106,10 +106,10 @@
*/
void fileBlockGetQuery(const DBlock * db,
unsigned int len,
- HashCode160 * query) {
+ HashCode512 * query) {
char * tmp;
const char * data;
- HashCode160 hc;
+ HashCode512 hc;
SESSIONKEY skey;
INITVECTOR iv;
@@ -150,7 +150,7 @@
*/
int getQueryFor(unsigned int size,
const DBlock * data,
- HashCode160 * query) {
+ HashCode512 * query) {
unsigned int type;
type = getTypeOfBlock(size, data);
@@ -264,8 +264,8 @@
unsigned int size,
const DBlock * data,
unsigned int keyCount,
- const HashCode160 * keys) {
- HashCode160 hc;
+ const HashCode512 * keys) {
+ HashCode512 hc;
if (type != getTypeOfBlock(size, data)) {
BREAK();
@@ -275,7 +275,7 @@
BREAK(); /* malformed data */
return SYSERR;
}
- if (! equalsHashCode160(&hc, &keys[0])) {
+ if (! equalsHashCode512(&hc, &keys[0])) {
BREAK(); /* mismatch between primary queries,
we should not even see those here. */
return SYSERR;
@@ -289,7 +289,7 @@
hash(&((SBlock*)data)->subspace,
sizeof(PublicKey),
&hc);
- if (equalsHashCode160(&keys[1],
+ if (equalsHashCode512(&keys[1],
&hc))
return OK;
else
@@ -300,7 +300,7 @@
hash(&((NBlock*)data)->subspace,
sizeof(PublicKey),
&hc);
- if (equalsHashCode160(&keys[1],
+ if (equalsHashCode512(&keys[1],
&hc))
return OK;
else
Modified: GNUnet/src/applications/fs/fsui/collection.c
===================================================================
--- GNUnet/src/applications/fs/fsui/collection.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/fsui/collection.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -58,7 +58,7 @@
typedef struct CollectionData {
DataContainer hdr;
- HashCode160 nextId;
+ HashCode512 nextId;
char name[1];
} CollectionData;
@@ -72,7 +72,7 @@
const struct ECRS_MetaData * meta) {
struct ECRS_URI * advertisement;
struct ECRS_URI * rootURI;
- HashCode160 nextId;
+ HashCode512 nextId;
cron_t now;
unsigned int prio;
CollectionData * cd;
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/fsui/download.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -49,7 +49,7 @@
static int triggerRecursiveDownload(const ECRS_FileInfo * fi,
unsigned int anonymityLevel,
- const HashCode160 * key,
+ const HashCode512 * key,
FSUI_DownloadList * parent) {
int i;
FSUI_DownloadList * pos;
Modified: GNUnet/src/applications/fs/fsui/fsui.h
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/fsui/fsui.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -60,7 +60,7 @@
/**
* What are these keys?
*/
- HashCode160 * matchingKeys;
+ HashCode512 * matchingKeys;
/**
* What info do we have about this result?
*/
Modified: GNUnet/src/applications/fs/fsui/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/namespace_info.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/fsui/namespace_info.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -151,7 +151,7 @@
const char * namespaceName,
const struct ECRS_MetaData * meta,
const struct ECRS_URI * advertisementURI,
- const HashCode160 * rootEntry,
+ const HashCode512 * rootEntry,
struct ECRS_URI ** root) {
int ret;
@@ -322,16 +322,16 @@
unsigned int anonymityLevel,
const char * name,
cron_t updateInterval,
- const HashCode160 * lastId,
- const HashCode160 * thisId,
- const HashCode160 * nextId,
+ const HashCode512 * lastId,
+ const HashCode512 * thisId,
+ const HashCode512 * nextId,
const struct ECRS_URI * dst,
const struct ECRS_MetaData * md,
struct ECRS_URI ** uri) {
int ret;
cron_t creationTime;
- HashCode160 nid;
- HashCode160 tid;
+ HashCode512 nid;
+ HashCode512 tid;
ret = ECRS_addToNamespace(name,
Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/fsui/search.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -57,7 +57,7 @@
* Process results found by ECRS.
*/
static int spcb(const ECRS_FileInfo * fi,
- const HashCode160 * key,
+ const HashCode512 * key,
FSUI_SearchList * pos) {
unsigned int i;
unsigned int j;
@@ -78,7 +78,7 @@
if (ECRS_equalsUri(fi->uri,
rp->fi.uri)) {
for (j=0;j<rp->matchingKeyCount;j++)
- if (equalsHashCode160(key,
+ if (equalsHashCode512(key,
&rp->matchingKeys[j]))
return OK;
if (rp->matchingKeyCount + 1 < pos->numberOfURIKeys) {
Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/lib/fslib.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -53,7 +53,7 @@
CS_HEADER * hdr;
int i;
ReplyContent * rep;
- HashCode160 query;
+ HashCode512 query;
unsigned int size;
cron_t delay;
@@ -83,7 +83,7 @@
}
MUTEX_LOCK(ctx->lock);
for (i=ctx->handleCount-1;i>=0;i--) {
- if (equalsHashCode160(&query,
+ if (equalsHashCode512(&query,
&ctx->handles[i]->req->query[0])) {
Datastore_Value * value;
@@ -165,7 +165,7 @@
SEARCH_HANDLE * FS_start_search(SEARCH_CONTEXT * ctx,
unsigned int type,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
unsigned int anonymityLevel,
unsigned int prio,
cron_t timeout,
@@ -176,8 +176,8 @@
EncName enc;
ret = MALLOC(sizeof(SEARCH_HANDLE));
- req = MALLOC(sizeof(RequestSearch) + (keyCount-1) * sizeof(HashCode160));
- req->header.size = htons(sizeof(RequestSearch) + (keyCount-1) *
sizeof(HashCode160));
+ req = MALLOC(sizeof(RequestSearch) + (keyCount-1) * sizeof(HashCode512));
+ req->header.size = htons(sizeof(RequestSearch) + (keyCount-1) *
sizeof(HashCode512));
req->header.type = htons(AFS_CS_PROTO_QUERY_START);
req->prio = htonl(prio);
req->anonymityLevel = htonl(anonymityLevel);
@@ -185,7 +185,7 @@
req->type = htonl(type);
memcpy(&req->query[0],
keys,
- keyCount * sizeof(HashCode160));
+ keyCount * sizeof(HashCode512));
ret->req = req;
ret->callback = callback;
ret->closure = closure;
@@ -301,7 +301,7 @@
* @return OK on success, SYSERR on error
*/
int FS_index(GNUNET_TCP_SOCKET * sock,
- const HashCode160 * fileHc,
+ const HashCode512 * fileHc,
const Datastore_Value * block,
unsigned long long offset) {
int ret;
@@ -380,7 +380,7 @@
*/
int FS_unindex(GNUNET_TCP_SOCKET * sock,
unsigned int blocksize,
- const HashCode160 * hc) {
+ const HashCode512 * hc) {
int ret;
RequestUnindex ru;
Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/lib/fslibtest.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -59,10 +59,10 @@
SEMAPHORE_UP(sem);
}
-static int searchResultCB(const HashCode160 * key,
+static int searchResultCB(const HashCode512 * key,
const Datastore_Value * value,
TSC * cls) {
- HashCode160 ekey;
+ HashCode512 ekey;
Datastore_Value * blk;
Datastore_Value * eblk;
int ret;
@@ -79,7 +79,7 @@
ntohl(blk->size) - sizeof(Datastore_Value),
&ekey,
&eblk));
- if ( (equalsHashCode160(&ekey,
+ if ( (equalsHashCode512(&ekey,
key)) &&
(value->size == blk->size) &&
(0 == memcmp(value,
@@ -102,7 +102,7 @@
int i) {
struct FS_SEARCH_HANDLE * handle;
cron_t now;
- HashCode160 query;
+ HashCode512 query;
TSC closure;
Datastore_Value * dv;
DBlock * db;
@@ -150,8 +150,8 @@
GNUNET_TCP_SOCKET * sock;
Datastore_Value * block;
Datastore_Value * eblock;
- HashCode160 hc;
- HashCode160 query;
+ HashCode512 hc;
+ HashCode512 query;
int i;
cronTime(&now);
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/fs/module/fs.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -94,14 +94,14 @@
* SYSERR if the value is malformed
*/
static int gapPut(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value,
unsigned int prio) {
Datastore_Value * dv;
GapWrapper * gw;
unsigned int size;
int ret;
- HashCode160 hc;
+ HashCode512 hc;
cron_t et;
cron_t now;
EncName enc;
@@ -117,7 +117,7 @@
if ( (OK != getQueryFor(size - sizeof(Datastore_Value),
(DBlock*)&gw[1],
&hc)) ||
- (! equalsHashCode160(&hc, key)) ) {
+ (! equalsHashCode512(&hc, key)) ) {
BREAK(); /* value failed verification! */
return SYSERR;
}
@@ -162,7 +162,7 @@
return ret;
}
-static int get_result_callback(const HashCode160 * key,
+static int get_result_callback(const HashCode512 * key,
const DataContainer * value,
DHT_GET_CLS * cls) {
EncName enc;
@@ -215,7 +215,7 @@
trackQuery(&rs->query[0],
ntohl(rs->type),
sock);
- keyCount = 1 + (ntohs(req->size) - sizeof(RequestSearch)) /
sizeof(HashCode160);
+ keyCount = 1 + (ntohs(req->size) - sizeof(RequestSearch)) /
sizeof(HashCode512);
gap->get_start(ntohl(rs->type),
ntohl(rs->anonymityLevel),
keyCount,
@@ -267,7 +267,7 @@
/* FIXME 0.7.1: cancel with dht? */
}
gap->get_stop(ntohl(rs->type),
- 1 + (ntohs(req->size) - sizeof(RequestSearch)) /
sizeof(HashCode160),
+ 1 + (ntohs(req->size) - sizeof(RequestSearch)) /
sizeof(HashCode512),
&rs->query[0]);
untrackQuery(&rs->query[0], sock);
return OK;
@@ -283,7 +283,7 @@
const RequestInsert * ri;
Datastore_Value * datum;
int ret;
- HashCode160 query;
+ HashCode512 query;
unsigned int type;
EncName enc;
@@ -400,7 +400,7 @@
* abort the iteration: we found what we're looing for. Otherwise
* continue.
*/
-static int completeValue(const HashCode160 * key,
+static int completeValue(const HashCode512 * key,
const Datastore_Value * value,
void * closure) {
Datastore_Value * comp = closure;
@@ -433,7 +433,7 @@
int ret;
const RequestDelete * rd;
Datastore_Value * value;
- HashCode160 query;
+ HashCode512 query;
unsigned int type;
EncName enc;
@@ -549,7 +549,7 @@
DataProcessor resultCallback;
void * resCallbackClosure;
unsigned int keyCount;
- const HashCode160 * keys;
+ const HashCode512 * keys;
int count;
} GGC;
@@ -558,7 +558,7 @@
* from the datastore to Blockstore values for the
* gap routing protocol.
*/
-static int gapGetConverter(const HashCode160 * key,
+static int gapGetConverter(const HashCode512 * key,
const Datastore_Value * invalue,
void * cls) {
GGC * ggc = (GGC*) cls;
@@ -703,7 +703,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
DataProcessor resultCallback,
void * resCallbackClosure) {
int ret;
@@ -749,7 +749,7 @@
* @return OK if the value could be removed, SYSERR if not (i.e. not present)
*/
static int gapDel(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value) {
BREAK(); /* gap does not use 'del'! */
return SYSERR;
@@ -775,7 +775,7 @@
* from the datastore to Blockstore values for the
* DHT routing protocol.
*/
-static int dhtGetConverter(const HashCode160 * key,
+static int dhtGetConverter(const HashCode512 * key,
const Datastore_Value * invalue,
void * cls) {
GGC * ggc = (GGC*) cls;
@@ -863,7 +863,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
DataProcessor resultCallback,
void * resCallbackClosure) {
int ret;
@@ -895,8 +895,8 @@
static int uniqueReplyIdentifier(const void * content,
unsigned int size,
unsigned int type,
- const HashCode160 * primaryKey) {
- HashCode160 q;
+ const HashCode512 * primaryKey) {
+ HashCode512 q;
unsigned int t;
const GapWrapper * gw;
@@ -908,7 +908,7 @@
if ( (OK == getQueryFor(size - sizeof(GapWrapper),
(const DBlock*) &gw[1],
&q)) &&
- (equalsHashCode160(&q,
+ (equalsHashCode512(&q,
primaryKey)) &&
( (type == ANY_BLOCK) ||
(type == (t = getTypeOfBlock(size - sizeof(GapWrapper),
Modified: GNUnet/src/applications/fs/module/migration.c
===================================================================
--- GNUnet/src/applications/fs/module/migration.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/module/migration.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -70,7 +70,7 @@
char * position,
unsigned int padding) {
unsigned int ret;
- HashCode160 key;
+ HashCode512 key;
Datastore_Value * content;
GapWrapper * gw;
unsigned int size;
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/module/ondemand.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -57,11 +57,11 @@
* this block? Used to determine the name
* of the file in the on-demand datastore.
*/
- HashCode160 fileId;
+ HashCode512 fileId;
} OnDemandBlock;
-static char * getOnDemandFile(const HashCode160 * fileId) {
+static char * getOnDemandFile(const HashCode512 * fileId) {
EncName enc;
char * fn;
char * dir;
@@ -87,7 +87,7 @@
* present in the datastore. Presence is indicated
* by aborting the iteration.
*/
-static int checkPresent(const HashCode160 * key,
+static int checkPresent(const HashCode512 * key,
const Datastore_Value * value,
void * closure) {
Datastore_Value * comp = closure;
@@ -114,14 +114,14 @@
cron_t expiration,
unsigned long long fileOffset,
unsigned int anonymityLevel,
- const HashCode160 * fileId,
+ const HashCode512 * fileId,
unsigned int size,
const DBlock * content) {
char * fn;
int fd;
int ret;
OnDemandBlock odb;
- HashCode160 key;
+ HashCode512 key;
EncName enc;
if (size <= sizeof(DBlock)) {
@@ -218,7 +218,7 @@
*/
int ONDEMAND_getIndexed(Datastore_ServiceAPI * datastore,
const Datastore_Value * dbv,
- const HashCode160 * query,
+ const HashCode512 * query,
Datastore_Value ** enc) {
char * fn;
char * iobuf;
@@ -315,7 +315,7 @@
* @return YES if so, NO if not.
*/
int ONDEMAND_testindexed(Datastore_ServiceAPI * datastore,
- const HashCode160 * fileId) {
+ const HashCode512 * fileId) {
char * fn;
int fd;
@@ -336,7 +336,7 @@
* abort the iteration: we found what we're looing for. Otherwise
* continue.
*/
-static int completeValue(const HashCode160 * key,
+static int completeValue(const HashCode512 * key,
const Datastore_Value * value,
void * closure) {
Datastore_Value * comp = closure;
@@ -371,12 +371,12 @@
*/
int ONDEMAND_unindex(Datastore_ServiceAPI * datastore,
unsigned int blocksize,
- const HashCode160 * fileId) {
+ const HashCode512 * fileId) {
char * fn;
int fd;
int ret;
OnDemandBlock odb;
- HashCode160 key;
+ HashCode512 key;
unsigned long long pos;
unsigned long long size;
unsigned long long delta;
Modified: GNUnet/src/applications/fs/module/ondemand.h
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.h 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/module/ondemand.h 2005-03-05 05:37:01 UTC
(rev 366)
@@ -38,7 +38,7 @@
cron_t expiration,
unsigned long long fileOffset,
unsigned int anonymityLevel,
- const HashCode160 * fileId,
+ const HashCode512 * fileId,
unsigned int size,
const DBlock * content);
@@ -52,7 +52,7 @@
*/
int ONDEMAND_getIndexed(Datastore_ServiceAPI * datastore,
const Datastore_Value * odb,
- const HashCode160 * query,
+ const HashCode512 * query,
Datastore_Value ** enc);
/**
@@ -67,7 +67,7 @@
*/
int ONDEMAND_unindex(Datastore_ServiceAPI * datastore,
unsigned int blocksize,
- const HashCode160 * fileId);
+ const HashCode512 * fileId);
/**
* Test if the file with the given ID is
@@ -75,7 +75,7 @@
* @return YES if so, NO if not.
*/
int ONDEMAND_testindexed(Datastore_ServiceAPI * datastore,
- const HashCode160 * fileId);
+ const HashCode512 * fileId);
/* end of ondemand.h */
#endif
Modified: GNUnet/src/applications/fs/module/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/module/querymanager.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -31,7 +31,7 @@
#include "querymanager.h"
typedef struct {
- HashCode160 query;
+ HashCode512 query;
unsigned int type;
ClientHandle client;
} TrackRecord;
@@ -77,7 +77,7 @@
* @param msg the query
* @param client where did the query come from?
*/
-void trackQuery(const HashCode160 * query,
+void trackQuery(const HashCode512 * query,
unsigned int type,
const ClientHandle client) {
int i;
@@ -86,7 +86,7 @@
MUTEX_LOCK(&queryManagerLock);
for (i=trackerCount-1;i>=0;i--)
if ( (trackers[i]->client == client) &&
- (equalsHashCode160(&trackers[i]->query,
+ (equalsHashCode512(&trackers[i]->query,
query)) ) {
MUTEX_UNLOCK(&queryManagerLock);
return;
@@ -109,14 +109,14 @@
* @param msg the query
* @param client where did the query come from?
*/
-void untrackQuery(const HashCode160 * query,
+void untrackQuery(const HashCode512 * query,
const ClientHandle client) {
int i;
MUTEX_LOCK(&queryManagerLock);
for (i=trackerCount-1;i>=0;i--)
if ( (trackers[i]->client == client) &&
- (equalsHashCode160(&trackers[i]->query,
+ (equalsHashCode512(&trackers[i]->query,
query)) ) {
removeEntry(i);
MUTEX_UNLOCK(&queryManagerLock);
@@ -131,7 +131,7 @@
*
* @param value the response
*/
-void processResponse(const HashCode160 * key,
+void processResponse(const HashCode512 * key,
const Datastore_Value * value) {
int i;
ReplyContent * rc;
@@ -139,7 +139,7 @@
GNUNET_ASSERT(ntohl(value->size) > sizeof(Datastore_Value));
MUTEX_LOCK(&queryManagerLock);
for (i=trackerCount-1;i>=0;i--) {
- if ( (equalsHashCode160(&trackers[i]->query,
+ if ( (equalsHashCode512(&trackers[i]->query,
key)) &&
( (trackers[i]->type == ANY_BLOCK) ||
(trackers[i]->type == ntohl(value->type)) ) ) {
Modified: GNUnet/src/applications/fs/module/querymanager.h
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.h 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/module/querymanager.h 2005-03-05 05:37:01 UTC
(rev 366)
@@ -45,7 +45,7 @@
* @param msg the query
* @param client where did the query come from?
*/
-void trackQuery(const HashCode160 * query,
+void trackQuery(const HashCode512 * query,
unsigned int type,
const ClientHandle client);
@@ -55,7 +55,7 @@
* @param msg the query
* @param client where did the query come from?
*/
-void untrackQuery(const HashCode160 * query,
+void untrackQuery(const HashCode512 * query,
const ClientHandle client);
/**
@@ -64,7 +64,7 @@
*
* @param value the response
*/
-void processResponse(const HashCode160 * key,
+void processResponse(const HashCode512 * key,
const Datastore_Value * value);
#endif
Modified: GNUnet/src/applications/fs/tools/gnunet-directory.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-directory.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/tools/gnunet-directory.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -52,7 +52,7 @@
}
static int printNode(const ECRS_FileInfo * fi,
- const HashCode160 * key,
+ const HashCode512 * key,
void * unused) {
char * string;
Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -66,9 +66,9 @@
*/
static void postProcess(const struct ECRS_URI * uri) {
char * pname;
- HashCode160 prevId;
- HashCode160 thisId;
- HashCode160 nextId;
+ HashCode512 prevId;
+ HashCode512 thisId;
+ HashCode512 nextId;
char * pid;
char * tid;
char * nid;
@@ -147,14 +147,14 @@
#ifdef MINGW
_("\nUpload of '%s' complete, %I64u bytes took %I64u seconds (%8.3f
kbps).\n"),
#else
- _("\nUpload of '%s' complete, %I64u bytes took %I64u seconds (%8.3f
kbps).\n"),
+ _("\nUpload of '%s' complete, %llu bytes took %llu seconds (%8.3f
kbps).\n"),
#endif
- event->data.UploadComplete.filename,
- event->data.UploadComplete.total,
- delta / cronSECONDS,
- (delta == 0)
- ? (double) (-1.0)
- : (double) (event->data.UploadComplete.total / 1024.0 *
cronSECONDS / delta));
+ event->data.UploadComplete.filename,
+ event->data.UploadComplete.total,
+ delta / cronSECONDS,
+ (delta == 0)
+ ? (double) (-1.0)
+ : (double) (event->data.UploadComplete.total / 1024.0 * cronSECONDS /
delta));
}
fstring = ECRS_uriToString(event->data.UploadComplete.uri);
printf(_("File '%s' has URI: %s\n"),
@@ -397,7 +397,7 @@
break;
case 'N': {
EncName enc;
- HashCode160 nextId;
+ HashCode512 nextId;
if (enc2hash(GNoptarg,
&nextId) == SYSERR)
@@ -443,7 +443,7 @@
break;
case 't': {
EncName enc;
- HashCode160 thisId;
+ HashCode512 thisId;
if (enc2hash(GNoptarg,
&thisId) == SYSERR)
@@ -463,7 +463,7 @@
break;
case 'u': {
EncName enc;
- HashCode160 nextId;
+ HashCode512 nextId;
if (enc2hash(GNoptarg,
&nextId) == SYSERR)
Modified: GNUnet/src/applications/fs/tools/gnunet-pseudonym.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/fs/tools/gnunet-pseudonym.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -155,7 +155,7 @@
break;
case 'R': {
EncName enc;
- HashCode160 hc;
+ HashCode512 hc;
if (SYSERR == enc2hash(GNoptarg,
&hc))
@@ -384,7 +384,7 @@
EXTRACTOR_OWNER,
pname);
} else { /* no collection */
- HashCode160 rootEntry;
+ HashCode512 rootEntry;
char * root;
char * keyword;
struct ECRS_URI * advertisement;
@@ -393,7 +393,7 @@
root = getConfigurationString("PSEUDONYM",
"ROOT");
if (root == NULL) {
- memset(&rootEntry, 0, sizeof(HashCode160));
+ memset(&rootEntry, 0, sizeof(HashCode512));
} else {
enc2hash(root, &rootEntry);
FREE(root);
Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/applications/gap/gap.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -206,7 +206,7 @@
* Hashcodes of the file(s) we're looking for.
* Details depend on the query type.
*/
- HashCode160 queries[1];
+ HashCode512 queries[1];
} GAP_QUERY;
@@ -216,7 +216,7 @@
typedef struct {
p2p_HEADER header;
- HashCode160 primaryKey;
+ HashCode512 primaryKey;
} GAP_REPLY;
@@ -289,7 +289,7 @@
/**
* What are we waiting for?
*/
- HashCode160 primaryKey;
+ HashCode512 primaryKey;
/**
* For what type of reply are we waiting?
@@ -319,7 +319,7 @@
/**
* Hashcodes of the encrypted (!) replies that we have forwarded so far
*/
- HashCode160 * seen;
+ HashCode512 * seen;
/**
* How many hosts are waiting for an answer to this query (length of
@@ -719,7 +719,7 @@
pos = rtdList;
while (pos != NULL) {
- if (equalsHashCode160(&pos->queryOrigin.hashPubKey,
+ if (equalsHashCode512(&pos->queryOrigin.hashPubKey,
&qr->noTarget.hashPubKey))
break;
pos = pos->next;
@@ -727,7 +727,7 @@
if (pos != NULL) {
rp = pos->responseList;
while (rp != NULL) {
- if (equalsHashCode160(&rp->responder.hashPubKey,
+ if (equalsHashCode512(&rp->responder.hashPubKey,
&id->hashPubKey))
break;
rp = rp->next;
@@ -740,7 +740,7 @@
}
}
distance
- = distanceHashCode160(&qr->msg->queries[0],
+ = distanceHashCode512(&qr->msg->queries[0],
&id->hashPubKey);
if (distance <= 0)
distance = 1;
@@ -755,7 +755,7 @@
*/
static void sendToSelected(const PeerIdentity * id,
const QueryRecord * qr) {
- if (equalsHashCode160(&id->hashPubKey,
+ if (equalsHashCode512(&id->hashPubKey,
&qr->noTarget.hashPubKey))
return;
if (getBit(qr, getIndex(id)) == 1) {
@@ -800,7 +800,7 @@
&msg->queries[0],
ntohs(msg->header.size)
- sizeof(GAP_QUERY)
- + sizeof(HashCode160))) ) {
+ + sizeof(HashCode512))) ) {
/* We have exactly this query pending already.
Replace existing query! */
oldestIndex = i;
@@ -903,7 +903,7 @@
* Stop transmitting a certain query (we don't route it anymore or
* we have learned the answer).
*/
-static int dequeueQuery(const HashCode160 * query) {
+static int dequeueQuery(const HashCode512 * query) {
int i;
int ret;
QueryRecord * qr;
@@ -913,7 +913,7 @@
for (i=0;i<QUERY_RECORD_COUNT;i++) {
qr = &queries[i];
if( qr->msg != NULL ) {
- if (equalsHashCode160(query,
+ if (equalsHashCode512(query,
&qr->msg->queries[0])) {
qr->expires = 0; /* expire NOW! */
ret = OK;
@@ -930,7 +930,7 @@
/**
* Compute the hashtable index of a host id.
*/
-static unsigned int computeRoutingIndex(const HashCode160 * query) {
+static unsigned int computeRoutingIndex(const HashCode512 * query) {
unsigned int res
= (((unsigned int*)query)[0] +
((unsigned int*)query)[1] * random_qsel)
@@ -965,14 +965,14 @@
* @param result the content that was found
*/
static void queueReply(const PeerIdentity * sender,
- const HashCode160 * primaryKey,
+ const HashCode512 * primaryKey,
const DataContainer * data) {
GAP_REPLY * pmsg;
IndirectionTableEntry * ite;
unsigned int size;
ite = &ROUTING_indTable_[computeRoutingIndex(primaryKey)];
- if (! equalsHashCode160(&ite->primaryKey,
+ if (! equalsHashCode512(&ite->primaryKey,
primaryKey) ) {
return; /* we don't care for the reply (anymore) */
}
@@ -1021,7 +1021,7 @@
*/
static int addToSlot(int mode,
IndirectionTableEntry * ite,
- const HashCode160 * query,
+ const HashCode512 * query,
int ttl,
unsigned int priority,
const PeerIdentity * sender) {
@@ -1035,12 +1035,12 @@
ite->seenIndex,
0);
ite->seenReplyWasUnique = NO;
- if (equalsHashCode160(query,
+ if (equalsHashCode512(query,
&ite->primaryKey)) {
ite->ttl = now + ttl;
ite->priority += priority;
for (i=0;i<ite->hostsWaiting;i++)
- if (equalsHashCode160(&ite->destination[i].hashPubKey,
+ if (equalsHashCode512(&ite->destination[i].hashPubKey,
&sender->hashPubKey))
return SYSERR;
} else {
@@ -1055,10 +1055,10 @@
ite->priority = priority;
}
} else { /* GROW mode */
- GNUNET_ASSERT(equalsHashCode160(query,
+ GNUNET_ASSERT(equalsHashCode512(query,
&ite->primaryKey));
for (i=0;i<ite->hostsWaiting;i++)
- if (equalsHashCode160(&sender->hashPubKey,
+ if (equalsHashCode512(&sender->hashPubKey,
&ite->destination[i].hashPubKey))
return SYSERR; /* already there! */
/* extend lifetime */
@@ -1104,7 +1104,7 @@
* forward the query, SYSERR if not
* @return a case ID for debugging
*/
-static int needsForwarding(const HashCode160 * query,
+static int needsForwarding(const HashCode512 * query,
int ttl,
unsigned int priority,
const PeerIdentity * sender,
@@ -1124,7 +1124,7 @@
return 21;
}
if ( ( ttl < 0) &&
- (equalsHashCode160(query,
+ (equalsHashCode512(query,
&ite->primaryKey) ) ) {
/* if ttl is "expired" and we have
the exact query pending, route
@@ -1150,7 +1150,7 @@
ite->seenIndex,
0);
ite->seenReplyWasUnique = NO;
- if ( equalsHashCode160(query,
+ if ( equalsHashCode512(query,
&ite->primaryKey) &&
(YES == ite-> successful_local_lookup_in_delay_loop) ) {
*isRouted = NO;
@@ -1164,7 +1164,7 @@
return 2;
}
}
- if (equalsHashCode160(query,
+ if (equalsHashCode512(query,
&ite->primaryKey) ) {
if (ite->seenIndex == 0) {
if (ite->ttl + TTL_DECREMENT < (cron_t)(now + ttl)) {
@@ -1361,10 +1361,10 @@
};
static int
-queryLocalResultCallback(const HashCode160 * primaryKey,
+queryLocalResultCallback(const HashCode512 * primaryKey,
const DataContainer * value,
struct qLRC * cls) {
- HashCode160 hc;
+ HashCode512 hc;
int i;
IndirectionTableEntry * ite;
@@ -1375,7 +1375,7 @@
ntohl(value->size) - sizeof(DataContainer),
&hc);
for (i=0;i<ite->seenIndex;i++)
- if (equalsHashCode160(&hc,
+ if (equalsHashCode512(&hc,
&ite->seen[i]))
return OK; /* drop, duplicate result! */
@@ -1461,7 +1461,7 @@
ntohl(query->type),
prio,
1 + ( ntohs(query->header.size)
- - sizeof(GAP_QUERY)) / sizeof(HashCode160),
+ - sizeof(GAP_QUERY)) / sizeof(HashCode512),
&query->queries[0],
(DataProcessor) &queryLocalResultCallback,
&cls);
@@ -1537,7 +1537,7 @@
static int useContent(const PeerIdentity * hostId,
const GAP_REPLY * msg) {
unsigned int i;
- HashCode160 contentHC;
+ HashCode512 contentHC;
IndirectionTableEntry * ite;
unsigned int size;
int ret;
@@ -1551,7 +1551,7 @@
ite = &ROUTING_indTable_[computeRoutingIndex(&msg->primaryKey)];
size = ntohs(msg->header.size) - sizeof(GAP_REPLY);
MUTEX_LOCK(&ite->lookup_exclusion);
- if (! equalsHashCode160(&ite->primaryKey,
+ if (! equalsHashCode512(&ite->primaryKey,
&msg->primaryKey) ) {
MUTEX_UNLOCK(&ite->lookup_exclusion);
value = MALLOC(size + sizeof(DataContainer));
@@ -1583,7 +1583,7 @@
(if the sender was waiting for a response) */
if (hostId != NULL)
for (i=0;i<ite->hostsWaiting;i++) {
- if (equalsHashCode160(&hostId->hashPubKey,
+ if (equalsHashCode512(&hostId->hashPubKey,
&ite->destination[i].hashPubKey)) {
ite->destination[i] = ite->destination[ite->hostsWaiting-1];
GROW(ite->destination,
@@ -1593,7 +1593,7 @@
}
for (i=0;i<ite->seenIndex;i++) {
- if (equalsHashCode160(&contentHC,
+ if (equalsHashCode512(&contentHC,
&ite->seen[i])) {
MUTEX_UNLOCK(&ite->lookup_exclusion);
return 0; /* seen before, useless */
@@ -1685,14 +1685,14 @@
static int get_start(unsigned int type,
unsigned int anonymityLevel,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
cron_t timeout,
unsigned int prio) {
GAP_QUERY * msg;
unsigned int size;
int ret;
- size = sizeof(GAP_QUERY) + (keyCount-1) * sizeof(HashCode160);
+ size = sizeof(GAP_QUERY) + (keyCount-1) * sizeof(HashCode512);
if (size >= MAX_BUFFER_SIZE) {
BREAK();
return SYSERR; /* too many keys! */
@@ -1758,7 +1758,7 @@
prio));
memcpy(&msg->queries[0],
keys,
- sizeof(HashCode160) * keyCount);
+ sizeof(HashCode512) * keyCount);
msg->returnTo
= *coreAPI->myIdentity;
ret = execQuery(NULL,
@@ -1777,7 +1777,7 @@
*/
static int get_stop(unsigned int type,
unsigned int keyCount,
- const HashCode160 * keys) {
+ const HashCode512 * keys) {
if (keyCount < 1)
return SYSERR;
return dequeueQuery(&keys[0]);
@@ -1794,7 +1794,7 @@
*/
static unsigned int
tryMigrate(const DataContainer * data,
- const HashCode160 * primaryKey,
+ const HashCode512 * primaryKey,
char * position,
unsigned int padding) {
GAP_REPLY * reply;
@@ -1837,17 +1837,17 @@
}
queries = 1 + (ntohs(msg->size) - sizeof(GAP_QUERY))
- / sizeof(HashCode160);
+ / sizeof(HashCode512);
if ( (queries <= 0) ||
(ntohs(msg->size) < sizeof(GAP_QUERY)) ||
(ntohs(msg->size) != sizeof(GAP_QUERY) +
- (queries-1) * sizeof(HashCode160)) ) {
+ (queries-1) * sizeof(HashCode512)) ) {
BREAK();
return SYSERR; /* malformed query */
}
qmsg = MALLOC(ntohs(msg->size));
memcpy(qmsg, msg, ntohs(msg->size));
- if (equalsHashCode160(&qmsg->returnTo.hashPubKey,
+ if (equalsHashCode512(&qmsg->returnTo.hashPubKey,
&coreAPI->myIdentity->hashPubKey)) {
/* A to B, B sends back to A without (!) source rewriting,
in this case, A must just drop; however, this
Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -211,7 +211,7 @@
return NULL; /* error */
lens = mysql_fetch_lengths(res);
- if ( (lens[5] != sizeof(HashCode160)) ||
+ if ( (lens[5] != sizeof(HashCode512)) ||
(lens[6] != contentSize) ||
(sscanf(sql_row[1], "%u", &type) != 1) ||
(sscanf(sql_row[2], "%u", &prio) != 1) ||
@@ -230,7 +230,7 @@
datum->value.expirationTime = htonll(exp);
memcpy(&datum->key,
sql_row[5],
- sizeof(HashCode160));
+ sizeof(HashCode512));
memcpy(&datum[1],
sql_row[6],
contentSize);
@@ -576,7 +576,7 @@
* @return the number of results, SYSERR if the
* iter is non-NULL and aborted the iteration
*/
-static int getOLD(const HashCode160 * query,
+static int getOLD(const HashCode512 * query,
unsigned int type,
Datum_Iterator iter,
void * closure) {
@@ -592,12 +592,12 @@
return iterateLowPriority(type, iter, closure);
MUTEX_LOCK(&dbh->DATABASE_Lock_);
- escapedHash = MALLOC(2*sizeof(HashCode160)+1);
+ escapedHash = MALLOC(2*sizeof(HashCode512)+1);
mysql_real_escape_string(dbh->dbf,
escapedHash,
(char *) query,
- sizeof(HashCode160));
- n = sizeof(HashCode160)*2+400+1;
+ sizeof(HashCode512));
+ n = sizeof(HashCode512)*2+400+1;
scratch = MALLOC(n);
if (type != 0) {
@@ -676,7 +676,7 @@
* @return the number of results, SYSERR if the
* iter is non-NULL and aborted the iteration
*/
-static int get(const HashCode160 * query,
+static int get(const HashCode512 * query,
unsigned int type,
Datum_Iterator iter,
void * closure) {
@@ -691,7 +691,7 @@
unsigned long datasize;
unsigned long twenty;
Datastore_Value * datum;
- HashCode160 key;
+ HashCode512 key;
unsigned long hashSize;
EncName enc;
@@ -717,7 +717,7 @@
else
stmt = dbh->select;
}
- hashSize = sizeof(HashCode160);
+ hashSize = sizeof(HashCode512);
dbh->sbind[0].buffer = (char*) query;
dbh->sbind[1].buffer = (char*) &type;
dbh->sbind[0].length = &hashSize;
@@ -758,7 +758,7 @@
}
datum = MALLOC(sizeof(Datastore_Value) + MAX_DATUM_SIZE);
- twenty = sizeof(HashCode160);
+ twenty = sizeof(HashCode512);
dbh->bind[0].buffer = (char*) &size;
dbh->bind[1].buffer = (char*) &rtype;
dbh->bind[2].buffer = (char*) &prio;
@@ -768,7 +768,7 @@
dbh->bind[6].buffer = (char*) &datum[1];
dbh->bind[5].length = &twenty;
dbh->bind[6].length = &datasize;
- dbh->bind[5].buffer_length = sizeof(HashCode160);
+ dbh->bind[5].buffer_length = sizeof(HashCode512);
dbh->bind[6].buffer_length = MAX_DATUM_SIZE;
if (mysql_stmt_bind_result(stmt,
dbh->bind)) {
@@ -796,11 +796,11 @@
while (! mysql_stmt_fetch(stmt)) {
count++;
- if (twenty != sizeof(HashCode160)) {
+ if (twenty != sizeof(HashCode512)) {
BREAK();
LOG(LOG_WARNING,
_("Invalid data in MySQL database. Please verify integrity!\n"));
- twenty = sizeof(HashCode160);
+ twenty = sizeof(HashCode512);
datasize = MAX_DATUM_SIZE;
continue;
}
@@ -865,7 +865,7 @@
*
* @return OK on success, SYSERR on error
*/
-static int put(const HashCode160 * key,
+static int put(const HashCode512 * key,
const Datastore_Value * value) {
unsigned long contentSize;
unsigned long hashSize;
@@ -883,7 +883,7 @@
MUTEX_LOCK(&dbh->DATABASE_Lock_);
contentSize = ntohl(value->size)-sizeof(Datastore_Value);
- hashSize = sizeof(HashCode160);
+ hashSize = sizeof(HashCode512);
size = ntohl(value->size);
type = ntohl(value->type);
@@ -940,7 +940,7 @@
* @return the number of items deleted, 0 if
* none were found, SYSERR on errors
*/
-static int del(const HashCode160 * key,
+static int del(const HashCode512 * key,
const Datastore_Value * value) {
char * escapedHash;
char * escapedBlock;
@@ -959,18 +959,18 @@
ntohl(value->type));
MUTEX_LOCK(&dbh->DATABASE_Lock_);
contentSize = ntohl(value->size)-sizeof(Datastore_Value);
- escapedHash = MALLOC(2*sizeof(HashCode160)+1);
+ escapedHash = MALLOC(2*sizeof(HashCode512)+1);
mysql_real_escape_string(dbh->dbf,
escapedHash,
(char *)key,
- sizeof(HashCode160));
+ sizeof(HashCode512));
escapedBlock = MALLOC(2*contentSize+1);
mysql_real_escape_string(dbh->dbf,
escapedBlock,
(char *)&value[1],
contentSize);
- n = sizeof(HashCode160)*2+contentSize*2+400+1;
+ n = sizeof(HashCode512)*2+contentSize*2+400+1;
scratch = MALLOC(n);
if(value == NULL) {
SNPRINTF(scratch,
@@ -1019,7 +1019,7 @@
* in the datastore.
*
*/
-static int update(const HashCode160 * key,
+static int update(const HashCode512 * key,
const Datastore_Value * value,
int delta) {
char * escapedHash;
@@ -1031,15 +1031,15 @@
MUTEX_LOCK(&dbh->DATABASE_Lock_);
contentSize = ntohl(value->size)-sizeof(Datastore_Value);
- escapedHash = MALLOC(2*sizeof(HashCode160)+1);
+ escapedHash = MALLOC(2*sizeof(HashCode512)+1);
mysql_escape_string(escapedHash,
(char *)key,
- sizeof(HashCode160));
+ sizeof(HashCode512));
escapedBlock = MALLOC(2*contentSize+1);
mysql_escape_string(escapedBlock,
(char *)&value[1],
contentSize);
- n = contentSize*2+sizeof(HashCode160)*2+100+1;
+ n = contentSize*2+sizeof(HashCode512)*2+100+1;
scratch = MALLOC(n);
/* NOTE: as the table entry for 'prio' is defined as unsigned,
Modified: GNUnet/src/applications/sqstore_mysql/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -27,7 +27,7 @@
return value;
}
-static int checkValue(const HashCode160 * key,
+static int checkValue(const HashCode512 * key,
const Datastore_Value * val,
void * closure) {
int i;
@@ -49,7 +49,7 @@
return ret;
}
-static int iterateUp(const HashCode160 * key,
+static int iterateUp(const HashCode512 * key,
const Datastore_Value * val,
int * closure) {
int ret;
@@ -59,7 +59,7 @@
return ret;
}
-static int iterateUp1(const HashCode160 * key,
+static int iterateUp1(const HashCode512 * key,
const Datastore_Value * val,
int * closure) {
int ret;
@@ -69,7 +69,7 @@
return ret;
}
-static int iterateDown(const HashCode160 * key,
+static int iterateDown(const HashCode512 * key,
const Datastore_Value * val,
int * closure) {
int ret;
@@ -84,7 +84,7 @@
*/
static int test(SQstore_ServiceAPI * api) {
Datastore_Value * value;
- HashCode160 key;
+ HashCode512 key;
unsigned long long oldSize;
int i;
@@ -92,7 +92,7 @@
oldSize = api->getSize();
for (i=0;i<256;i++) {
value = initValue(i+1);
- memset(&key, 256-i, sizeof(HashCode160));
+ memset(&key, 256-i, sizeof(HashCode512));
api->put(&key, value);
FREE(value);
}
@@ -105,13 +105,13 @@
(Datum_Iterator) &iterateUp1,
&i));
for (i=255;i>=0;i--) {
- memset(&key, 256-i, sizeof(HashCode160));
+ memset(&key, 256-i, sizeof(HashCode512));
ASSERT(1 == api->get(&key, i+1, &checkValue, &i));
}
oldSize = api->getSize();
for (i=255;i>=0;i-=2) {
- memset(&key, 256-i, sizeof(HashCode160));
+ memset(&key, 256-i, sizeof(HashCode512));
value = initValue(i+1);
ASSERT(1 == api->del(&key, value));
FREE(value);
@@ -127,7 +127,7 @@
&i));
ASSERT(0 == i);
for (i=254;i>=0;i-=2) {
- memset(&key, 256-i, sizeof(HashCode160));
+ memset(&key, 256-i, sizeof(HashCode512));
value = initValue(i+1);
ASSERT(1 == api->del(&key, value));
FREE(value);
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -173,7 +173,7 @@
return NULL; /* error */
}
- if (sqlite3_column_bytes(stmt, 5) > sizeof(HashCode160) * 2 + 1 ||
+ if (sqlite3_column_bytes(stmt, 5) > sizeof(HashCode512) * 2 + 1 ||
sqlite3_column_bytes(stmt, 6) > contentSize * 2 + 1) {
LOG(LOG_WARNING,
@@ -190,7 +190,7 @@
if (sqlite_decode_binary_n(sqlite3_column_blob(stmt, 5),
(char *) &datum->key,
- sizeof(HashCode160)) != sizeof(HashCode160) ||
+ sizeof(HashCode512)) != sizeof(HashCode512) ||
sqlite_decode_binary_n(sqlite3_column_blob(stmt, 6),
(char *) &datum[1],
contentSize) != contentSize) {
@@ -310,7 +310,7 @@
unsigned long long lastExp;
unsigned long hashLen;
char * lastHash;
- HashCode160 key;
+ HashCode512 key;
#if DEBUG_SQLITE
LOG(LOG_DEBUG, "SQLite: iterating through the database\n");
@@ -351,11 +351,11 @@
count = 0;
lastPrio = 0;
lastExp = 0x8000000000000000LL; /* MIN long long; sqlite does not know
about unsigned... */
- memset(&key, 0, sizeof(HashCode160));
- lastHash = MALLOC(sizeof(HashCode160)*2 + 2);
+ memset(&key, 0, sizeof(HashCode512));
+ lastHash = MALLOC(sizeof(HashCode512)*2 + 2);
while (1) {
hashLen = sqlite_encode_binary((const char *) &key,
- sizeof(HashCode160),
+ sizeof(HashCode512),
lastHash);
sqlite3_bind_blob(stmt,
@@ -520,7 +520,7 @@
* @return the number of results, SYSERR if the
* iter is non-NULL and aborted the iteration
*/
-static int get(const HashCode160 * key,
+static int get(const HashCode512 * key,
unsigned int type,
Datum_Iterator iter,
void * closure) {
@@ -574,9 +574,9 @@
ret = SQLITE_OK;
if (key && (ret == SQLITE_OK)) {
- escapedHash = MALLOC(sizeof(HashCode160)*2 + 2);
+ escapedHash = MALLOC(sizeof(HashCode512)*2 + 2);
len = sqlite_encode_binary((const char *) key,
- sizeof(HashCode160),
+ sizeof(HashCode512),
escapedHash);
ret = sqlite3_bind_blob(stmt,
bind,
@@ -643,7 +643,7 @@
*
* @return SYSERR on error, OK if ok.
*/
-static int put(const HashCode160 * key,
+static int put(const HashCode512 * key,
const Datastore_Value * value) {
char *escapedBlock;
char *escapedHash;
@@ -670,9 +670,9 @@
rowLen = 0;
contentSize = ntohl(value->size)-sizeof(Datastore_Value);
- escapedHash = MALLOC(2*sizeof(HashCode160)+1);
+ escapedHash = MALLOC(2*sizeof(HashCode512)+1);
hashLen = sqlite_encode_binary((const char *) key,
- sizeof(HashCode160),
+ sizeof(HashCode512),
escapedHash);
escapedBlock = MALLOC(2 * contentSize + 1);
@@ -719,7 +719,7 @@
* @return the number of items deleted, 0 if
* none were found, SYSERR on errors
*/
-static int del(const HashCode160 * key,
+static int del(const HashCode512 * key,
const Datastore_Value * value) {
char *escapedHash;
size_t n;
@@ -739,9 +739,9 @@
if (dbh->lastSync > 1000)
syncStats(dbh);
- escapedHash = MALLOC(2 * sizeof(HashCode160) + 1);
+ escapedHash = MALLOC(2 * sizeof(HashCode512) + 1);
hashLen = sqlite_encode_binary((const char *)key,
- sizeof(HashCode160),
+ sizeof(HashCode512),
escapedHash);
if (!value) {
sqlite3_bind_blob(dbh->exists,
@@ -825,7 +825,7 @@
* Update the priority for a particular key
* in the datastore.
*/
-static int update(const HashCode160 * key,
+static int update(const HashCode512 * key,
const Datastore_Value * value,
int delta) {
char *escapedHash, *escapedBlock;
@@ -841,9 +841,9 @@
contentSize = ntohl(value->size)-sizeof(Datastore_Value);
- escapedHash = MALLOC(2*sizeof(HashCode160)+1);
+ escapedHash = MALLOC(2*sizeof(HashCode512)+1);
hashLen = sqlite_encode_binary((const char *) key,
- sizeof(HashCode160),
+ sizeof(HashCode512),
escapedHash);
escapedBlock = MALLOC(2*contentSize+1);
blockLen = sqlite_encode_binary((const char *) &value[1],
Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -27,7 +27,7 @@
return value;
}
-static int checkValue(const HashCode160 * key,
+static int checkValue(const HashCode512 * key,
const Datastore_Value * val,
void * closure) {
int i;
@@ -53,7 +53,7 @@
return ret;
}
-static int iterateUp(const HashCode160 * key,
+static int iterateUp(const HashCode512 * key,
const Datastore_Value * val,
int * closure) {
int ret;
@@ -63,7 +63,7 @@
return ret;
}
-static int iterateDown(const HashCode160 * key,
+static int iterateDown(const HashCode512 * key,
const Datastore_Value * val,
int * closure) {
int ret;
@@ -78,7 +78,7 @@
*/
static int test(SQstore_ServiceAPI * api) {
Datastore_Value * value;
- HashCode160 key;
+ HashCode512 key;
unsigned long long oldSize;
int i;
@@ -87,7 +87,7 @@
oldSize = api->getSize();
for (i=0;i<256;i++) {
value = initValue(i);
- memset(&key, 256-i, sizeof(HashCode160));
+ memset(&key, 256-i, sizeof(HashCode512));
api->put(&key, value);
FREE(value);
}
@@ -99,12 +99,12 @@
NULL,
NULL));
for (i=255;i>=0;i--) {
- memset(&key, 256-i, sizeof(HashCode160));
+ memset(&key, 256-i, sizeof(HashCode512));
ASSERT(1 == api->get(&key, i, &checkValue, (void*) &i));
}
oldSize = api->getSize();
for (i=255;i>=0;i-=2) {
- memset(&key, 256-i, sizeof(HashCode160));
+ memset(&key, 256-i, sizeof(HashCode512));
value = initValue(i);
ASSERT(1 == api->del(&key, value));
FREE(value);
Modified: GNUnet/src/applications/tracekit/gnunet-tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/gnunet-tracekit.c 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/applications/tracekit/gnunet-tracekit.c 2005-03-05 05:37:01 UTC
(rev 366)
@@ -197,7 +197,7 @@
&enc);
match = NO;
for (j=0;j<prCount;j++)
- if (equalsHashCode160(&buffer->responderId.hashPubKey,
+ if (equalsHashCode512(&buffer->responderId.hashPubKey,
&peersResponding[j].hashPubKey))
match = YES;
if (match == NO) {
@@ -240,7 +240,7 @@
for (i=0;i<count;i++) {
match = NO;
for (j=0;j<psCount;j++)
- if
(equalsHashCode160(&((TRACEKIT_CS_REPLY_GENERIC*)buffer)->peerList[i].hashPubKey,
+ if
(equalsHashCode512(&((TRACEKIT_CS_REPLY_GENERIC*)buffer)->peerList[i].hashPubKey,
&peersSeen[j].hashPubKey))
match = YES;
if (match == NO) {
@@ -285,7 +285,7 @@
match = NO;
for (j=0;j<prCount;j++)
- if (equalsHashCode160(&peersResponding[j].hashPubKey,
+ if (equalsHashCode512(&peersResponding[j].hashPubKey,
&peersSeen[i].hashPubKey)) {
match = YES;
break;
Modified: GNUnet/src/applications/tracekit/tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/tracekit.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/tracekit/tracekit.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -85,11 +85,11 @@
if (routeTable[i] == NULL)
continue;
if ( (routeTable[i]->timestamp ==
(TIME_T)ntohl(reply->initiatorTimestamp)) &&
- (equalsHashCode160(&routeTable[i]->initiator.hashPubKey,
+ (equalsHashCode512(&routeTable[i]->initiator.hashPubKey,
&reply->initiatorId.hashPubKey) ) ) {
LOG(LOG_DEBUG,
"TRACEKIT: found matching entry in routing table\n");
- if (equalsHashCode160(&coreAPI->myIdentity->hashPubKey,
+ if (equalsHashCode512(&coreAPI->myIdentity->hashPubKey,
&routeTable[i]->replyTo.hashPubKey) ) {
unsigned int idx;
TRACEKIT_CS_REPLY * csReply;
@@ -219,7 +219,7 @@
if (routeTable[i] == NULL)
continue;
if ( (routeTable[i]->timestamp == (TIME_T)ntohl(msg->timestamp)) &&
- equalsHashCode160(&routeTable[i]->initiator.hashPubKey,
+ equalsHashCode512(&routeTable[i]->initiator.hashPubKey,
&msg->initiatorId.hashPubKey) ) {
LOG(LOG_DEBUG,
"TRACEKIT-PROBE %d from '%s' received twice (slot %d), ignored\n",
@@ -317,7 +317,7 @@
}
reply->header.size
= htons(maxBytes);
- if (equalsHashCode160(&coreAPI->myIdentity->hashPubKey,
+ if (equalsHashCode512(&coreAPI->myIdentity->hashPubKey,
&sender->hashPubKey)) {
handlep2pReply(coreAPI->myIdentity,
&reply->header);
Modified: GNUnet/src/applications/traffic/traffic.c
===================================================================
--- GNUnet/src/applications/traffic/traffic.c 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/applications/traffic/traffic.c 2005-03-05 05:37:01 UTC (rev
366)
@@ -490,7 +490,7 @@
checkPort(port);
updateUse(&counters[port]->receive,
ntohs(header->size),
- sender->hashPubKey.a,
+ sender->hashPubKey.bits[0],
NO);
MUTEX_UNLOCK(&lock);
return OK;
@@ -513,7 +513,7 @@
checkPort(port);
updateUse(&counters[port]->send,
ntohs(header->size),
- receiver->hashPubKey.a,
+ receiver->hashPubKey.bits[0],
NO);
MUTEX_UNLOCK(&lock);
return OK;
Modified: GNUnet/src/conf/gnunet-win-tool.c
===================================================================
--- GNUnet/src/conf/gnunet-win-tool.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/conf/gnunet-win-tool.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -297,7 +297,7 @@
*/
void doHash()
{
- HashCode160 code;
+ HashCode512 code;
EncName hex;
char *c;
Modified: GNUnet/src/include/ecrs_core.h
===================================================================
--- GNUnet/src/include/ecrs_core.h 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/include/ecrs_core.h 2005-03-05 05:37:01 UTC (rev 366)
@@ -36,8 +36,8 @@
* @brief content hash key
*/
typedef struct {
- HashCode160 key;
- HashCode160 query;
+ HashCode512 key;
+ HashCode512 query;
} CHK;
/**
@@ -100,12 +100,12 @@
/**
* R = H(N-I)^S, used for routing!
*/
- HashCode160 identifier;
+ HashCode512 identifier;
/* from here on encrypted */
cron_t creationTime; /* in network byte order */
cron_t updateInterval; /* in network byte order */
- HashCode160 nextIdentifier; /* N, 20 b */
- HashCode160 identifierIncrement; /* I, 20 b */
+ HashCode512 nextIdentifier; /* N, 20 b */
+ HashCode512 identifierIncrement; /* I, 20 b */
/* 0-terminated URI follows here! */
/* variable-size Meta-Data follows here! */
} SBlock;
@@ -119,18 +119,18 @@
/**
* Must be all zeros
*/
- HashCode160 identifier;
+ HashCode512 identifier;
/* The REST (from here on) is encrypted! */
/**
* Identifier of the namespace
*/
- HashCode160 namespace;
+ HashCode512 namespace;
/**
* Key of an (optional) root entry into the namespace
* (use all-zeros for not given).
*/
- HashCode160 rootEntry;
+ HashCode512 rootEntry;
/* variable-size Meta-Data follows here! */
} NBlock;
@@ -163,7 +163,7 @@
*/
int fileBlockEncode(const DBlock * data,
unsigned int len,
- const HashCode160 * query,
+ const HashCode512 * query,
Datastore_Value ** value);
/**
@@ -172,7 +172,7 @@
*/
void fileBlockGetQuery(const DBlock * data,
unsigned int len,
- HashCode160 * query);
+ HashCode512 * query);
/**
@@ -181,7 +181,7 @@
*/
void fileBlockGetKey(const DBlock * data,
unsigned int len,
- HashCode160 * key);
+ HashCode512 * key);
/**
* What is the type of the given block of data?
@@ -202,7 +202,7 @@
*/
int getQueryFor(unsigned int size,
const DBlock * data,
- HashCode160 * query);
+ HashCode512 * query);
/**
* Verify that the given Datum is a valid response
@@ -221,7 +221,7 @@
unsigned int size,
const DBlock * data,
unsigned int keyCount,
- const HashCode160 * keys);
+ const HashCode512 * keys);
#endif
Modified: GNUnet/src/include/fs.h
===================================================================
--- GNUnet/src/include/fs.h 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/include/fs.h 2005-03-05 05:37:01 UTC (rev 366)
@@ -62,7 +62,7 @@
/**
* What are the queries?
*/
- HashCode160 query[1];
+ HashCode512 query[1];
} RequestSearch;
@@ -140,7 +140,7 @@
* this block? Used by gnunetd for the name
* of the file in the on-demand datastore.
*/
- HashCode160 fileId;
+ HashCode512 fileId;
} RequestIndex;
@@ -169,7 +169,7 @@
* What is the hash of the file that should be
* unindexed?
*/
- HashCode160 fileId;
+ HashCode512 fileId;
} RequestUnindex;
@@ -183,7 +183,7 @@
* What is the hash of the file that should be
* unindexed?
*/
- HashCode160 fileId;
+ HashCode512 fileId;
} RequestTestindex;
Modified: GNUnet/src/include/gnunet_blockstore.h
===================================================================
--- GNUnet/src/include/gnunet_blockstore.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/include/gnunet_blockstore.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -48,7 +48,7 @@
* @param cls argument passed for context (closure)
* @return OK to continue with iteration, SYSERR to abort
*/
-typedef int (*DataProcessor)(const HashCode160 * key,
+typedef int (*DataProcessor)(const HashCode512 * key,
const DataContainer * value,
void * cls);
@@ -90,7 +90,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
DataProcessor resultCallback,
void * resCallbackClosure);
@@ -105,7 +105,7 @@
* SYSERR if the value is malformed
*/
int (*put)(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value,
unsigned int prio);
@@ -117,7 +117,7 @@
* @return OK if the value could be removed, SYSERR if not (i.e. not present)
*/
int (*del)(void * closure,
- const HashCode160 * key,
+ const HashCode512 * key,
const DataContainer * value);
/**
Modified: GNUnet/src/include/gnunet_datastore_service.h
===================================================================
--- GNUnet/src/include/gnunet_datastore_service.h 2005-03-04 19:31:22 UTC
(rev 365)
+++ GNUnet/src/include/gnunet_datastore_service.h 2005-03-05 05:37:01 UTC
(rev 366)
@@ -82,7 +82,7 @@
* A key (not unique) that can be used to lookup this Datum in the
* datastore.
*/
- HashCode160 key;
+ HashCode512 key;
/**
* The value associated with the key.
@@ -98,7 +98,7 @@
* @param closure user-defined extra argument
* @return SYSERR to abort the iteration, OK to continue.
*/
-typedef int (*Datum_Iterator)(const HashCode160 * key,
+typedef int (*Datum_Iterator)(const HashCode512 * key,
const Datastore_Value * value,
void * closure);
@@ -137,7 +137,7 @@
* to justify removing something else, SYSERR on
* other serious error (i.e. IO permission denied)
*/
- int (*put)(const HashCode160 * key,
+ int (*put)(const HashCode512 * key,
const Datastore_Value * value);
/**
@@ -150,7 +150,7 @@
* to justify removing something else, SYSERR on
* other serious error (i.e. IO permission denied)
*/
- int (*putUpdate)(const HashCode160 * key,
+ int (*putUpdate)(const HashCode512 * key,
const Datastore_Value * value);
/**
@@ -166,7 +166,7 @@
* 0 if no matches were found. May NOT return
* SYSERR unless the iterator aborted!
*/
- int (*get)(const HashCode160 * key,
+ int (*get)(const HashCode512 * key,
unsigned int type,
Datum_Iterator iter,
void * closure);
@@ -183,9 +183,9 @@
* for any type.
* @return OK if a value was found, SYSERR if not
*/
- int (*getRandom)(const HashCode160 * approx,
+ int (*getRandom)(const HashCode512 * approx,
unsigned int sizeLimit,
- HashCode160 * key,
+ HashCode512 * key,
Datastore_Value ** value,
unsigned int type);
@@ -197,7 +197,7 @@
* @return the number of items deleted, 0 if
* none were found, SYSERR on errors
*/
- int (*del)(const HashCode160 * key,
+ int (*del)(const HashCode512 * key,
const Datastore_Value * value);
} Datastore_ServiceAPI;
Modified: GNUnet/src/include/gnunet_dht.h
===================================================================
--- GNUnet/src/include/gnunet_dht.h 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/include/gnunet_dht.h 2005-03-05 05:37:01 UTC (rev 366)
@@ -48,9 +48,9 @@
* tables. The GNUnet DHT infrastructure supports multiple
* tables, the table to lookup peers is just one of these.
*/
-typedef HashCode160 DHT_TableId;
+typedef HashCode512 DHT_TableId;
-#define equalsDHT_TableId(a,b) equalsHashCode160(a,b)
+#define equalsDHT_TableId(a,b) equalsHashCode512(a,b)
/**
* TCP communication: client to gnunetd: join table.
@@ -92,7 +92,7 @@
unsigned long long timeout; /* nbo */
- HashCode160 key;
+ HashCode512 key;
unsigned int priority; /* nbo */
@@ -115,7 +115,7 @@
unsigned int priority; /* nbo */
/* one or more keys */
- HashCode160 keys;
+ HashCode512 keys;
} DHT_CS_REQUEST_GET;
@@ -130,7 +130,7 @@
unsigned long long timeout; /* nbo */
- HashCode160 key;
+ HashCode512 key;
} DHT_CS_REQUEST_REMOVE;
@@ -157,7 +157,7 @@
DHT_TableId table;
- HashCode160 key;
+ HashCode512 key;
DataContainer data;
Modified: GNUnet/src/include/gnunet_dht_lib.h
===================================================================
--- GNUnet/src/include/gnunet_dht_lib.h 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/include/gnunet_dht_lib.h 2005-03-05 05:37:01 UTC (rev 366)
@@ -95,7 +95,7 @@
unsigned int type,
unsigned int prio,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
cron_t timeout,
DataProcessor resultCallback,
void * resCallbackClosure);
@@ -112,7 +112,7 @@
* @return OK on success, SYSERR on error (or timeout)
*/
int DHT_LIB_put(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
unsigned int prio,
cron_t timeout,
const DataContainer * value);
@@ -129,7 +129,7 @@
* @return OK on success, SYSERR on error (or timeout)
*/
int DHT_LIB_remove(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
const DataContainer * value);
Modified: GNUnet/src/include/gnunet_dht_service.h
===================================================================
--- GNUnet/src/include/gnunet_dht_service.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/include/gnunet_dht_service.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -98,7 +98,7 @@
struct DHT_GET_RECORD * (*get_start)(const DHT_TableId * table,
unsigned int type,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
cron_t timeout,
DataProcessor callback,
void * cls,
@@ -125,7 +125,7 @@
* @return handle to stop the async put
*/
struct DHT_PUT_RECORD * (*put_start)(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
const DataContainer * value,
DHT_OP_Complete callback,
@@ -151,7 +151,7 @@
* @return handle to stop the async remove
*/
struct DHT_REMOVE_RECORD * (*remove_start)(const DHT_TableId * table,
- const HashCode160 * key,
+ const HashCode512 * key,
cron_t timeout,
const DataContainer * value,
DHT_OP_Complete callback,
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -363,7 +363,7 @@
unsigned int priority,
cron_t expiration,
const struct ECRS_URI * advertisementURI,
- const HashCode160 * rootEntry,
+ const HashCode512 * rootEntry,
struct ECRS_URI ** rootURI); /* namespace.c */
/**
@@ -373,7 +373,7 @@
* @return OK if the namespace exists, SYSERR if not
*/
int ECRS_testNamespaceExists(const char * name,
- const HashCode160 * hc);
+ const HashCode512 * hc);
/**
* Delete a local namespace. Only prevents future insertions
@@ -410,8 +410,8 @@
cron_t expirationTime,
cron_t creationTime,
cron_t updateInterval,
- const HashCode160 * thisId,
- const HashCode160 * nextId,
+ const HashCode512 * thisId,
+ const HashCode512 * nextId,
const struct ECRS_URI * dst,
const struct ECRS_MetaData * md,
struct ECRS_URI ** uri); /* namespace.c */
@@ -444,7 +444,7 @@
*/
typedef int (*ECRS_SearchProgressCallback)
(const ECRS_FileInfo * fi,
- const HashCode160 * key,
+ const HashCode512 * key,
void * closure);
/**
Modified: GNUnet/src/include/gnunet_fs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fs_lib.h 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/include/gnunet_fs_lib.h 2005-03-05 05:37:01 UTC (rev 366)
@@ -54,7 +54,7 @@
struct FS_SEARCH_HANDLE * FS_start_search(struct FS_SEARCH_CONTEXT * ctx,
unsigned int type,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
unsigned int anonymityLevel,
unsigned int prio,
cron_t timeout,
@@ -96,7 +96,7 @@
* @return OK on success, SYSERR on error
*/
int FS_index(GNUNET_TCP_SOCKET * sock,
- const HashCode160 * fileHc,
+ const HashCode512 * fileHc,
const Datastore_Value * block,
unsigned long long offset);
@@ -119,6 +119,6 @@
*/
int FS_unindex(GNUNET_TCP_SOCKET * sock,
unsigned int blocksize,
- const HashCode160 * hc);
+ const HashCode512 * hc);
#endif
Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/include/gnunet_fsui_lib.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -306,8 +306,8 @@
*/
typedef int (*FSUI_UpdateIterator)(void * cls,
const ECRS_FileInfo * uri,
- const HashCode160 * lastId,
- const HashCode160 * nextId,
+ const HashCode512 * lastId,
+ const HashCode512 * nextId,
cron_t nextPublicationTime);
/**
@@ -564,7 +564,7 @@
const char * namespaceName,
const struct ECRS_MetaData * meta,
const struct ECRS_URI * advertisementURI,
- const HashCode160 * rootEntry,
+ const HashCode512 * rootEntry,
struct ECRS_URI ** root); /* namespace_info.c */
/**
@@ -627,9 +627,9 @@
unsigned int anonymityLevel,
const char * name,
cron_t updateInterval,
- const HashCode160 * lastId,
- const HashCode160 * thisId,
- const HashCode160 * nextId,
+ const HashCode512 * lastId,
+ const HashCode512 * thisId,
+ const HashCode512 * nextId,
const struct ECRS_URI * dst,
const struct ECRS_MetaData * md,
struct ECRS_URI ** uri); /* namespace_info.c */
Modified: GNUnet/src/include/gnunet_gap_service.h
===================================================================
--- GNUnet/src/include/gnunet_gap_service.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/include/gnunet_gap_service.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -41,7 +41,7 @@
typedef int (*UniqueReplyIdentifier)(const void * content,
unsigned int size,
unsigned int query_type,
- const HashCode160 * primaryKey);
+ const HashCode512 * primaryKey);
/**
* Functions of the GAP Service API.
@@ -73,7 +73,7 @@
int (*get_start)(unsigned int type,
unsigned int anonymityLevel,
unsigned int keyCount,
- const HashCode160 * keys,
+ const HashCode512 * keys,
cron_t timeout,
unsigned int prio);
@@ -84,7 +84,7 @@
*/
int (*get_stop)(unsigned int type,
unsigned int keyCount,
- const HashCode160 * keys);
+ const HashCode512 * keys);
/**
* Try to migrate the given content.
@@ -96,7 +96,7 @@
* that buffer (must be a positive number).
*/
unsigned int (*tryMigrate)(const DataContainer * data,
- const HashCode160 * primaryKey,
+ const HashCode512 * primaryKey,
char * position,
unsigned int padding);
Modified: GNUnet/src/include/gnunet_sqstore_service.h
===================================================================
--- GNUnet/src/include/gnunet_sqstore_service.h 2005-03-04 19:31:22 UTC (rev
365)
+++ GNUnet/src/include/gnunet_sqstore_service.h 2005-03-05 05:37:01 UTC (rev
366)
@@ -53,7 +53,7 @@
*
* @return OK on success, SYSERR on error
*/
- int (*put)(const HashCode160 * key,
+ int (*put)(const HashCode512 * key,
const Datastore_Value * value);
/**
@@ -67,7 +67,7 @@
* @return the number of results, SYSERR if the
* iter is non-NULL and aborted the iteration
*/
- int (*get)(const HashCode160 * key,
+ int (*get)(const HashCode512 * key,
unsigned int type,
Datum_Iterator iter,
void * closure);
@@ -94,7 +94,7 @@
* @return OK if a match was found and the update
* was successful, SYSERR on error
*/
- int (*update)(const HashCode160 * key,
+ int (*update)(const HashCode512 * key,
const Datastore_Value * value,
int delta);
@@ -143,7 +143,7 @@
* @return the number of items deleted (at most 1!), 0 if
* none were found, SYSERR on errors
*/
- int (*del)(const HashCode160 * key,
+ int (*del)(const HashCode512 * key,
const Datastore_Value * value);
/**
Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/include/gnunet_util.h 2005-03-05 05:37:01 UTC (rev 366)
@@ -105,9 +105,9 @@
#define LOG_EVERYTHING 9
/**
- * @brief length of the sessionkey in bytes (128 BIT sessionkey)
+ * @brief length of the sessionkey in bytes (256 BIT sessionkey)
*/
-#define SESSIONKEY_LEN (128/8)
+#define SESSIONKEY_LEN (256/8)
/**
* @brief Default names of the configuration files.
@@ -303,29 +303,25 @@
} PTHREAD_T;
/**
- * A 160-bit hashcode
+ * @brief A 512-bit hashcode
*/
typedef struct {
- int a;
- int b;
- int c;
- int d;
- int e;
-} HashCode160;
+ unsigned int bits[512 / 8 / sizeof(unsigned int)]; /* = 16 */
+} HashCode512;
/**
* The identity of the host (basically the RIPE160 hashcode of
* it's public key).
*/
typedef struct {
- HashCode160 hashPubKey;
+ HashCode512 hashPubKey;
} PeerIdentity;
/**
- * ASCII encoding of a HashCode160.
+ * @brief 0-terminated ASCII encoding of a HashCode512.
*/
typedef struct {
- unsigned char encoding[33];
+ unsigned char encoding[104];
} EncName;
/**
@@ -464,7 +460,7 @@
* @brief IV for sym cipher
*
* NOTE: must be smaller (!) in size than the
- * HashCode160.
+ * HashCode512.
*/
typedef struct {
unsigned char iv[SESSIONKEY_LEN/2];
@@ -502,7 +498,7 @@
/**
* Iterator over all HashCodes stored in a Bloomfilter.
*/
-typedef HashCode160 * (*ElementIterator)(void * arg);
+typedef HashCode512 * (*ElementIterator)(void * arg);
/**
* @brief a Vector (ordered variable size set of elements), opaque
@@ -1358,7 +1354,7 @@
* @param result where to store the encoding (EncName can be
* safely cast to char*, a '\0' termination is set).
*/
-void hash2enc(const HashCode160 * block,
+void hash2enc(const HashCode512 * block,
EncName * result);
/**
@@ -1368,7 +1364,7 @@
* @return OK on success, SYSERR if result has the wrong encoding
*/
int enc2hash(const char * enc,
- HashCode160 * result);
+ HashCode512 * result);
/**
* Compute the distance between 2 hashcodes.
@@ -1377,14 +1373,14 @@
* be somewhat consistent. And of course, the
* result should be a positive number.
*/
-int distanceHashCode160(const HashCode160 * a,
- const HashCode160 * b);
+int distanceHashCode512(const HashCode512 * a,
+ const HashCode512 * b);
/**
* compare two hashcodes.
*/
-int equalsHashCode160(const HashCode160 * a,
- const HashCode160 * b);
+int equalsHashCode512(const HashCode512 * a,
+ const HashCode512 * b);
/**
* Hash block of given size.
@@ -1392,8 +1388,8 @@
* @param ret pointer to where to write the hashcode
*/
void hash(const void * block,
- int size,
- HashCode160 * ret);
+ unsigned int size,
+ HashCode512 * ret);
/**
@@ -1401,7 +1397,7 @@
* @return OK on success, SYSERR on error
*/
int getFileHash(const char * filename,
- HashCode160 * ret);
+ HashCode512 * ret);
/**
* Check if 2 hosts are the same (returns 1 if yes)
@@ -1412,27 +1408,27 @@
int hostIdentityEquals(const PeerIdentity * first,
const PeerIdentity * second);
-void makeRandomId(HashCode160 * result);
+void makeRandomId(HashCode512 * result);
/* compute result(delta) = b - a */
-void deltaId(const HashCode160 * a,
- const HashCode160 * b,
- HashCode160 * result);
+void deltaId(const HashCode512 * a,
+ const HashCode512 * b,
+ HashCode512 * result);
/* compute result(b) = a + delta */
-void addHashCodes(const HashCode160 * a,
- const HashCode160 * delta,
- HashCode160 * result);
+void addHashCodes(const HashCode512 * a,
+ const HashCode512 * delta,
+ HashCode512 * result);
/* compute result = a ^ b */
-void xorHashCodes(const HashCode160 * a,
- const HashCode160 * b,
- HashCode160 * result);
+void xorHashCodes(const HashCode512 * a,
+ const HashCode512 * b,
+ HashCode512 * result);
/**
* Convert a hashcode into a key.
*/
-void hashToKey(const HashCode160 * hc,
+void hashToKey(const HashCode512 * hc,
SESSIONKEY * skey,
INITVECTOR * iv);
@@ -1442,7 +1438,7 @@
* @param bit index into the hashcode, [0...159]
* @return Bit \a bit from hashcode \a code, -1 for invalid index
*/
-int getHashCodeBit(const HashCode160 * code,
+int getHashCodeBit(const HashCode512 * code,
unsigned int bit);
/**
@@ -1450,17 +1446,17 @@
* of all hashcodes.
* @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
*/
-int hashCodeCompare(const HashCode160 * h1,
- const HashCode160 * h2);
+int hashCodeCompare(const HashCode512 * h1,
+ const HashCode512 * h2);
/**
* Find out which of the two hash codes is closer to target
* in the XOR metric (Kademlia).
* @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2.
*/
-int hashCodeCompareDistance(const HashCode160 * h1,
- const HashCode160 * h2,
- const HashCode160 * target);
+int hashCodeCompareDistance(const HashCode512 * h1,
+ const HashCode512 * h2,
+ const HashCode512 * target);
/**
* create a new hostkey. Callee must free return value.
@@ -1471,7 +1467,7 @@
* Deterministically (!) create a hostkey using only the
* given HashCode as input to the PRNG.
*/
-struct PrivateKey * makeKblockKey(const HashCode160 * input);
+struct PrivateKey * makeKblockKey(const HashCode512 * input);
/**
* Free memory occupied by hostkey
@@ -2006,7 +2002,7 @@
* @return YES if the element is in the filter, NO if not
*/
int testBloomfilter(struct Bloomfilter * bf,
- const HashCode160 * e);
+ const HashCode512 * e);
/**
* Add an element to the filter
@@ -2014,7 +2010,7 @@
* @param e the element
*/
void addToBloomfilter(struct Bloomfilter * bf,
- const HashCode160 * e);
+ const HashCode512 * e);
/**
* Remove an element from the filter.
@@ -2022,7 +2018,7 @@
* @param e the element to remove
*/
void delFromBloomfilter(struct Bloomfilter * bf,
- const HashCode160 * e);
+ const HashCode512 * e);
/**
* Free the space associcated with a filter
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/server/connection.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -1057,12 +1057,12 @@
int msgCap;
int l = getCPULoad();
if (l >= 50) {
- msgCap = be->session.mtu / sizeof(HashCode160);
+ msgCap = be->session.mtu / sizeof(HashCode512);
} else {
if (l <= 0)
l = 1;
- msgCap = be->session.mtu / sizeof(HashCode160)
- + (MAX_SEND_BUFFER_SIZE - be->session.mtu / sizeof(HashCode160)) / l;
+ msgCap = be->session.mtu / sizeof(HashCode512)
+ + (MAX_SEND_BUFFER_SIZE - be->session.mtu / sizeof(HashCode512)) / l;
}
if (be->max_bpm > 2) {
msgCap += 2 * (int) log((double)be->max_bpm);
@@ -1129,8 +1129,8 @@
encryptedMsg = MALLOC(p);
hash(&p2pHdr->sequenceNumber,
- p - sizeof(HashCode160),
- (HashCode160*) encryptedMsg);
+ p - sizeof(HashCode512),
+ (HashCode512*) encryptedMsg);
#if DEBUG_CONNECTION
LOG(LOG_DEBUG,
"Encrypting with key %u and IV %u\n",
@@ -1138,7 +1138,7 @@
*(int*) &encryptedMsg /* IV */);
#endif
encryptBlock(&p2pHdr->sequenceNumber,
- p - sizeof(HashCode160),
+ p - sizeof(HashCode512),
&be->skey_local,
(const INITVECTOR*) encryptedMsg, /* IV */
&((P2P_Message*)encryptedMsg)->sequenceNumber);
@@ -1289,7 +1289,7 @@
root = CONNECTION_buffer_[computeIndex(hostId)];
while (root != NULL) {
- if (equalsHashCode160(&hostId->hashPubKey,
+ if (equalsHashCode512(&hostId->hashPubKey,
&root->session.sender.hashPubKey))
return root;
root = root->overflowChain;
@@ -1331,7 +1331,7 @@
while (NULL != root) {
/* settle for entry in the linked list that is down */
if ( (root->status == STAT_DOWN) ||
- (equalsHashCode160(&hostId->hashPubKey,
+ (equalsHashCode512(&hostId->hashPubKey,
&root->session.sender.hashPubKey)) )
break;
prev = root;
@@ -1844,7 +1844,7 @@
unsigned int sequenceNumber;
TIME_T stamp;
char * tmp;
- HashCode160 hc;
+ HashCode512 hc;
EncName enc;
ENTRY();
@@ -1861,9 +1861,9 @@
hash2enc(&sender->hashPubKey,
&enc);
hash(&msg->sequenceNumber,
- size - sizeof(HashCode160),
+ size - sizeof(HashCode512),
&hc);
- if ( equalsHashCode160(&hc,
+ if ( equalsHashCode512(&hc,
&msg->hash) &&
(msg->sequenceNumber == 0) &&
(msg->bandwidth == 0) &&
@@ -1890,7 +1890,7 @@
MUTEX_UNLOCK(&lock);
return SYSERR; /* could not decrypt */
}
- tmp = MALLOC(size - sizeof(HashCode160));
+ tmp = MALLOC(size - sizeof(HashCode512));
#if DEBUG_CONNECTION
LOG(LOG_DEBUG,
"Decrypting with key %u and IV %u\n",
@@ -1899,14 +1899,14 @@
#endif
res = decryptBlock(&be->skey_remote,
&msg->sequenceNumber,
- size - sizeof(HashCode160),
+ size - sizeof(HashCode512),
(const INITVECTOR*) &msg->hash, /* IV */
tmp);
hash(tmp,
- size - sizeof(HashCode160),
+ size - sizeof(HashCode512),
&hc);
if ( ! ( (res != OK) &&
- equalsHashCode160(&hc,
+ equalsHashCode512(&hc,
&msg->hash)) ) {
LOG(LOG_INFO,
"Decrypting message from host '%s' failed, wrong sessionkey!\n",
@@ -1918,7 +1918,7 @@
}
memcpy(&msg->sequenceNumber,
tmp,
- size - sizeof(HashCode160));
+ size - sizeof(HashCode512));
FREE(tmp);
res = YES;
sequenceNumber = ntohl(msg->sequenceNumber);
@@ -2460,10 +2460,10 @@
hash2enc(&tmp->session.sender.hashPubKey,
&hostName));
IFLOG(LOG_MESSAGE,
- hash2enc((HashCode160*) &tmp->skey_local,
+ hash2enc((HashCode512*) &tmp->skey_local,
&skey_local);)
IFLOG(LOG_MESSAGE,
- hash2enc((HashCode160*) &tmp->skey_remote,
+ hash2enc((HashCode512*) &tmp->skey_remote,
&skey_remote));
ttype = 0;
if (tmp->session.tsession != NULL)
@@ -2599,7 +2599,7 @@
msg,
size);
hash(&hdr->sequenceNumber,
- size + sizeof(P2P_Message) - sizeof(HashCode160),
+ size + sizeof(P2P_Message) - sizeof(HashCode512),
&hdr->hash);
ret = transport->send(tsession,
buf,
@@ -2711,7 +2711,7 @@
* @return the index for this peer in the connection table
*/
unsigned int computeIndex(const PeerIdentity * hostId) {
- unsigned int res = (((unsigned int)hostId->hashPubKey.a) &
+ unsigned int res = (((unsigned int)hostId->hashPubKey.bits[0]) &
((unsigned int)(CONNECTION_MAX_HOSTS_ - 1)));
GNUNET_ASSERT(res < CONNECTION_MAX_HOSTS_);
return res;
Modified: GNUnet/src/server/connection.h
===================================================================
--- GNUnet/src/server/connection.h 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/server/connection.h 2005-03-05 05:37:01 UTC (rev 366)
@@ -41,7 +41,7 @@
typedef struct {
/* hash of the plaintext, used to verify message integrity;
ALSO used as the IV for the symmetric cipher! */
- HashCode160 hash;
+ HashCode512 hash;
/* sequence number, in network byte order, 0 for plaintext messages! */
unsigned int sequenceNumber;
/* timestamp (network byte order), 0 for plaintext messages! */
Modified: GNUnet/src/server/version.c
===================================================================
--- GNUnet/src/server/version.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/server/version.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -69,7 +69,7 @@
* require us to run gnunet-update!
*/
static void getVersionHash(EncName * enc) {
- HashCode160 hc;
+ HashCode512 hc;
char * string;
string = STRDUP("");
Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/transports/nat.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -67,7 +67,7 @@
"YES")) {
/* if WE are a NAT and this is not our HELO,
it is invalid since NAT-to-NAT is not possible! */
- if (equalsHashCode160(&coreAPI->myIdentity->hashPubKey,
+ if (equalsHashCode512(&coreAPI->myIdentity->hashPubKey,
&helo->senderIdentity.hashPubKey))
return OK;
else
Modified: GNUnet/src/util/Makefile.am
===================================================================
--- GNUnet/src/util/Makefile.am 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/Makefile.am 2005-03-05 05:37:01 UTC (rev 366)
@@ -50,7 +50,9 @@
random_gcrypt.c \
random_openssl.c
-libgnunetutil_la_LDFLAGS = -export-dynamic $(LIBLTDL) $(CRYPTLIB) $(SOLFLAGS)
$(WINFLAGS) $(LIBS) -lgmp
+libgnunetutil_la_LDFLAGS = \
+ -export-dynamic $(LIBLTDL) $(CRYPTLIB) $(SOLFLAGS) $(WINFLAGS) $(LIBS) -lgmp \
+ -version-info 1:0:0
generate_gnunetd_conf.c: generate
./generate $(top_srcdir)/contrib/gnunet.root generate_gnunetd_conf >
generate_gnunetd_conf.c
Modified: GNUnet/src/util/bloomfilter.c
===================================================================
--- GNUnet/src/util/bloomfilter.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/bloomfilter.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -273,8 +273,8 @@
static void iterateBits(Bloomfilter * bf,
BitIterator callback,
void * arg,
- const HashCode160 * key) {
- HashCode160 tmp[2];
+ const HashCode512 * key) {
+ HashCode512 tmp[2];
int bitCount;
int round;
unsigned int slot=0;
@@ -282,10 +282,10 @@
bitCount = bf->addressesPerElement;
memcpy(&tmp[0],
key,
- sizeof(HashCode160));
+ sizeof(HashCode512));
round = 0;
while (bitCount > 0) {
- while (slot < (sizeof(HashCode160)/sizeof(unsigned int))) {
+ while (slot < (sizeof(HashCode512)/sizeof(unsigned int))) {
callback(bf,
(((unsigned int*)&tmp[round&1])[slot]) &
((bf->bitArraySize*8)-1),
arg);
@@ -296,7 +296,7 @@
}
if (bitCount > 0) {
hash(&tmp[round & 1],
- sizeof(HashCode160),
+ sizeof(HashCode512),
&tmp[(round+1) & 1]);
round++;
slot = 0;
@@ -481,7 +481,7 @@
* @return YES if the element is in the filter, NO if not
*/
int testBloomfilter(Bloomfilter * bf,
- const HashCode160 * e) {
+ const HashCode512 * e) {
int res;
if (NULL == bf)
@@ -503,7 +503,7 @@
* @param e the element
*/
void addToBloomfilter(Bloomfilter * bf,
- const HashCode160 * e) {
+ const HashCode512 * e) {
if (NULL == bf)
return;
@@ -522,7 +522,7 @@
* @param e the element to remove
*/
void delFromBloomfilter(Bloomfilter * bf,
- const HashCode160 * e) {
+ const HashCode512 * e) {
if(NULL == bf)
return;
MUTEX_LOCK(&bf->lock);
@@ -549,7 +549,7 @@
void * iterator_arg,
unsigned int size,
unsigned int k) {
- HashCode160 * e;
+ HashCode512 * e;
unsigned int i;
MUTEX_LOCK(&bf->lock);
Modified: GNUnet/src/util/bloomtest.c
===================================================================
--- GNUnet/src/util/bloomtest.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/bloomtest.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -13,17 +13,13 @@
/**
* Generate a random hashcode.
*/
-static void nextHC(HashCode160 * hc) {
- hc->a=rand();
- hc->b=rand();
- hc->c=rand();
- hc->d=rand();
- hc->e=rand();
+static void nextHC(HashCode512 * hc) {
+ makeRandomId(hc);
}
int main(int argc, char *argv[]) {
struct Bloomfilter *bf;
- HashCode160 tmp;
+ HashCode512 tmp;
int i;
int ok;
int falseok;
Modified: GNUnet/src/util/hashing.c
===================================================================
--- GNUnet/src/util/hashing.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/hashing.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -16,6 +16,12 @@
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
+
+ SHA-512 code by Jean-Luc Cooke <address@hidden>
+
+ Copyright (c) Jean-Luc Cooke <address@hidden>
+ Copyright (c) Andrew McDonald <address@hidden>
+ Copyright (c) 2003 Kyle McMartin <address@hidden>
*/
/**
@@ -27,42 +33,283 @@
#include "gnunet_util.h"
#include "platform.h"
-#if ! (USE_OPENSSL || USE_GCRYPT)
-#error Must use OpenSSL or libgcrypt
-#endif
+#define SHA512_DIGEST_SIZE 64
+#define SHA512_HMAC_BLOCK_SIZE 128
-#if USE_OPENSSL
-#include <openssl/evp.h>
-#include <openssl/bn.h>
-#include <openssl/err.h>
-#include <openssl/ripemd.h>
-#endif
+struct sha512_ctx {
+ unsigned long long state[8];
+ unsigned int count[4];
+ unsigned char buf[128];
+};
-#if USE_GCRYPT
-#include <gcrypt.h>
-#include "locking_gcrypt.h"
-#endif
+static unsigned long long Ch(unsigned long long x,
+ unsigned long long y,
+ unsigned long long z) {
+ return z ^ (x & (y ^ z));
+}
+static unsigned long long Maj(unsigned long long x,
+ unsigned long long y,
+ unsigned long long z) {
+ return (x & y) | (z & (x | y));
+}
+
+static unsigned long long RORu64(unsigned long long x,
+ unsigned long long y) {
+ return (x >> y) | (x << (64 - y));
+}
+
+const unsigned long long sha512_K[80] = {
+ 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL,
+ 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
+ 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL,
+ 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
+ 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL,
+ 0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
+ 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL,
+ 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
+ 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL,
+ 0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
+ 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL,
+ 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
+ 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL,
+ 0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
+ 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL,
+ 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
+ 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL,
+ 0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
+ 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL,
+ 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
+ 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL,
+ 0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
+ 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL,
+ 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
+ 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL,
+ 0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
+ 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL,
+};
+
+#define e0(x) (RORu64(x,28) ^ RORu64(x,34) ^ RORu64(x,39))
+#define e1(x) (RORu64(x,14) ^ RORu64(x,18) ^ RORu64(x,41))
+#define s0(x) (RORu64(x, 1) ^ RORu64(x, 8) ^ (x >> 7))
+#define s1(x) (RORu64(x,19) ^ RORu64(x,61) ^ (x >> 6))
+
+/* H* initial state for SHA-512 */
+#define H0 0x6a09e667f3bcc908ULL
+#define H1 0xbb67ae8584caa73bULL
+#define H2 0x3c6ef372fe94f82bULL
+#define H3 0xa54ff53a5f1d36f1ULL
+#define H4 0x510e527fade682d1ULL
+#define H5 0x9b05688c2b3e6c1fULL
+#define H6 0x1f83d9abfb41bd6bULL
+#define H7 0x5be0cd19137e2179ULL
+
+/* H'* initial state for SHA-384 */
+#define HP0 0xcbbb9d5dc1059ed8ULL
+#define HP1 0x629a292a367cd507ULL
+#define HP2 0x9159015a3070dd17ULL
+#define HP3 0x152fecd8f70e5939ULL
+#define HP4 0x67332667ffc00b31ULL
+#define HP5 0x8eb44a8768581511ULL
+#define HP6 0xdb0c2e0d64f98fa7ULL
+#define HP7 0x47b5481dbefa4fa4ULL
+
+static void LOAD_OP(int I, unsigned long long *W, const unsigned char *input) {
+ unsigned long long t1 = input[(8*I) ] & 0xff;
+ t1 <<= 8;
+ t1 |= input[(8*I)+1] & 0xff;
+ t1 <<= 8;
+ t1 |= input[(8*I)+2] & 0xff;
+ t1 <<= 8;
+ t1 |= input[(8*I)+3] & 0xff;
+ t1 <<= 8;
+ t1 |= input[(8*I)+4] & 0xff;
+ t1 <<= 8;
+ t1 |= input[(8*I)+5] & 0xff;
+ t1 <<= 8;
+ t1 |= input[(8*I)+6] & 0xff;
+ t1 <<= 8;
+ t1 |= input[(8*I)+7] & 0xff;
+ W[I] = t1;
+}
+
+static void BLEND_OP(int I, unsigned long long *W) {
+ W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
+}
+
+static void
+sha512_transform(unsigned long long *state, const unsigned char *input) {
+ unsigned long long a, b, c, d, e, f, g, h, t1, t2;
+ unsigned long long W[80];
+
+ int i;
+
+ /* load the input */
+ for (i = 0; i < 16; i++)
+ LOAD_OP(i, W, input);
+
+ for (i = 16; i < 80; i++) {
+ BLEND_OP(i, W);
+ }
+
+ /* load the state into our registers */
+ a=state[0]; b=state[1]; c=state[2]; d=state[3];
+ e=state[4]; f=state[5]; g=state[6]; h=state[7];
+
+ /* now iterate */
+ for (i=0; i<80; i+=8) {
+ t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i ] + W[i ];
+ t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
+ t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[i+1];
+ t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
+ t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[i+2];
+ t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
+ t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[i+3];
+ t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
+ t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[i+4];
+ t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
+ t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[i+5];
+ t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
+ t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[i+6];
+ t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
+ t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[i+7];
+ t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
+ }
+
+ state[0] += a; state[1] += b; state[2] += c; state[3] += d;
+ state[4] += e; state[5] += f; state[6] += g; state[7] += h;
+
+ /* erase our data */
+ a = b = c = d = e = f = g = h = t1 = t2 = 0;
+ memset(W, 0, 80 * sizeof(unsigned long long));
+}
+
+static void
+sha512_init(struct sha512_ctx * sctx) {
+ sctx->state[0] = H0;
+ sctx->state[1] = H1;
+ sctx->state[2] = H2;
+ sctx->state[3] = H3;
+ sctx->state[4] = H4;
+ sctx->state[5] = H5;
+ sctx->state[6] = H6;
+ sctx->state[7] = H7;
+ sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
+ memset(sctx->buf, 0, sizeof(sctx->buf));
+}
+
+static void
+sha512_update(struct sha512_ctx * sctx,
+ const unsigned char *data,
+ unsigned int len) {
+ unsigned int i, index, part_len;
+
+ /* Compute number of bytes mod 128 */
+ index = (unsigned int)((sctx->count[0] >> 3) & 0x7F);
+
+ /* Update number of bits */
+ if ((sctx->count[0] += (len << 3)) < (len << 3)) {
+ if ((sctx->count[1] += 1) < 1)
+ if ((sctx->count[2] += 1) < 1)
+ sctx->count[3]++;
+ sctx->count[1] += (len >> 29);
+ }
+
+ part_len = 128 - index;
+
+ /* Transform as many times as possible. */
+ if (len >= part_len) {
+ memcpy(&sctx->buf[index], data, part_len);
+ sha512_transform(sctx->state, sctx->buf);
+
+ for (i = part_len; i + 127 < len; i+=128)
+ sha512_transform(sctx->state, &data[i]);
+
+ index = 0;
+ } else {
+ i = 0;
+ }
+
+ /* Buffer remaining input */
+ memcpy(&sctx->buf[index], &data[i], len - i);
+}
+
+static void
+sha512_final(struct sha512_ctx * sctx,
+ unsigned char *hash) {
+ static unsigned char padding[128] = { 0x80, };
+
+ unsigned int t;
+ unsigned long long t2;
+ unsigned char bits[128];
+ unsigned int index, pad_len;
+ int i, j;
+
+ index = pad_len = t = i = j = 0;
+ t2 = 0;
+
+ /* Save number of bits */
+ t = sctx->count[0];
+ bits[15] = t; t>>=8;
+ bits[14] = t; t>>=8;
+ bits[13] = t; t>>=8;
+ bits[12] = t;
+ t = sctx->count[1];
+ bits[11] = t; t>>=8;
+ bits[10] = t; t>>=8;
+ bits[9 ] = t; t>>=8;
+ bits[8 ] = t;
+ t = sctx->count[2];
+ bits[7 ] = t; t>>=8;
+ bits[6 ] = t; t>>=8;
+ bits[5 ] = t; t>>=8;
+ bits[4 ] = t;
+ t = sctx->count[3];
+ bits[3 ] = t; t>>=8;
+ bits[2 ] = t; t>>=8;
+ bits[1 ] = t; t>>=8;
+ bits[0 ] = t;
+
+ /* Pad out to 112 mod 128. */
+ index = (sctx->count[0] >> 3) & 0x7f;
+ pad_len = (index < 112) ? (112 - index) : ((128+112) - index);
+ sha512_update(sctx, padding, pad_len);
+
+ /* Append length (before padding) */
+ sha512_update(sctx, bits, 16);
+
+ /* Store state in digest */
+ for (i = j = 0; i < 8; i++, j += 8) {
+ t2 = sctx->state[i];
+ hash[j+7] = (char)t2 & 0xff; t2>>=8;
+ hash[j+6] = (char)t2 & 0xff; t2>>=8;
+ hash[j+5] = (char)t2 & 0xff; t2>>=8;
+ hash[j+4] = (char)t2 & 0xff; t2>>=8;
+ hash[j+3] = (char)t2 & 0xff; t2>>=8;
+ hash[j+2] = (char)t2 & 0xff; t2>>=8;
+ hash[j+1] = (char)t2 & 0xff; t2>>=8;
+ hash[j ] = (char)t2 & 0xff;
+ }
+
+ /* Zeroize sensitive information. */
+ memset(sctx, 0, sizeof(struct sha512_ctx));
+}
+
/**
* Hash block of given size.
+ *
* @param block the data to hash, length is given as a second argument
* @param size the length of the data to hash
* @param ret pointer to where to write the hashcode
*/
void hash(const void * block,
- int size,
- HashCode160 * ret) {
-#if USE_OPENSSL
- RIPEMD160(block, size, (unsigned char*) ret);
-#endif
-#if USE_GCRYPT
- lockGcrypt();
- gcry_md_hash_buffer(GCRY_MD_RMD160,
- (char*) ret,
- block,
- size);
- unlockGcrypt();
-#endif
+ unsigned int size,
+ HashCode512 * ret) {
+ struct sha512_ctx ctx;
+
+ sha512_init(&ctx);
+ sha512_update(&ctx, block, size);
+ sha512_final(&ctx, (unsigned char*) ret);
}
/**
@@ -73,41 +320,24 @@
* @return OK on success, SYSERR on error
*/
int getFileHash(const char * filename,
- HashCode160 * ret) {
+ HashCode512 * ret) {
char * buf;
- unsigned int len;
- unsigned int pos;
+ unsigned long long len;
+ unsigned long long pos;
unsigned int delta;
int fh;
-#if USE_GCRYPT
- gcry_md_hd_t hd;
- char * res;
+ struct sha512_ctx ctx;
- lockGcrypt();
- if (0 != gcry_md_open(&hd,
- GCRY_MD_RMD160,
- 0)) {
- unlockGcrypt();
- return SYSERR;
- }
+ fh = OPEN(filename,
+#ifdef O_LARGEFILE
+ O_RDONLY | O_LARGEFILE
+#else
+ O_RDONLY
#endif
-#if USE_OPENSSL
- RIPEMD160_CTX hd;
- RIPEMD160_Init(&hd);
-#endif
-
- fh = OPEN(filename, O_RDONLY);
- if (fh == -1) {
-#if USE_GCRYPT
- gcry_md_close(hd);
- unlockGcrypt();
-#endif
-#if USE_OPENSSL
- RIPEMD160_Final((unsigned char*)ret,
- &hd);
-#endif
- return SYSERR;
- }
+ );
+ if (fh == -1)
+ return SYSERR;
+ sha512_init(&ctx);
pos = 0;
buf = MALLOC(65536);
len = getFileSize(filename);
@@ -119,42 +349,20 @@
buf,
delta)) {
CLOSE(fh);
-#if USE_GCRYPT
- gcry_md_close(hd);
- unlockGcrypt();
-#endif
-#if USE_OPENSSL
- RIPEMD160_Final((unsigned char*)ret,
- &hd);
-#endif
FREE(buf);
return SYSERR;
}
-#if USE_GCRYPT
- gcry_md_write(hd,
+ sha512_update(&ctx,
buf,
delta);
-#endif
-#if USE_OPENSSL
- RIPEMD160_Update(&hd,
- buf,
- delta);
-#endif
- pos += delta;
+ if (pos + delta > pos)
+ pos += delta;
+ else
+ break;
}
CLOSE(fh);
-#if USE_GCRYPT
- res = gcry_md_read(hd, 0);
- memcpy(ret,
- res,
- sizeof(HashCode160));
- gcry_md_close(hd);
- unlockGcrypt();
-#endif
-#if USE_OPENSSL
- RIPEMD160_Final((unsigned char*)ret,
- &hd);
-#endif
+ sha512_final(&ctx,
+ (unsigned char*) ret);
FREE(buf);
return OK;
}
@@ -177,145 +385,95 @@
/**
* Convert hash to ASCII encoding. The ASCII encoding is rather
* GNUnet specific. It was chosen such that it only uses characters
- * in [0-9A-Z], can be produced without complex arithmetics and
- * uses a small number of characters. The theoretical limit is 28
- * characters, the GNUnet encoding uses 32 and is thus pretty close.
+ * in [0-9A-Z], can be produced without complex arithmetics and uses a
+ * small number of characters. The GNUnet encoding uses 102
+ * characters plus a null terminator.
*
* @param block the hash code
* @param result where to store the encoding (EncName can be
* safely cast to char*, a '\0' termination is set).
*/
-void hash2enc(const HashCode160 * block,
+void hash2enc(const HashCode512 * block,
EncName * result) {
- unsigned long long v1;
- unsigned long long v2;
- unsigned long long v3;
+ unsigned int wpos;
+ unsigned int rpos;
+ unsigned int bits;
+ unsigned int vbit;
- GNUNET_ASSERT(sizeof(EncName) == 33);
- GNUNET_ASSERT(strlen(encTable__) == 32);
- v1 = (((unsigned long long) (unsigned int) block->a) << 32) +
- (unsigned long long) (unsigned int) block->b;
- result->encoding[0] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[1] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[2] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[3] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[4] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[5] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[6] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[7] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[8] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[9] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[10] = encTable__[v1 & 31]; v1 >>= 5;
- result->encoding[11] = encTable__[v1 & 31]; v1 >>= 5;
- v2 = (((unsigned long long) (unsigned int) block->c) << 32) +
- (unsigned long long) (unsigned int) block->d;
- result->encoding[13] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[14] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[15] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[16] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[17] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[18] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[19] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[20] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[21] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[22] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[23] = encTable__[v2 & 31]; v2 >>= 5;
- result->encoding[24] = encTable__[v2 & 31]; v2 >>= 5;
-
- v3 = (unsigned long long) (unsigned int) block->e;
- result->encoding[26] = encTable__[v3 & 31]; v3 >>= 5;
- result->encoding[27] = encTable__[v3 & 31]; v3 >>= 5;
- result->encoding[28] = encTable__[v3 & 31]; v3 >>= 5;
- result->encoding[29] = encTable__[v3 & 31]; v3 >>= 5;
- result->encoding[30] = encTable__[v3 & 31]; v3 >>= 5;
- result->encoding[31] = encTable__[v3 & 31]; v3 >>= 5;
-
- v1 |= (v3 & 1) << 4; /* use highest bit in v1 */
- v2 |= (v3 & 2) << 3; /* use highest bit in v2 */
- result->encoding[12] = encTable__[v1 & 31];
- result->encoding[25] = encTable__[v2 & 31];
- result->encoding[32] = '\0';
+ vbit = 0;
+ wpos = 0;
+ rpos = 0;
+ bits = 0;
+ while ( (rpos < sizeof(HashCode512)) ||
+ (vbit > 0) ) {
+ if ( (rpos < sizeof(HashCode512)) &&
+ (vbit < 5) ) {
+ bits = (bits << 8) | ((unsigned char*)block)[rpos++]; /* eat 8 more bits
*/
+ vbit += 8;
+ }
+ if (vbit < 5) {
+ bits = bits << (5 - vbit); /* zero-padding */
+ GNUNET_ASSERT(vbit == 2); /* padding by 3: 512+3 mod 5 == 0 */
+ vbit = 5;
+ }
+ GNUNET_ASSERT(wpos < sizeof(EncName)-1);
+ result->encoding[wpos++] = encTable__[(bits >> (vbit - 5)) & 31];
+ vbit -= 5;
+ }
+ GNUNET_ASSERT(wpos == sizeof(EncName)-1);
+ GNUNET_ASSERT(vbit == 0);
+ result->encoding[wpos] = '\0';
}
-
/**
* Convert ASCII encoding back to hash
+ *
* @param enc the encoding
* @param result where to store the hash code
* @return OK on success, SYSERR if result has the wrong encoding
*/
int enc2hash(const char * enc,
- HashCode160 * result) {
- unsigned long long v;
- int pos;
-
- GNUNET_ASSERT(sizeof(EncName) == 33);
+ HashCode512 * result) {
+ unsigned int rpos;
+ unsigned int wpos;
+ unsigned int bits;
+ unsigned int vbit;
+
if (strlen(enc) != sizeof(EncName)-1)
return SYSERR;
- for (pos=strlen(enc)-1;pos>=0;pos--) {
- if (-1 == getValue__(enc[pos]))
- return SYSERR;
-#if EXPENSIVE_CHECKS
- GNUNET_ASSERT((encTable__[getValue__(enc[pos])] == enc[pos]));
-#endif
+
+ vbit = 2; /* padding! */
+ wpos = sizeof(HashCode512);
+ rpos = sizeof(EncName)-1;
+ bits = getValue__(enc[--rpos]) >> 3;
+ while (wpos > 0) {
+ GNUNET_ASSERT(rpos > 0);
+ bits = (getValue__(enc[--rpos]) << vbit) | bits;
+ vbit += 5;
+ if (vbit >= 8) {
+ ((unsigned char*)result)[--wpos]
+ = (unsigned char) bits;
+ bits = bits >> 8;
+ vbit -= 8;
+ }
}
-
- v = getValue__(enc[12]);
- v <<= 5; v+= getValue__(enc[11]);
- v <<= 5; v+= getValue__(enc[10]);
- v <<= 5; v+= getValue__(enc[9]);
- v <<= 5; v+= getValue__(enc[8]);
- v <<= 5; v+= getValue__(enc[7]);
- v <<= 5; v+= getValue__(enc[6]);
- v <<= 5; v+= getValue__(enc[5]);
- v <<= 5; v+= getValue__(enc[4]);
- v <<= 5; v+= getValue__(enc[3]);
- v <<= 5; v+= getValue__(enc[2]);
- v <<= 5; v+= getValue__(enc[1]);
- v <<= 5; v+= getValue__(enc[0]);
- result->a = (unsigned int)(v >> 32);
- result->b = (unsigned int) v;
-
- v = getValue__(enc[25]);
- v <<= 5; v+= getValue__(enc[24]);
- v <<= 5; v+= getValue__(enc[23]);
- v <<= 5; v+= getValue__(enc[22]);
- v <<= 5; v+= getValue__(enc[21]);
- v <<= 5; v+= getValue__(enc[20]);
- v <<= 5; v+= getValue__(enc[19]);
- v <<= 5; v+= getValue__(enc[18]);
- v <<= 5; v+= getValue__(enc[17]);
- v <<= 5; v+= getValue__(enc[16]);
- v <<= 5; v+= getValue__(enc[15]);
- v <<= 5; v+= getValue__(enc[14]);
- v <<= 5; v+= getValue__(enc[13]);
- result->c = (unsigned int)(v >> 32);
- result->d = (unsigned int) v;
-
- /* get lowest two bits from 12 and 25 */
- v = ((getValue__(enc[25]) >> 4) << 1) | (getValue__(enc[12]) >> 4);
- v <<= 5; v+= getValue__(enc[31]);
- v <<= 5; v+= getValue__(enc[30]);
- v <<= 5; v+= getValue__(enc[29]);
- v <<= 5; v+= getValue__(enc[28]);
- v <<= 5; v+= getValue__(enc[27]);
- v <<= 5; v+= getValue__(enc[26]);
- result->e = (unsigned int) v;
+ GNUNET_ASSERT(rpos == 0);
+ GNUNET_ASSERT(vbit == 0);
return OK;
}
/**
* Compute the distance between 2 hashcodes. The computation must be
- * fast, not involve a.a or a.e (they're used elsewhere), and be
+ * fast, not involve bits[0] or bits[4] (they're used elsewhere), and be
* somewhat consistent. And of course, the result should be a positive
* number.
*
* @returns a positive number which is a measure for
* hashcode proximity.
*/
-int distanceHashCode160(const HashCode160 * a,
- const HashCode160 * b) {
- int x = (a->b - b->b)>>16;
+int distanceHashCode512(const HashCode512 * a,
+ const HashCode512 * b) {
+ int x = (a->bits[1] - b->bits[1])>>16;
return ((x*x)>>16);
}
@@ -323,47 +481,39 @@
* Compare two hashcodes.
* @return 1 if they are equal, 0 if not.
*/
-int equalsHashCode160(const HashCode160 * a,
- const HashCode160 * b) {
- return (0 == memcmp(a,b,sizeof(HashCode160)));
+int equalsHashCode512(const HashCode512 * a,
+ const HashCode512 * b) {
+ return (0 == memcmp(a,b,sizeof(HashCode512)));
}
-void makeRandomId(HashCode160 * result) {
- result->a = rand();
- result->b = rand();
- result->c = rand();
- result->d = rand();
- result->e = rand();
+void makeRandomId(HashCode512 * result) {
+ int i;
+ for (i=(sizeof(HashCode512)/sizeof(unsigned int))-1;i>=0;i--)
+ result->bits[i] = rand();
}
-void deltaId(const HashCode160 * a,
- const HashCode160 * b,
- HashCode160 * result) {
- result->a = b->a - a->a;
- result->b = b->b - a->b;
- result->c = b->c - a->c;
- result->d = b->d - a->d;
- result->e = b->e - a->e;
+void deltaId(const HashCode512 * a,
+ const HashCode512 * b,
+ HashCode512 * result) {
+ int i;
+ for (i=(sizeof(HashCode512)/sizeof(unsigned int))-1;i>=0;i--)
+ result->bits[i] = b->bits[i] - a->bits[i];
}
-void addHashCodes(const HashCode160 * a,
- const HashCode160 * delta,
- HashCode160 * result) {
- result->a = delta->a + a->a;
- result->b = delta->b + a->b;
- result->c = delta->c + a->c;
- result->d = delta->d + a->d;
- result->e = delta->e + a->e;
+void addHashCodes(const HashCode512 * a,
+ const HashCode512 * delta,
+ HashCode512 * result) {
+ int i;
+ for (i=(sizeof(HashCode512)/sizeof(unsigned int))-1;i>=0;i--)
+ result->bits[i] = delta->bits[i] + a->bits[i];
}
-void xorHashCodes(const HashCode160 * a,
- const HashCode160 * b,
- HashCode160 * result) {
- result->a = b->a ^ a->a;
- result->b = b->b ^ a->b;
- result->c = b->c ^ a->c;
- result->d = b->d ^ a->d;
- result->e = b->e ^ a->e;
+void xorHashCodes(const HashCode512 * a,
+ const HashCode512 * b,
+ HashCode512 * result) {
+ int i;
+ for (i=(sizeof(HashCode512)/sizeof(unsigned int))-1;i>=0;i--)
+ result->bits[i] = a->bits[i] ^ a->bits[i];
}
/**
@@ -375,41 +525,38 @@
if ( (first == NULL) ||
(second == NULL) )
return NO;
- return equalsHashCode160(&first->hashPubKey,
+ return equalsHashCode512(&first->hashPubKey,
&second->hashPubKey);
}
/**
* Convert a hashcode into a key.
*/
-void hashToKey(const HashCode160 * hc,
+void hashToKey(const HashCode512 * hc,
SESSIONKEY * skey,
INITVECTOR * iv) {
- GNUNET_ASSERT((sizeof(HashCode160) - SESSIONKEY_LEN) * 2
- == sizeof(INITVECTOR));
+ GNUNET_ASSERT(sizeof(HashCode512) >=
+ SESSIONKEY_LEN +
+ sizeof(INITVECTOR));
memcpy(skey,
hc,
- sizeof(SESSIONKEY));
+ SESSIONKEY_LEN);
skey->crc32 = htonl(crc32N(skey,
SESSIONKEY_LEN));
- memcpy(&iv->iv[0],
- &(((char *)hc)[SESSIONKEY_LEN]),
- sizeof(HashCode160) - SESSIONKEY_LEN);
- memcpy(&iv->iv[sizeof(HashCode160) - SESSIONKEY_LEN],
- &(((char *)hc)[SESSIONKEY_LEN]),
- sizeof(HashCode160) - SESSIONKEY_LEN);
+ memcpy(iv,
+ &((char *)hc)[SESSIONKEY_LEN],
+ sizeof(INITVECTOR));
}
-
/**
* Obtain a bit from a hashcode.
* @param code the hash to index bit-wise
- * @param bit index into the hashcode, [0...159]
+ * @param bit index into the hashcode, [0...511]
* @return Bit \a bit from hashcode \a code, -1 for invalid index
*/
-int getHashCodeBit(const HashCode160 * code,
+int getHashCodeBit(const HashCode512 * code,
unsigned int bit) {
- if (bit >= 8 * sizeof(HashCode160)) {
+ if (bit >= 8 * sizeof(HashCode512)) {
BREAK();
return -1; /* error */
}
@@ -421,12 +568,12 @@
* of all hashcodes.
* @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
*/
-int hashCodeCompare(const HashCode160 * h1,
- const HashCode160 * h2) {
+int hashCodeCompare(const HashCode512 * h1,
+ const HashCode512 * h2) {
int i;
int diff;
/* FIXME: we can do this much more efficiently... */
- for (i = sizeof(HashCode160)*8 - 1; i >= 0; --i) {
+ for (i = sizeof(HashCode512)*8 - 1; i >= 0; --i) {
diff = getHashCodeBit(h2, i) - getHashCodeBit(h1, i);
if (diff < 0)
return -1;
@@ -441,9 +588,9 @@
* in the XOR metric (Kademlia).
* @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2.
*/
-int hashCodeCompareDistance(const HashCode160 * h1,
- const HashCode160 * h2,
- const HashCode160 * target) {
+int hashCodeCompareDistance(const HashCode512 * h1,
+ const HashCode512 * h2,
+ const HashCode512 * target) {
int i;
#if 0
int diff;
@@ -452,7 +599,7 @@
unsigned int d1;
unsigned int d2;
- for (i=sizeof(HashCode160)/sizeof(unsigned int)-1;i>=0;i--) {
+ for (i=sizeof(HashCode512)/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)
@@ -462,7 +609,7 @@
}
#if 0
/* Old code: */
- for (i = sizeof(HashCode160) * 8 - 1; i >= 0; --i) {
+ for (i = sizeof(HashCode512) * 8 - 1; i >= 0; --i) {
b1 = getHashCodeBit(h1, i);
b2 = getHashCodeBit(h2, i);
bt = getHashCodeBit(target, i);
Modified: GNUnet/src/util/hashingtest.c
===================================================================
--- GNUnet/src/util/hashingtest.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/hashingtest.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -13,18 +13,18 @@
#endif
static int test(int number) {
- HashCode160 h1;
- HashCode160 h2;
+ HashCode512 h1;
+ HashCode512 h2;
EncName enc;
- memset(&h1, number, sizeof(HashCode160));
+ memset(&h1, number, sizeof(HashCode512));
hash2enc(&h1, &enc);
if (OK != enc2hash((char*)&enc, &h2)) {
printf("enc2hash failed!\n");
return 1;
}
- if (! equalsHashCode160(&h1, &h2)) {
+ if (! equalsHashCode512(&h1, &h2)) {
return 1;
}
return 0;
Modified: GNUnet/src/util/hashtest.c
===================================================================
--- GNUnet/src/util/hashtest.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/hashtest.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -15,27 +15,35 @@
}
int main(int argc, char * argv[]){
- HashCode160 hc;
+ HashCode512 hc;
initUtil(argc, argv, &parseCommandLine);
hash("TEST", 4, &hc);
- if ( (hc.a != ntohl(830102737)) ||
- (hc.b != ntohl(-2066785626)) ||
- (hc.c != ntohl(-326698784)) ||
- (hc.d != ntohl(-183450437)) ||
- (hc.e != ntohl(1019905624)) ) {
+ if ( (hc.bits[0] != ntohl(2080019878)) ||
+ (hc.bits[1] != ntohl(-2003678137)) ||
+ (hc.bits[2] != ntohl(-942529663)) ||
+ (hc.bits[3] != ntohl(-234043098)) ||
+ (hc.bits[4] != ntohl(-182141268)) ) {
printf("Hash of TEST wrong (%d, %d, %d, %d, %d).\n",
- hc.a, hc.b, hc.c, hc.d, hc.e);
+ ntohl(hc.bits[0]),
+ ntohl(hc.bits[1]),
+ ntohl(hc.bits[2]),
+ ntohl(hc.bits[3]),
+ ntohl(hc.bits[4]));
return -1;
}
hash(NULL, 0, &hc);
- if ( (hc.a != ntohl(-1676573275)) ||
- (hc.b != ntohl(-974521260)) ||
- (hc.c != ntohl(1630013591)) ||
- (hc.d != ntohl(2129196360)) ||
- (hc.e != ntohl(-1306161871)) ) {
+ if ( (hc.bits[0] != ntohl(-813440715)) ||
+ (hc.bits[1] != ntohl(2129639613)) ||
+ (hc.bits[2] != ntohl(-246142896)) ||
+ (hc.bits[3] != ntohl(-697466873)) ||
+ (hc.bits[4] != ntohl(-702487547)) ) {
printf("Hash of nothing (0-size) wrong (%d, %d, %d, %d, %d).\n",
- hc.a, hc.b, hc.c, hc.d, hc.e);
+ ntohl(hc.bits[0]),
+ ntohl(hc.bits[1]),
+ ntohl(hc.bits[2]),
+ ntohl(hc.bits[3]),
+ ntohl(hc.bits[4]));
return -1;
}
doneUtil();
Modified: GNUnet/src/util/hostkey_gcrypt.c
===================================================================
--- GNUnet/src/util/hostkey_gcrypt.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/hostkey_gcrypt.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -620,7 +620,7 @@
size_t erroff;
int rc;
- GNUNET_ASSERT(size <= sizeof(HashCode160));
+ GNUNET_ASSERT(size <= sizeof(HashCode512));
pubkey = public2PrivateKey(publicKey);
isize = size;
lockGcrypt();
@@ -832,21 +832,21 @@
gcry_sexp_t data;
size_t ssize;
gcry_mpi_t rval;
- HashCode160 hc;
+ HashCode512 hc;
char * buff;
int bufSize;
int rc;
hash(block, size, &hc);
-#define FORMATSTRING
"(4:data(5:flags5:pkcs1)(4:hash6:rmd16020:01234567890123456789))"
+#define FORMATSTRING
"(4:data(5:flags5:pkcs1)(4:hash6:sha51264:0123456789012345678901234567890123456789012345678901234567890123))"
bufSize = strlen(FORMATSTRING) + 1;
buff = MALLOC(bufSize);
memcpy(buff,
FORMATSTRING,
bufSize);
- memcpy(&buff[bufSize - strlen("012345678901234567890))")],
+ memcpy(&buff[bufSize -
strlen("0123456789012345678901234567890123456789012345678901234567890123))") -
1],
&hc,
- sizeof(HashCode160));
+ sizeof(HashCode512));
lockGcrypt();
rc = gcry_sexp_new(&data,
buff,
@@ -912,7 +912,7 @@
size_t size;
gcry_mpi_t val;
struct PrivateKey * hostkey;
- HashCode160 hc;
+ HashCode512 hc;
char * buff;
int bufSize;
size_t erroff;
@@ -946,9 +946,9 @@
memcpy(buff,
FORMATSTRING,
bufSize);
- memcpy(&buff[strlen(FORMATSTRING) - strlen("01234567890123456789))")],
+ memcpy(&buff[strlen(FORMATSTRING) -
strlen("0123456789012345678901234567890123456789012345678901234567890123))")],
&hc,
- sizeof(HashCode160));
+ sizeof(HashCode512));
rc = gcry_sexp_new(&data,
buff,
bufSize,
Modified: GNUnet/src/util/hostkey_openssl.c
===================================================================
--- GNUnet/src/util/hostkey_openssl.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/hostkey_openssl.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -420,7 +420,7 @@
#endif
int rs = RSA_size(hostkey->rsa);
unsigned int sigSize;
- HashCode160 hc;
+ HashCode512 hc;
if (block == NULL)
return SYSERR;
@@ -433,7 +433,7 @@
&hc);
if (1 != RSA_sign(NID_ripemd160,
(unsigned char*)&hc,
- sizeof(HashCode160),
+ sizeof(HashCode512),
&sig->sig[0],
&sigSize,
hostkey->rsa)) {
@@ -451,7 +451,7 @@
#if EXTRA_CHECKS
if (1 != RSA_verify(NID_ripemd160,
(unsigned char*)&hc,
- sizeof(HashCode160),
+ sizeof(HashCode512),
&sig->sig[0],
sizeof(Signature),
hostkey->rsa))
@@ -462,7 +462,7 @@
BREAK();
if (1 != RSA_verify(NID_ripemd160,
(unsigned char*)&hc,
- sizeof(HashCode160),
+ sizeof(HashCode512),
&sig->sig[0],
sizeof(Signature),
hostkey->rsa))
@@ -488,7 +488,7 @@
const PublicKey * publicKey) {
struct PrivateKey * hostkey;
int rs;
- HashCode160 hc;
+ HashCode512 hc;
hostkey = public2PrivateKey(publicKey);
if ( (hostkey == NULL) ||
@@ -505,7 +505,7 @@
&hc);
if (1 != RSA_verify(NID_ripemd160,
(unsigned char*)&hc,
- sizeof(HashCode160),
+ sizeof(HashCode512),
(unsigned char*) &sig->sig[0], /* cast because OpenSSL
may not declare const */
sizeof(Signature),
hostkey->rsa)) {
Modified: GNUnet/src/util/hostkeytest.c
===================================================================
--- GNUnet/src/util/hostkeytest.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/hostkeytest.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -8,7 +8,7 @@
#include "platform.h"
#define TESTSTRING "Hello World\0"
-#define MAX_TESTVAL 20
+#define MAX_TESTVAL sizeof(SESSIONKEY)
#define ITER 10
static int testEncryptDecrypt() {
Modified: GNUnet/src/util/kblockkey.c
===================================================================
--- GNUnet/src/util/kblockkey.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/kblockkey.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -165,29 +165,29 @@
static void mpz_randomize(mpz_t n,
unsigned int nbits,
- HashCode160 * rnd) {
- HashCode160 * tmp;
+ HashCode512 * rnd) {
+ HashCode512 * tmp;
int cnt;
int i;
- cnt = (nbits / sizeof(HashCode160) / 8) + 1;
- tmp = MALLOC(sizeof(HashCode160) * cnt);
+ cnt = (nbits / sizeof(HashCode512) / 8) + 1;
+ tmp = MALLOC(sizeof(HashCode512) * cnt);
tmp[0] = *rnd;
for (i=0;i<cnt-1;i++) {
hash(&tmp[i],
- sizeof(HashCode160),
+ sizeof(HashCode512),
&tmp[i+1]);
}
*rnd = tmp[cnt-1];
/*
printf("RND: ");
- for (i=0;i<cnt * sizeof(HashCode160);i++)
+ for (i=0;i<cnt * sizeof(HashCode512);i++)
printf("%02x", ((unsigned char*) tmp)[i]);
printf("\n");
*/
- mpz_import(n, cnt * sizeof(HashCode160) / sizeof(unsigned int),
+ mpz_import(n, cnt * sizeof(HashCode512) / sizeof(unsigned int),
1, sizeof(unsigned int), 1, 0, tmp);
FREE(tmp);
i = get_nbits(n);
@@ -200,7 +200,7 @@
*/
static int is_prime (mpz_t n,
int steps,
- HashCode160 * hc) {
+ HashCode512 * hc) {
mpz_t x;
mpz_t y;
mpz_t z;
@@ -266,7 +266,7 @@
static void gen_prime(mpz_t ptest,
unsigned int nbits,
- HashCode160 * hc) {
+ HashCode512 * hc) {
mpz_t prime, pminus1, val_2, val_3, result;
int i;
unsigned x, step;
@@ -366,7 +366,7 @@
*/
static void generate_kblock_key(KBlock_secret_key *sk,
unsigned int nbits,
- HashCode160 * hc) {
+ HashCode512 * hc) {
mpz_t t1, t2;
mpz_t phi; /* helper: (p-1)(q-1) */
mpz_t g;
@@ -426,9 +426,9 @@
* Deterministically (!) create a hostkey using only the
* given HashCode as input to the PRNG.
*/
-struct PrivateKey * makeKblockKey(const HashCode160 * hc) {
+struct PrivateKey * makeKblockKey(const HashCode512 * hc) {
KBlock_secret_key sk;
- HashCode160 hx;
+ HashCode512 hx;
void * pbu[6];
mpz_t * pkv[6];
size_t sizes[6];
Modified: GNUnet/src/util/kblockkey_test.c
===================================================================
--- GNUnet/src/util/kblockkey_test.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/kblockkey_test.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -14,7 +14,7 @@
static int testMultiKey(const char * word) {
- HashCode160 in;
+ HashCode512 in;
struct PrivateKey * hostkey;
PublicKey pkey;
PublicKey pkey1;
@@ -206,7 +206,7 @@
int main(int argc, char * argv[]) {
int failureCount = 0;
- HashCode160 in;
+ HashCode512 in;
struct PrivateKey * hostkey;
#if USE_GCRYPT
Modified: GNUnet/src/util/storagetest.c
===================================================================
--- GNUnet/src/util/storagetest.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/storagetest.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -18,7 +18,7 @@
}
static int testReadWrite() {
- HashCode160 ha;
+ HashCode512 ha;
EncName filename;
char tmp[100];
Modified: GNUnet/src/util/symcipher_gcrypt.c
===================================================================
--- GNUnet/src/util/symcipher_gcrypt.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/symcipher_gcrypt.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing
authors)
+ (C) 2001, 2002, 2003, 2004, 2005 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
@@ -97,7 +97,7 @@
#endif
lockGcrypt();
rc = gcry_cipher_open(&handle,
- GCRY_CIPHER_BLOWFISH,
+ GCRY_CIPHER_AES256,
GCRY_CIPHER_MODE_CFB,
0);
if (rc) {
@@ -107,7 +107,7 @@
}
rc = gcry_cipher_setkey(handle,
sessionkey,
- sizeof(SESSIONKEY));
+ SESSIONKEY_LEN);
if (rc && ((char)rc != GPG_ERR_WEAK_KEY)) {
LOG_GCRY(LOG_FAILURE, "gcry_cipher_setkey", rc);
@@ -174,7 +174,7 @@
#endif
lockGcrypt();
rc = gcry_cipher_open(&handle,
- GCRY_CIPHER_BLOWFISH,
+ GCRY_CIPHER_AES256,
GCRY_CIPHER_MODE_CFB,
0);
if (rc) {
@@ -183,8 +183,8 @@
return -1;
}
rc = gcry_cipher_setkey(handle,
- sessionkey,
- sizeof(SESSIONKEY));
+ sessionkey,
+ SESSIONKEY_LEN);
if (rc && ((char)rc != GPG_ERR_WEAK_KEY)) {
LOG_GCRY(LOG_FAILURE, "gcry_cipher_setkey", rc);
Modified: GNUnet/src/util/symcipher_openssl.c
===================================================================
--- GNUnet/src/util/symcipher_openssl.c 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/src/util/symcipher_openssl.c 2005-03-05 05:37:01 UTC (rev 366)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2004 Christian Grothoff (and other contributing authors)
+ (C) 2001, 2002, 2004, 2005 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
@@ -27,7 +27,7 @@
#include "gnunet_util.h"
#include "platform.h"
-#include <openssl/blowfish.h>
+#include <openssl/aes.h>
#include <openssl/evp.h>
#include <openssl/bn.h>
#include <openssl/err.h>
@@ -68,7 +68,7 @@
GNUNET_ASSERT( (block != NULL) && (sessionkey != NULL) );
/* compute result size by adding block-length, always padded */
EVP_EncryptInit(&ctx,
- EVP_bf_cfb(),
+ EVP_aes_256_cfb(),
(void*) sessionkey->key, /* cast for old OpenSSL versions */
(void*) iv); /* cast for old OpenSSL versions */
#if SSL_MICRO >= 6
@@ -128,9 +128,9 @@
BREAK();
return SYSERR;
}
- /* use blowfish-cfb */
+ /* use aes-256-cfb */
EVP_DecryptInit(&ctx,
- EVP_bf_cfb(),
+ EVP_aes_256_cfb(),
(void*)sessionkey->key, /* cast for old OpenSSL versions */
(void*)iv); /* cast for old OpenSSL versions */
#if SSL_MICRO >= 6
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-03-04 19:31:22 UTC (rev 365)
+++ GNUnet/todo 2005-03-05 05:37:01 UTC (rev 366)
@@ -6,9 +6,6 @@
- 593??? [ gnunet-setup ]
0.7.0pre1 [4'05] (aka "preview"):
-- util:
- * switch hash to SHA-512
- * switch cipher to AES-256
- testing:
* sqlite-tests: test update function, concurrency with iterators
* ECRS-directories (build, iterate)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r366 - in GNUnet: . src/applications/advertising src/applications/chat src/applications/datastore src/applications/dht/module src/applications/dht/tools src/applications/fragmentation src/applications/fs src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/lib src/applications/fs/module src/applications/fs/tools src/applications/gap src/applications/sqstore_mysql src/applications/sqstore_sqlite src/applications/tracekit src/applications/traffic src/conf src/include src/server src/transports src/util,
grothoff <=