mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-24 14:16:21 +00:00
Move OMEMO initialization to profanity intialization
Also store identity keys into account
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user