about summary refs log tree commit diff stats
path: root/src/omemo/omemo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/omemo/omemo.c')
-rw-r--r--src/omemo/omemo.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index 1efe0296..9e46058e 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -72,21 +72,6 @@ void
 omemo_init(void)
 {
     log_info("OMEMO: initialising");
-    signal_crypto_provider crypto_provider = {
-        .random_func = omemo_random_func,
-        .hmac_sha256_init_func = omemo_hmac_sha256_init_func,
-        .hmac_sha256_update_func = omemo_hmac_sha256_update_func,
-        .hmac_sha256_final_func = omemo_hmac_sha256_final_func,
-        .hmac_sha256_cleanup_func = omemo_hmac_sha256_cleanup_func,
-        .sha512_digest_init_func = omemo_sha512_digest_init_func,
-        .sha512_digest_update_func = omemo_sha512_digest_update_func,
-        .sha512_digest_final_func = omemo_sha512_digest_final_func,
-        .sha512_digest_cleanup_func = omemo_sha512_digest_cleanup_func,
-        .encrypt_func = omemo_encrypt_func,
-        .decrypt_func = omemo_decrypt_func,
-        .user_data = NULL
-    };
-
     if (omemo_crypto_init() != 0) {
         cons_show("Error initializing OMEMO crypto");
     }
@@ -95,6 +80,14 @@ omemo_init(void)
     pthread_mutexattr_settype(&omemo_ctx.attr, PTHREAD_MUTEX_RECURSIVE);
     pthread_mutex_init(&omemo_ctx.lock, &omemo_ctx.attr);
 
+    omemo_ctx.fingerprint_ac = autocomplete_new();
+}
+
+void
+omemo_on_connect(ProfAccount *account)
+{
+    GError *error = NULL;
+
     if (signal_context_create(&omemo_ctx.signal, &omemo_ctx) != 0) {
         cons_show("Error initializing OMEMO context");
         return;
@@ -104,6 +97,21 @@ omemo_init(void)
         cons_show("Error initializing OMEMO log");
     }
 
+    signal_crypto_provider crypto_provider = {
+        .random_func = omemo_random_func,
+        .hmac_sha256_init_func = omemo_hmac_sha256_init_func,
+        .hmac_sha256_update_func = omemo_hmac_sha256_update_func,
+        .hmac_sha256_final_func = omemo_hmac_sha256_final_func,
+        .hmac_sha256_cleanup_func = omemo_hmac_sha256_cleanup_func,
+        .sha512_digest_init_func = omemo_sha512_digest_init_func,
+        .sha512_digest_update_func = omemo_sha512_digest_update_func,
+        .sha512_digest_final_func = omemo_sha512_digest_final_func,
+        .sha512_digest_cleanup_func = omemo_sha512_digest_cleanup_func,
+        .encrypt_func = omemo_encrypt_func,
+        .decrypt_func = omemo_decrypt_func,
+        .user_data = NULL
+    };
+
     if (signal_context_set_crypto_provider(omemo_ctx.signal, &crypto_provider) != 0) {
         cons_show("Error initializing OMEMO crypto");
         return;
@@ -166,12 +174,7 @@ omemo_init(void)
     omemo_ctx.known_devices = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)g_hash_table_free);
 
     omemo_ctx.fingerprint_ac = autocomplete_new();
-}
 
-void
-omemo_on_connect(ProfAccount *account)
-{
-    GError *error = NULL;
     char *omemodir = files_get_data_path(DIR_OMEMO);
     GString *basedir = g_string_new(omemodir);
     free(omemodir);