mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-06 02:59:12 +00:00
progress towards obfuscated senders working.
This commit is contained in:
parent
80b195456f
commit
2af6d245f7
6
meshms.c
6
meshms.c
@ -49,9 +49,9 @@ rhizome_manifest *meshms_find_or_create_manifestid
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WHYF("rhizome_retreive_manifest(%s) failed",manifestid_hex);
|
// The manifest can't be read. This is normal for outgoing plys of meshms
|
||||||
rhizome_manifest_free(m);
|
// threads, because we compute the BID deterministically.
|
||||||
return NULL;
|
// So just ignore if this happens.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!createP) {
|
if (!createP) {
|
||||||
|
@ -1215,17 +1215,39 @@ cleanup:
|
|||||||
The offset argument can be used to return multiple results as a preliminary
|
The offset argument can be used to return multiple results as a preliminary
|
||||||
mechanism for dealing with this.
|
mechanism for dealing with this.
|
||||||
*/
|
*/
|
||||||
int rhizome_meshms_find_conversation(const char *sender_sid,
|
int rhizome_meshms_find_conversation(const char *sender_sid_hex,
|
||||||
const char *recipient_sid,
|
const char *recipient_sid_hex,
|
||||||
char *manifest_id, int offset)
|
char *manifest_id_hex, int offset)
|
||||||
{
|
{
|
||||||
IN();
|
IN();
|
||||||
|
|
||||||
|
int cn=0,in=0,kp=0;
|
||||||
|
sid_t authorSid;
|
||||||
|
if (str_to_sid_t(&authorSid, sender_sid_hex)==-1)
|
||||||
|
RETURN(WHYF("invalid sender_sid: '%s'", sender_sid_hex));
|
||||||
|
|
||||||
|
if(keyring_find_sid(keyring,&cn,&in,&kp,authorSid.binary))
|
||||||
|
{
|
||||||
|
// We are the sender, so the BID is precisely determined
|
||||||
|
rhizome_manifest m;
|
||||||
|
sid_t rxSid;
|
||||||
|
if (str_to_sid_t(&rxSid, recipient_sid_hex)==-1)
|
||||||
|
RETURN(WHYF("invalid recipient_sid: '%s'", recipient_sid_hex));
|
||||||
|
if (!rhizome_obfuscated_manifest_generate_outgoing_bid
|
||||||
|
(&m,authorSid.binary,recipient_sid_hex))
|
||||||
|
{
|
||||||
|
tohex(manifest_id_hex,m.cryptoSignPublic,
|
||||||
|
crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES);
|
||||||
|
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");
|
||||||
|
|
||||||
if (sender_sid && *sender_sid)
|
if (sender_sid_hex && *sender_sid_hex)
|
||||||
strbuf_sprintf(b, " AND sender = ?3");
|
strbuf_sprintf(b, " AND sender = ?3");
|
||||||
if (recipient_sid && *recipient_sid)
|
if (recipient_sid_hex && *recipient_sid_hex)
|
||||||
strbuf_sprintf(b, " AND recipient = ?4");
|
strbuf_sprintf(b, " AND recipient = ?4");
|
||||||
|
|
||||||
strbuf_sprintf(b, " ORDER BY inserttime DESC");
|
strbuf_sprintf(b, " ORDER BY inserttime DESC");
|
||||||
@ -1244,10 +1266,10 @@ int rhizome_meshms_find_conversation(const char *sender_sid,
|
|||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ret==SQLITE_OK && sender_sid && *sender_sid)
|
if (ret==SQLITE_OK && sender_sid_hex && *sender_sid_hex)
|
||||||
ret = sqlite3_bind_text(statement, 3, sender_sid, -1, SQLITE_STATIC);
|
ret = sqlite3_bind_text(statement, 3, sender_sid_hex, -1, SQLITE_STATIC);
|
||||||
if (ret==SQLITE_OK && recipient_sid && *recipient_sid)
|
if (ret==SQLITE_OK && recipient_sid_hex && *recipient_sid_hex)
|
||||||
ret = sqlite3_bind_text(statement, 4, recipient_sid, -1, SQLITE_STATIC);
|
ret = sqlite3_bind_text(statement, 4, recipient_sid_hex, -1, SQLITE_STATIC);
|
||||||
|
|
||||||
if (ret!=SQLITE_OK){
|
if (ret!=SQLITE_OK){
|
||||||
ret = WHYF("Failed to bind parameters: %s", sqlite3_errmsg(rhizome_db));
|
ret = WHYF("Failed to bind parameters: %s", sqlite3_errmsg(rhizome_db));
|
||||||
@ -1266,7 +1288,7 @@ int rhizome_meshms_find_conversation(const char *sender_sid,
|
|||||||
}
|
}
|
||||||
const char *q_manifestid = (const char *) sqlite3_column_text(statement, 0);
|
const char *q_manifestid = (const char *) sqlite3_column_text(statement, 0);
|
||||||
if (q_manifestid) {
|
if (q_manifestid) {
|
||||||
bcopy(q_manifestid,manifest_id,
|
bcopy(q_manifestid,manifest_id_hex,
|
||||||
1+min(RHIZOME_MANIFEST_ID_STRLEN,strlen(q_manifestid)));
|
1+min(RHIZOME_MANIFEST_ID_STRLEN,strlen(q_manifestid)));
|
||||||
ret=0;
|
ret=0;
|
||||||
// fall through to clean up and return
|
// fall through to clean up and return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user