Improve log messages for OMEMO sending issues
This commit is contained in:
parent
3cfe0d60f6
commit
41f9827166
|
@ -27,12 +27,11 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
public bool active_send_attempt { get; set; }
|
public bool active_send_attempt { get; set; }
|
||||||
|
|
||||||
public MessageState(Entities.Message msg, EncryptState last_try) {
|
public MessageState(Entities.Message msg, EncryptState last_try) {
|
||||||
this.msg = msg;
|
update_from_encrypt_status(msg, last_try);
|
||||||
this.last_try = last_try;
|
|
||||||
update_from_encrypt_status(last_try);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update_from_encrypt_status(EncryptState new_try) {
|
public void update_from_encrypt_status(Entities.Message msg, EncryptState new_try) {
|
||||||
|
this.msg = msg;
|
||||||
this.last_try = new_try;
|
this.last_try = new_try;
|
||||||
this.waiting_other_sessions = new_try.other_unknown;
|
this.waiting_other_sessions = new_try.other_unknown;
|
||||||
this.waiting_own_sessions = new_try.own_unknown;
|
this.waiting_own_sessions = new_try.own_unknown;
|
||||||
|
@ -56,7 +55,7 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
public string to_string() {
|
public string to_string() {
|
||||||
return @"MessageState (waiting=(others=$waiting_other_sessions, own=$waiting_own_sessions, other_lists=$waiting_other_devicelists, own_list=$waiting_own_devicelist))";
|
return @"MessageState (msg=$(msg.stanza_id), send=$will_send_now, $last_try)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +126,10 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
lock (message_states) {
|
lock (message_states) {
|
||||||
if (message_states.has_key(message)) {
|
if (message_states.has_key(message)) {
|
||||||
state = message_states.get(message);
|
state = message_states.get(message);
|
||||||
state.update_from_encrypt_status(enc_state);
|
state.update_from_encrypt_status(message, enc_state);
|
||||||
|
if (state.will_send_now) {
|
||||||
|
debug("sending message delayed: %s", state.to_string());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
state = new MessageState(message, enc_state);
|
state = new MessageState(message, enc_state);
|
||||||
message_states[message] = state;
|
message_states[message] = state;
|
||||||
|
@ -140,10 +142,10 @@ public class Manager : StreamInteractionModule, Object {
|
||||||
//Encryption failed - need to fetch more information
|
//Encryption failed - need to fetch more information
|
||||||
if (!state.will_send_now) {
|
if (!state.will_send_now) {
|
||||||
if (message.marked == Entities.Message.Marked.WONTSEND) {
|
if (message.marked == Entities.Message.Marked.WONTSEND) {
|
||||||
debug("message was not sent: %s", state.to_string());
|
debug("retracting message %s", state.to_string());
|
||||||
message_states.unset(message);
|
message_states.unset(message);
|
||||||
} else {
|
} else {
|
||||||
debug("message will be delayed: %s", state.to_string());
|
debug("delaying message %s", state.to_string());
|
||||||
|
|
||||||
if (state.waiting_own_sessions > 0) {
|
if (state.waiting_own_sessions > 0) {
|
||||||
module.fetch_bundles((!)stream, conversation.account.bare_jid, trust_manager.get_trusted_devices(conversation.account, conversation.account.bare_jid));
|
module.fetch_bundles((!)stream, conversation.account.bare_jid, trust_manager.get_trusted_devices(conversation.account, conversation.account.bare_jid));
|
||||||
|
|
|
@ -175,6 +175,8 @@ public class TrustManager {
|
||||||
status.encrypted = true;
|
status.encrypted = true;
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
warning(@"Signal error while encrypting message: $(e.message)\n");
|
warning(@"Signal error while encrypting message: $(e.message)\n");
|
||||||
|
message.body = "[OMEMO encryption failed]";
|
||||||
|
status.encrypted = false;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,14 +208,14 @@ int signal_vala_encrypt(signal_buffer **output,
|
||||||
const uint8_t *iv, size_t iv_len,
|
const uint8_t *iv, size_t iv_len,
|
||||||
const uint8_t *plaintext, size_t plaintext_len,
|
const uint8_t *plaintext, size_t plaintext_len,
|
||||||
void *user_data) {
|
void *user_data) {
|
||||||
int algo, mode;
|
int algo, mode, error_code = SG_ERR_UNKNOWN;
|
||||||
if (aes_cipher(cipher, key_len, &algo, &mode)) return SG_ERR_UNKNOWN;
|
if (aes_cipher(cipher, key_len, &algo, &mode)) return SG_ERR_INVAL;
|
||||||
|
|
||||||
if (iv_len != 16 && iv_len != 12) return SG_ERR_UNKNOWN;
|
if (iv_len != 16 && iv_len != 12) return SG_ERR_INVAL;
|
||||||
|
|
||||||
gcry_cipher_hd_t ctx = {0};
|
gcry_cipher_hd_t ctx = {0};
|
||||||
|
|
||||||
if (gcry_cipher_open(&ctx, algo, mode, 0)) return SG_ERR_UNKNOWN;
|
if (gcry_cipher_open(&ctx, algo, mode, 0)) return SG_ERR_NOMEM;
|
||||||
|
|
||||||
signal_buffer* padded = 0;
|
signal_buffer* padded = 0;
|
||||||
signal_buffer* out_buf = 0;
|
signal_buffer* out_buf = 0;
|
||||||
|
@ -228,7 +228,7 @@ error:
|
||||||
if (out_buf != 0) {
|
if (out_buf != 0) {
|
||||||
signal_buffer_free(out_buf);
|
signal_buffer_free(out_buf);
|
||||||
}
|
}
|
||||||
return SG_ERR_UNKNOWN;
|
return error_code;
|
||||||
no_error:
|
no_error:
|
||||||
|
|
||||||
if (gcry_cipher_setkey(ctx, key, key_len)) goto error;
|
if (gcry_cipher_setkey(ctx, key, key_len)) goto error;
|
||||||
|
@ -254,6 +254,7 @@ no_error:
|
||||||
size_t padded_len = plaintext_len + pad_len;
|
size_t padded_len = plaintext_len + pad_len;
|
||||||
padded = signal_buffer_alloc(padded_len);
|
padded = signal_buffer_alloc(padded_len);
|
||||||
if (padded == 0) {
|
if (padded == 0) {
|
||||||
|
error_code = SG_ERR_NOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +263,7 @@ no_error:
|
||||||
|
|
||||||
out_buf = signal_buffer_alloc(padded_len + tag_len);
|
out_buf = signal_buffer_alloc(padded_len + tag_len);
|
||||||
if (out_buf == 0) {
|
if (out_buf == 0) {
|
||||||
|
error_code = SG_ERR_NOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,16 +289,16 @@ int signal_vala_decrypt(signal_buffer **output,
|
||||||
const uint8_t *iv, size_t iv_len,
|
const uint8_t *iv, size_t iv_len,
|
||||||
const uint8_t *ciphertext, size_t ciphertext_len,
|
const uint8_t *ciphertext, size_t ciphertext_len,
|
||||||
void *user_data) {
|
void *user_data) {
|
||||||
int algo, mode;
|
int algo, mode, error_code = SG_ERR_UNKNOWN;
|
||||||
*output = 0;
|
*output = 0;
|
||||||
if (aes_cipher(cipher, key_len, &algo, &mode)) return SG_ERR_UNKNOWN;
|
if (aes_cipher(cipher, key_len, &algo, &mode)) return SG_ERR_INVAL;
|
||||||
if (ciphertext_len == 0) return SG_ERR_UNKNOWN;
|
if (ciphertext_len == 0) return SG_ERR_INVAL;
|
||||||
|
|
||||||
if (iv_len != 16 && iv_len != 12) return SG_ERR_UNKNOWN;
|
if (iv_len != 16 && iv_len != 12) return SG_ERR_INVAL;
|
||||||
|
|
||||||
gcry_cipher_hd_t ctx = {0};
|
gcry_cipher_hd_t ctx = {0};
|
||||||
|
|
||||||
if (gcry_cipher_open(&ctx, algo, mode, 0)) return SG_ERR_UNKNOWN;
|
if (gcry_cipher_open(&ctx, algo, mode, 0)) return SG_ERR_NOMEM;
|
||||||
|
|
||||||
signal_buffer* out_buf = 0;
|
signal_buffer* out_buf = 0;
|
||||||
goto no_error;
|
goto no_error;
|
||||||
|
@ -305,7 +307,7 @@ error:
|
||||||
if (out_buf != 0) {
|
if (out_buf != 0) {
|
||||||
signal_buffer_bzero_free(out_buf);
|
signal_buffer_bzero_free(out_buf);
|
||||||
}
|
}
|
||||||
return SG_ERR_UNKNOWN;
|
return error_code;
|
||||||
no_error:
|
no_error:
|
||||||
|
|
||||||
if (gcry_cipher_setkey(ctx, key, key_len)) goto error;
|
if (gcry_cipher_setkey(ctx, key, key_len)) goto error;
|
||||||
|
@ -331,6 +333,7 @@ no_error:
|
||||||
size_t padded_len = ciphertext_len - tag_len;
|
size_t padded_len = ciphertext_len - tag_len;
|
||||||
out_buf = signal_buffer_alloc(padded_len);
|
out_buf = signal_buffer_alloc(padded_len);
|
||||||
if (out_buf == 0) {
|
if (out_buf == 0) {
|
||||||
|
error_code = SG_ERR_NOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue