diff options
author | Paul Fariello <paul@fariello.eu> | 2019-02-19 20:03:50 +0140 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2019-04-10 15:37:22 +0200 |
commit | 2602cbf7852fa4317d961316b601a383b9077079 (patch) | |
tree | 31a21338b33a2efa61db9a9da67b7f922ac6b22d /src/omemo | |
parent | 519cf295f31d77bec45644424f7212e9fb2692e8 (diff) | |
download | profani-tty-2602cbf7852fa4317d961316b601a383b9077079.tar.gz |
Move OMEMO initialization to profanity intialization
Also store identity keys into account
Diffstat (limited to 'src/omemo')
-rw-r--r-- | src/omemo/omemo.c | 24 | ||||
-rw-r--r-- | src/omemo/omemo.h | 3 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 96e07d1c..1b2998b0 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -8,6 +8,7 @@ static void lock(void *user_data); static void unlock(void *user_data); +static void omemo_load_crypto_materials(ProfAccount *account); struct omemo_context_t { pthread_mutexattr_t attr; @@ -15,8 +16,9 @@ struct omemo_context_t { }; void -omemo_init(ProfAccount *account) +omemo_init(void) { + log_info("Initialising OMEMO"); signal_context *signal_ctx; omemo_context *ctx = malloc(sizeof(omemo_context)); signal_crypto_provider crypto_provider = { @@ -35,7 +37,7 @@ omemo_init(ProfAccount *account) }; if (omemo_crypto_init() != 0) { - cons_show("Error initializing Omemo crypto"); + cons_show("Error initializing OMEMO crypto"); } pthread_mutexattr_init(&ctx->attr); @@ -43,18 +45,32 @@ omemo_init(ProfAccount *account) pthread_mutex_init(&ctx->lock, &ctx->attr); if (signal_context_create(&signal_ctx, ctx) != 0) { - cons_show("Error initializing Omemo context"); + cons_show("Error initializing OMEMO context"); return; } if (signal_context_set_crypto_provider(signal_ctx, &crypto_provider) != 0) { - cons_show("Error initializing Omemo crypto"); + cons_show("Error initializing OMEMO crypto"); return; } signal_context_set_locking_functions(signal_ctx, lock, unlock); } +void +omemo_generate_crypto_materials(ProfAccount *account) +{ + ratchet_identity_key_pair *identity_key_pair; + uint32_t registration_id; + signal_protocol_key_helper_pre_key_list_node *pre_keys_head; + session_signed_pre_key *signed_pre_key; + + signal_protocol_key_helper_generate_identity_key_pair(&identity_key_pair, global_context); + signal_protocol_key_helper_generate_registration_id(®istration_id, 0, global_context); + signal_protocol_key_helper_generate_pre_keys(&pre_keys_head, start_id, 100, global_context); + signal_protocol_key_helper_generate_signed_pre_key(&signed_pre_key, identity_key_pair, 5, timestamp, global_context); +} + static void lock(void *user_data) { diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h index d34b90bf..825529b1 100644 --- a/src/omemo/omemo.h +++ b/src/omemo/omemo.h @@ -2,4 +2,5 @@ typedef struct omemo_context_t omemo_context; -void omemo_init(ProfAccount *account); +void omemo_init(void); +void omemo_generate_crypto_materials(ProfAccount *account); |