fix various bugs preventing obfuscated sender / conversation list

bundle from working.
This commit is contained in:
gardners 2013-05-14 22:56:19 +09:30
parent 2431f64125
commit 1c0837f8cd
4 changed files with 75 additions and 106 deletions

View File

@ -307,7 +307,7 @@ int meshms_append_messageblock(const char *sender_sid_hex,
// Find the manifest (or create it if it doesn't yet exist) // Find the manifest (or create it if it doesn't yet exist)
rhizome_manifest *m=meshms_find_or_create_manifestid(sender_sid_hex, rhizome_manifest *m=meshms_find_or_create_manifestid(sender_sid_hex,
recipient_sid_hex,1); recipient_sid_hex,1);
if (!m) return -1; if (!m) return WHYF("Could not read manifest");
// Read the bundle file containing the meshms messages // Read the bundle file containing the meshms messages
// (and keep enough space to append the new message // (and keep enough space to append the new message
@ -339,7 +339,7 @@ int meshms_append_messageblock(const char *sender_sid_hex,
free(buffer_file); free(buffer_file);
rhizome_manifest *mout = NULL; rhizome_manifest *mout = NULL;
ret=rhizome_manifest_finalise(m,&mout); ret|=rhizome_manifest_finalise(m,&mout);
if (ret<0){ if (ret<0){
cli_printf("Error in manifest finalise"); cli_printf("Error in manifest finalise");
rhizome_manifest_free(m); rhizome_manifest_free(m);
@ -347,41 +347,6 @@ int meshms_append_messageblock(const char *sender_sid_hex,
return -1; return -1;
} }
{
char bid[RHIZOME_MANIFEST_ID_STRLEN + 1];
rhizome_bytes_to_hex_upper(mout->cryptoSignPublic, bid, RHIZOME_MANIFEST_ID_BYTES);
cli_puts("manifestid");
cli_delim(":");
cli_puts(bid);
cli_delim("\n");
}
{
char secret[RHIZOME_BUNDLE_KEY_STRLEN + 1];
rhizome_bytes_to_hex_upper(mout->cryptoSignSecret, secret, RHIZOME_BUNDLE_KEY_BYTES);
cli_puts("secret");
cli_delim(":");
cli_puts(secret);
cli_delim("\n");
}
cli_puts("version"); cli_delim(":"); cli_printf("%lld", m->version); cli_delim("\n");
cli_puts("filesize");
cli_delim(":");
cli_printf("%lld", mout->fileLength);
cli_delim("\n");
if (mout->fileLength != 0) {
cli_puts("filehash");
cli_delim(":");
cli_puts(mout->fileHexHash);
cli_delim("\n");
}
const char *name_manifest = rhizome_manifest_get(mout, "name", NULL, 0);
if (name_manifest) {
cli_puts("name");
cli_delim(":");
cli_puts(name_manifest);
cli_delim("\n");
}
if (mout != m) if (mout != m)
rhizome_manifest_free(mout); rhizome_manifest_free(mout);
rhizome_manifest_free(m); rhizome_manifest_free(m);

View File

@ -200,6 +200,8 @@ int rhizome_find_secret(const unsigned char *authorSid, int *rs_len, const unsig
int rhizome_extract_privatekey(rhizome_manifest *m, rhizome_bk_t *bsk) int rhizome_extract_privatekey(rhizome_manifest *m, rhizome_bk_t *bsk)
{ {
IN(); IN();
if (m->haveSecret) RETURN(0);
unsigned char bkBytes[RHIZOME_BUNDLE_KEY_BYTES]; unsigned char bkBytes[RHIZOME_BUNDLE_KEY_BYTES];
char *bk = rhizome_manifest_get(m, "BK", NULL, 0); char *bk = rhizome_manifest_get(m, "BK", NULL, 0);
int result; int result;
@ -723,6 +725,9 @@ int rhizome_obfuscated_manifest_generate_outgoing_bid
crypto_sign_edwards25519sha512batch_SECRETKEYBYTES); crypto_sign_edwards25519sha512batch_SECRETKEYBYTES);
if (crypto_sign_compute_public_key(m->cryptoSignSecret,m->cryptoSignPublic)) if (crypto_sign_compute_public_key(m->cryptoSignSecret,m->cryptoSignPublic))
return WHY("Could not compute BID"); return WHY("Could not compute BID");
m->haveSecret=1;
rhizome_manifest_set(m,"id",alloca_tohex_bid(m->cryptoSignPublic));
// Clear out sensitive data // Clear out sensitive data
bzero(secret,1024); bzero(secret,1024);

View File

@ -1229,18 +1229,21 @@ int rhizome_meshms_find_conversation(const char *sender_sid_hex,
if(keyring_find_sid(keyring,&cn,&in,&kp,authorSid.binary)) if(keyring_find_sid(keyring,&cn,&in,&kp,authorSid.binary))
{ {
// We are the sender, so the BID is precisely determined // We are the sender, so the BID is precisely determined
rhizome_manifest m; rhizome_manifest *m=rhizome_new_manifest();
if (m) {
sid_t rxSid; sid_t rxSid;
if (str_to_sid_t(&rxSid, recipient_sid_hex)==-1) if (str_to_sid_t(&rxSid, recipient_sid_hex)==-1)
RETURN(WHYF("invalid recipient_sid: '%s'", recipient_sid_hex)); RETURN(WHYF("invalid recipient_sid: '%s'", recipient_sid_hex));
if (!rhizome_obfuscated_manifest_generate_outgoing_bid if (!rhizome_obfuscated_manifest_generate_outgoing_bid
(&m,authorSid.binary,recipient_sid_hex)) (m,authorSid.binary,recipient_sid_hex))
{ {
tohex(manifest_id_hex,m.cryptoSignPublic, tohex(manifest_id_hex,m->cryptoSignPublic,
crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES); crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES);
rhizome_manifest_free(m);
RETURN(0); RETURN(0);
} }
} }
}
strbuf b = strbuf_alloca(1024); strbuf b = strbuf_alloca(1024);
strbuf_sprintf(b, "SELECT id FROM manifests WHERE 1=1"); strbuf_sprintf(b, "SELECT id FROM manifests WHERE 1=1");

View File

@ -30,12 +30,6 @@ setup() {
setup_rhizome setup_rhizome
} }
setup_createPly() {
set_instance +A
create_identities 2
assert [ $SIDA1 != $SIDA2 ]
}
doc_createPly="Create thread ply by sending a message" doc_createPly="Create thread ply by sending a message"
setup_createPly() { setup_createPly() {
setup setup
@ -52,8 +46,10 @@ setup_discriminatePlys() {
} }
test_discriminatePlys() { test_discriminatePlys() {
executeOk_servald meshms add message 12345 67890 $SIDA1 $SIDA2 "Message-1" executeOk_servald meshms add message 12345 67890 $SIDA1 $SIDA2 "Message-1"
tfw_cat --stderr --stdout
executeOk_servald rhizome list executeOk_servald rhizome list
assert_rhizome_list --fromhere=1 --author=$SIDA1 '' --and-others assert_rhizome_list --fromhere=1 --author=$SIDA1 '' --and-others
tfw_cat --stderr --stdout
executeOk_servald meshms list messages $SIDA1 $SIDA2 executeOk_servald meshms list messages $SIDA1 $SIDA2
assertStdoutGrep --stdout --stderr --matches=0 '^0:.*:received:meshms:Message-1' assertStdoutGrep --stdout --stderr --matches=0 '^0:.*:received:meshms:Message-1'
assertStdoutGrep --stdout --stderr --matches=1 '^0:.*:unacknowledged:meshms:Message-1' assertStdoutGrep --stdout --stderr --matches=1 '^0:.*:unacknowledged:meshms:Message-1'