From 231058a21887b99d8e5d4326c03b5865b1813738 Mon Sep 17 00:00:00 2001 From: gardners Date: Thu, 17 May 2012 11:39:12 +0930 Subject: [PATCH] fixed rhizome transfer bugs. --- rhizome_crypto.c | 5 +++-- rhizome_fetch.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rhizome_crypto.c b/rhizome_crypto.c index 2a6e16d8..2dfa2fd6 100644 --- a/rhizome_crypto.c +++ b/rhizome_crypto.c @@ -196,7 +196,6 @@ rhizome_signature *rhizome_sign_hash(rhizome_manifest *m,const char *author) { unsigned char *hash=m->manifesthash; unsigned char *publicKeyBytes=m->cryptoSignPublic; - unsigned char secretKeyBytes[crypto_sign_edwards25519sha512batch_SECRETKEYBYTES]; if (rhizome_extract_privatekey(m,author)) { @@ -212,11 +211,12 @@ rhizome_signature *rhizome_sign_hash(rhizome_manifest *m,const char *author) int mLen=crypto_hash_sha512_BYTES; int r=crypto_sign_edwards25519sha512batch(signatureBuffer,&sigLen, - &hash[0],mLen,secretKeyBytes); + &hash[0],mLen,m->cryptoSignSecret); if (r) { WHY("crypto_sign() failed."); return NULL; } + dump("formed sig",signatureBuffer,sigLen); rhizome_signature *out=calloc(sizeof(rhizome_signature),1); @@ -263,6 +263,7 @@ int rhizome_manifest_extract_signature(rhizome_manifest *m,int *ofs) bcopy(&m->manifestdata[(*ofs)+1+32],&sigBuf[96],32); /* Get public key of signatory */ bcopy(&m->manifestdata[(*ofs)+1+64],&publicKey[0],crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES); + dump("reconst sigblock",&sigBuf[0],128); unsigned long long mlen=0; int r=crypto_sign_edwards25519sha512batch_open(verifyBuf,&mlen,&sigBuf[0],128, diff --git a/rhizome_fetch.c b/rhizome_fetch.c index 1286a7b8..cdc49590 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -514,12 +514,12 @@ int rhizome_fetch_poll() q->close=1; if (debug&DEBUG_RHIZOME) fprintf(stderr,"Received all of file via rhizome -- now to import it\n"); { - fclose(q->file); + fclose(q->file); q->file=NULL; const char *id = rhizome_manifest_get(q->manifest, "id", NULL, 0); if (id == NULL) return WHY("Manifest missing ID"); char filename[1024]; - if (!FORM_RHIZOME_DATASTORE_PATH("import/manifest.%s", id)) + if (!FORM_RHIZOME_DATASTORE_PATH(filename,"import/manifest.%s", id)) return -1; /* Do really write the manifest unchanged */ if (debug&DEBUG_RHIZOME) { @@ -552,7 +552,7 @@ int rhizome_fetch_poll() errno=0; bytes=read(q->socket,&q->request[q->request_len], - 1024-q->request_len-1); + 1024-q->request_len-1); /* If we got some data, see if we have found the end of the HTTP request */ if (bytes>0) { @@ -578,7 +578,7 @@ int rhizome_fetch_poll() if (lfcount==2) { /* We have the response headers, so parse. (we may also have some extra bytes, so we need to be a little - careful) */ + careful) */ /* Terminate string at end of headers */ q->request[i]=0;