From 8f7c934625129b4dde3e57163a6b1a2b01bc5963 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Mon, 20 Feb 2017 05:39:47 +0300 Subject: protocols: jabber: omemo: init_device functio (skeletoon..) --- protocols/JabberG/src/jabber_omemo.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'protocols/JabberG/src/jabber_omemo.cpp') diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 9af0a2bb39..6cd11cbe42 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -361,11 +361,11 @@ namespace omemo { { signal_mutex.unlock(); } + signal_context *global_context; int init_omemo() { signal_mutex.unlock(); //fuck... - signal_context *global_context; signal_context_create(&global_context, NULL); signal_crypto_provider provider; provider.random_func = &random_func; @@ -380,10 +380,35 @@ namespace omemo { provider.encrypt_func = &encrypt_func; provider.decrypt_func = &decrypt_func; - signal_context_set_crypto_provider(global_context, &provider); - signal_context_set_locking_functions(global_context, &lock, &unlock); + if (signal_context_set_crypto_provider(global_context, &provider)) + { + //TODO: handle error + } + + if (signal_context_set_locking_functions(global_context, &lock, &unlock)) + { + //TODO: handle error + } return 0; } + struct omemo_device + { + int id; + ec_key_pair *device_key; + }; + + omemo_device* init_device() + { + omemo_device *dev = (omemo_device*)mir_alloc(sizeof(omemo_device)); + Utils_GetRandom((void*)dev->id, 4); + if (curve_generate_key_pair(global_context, &(dev->device_key))) + { + //TODO: handle error + } + + return dev; + } + }; -- cgit v1.2.3