mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 15:56:21 +00:00
@@ -612,9 +612,13 @@ omemo_sessions_keyfile(void)
|
|||||||
return omemo_ctx.sessions.keyfile;
|
return omemo_ctx.sessions.keyfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean omemo_sessions_keyfile_save_disable = FALSE;
|
||||||
|
|
||||||
void
|
void
|
||||||
omemo_sessions_keyfile_save(void)
|
omemo_sessions_keyfile_save(void)
|
||||||
{
|
{
|
||||||
|
if (omemo_sessions_keyfile_save_disable)
|
||||||
|
return;
|
||||||
save_keyfile(&omemo_ctx.sessions);
|
save_keyfile(&omemo_ctx.sessions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -766,6 +770,8 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
|||||||
unsigned char* key_tag = NULL;
|
unsigned char* key_tag = NULL;
|
||||||
size_t ciphertext_len, tag_len;
|
size_t ciphertext_len, tag_len;
|
||||||
|
|
||||||
|
omemo_sessions_keyfile_save_disable = TRUE;
|
||||||
|
|
||||||
ciphertext_len = strlen(message);
|
ciphertext_len = strlen(message);
|
||||||
ciphertext = malloc(ciphertext_len);
|
ciphertext = malloc(ciphertext_len);
|
||||||
if (!ciphertext) {
|
if (!ciphertext) {
|
||||||
@@ -775,8 +781,8 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
|||||||
tag = gcry_malloc_secure(tag_len);
|
tag = gcry_malloc_secure(tag_len);
|
||||||
key_tag = gcry_malloc_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH);
|
key_tag = gcry_malloc_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_TAG_LENGTH);
|
||||||
|
|
||||||
key = gcry_random_bytes_secure(AES128_GCM_KEY_LENGTH, GCRY_VERY_STRONG_RANDOM);
|
key = gcry_random_bytes_secure(AES128_GCM_KEY_LENGTH + AES128_GCM_IV_LENGTH, GCRY_VERY_STRONG_RANDOM);
|
||||||
iv = gcry_random_bytes_secure(AES128_GCM_IV_LENGTH, GCRY_VERY_STRONG_RANDOM);
|
iv = key + AES128_GCM_KEY_LENGTH;
|
||||||
|
|
||||||
res = aes128gcm_encrypt(ciphertext, &ciphertext_len, tag, &tag_len, (const unsigned char* const)message, strlen(message), iv, key);
|
res = aes128gcm_encrypt(ciphertext, &ciphertext_len, tag, &tag_len, (const unsigned char* const)message, strlen(message), iv, key);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
@@ -983,10 +989,11 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
omemo_sessions_keyfile_save_disable = FALSE;
|
||||||
|
omemo_sessions_keyfile_save();
|
||||||
g_list_free_full(keys, (GDestroyNotify)omemo_key_free);
|
g_list_free_full(keys, (GDestroyNotify)omemo_key_free);
|
||||||
free(ciphertext);
|
free(ciphertext);
|
||||||
gcry_free(key);
|
gcry_free(key);
|
||||||
gcry_free(iv);
|
|
||||||
gcry_free(tag);
|
gcry_free(tag);
|
||||||
gcry_free(key_tag);
|
gcry_free(key_tag);
|
||||||
|
|
||||||
|
|||||||
@@ -2668,8 +2668,10 @@ _iq_mam_request(ProfChatWin* win, GDateTime* startdate, GDateTime* enddate)
|
|||||||
if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
|
if (connection_supports(XMPP_FEATURE_MAM2) == FALSE) {
|
||||||
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_MAM2);
|
log_warning("Server doesn't advertise %s feature.", XMPP_FEATURE_MAM2);
|
||||||
cons_show_error("Server doesn't support MAM (%s).", XMPP_FEATURE_MAM2);
|
cons_show_error("Server doesn't support MAM (%s).", XMPP_FEATURE_MAM2);
|
||||||
g_date_time_unref(startdate);
|
if (startdate)
|
||||||
g_date_time_unref(enddate);
|
g_date_time_unref(startdate);
|
||||||
|
if (enddate)
|
||||||
|
g_date_time_unref(enddate);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2718,8 +2720,12 @@ void
|
|||||||
iq_mam_request(ProfChatWin* win, GDateTime* enddate)
|
iq_mam_request(ProfChatWin* win, GDateTime* enddate)
|
||||||
{
|
{
|
||||||
ProfMessage* last_msg = log_database_get_limits_info(win->barejid, TRUE);
|
ProfMessage* last_msg = log_database_get_limits_info(win->barejid, TRUE);
|
||||||
GDateTime* startdate = g_date_time_ref(last_msg->timestamp);
|
GDateTime* startdate = NULL;
|
||||||
message_free(last_msg);
|
if (last_msg) {
|
||||||
|
if (last_msg->timestamp)
|
||||||
|
startdate = g_date_time_ref(last_msg->timestamp);
|
||||||
|
message_free(last_msg);
|
||||||
|
}
|
||||||
|
|
||||||
// Save request for later if disco items haven't been received yet
|
// Save request for later if disco items haven't been received yet
|
||||||
if (!received_disco_items) {
|
if (!received_disco_items) {
|
||||||
|
|||||||
Reference in New Issue
Block a user