diff options
author | Paul Fariello <paul@fariello.eu> | 2019-03-27 17:15:59 +0100 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2019-04-10 17:23:45 +0200 |
commit | 904528b490e3e9e0d8ae0ecc8e8ec4126238c121 (patch) | |
tree | 2b8ff19c1d33cf26a783c56bfae5ca732070fdc8 | |
parent | 075d4cf35b4fce6d623822a63ae0abfbfc78b965 (diff) | |
download | profani-tty-904528b490e3e9e0d8ae0ecc8e8ec4126238c121.tar.gz |
Ensure signal context is built on connection
We can't keep it between two connection because signal context is specific to a given account.
-rw-r--r-- | src/omemo/omemo.c | 43 |
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); |