Fixed multiple trace problems.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4357 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
17
src/ssb.js.c
17
src/ssb.js.c
@ -1108,6 +1108,7 @@ static bool _tf_ssb_get_private_key_curve25519(sqlite3* db, const char* user, co
|
||||
{
|
||||
if (!user || !identity || !out_private_key)
|
||||
{
|
||||
tf_printf("user=%p identity=%p out_private_key=%p\n", user, identity, out_private_key);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1176,10 +1177,13 @@ static JSValue _tf_ssb_private_message_encrypt(JSContext* context, JSValueConst
|
||||
if (JS_IsUndefined(result))
|
||||
{
|
||||
tf_ssb_t* ssb = JS_GetOpaque(this_val, _tf_ssb_classId);
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
|
||||
uint8_t private_key[crypto_sign_SECRETKEYBYTES] = { 0 };
|
||||
if (_tf_ssb_get_private_key_curve25519(db, signer_user, signer_identity, private_key))
|
||||
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
bool found = _tf_ssb_get_private_key_curve25519(db, signer_user, signer_identity, private_key);
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
|
||||
if (found)
|
||||
{
|
||||
uint8_t public_key[crypto_box_PUBLICKEYBYTES] = { 0 };
|
||||
uint8_t secret_key[crypto_box_SECRETKEYBYTES] = { 0 };
|
||||
@ -1252,7 +1256,6 @@ static JSValue _tf_ssb_private_message_encrypt(JSContext* context, JSValueConst
|
||||
{
|
||||
result = JS_ThrowInternalError(context, "Unable to get key for ID %s of user %s.", signer_identity, signer_user);
|
||||
}
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
}
|
||||
|
||||
JS_FreeCString(context, signer_user);
|
||||
@ -1274,7 +1277,10 @@ static JSValue _tf_ssb_private_message_decrypt(JSContext* context, JSValueConst
|
||||
|
||||
tf_ssb_t* ssb = JS_GetOpaque(this_val, _tf_ssb_classId);
|
||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||
if (_tf_ssb_get_private_key_curve25519(db, user, identity, private_key))
|
||||
bool found = _tf_ssb_get_private_key_curve25519(db, user, identity, private_key);
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
|
||||
if (found)
|
||||
{
|
||||
uint8_t* decoded = tf_malloc(message_size);
|
||||
int decoded_length = tf_base64_decode(message, message_size - strlen(".box"), decoded, message_size);
|
||||
@ -1324,7 +1330,6 @@ static JSValue _tf_ssb_private_message_decrypt(JSContext* context, JSValueConst
|
||||
{
|
||||
result = JS_ThrowInternalError(context, "Private key not found for user %s with id %s.", user, identity);
|
||||
}
|
||||
tf_ssb_release_db_reader(ssb, db);
|
||||
|
||||
JS_FreeCString(context, user);
|
||||
JS_FreeCString(context, identity);
|
||||
|
Reference in New Issue
Block a user