From 615e383786849c65ac9ad388a5c5db765da1e41d Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sat, 28 Mar 2020 14:43:41 +0100 Subject: [PATCH] Use libomemo-c --- .gitmodules | 7 +- plugins/CMakeLists.txt | 2 +- plugins/omemo-vala/CMakeLists.txt | 128 +++++++++++++++++ plugins/omemo-vala/libomemo-c | 1 + .../src/context.vala | 4 +- .../src/signal_helper.c | 0 .../src/signal_helper.h | 0 .../src/simple_iks.vala | 2 +- .../src/simple_pks.vala | 4 +- .../src/simple_spks.vala | 4 +- .../src/simple_ss.vala | 4 +- .../src/store.vala | 2 +- .../src/util.vala | 4 +- .../tests/common.vala | 2 +- .../tests/curve25519.vala | 4 +- .../tests/hkdf.vala | 4 +- .../tests/session_builder.vala | 2 +- .../tests/testcase.vala | 0 .../vapi/omemo-native.vapi} | 59 ++++---- .../vapi/omemo-public.vapi} | 56 ++++---- plugins/omemo/CMakeLists.txt | 4 +- .../src/file_transfer/file_decryptor.vala | 2 +- .../src/file_transfer/file_encryptor.vala | 2 +- plugins/omemo/src/jingle/jet_omemo.vala | 2 +- plugins/omemo/src/logic/manager.vala | 4 +- plugins/omemo/src/logic/pre_key_store.vala | 2 +- plugins/omemo/src/logic/session_store.vala | 2 +- .../omemo/src/logic/signed_pre_key_store.vala | 2 +- plugins/omemo/src/logic/trust_manager.vala | 4 +- plugins/omemo/src/plugin.vala | 7 +- plugins/omemo/src/protocol/bundle.vala | 2 +- plugins/omemo/src/protocol/stream_module.vala | 2 +- .../omemo/src/ui/contact_details_dialog.vala | 7 +- plugins/signal-protocol/CMakeLists.txt | 135 ------------------ plugins/signal-protocol/libsignal-protocol-c | 1 - 35 files changed, 231 insertions(+), 236 deletions(-) create mode 100644 plugins/omemo-vala/CMakeLists.txt create mode 160000 plugins/omemo-vala/libomemo-c rename plugins/{signal-protocol => omemo-vala}/src/context.vala (98%) rename plugins/{signal-protocol => omemo-vala}/src/signal_helper.c (100%) rename plugins/{signal-protocol => omemo-vala}/src/signal_helper.h (100%) rename plugins/{signal-protocol => omemo-vala}/src/simple_iks.vala (98%) rename plugins/{signal-protocol => omemo-vala}/src/simple_pks.vala (97%) rename plugins/{signal-protocol => omemo-vala}/src/simple_spks.vala (98%) rename plugins/{signal-protocol => omemo-vala}/src/simple_ss.vala (99%) rename plugins/{signal-protocol => omemo-vala}/src/store.vala (99%) rename plugins/{signal-protocol => omemo-vala}/src/util.vala (98%) rename plugins/{signal-protocol => omemo-vala}/tests/common.vala (99%) rename plugins/{signal-protocol => omemo-vala}/tests/curve25519.vala (99%) rename plugins/{signal-protocol => omemo-vala}/tests/hkdf.vala (98%) rename plugins/{signal-protocol => omemo-vala}/tests/session_builder.vala (99%) rename plugins/{signal-protocol => omemo-vala}/tests/testcase.vala (100%) rename plugins/{signal-protocol/vapi/signal-protocol-native.vapi => omemo-vala/vapi/omemo-native.vapi} (91%) rename plugins/{signal-protocol/vapi/signal-protocol-public.vapi => omemo-vala/vapi/omemo-public.vapi} (89%) delete mode 100644 plugins/signal-protocol/CMakeLists.txt delete mode 160000 plugins/signal-protocol/libsignal-protocol-c diff --git a/.gitmodules b/.gitmodules index 02c33f98..af62cb7c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ -[submodule "libsignal-protocol-c"] - path = plugins/signal-protocol/libsignal-protocol-c - url = https://github.com/WhisperSystems/libsignal-protocol-c.git - branch = v2.3.2 +[submodule "libomemo-c"] + path = plugins/omemo-vala/libomemo-c + url = https://github.com/mar-v-in/libomemo-c.git diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 6cccec3b..85839477 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -9,8 +9,8 @@ endif(DINO_PLUGIN_ENABLED_openpgp) if(DINO_PLUGIN_ENABLED_omemo) add_subdirectory(crypto-vala) + add_subdirectory(omemo-vala) add_subdirectory(omemo) - add_subdirectory(signal-protocol) endif(DINO_PLUGIN_ENABLED_omemo) if(DINO_PLUGIN_ENABLED_notification-sound) diff --git a/plugins/omemo-vala/CMakeLists.txt b/plugins/omemo-vala/CMakeLists.txt new file mode 100644 index 00000000..36b9a2fa --- /dev/null +++ b/plugins/omemo-vala/CMakeLists.txt @@ -0,0 +1,128 @@ +find_package(GCrypt REQUIRED) +find_packages(OMEMO_VALA_PACKAGES REQUIRED + Gee + GLib + GObject +) + +vala_precompile(OMEMO_VALA_VALA_C +SOURCES + "src/context.vala" + "src/simple_iks.vala" + "src/simple_ss.vala" + "src/simple_pks.vala" + "src/simple_spks.vala" + "src/store.vala" + "src/util.vala" +CUSTOM_VAPIS + ${CMAKE_CURRENT_SOURCE_DIR}/vapi/omemo-public.vapi + ${CMAKE_CURRENT_SOURCE_DIR}/vapi/omemo-native.vapi +PACKAGES + ${OMEMO_VALA_PACKAGES} +GENERATE_VAPI + omemo-vala +GENERATE_HEADER + omemo-vala +) + +set(C_HEADERS_SRC "") +set(C_HEADERS_TARGET "") + +add_subdirectory(libomemo-c EXCLUDE_FROM_ALL) +set_property(TARGET curve25519 PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET protobuf-c PROPERTY POSITION_INDEPENDENT_CODE ON) +set_property(TARGET omemo-c PROPERTY POSITION_INDEPENDENT_CODE ON) + +set(OMEMO_VALA_C_HEADERS + signal_protocol.h + signal_protocol_types.h + curve.h + hkdf.h + ratchet.h + protocol.h + session_state.h + session_record.h + session_pre_key.h + session_builder.h + session_cipher.h + key_helper.h + sender_key.h + sender_key_state.h + sender_key_record.h + group_session_builder.h + group_cipher.h + fingerprint.h + device_consistency.h +) + +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/exports/omemo-vala") + +foreach(f ${OMEMO_VALA_C_HEADERS}) + list(APPEND C_HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/libomemo-c/src/${f}") + list(APPEND C_HEADERS_TARGET "${CMAKE_BINARY_DIR}/exports/omemo/${f}") + add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/omemo/${f}" + COMMAND + cp "${CMAKE_CURRENT_SOURCE_DIR}/libomemo-c/src/${f}" "${CMAKE_BINARY_DIR}/exports/omemo/${f}" + DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/libomemo-c/src/${f}" + COMMENT + Copy header file omemo/${f} + ) +endforeach(f) + +list(APPEND C_HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.h") +list(APPEND C_HEADERS_TARGET "${CMAKE_BINARY_DIR}/exports/signal_helper.h") + +add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/signal_helper.h" +COMMAND + cp "${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.h" "${CMAKE_BINARY_DIR}/exports/signal_helper.h" +DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.h" +COMMENT + Copy header file signal_helper.h +) + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/exports/omemo.vapi +COMMAND + cat "${CMAKE_CURRENT_SOURCE_DIR}/vapi/omemo-public.vapi" "${CMAKE_BINARY_DIR}/exports/omemo-vala.vapi" > "${CMAKE_BINARY_DIR}/exports/omemo.vapi" +DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/vapi/omemo-public.vapi + ${CMAKE_BINARY_DIR}/exports/omemo-vala.vapi +) + +add_custom_target(omemo-vapi +DEPENDS + ${CMAKE_BINARY_DIR}/exports/omemo.vapi + ${CMAKE_BINARY_DIR}/exports/omemo-vala.h + ${C_HEADERS_TARGET} +) + +set(CFLAGS ${VALA_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/libomemo-c/src -I${CMAKE_CURRENT_SOURCE_DIR}/src) +add_definitions(${CFLAGS}) +add_library(omemo-vala ${OMEMO_VALA_VALA_C} ${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.c) +add_dependencies(omemo-vala omemo-vapi) +target_link_libraries(omemo-vala ${OMEMO_VALA_PACKAGES} gcrypt omemo-c m) +set_property(TARGET omemo-vala PROPERTY POSITION_INDEPENDENT_CODE ON) + +if(BUILD_TESTS) + vala_precompile(OMEMO_TEST_VALA_C + SOURCES + "tests/common.vala" + "tests/testcase.vala" + + "tests/curve25519.vala" + "tests/hkdf.vala" + "tests/session_builder.vala" + CUSTOM_VAPIS + ${CMAKE_BINARY_DIR}/exports/omemo-vala_internal.vapi + ${CMAKE_CURRENT_SOURCE_DIR}/vapi/omemo-public.vapi + ${CMAKE_CURRENT_SOURCE_DIR}/vapi/omemo-native.vapi + PACKAGES + ${OMEMO_VALA_PACKAGES} + ) + + set(CFLAGS ${VALA_CFLAGS} -I${CMAKE_CURRENT_BINARY_DIR}/omemo) + add_executable(omemo-vala-test ${OMEMO_TEST_VALA_C}) + add_dependencies(omemo-vala-test omemo-vala) + target_link_libraries(omemo-vala-test omemo-vala ${OMEMO_VALA_PACKAGES}) +endif(BUILD_TESTS) diff --git a/plugins/omemo-vala/libomemo-c b/plugins/omemo-vala/libomemo-c new file mode 160000 index 00000000..0c5c9561 --- /dev/null +++ b/plugins/omemo-vala/libomemo-c @@ -0,0 +1 @@ +Subproject commit 0c5c9561b7e70d8c643460ef2c069255d15a9619 diff --git a/plugins/signal-protocol/src/context.vala b/plugins/omemo-vala/src/context.vala similarity index 98% rename from plugins/signal-protocol/src/context.vala rename to plugins/omemo-vala/src/context.vala index 40a07b0f..bece27e9 100644 --- a/plugins/signal-protocol/src/context.vala +++ b/plugins/omemo-vala/src/context.vala @@ -1,4 +1,4 @@ -namespace Signal { +namespace Omemo { public class Context { internal NativeContext native_context; @@ -30,7 +30,7 @@ public class Context { } public void randomize(uint8[] data) throws Error { - throw_by_code(Signal.native_random(data)); + throw_by_code(native_random(data)); } public SignedPreKeyRecord generate_signed_pre_key(IdentityKeyPair identity_key_pair, int32 id, uint64 timestamp = 0) throws Error { diff --git a/plugins/signal-protocol/src/signal_helper.c b/plugins/omemo-vala/src/signal_helper.c similarity index 100% rename from plugins/signal-protocol/src/signal_helper.c rename to plugins/omemo-vala/src/signal_helper.c diff --git a/plugins/signal-protocol/src/signal_helper.h b/plugins/omemo-vala/src/signal_helper.h similarity index 100% rename from plugins/signal-protocol/src/signal_helper.h rename to plugins/omemo-vala/src/signal_helper.h diff --git a/plugins/signal-protocol/src/simple_iks.vala b/plugins/omemo-vala/src/simple_iks.vala similarity index 98% rename from plugins/signal-protocol/src/simple_iks.vala rename to plugins/omemo-vala/src/simple_iks.vala index 5247c455..6f752d33 100644 --- a/plugins/signal-protocol/src/simple_iks.vala +++ b/plugins/omemo-vala/src/simple_iks.vala @@ -1,6 +1,6 @@ using Gee; -namespace Signal { +namespace Omemo { public class SimpleIdentityKeyStore : IdentityKeyStore { public override Bytes identity_key_private { get; set; } diff --git a/plugins/signal-protocol/src/simple_pks.vala b/plugins/omemo-vala/src/simple_pks.vala similarity index 97% rename from plugins/signal-protocol/src/simple_pks.vala rename to plugins/omemo-vala/src/simple_pks.vala index 1f059fda..c4574a32 100644 --- a/plugins/signal-protocol/src/simple_pks.vala +++ b/plugins/omemo-vala/src/simple_pks.vala @@ -1,6 +1,6 @@ using Gee; -namespace Signal { +namespace Omemo { public class SimplePreKeyStore : PreKeyStore { private Map pre_key_map = new HashMap(); @@ -30,4 +30,4 @@ public class SimplePreKeyStore : PreKeyStore { } } -} \ No newline at end of file +} diff --git a/plugins/signal-protocol/src/simple_spks.vala b/plugins/omemo-vala/src/simple_spks.vala similarity index 98% rename from plugins/signal-protocol/src/simple_spks.vala rename to plugins/omemo-vala/src/simple_spks.vala index f0fe09ab..d9ff3286 100644 --- a/plugins/signal-protocol/src/simple_spks.vala +++ b/plugins/omemo-vala/src/simple_spks.vala @@ -1,6 +1,6 @@ using Gee; -namespace Signal { +namespace Omemo { public class SimpleSignedPreKeyStore : SignedPreKeyStore { private Map pre_key_map = new HashMap(); @@ -30,4 +30,4 @@ public class SimpleSignedPreKeyStore : SignedPreKeyStore { } } -} \ No newline at end of file +} diff --git a/plugins/signal-protocol/src/simple_ss.vala b/plugins/omemo-vala/src/simple_ss.vala similarity index 99% rename from plugins/signal-protocol/src/simple_ss.vala rename to plugins/omemo-vala/src/simple_ss.vala index 5213f736..41e485c7 100644 --- a/plugins/signal-protocol/src/simple_ss.vala +++ b/plugins/omemo-vala/src/simple_ss.vala @@ -1,6 +1,6 @@ using Gee; -namespace Signal { +namespace Omemo { public class SimpleSessionStore : SessionStore { @@ -72,4 +72,4 @@ public class SimpleSessionStore : SessionStore { } } -} \ No newline at end of file +} diff --git a/plugins/signal-protocol/src/store.vala b/plugins/omemo-vala/src/store.vala similarity index 99% rename from plugins/signal-protocol/src/store.vala rename to plugins/omemo-vala/src/store.vala index b440d838..b1861d93 100644 --- a/plugins/signal-protocol/src/store.vala +++ b/plugins/omemo-vala/src/store.vala @@ -1,4 +1,4 @@ -namespace Signal { +namespace Omemo { public abstract class IdentityKeyStore : Object { public abstract Bytes identity_key_private { get; set; } diff --git a/plugins/signal-protocol/src/util.vala b/plugins/omemo-vala/src/util.vala similarity index 98% rename from plugins/signal-protocol/src/util.vala rename to plugins/omemo-vala/src/util.vala index 4c0ae72d..4b3e61f2 100644 --- a/plugins/signal-protocol/src/util.vala +++ b/plugins/omemo-vala/src/util.vala @@ -1,4 +1,4 @@ -namespace Signal { +namespace Omemo { public ECPublicKey generate_public_key(ECPrivateKey private_key) throws Error { ECPublicKey public_key; @@ -42,4 +42,4 @@ internal int catch_to_code(CodeErroringFunc func) { } } -} \ No newline at end of file +} diff --git a/plugins/signal-protocol/tests/common.vala b/plugins/omemo-vala/tests/common.vala similarity index 99% rename from plugins/signal-protocol/tests/common.vala rename to plugins/omemo-vala/tests/common.vala index 9bb9b1dc..af0f7250 100644 --- a/plugins/signal-protocol/tests/common.vala +++ b/plugins/omemo-vala/tests/common.vala @@ -1,4 +1,4 @@ -namespace Signal.Test { +namespace Omemo.Test { int main(string[] args) { GLib.Test.init(ref args); diff --git a/plugins/signal-protocol/tests/curve25519.vala b/plugins/omemo-vala/tests/curve25519.vala similarity index 99% rename from plugins/signal-protocol/tests/curve25519.vala rename to plugins/omemo-vala/tests/curve25519.vala index 6dfae62f..ca554033 100644 --- a/plugins/signal-protocol/tests/curve25519.vala +++ b/plugins/omemo-vala/tests/curve25519.vala @@ -1,4 +1,4 @@ -namespace Signal.Test { +namespace Omemo.Test { class Curve25519 : Gee.TestCase { @@ -204,4 +204,4 @@ class Curve25519 : Gee.TestCase { } -} \ No newline at end of file +} diff --git a/plugins/signal-protocol/tests/hkdf.vala b/plugins/omemo-vala/tests/hkdf.vala similarity index 98% rename from plugins/signal-protocol/tests/hkdf.vala rename to plugins/omemo-vala/tests/hkdf.vala index c30af275..1cd31f0e 100644 --- a/plugins/signal-protocol/tests/hkdf.vala +++ b/plugins/omemo-vala/tests/hkdf.vala @@ -1,4 +1,4 @@ -namespace Signal.Test { +namespace Omemo.Test { class HKDF : Gee.TestCase { @@ -56,4 +56,4 @@ class HKDF : Gee.TestCase { } -} \ No newline at end of file +} diff --git a/plugins/signal-protocol/tests/session_builder.vala b/plugins/omemo-vala/tests/session_builder.vala similarity index 99% rename from plugins/signal-protocol/tests/session_builder.vala rename to plugins/omemo-vala/tests/session_builder.vala index 7e2448e1..66eba561 100644 --- a/plugins/signal-protocol/tests/session_builder.vala +++ b/plugins/omemo-vala/tests/session_builder.vala @@ -1,4 +1,4 @@ -namespace Signal.Test { +namespace Omemo.Test { class SessionBuilderTest : Gee.TestCase { Address alice_address; diff --git a/plugins/signal-protocol/tests/testcase.vala b/plugins/omemo-vala/tests/testcase.vala similarity index 100% rename from plugins/signal-protocol/tests/testcase.vala rename to plugins/omemo-vala/tests/testcase.vala diff --git a/plugins/signal-protocol/vapi/signal-protocol-native.vapi b/plugins/omemo-vala/vapi/omemo-native.vapi similarity index 91% rename from plugins/signal-protocol/vapi/signal-protocol-native.vapi rename to plugins/omemo-vala/vapi/omemo-native.vapi index 0bac0317..3010a9c3 100644 --- a/plugins/signal-protocol/vapi/signal-protocol-native.vapi +++ b/plugins/omemo-vala/vapi/omemo-native.vapi @@ -1,6 +1,6 @@ -namespace Signal { +namespace Omemo { [Compact] - [CCode (cname = "signal_context", cprefix="signal_context_", free_function="signal_context_destroy", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_context", cprefix="signal_context_", free_function="signal_context_destroy", cheader_filename = "omemo/signal_protocol.h")] public class NativeContext { public static int create(out NativeContext context, void* user_data); public int set_crypto_provider(NativeCryptoProvider crypto_provider); @@ -13,7 +13,7 @@ namespace Signal { public delegate void LogFunc(LogLevel level, string message, size_t len, void* user_data); [Compact] - [CCode (cname = "signal_crypto_provider", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_crypto_provider", cheader_filename = "omemo/signal_protocol.h")] public struct NativeCryptoProvider { public RandomFunc random_func; public HmacSha256Init hmac_sha256_init_func; @@ -50,7 +50,7 @@ namespace Signal { public delegate int CryptFunc(out Buffer output, Cipher cipher, uint8[] key, uint8[] iv, uint8[] content, void* user_data); [Compact] - [CCode (cname = "signal_protocol_session_store", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_protocol_session_store", cheader_filename = "omemo/signal_protocol.h")] public struct NativeSessionStore { public LoadSessionFunc load_session_func; public GetSubDeviceSessionsFunc get_sub_device_sessions_func; @@ -75,7 +75,7 @@ namespace Signal { public delegate int DeleteAllSessionsFunc([CCode (array_length_type = "size_t")] char[] name, void* user_data); [Compact] - [CCode (cname = "signal_protocol_identity_key_store", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_protocol_identity_key_store", cheader_filename = "omemo/signal_protocol.h")] public struct NativeIdentityKeyStore { GetIdentityKeyPairFunc get_identity_key_pair; GetLocalRegistrationIdFunc get_local_registration_id; @@ -94,7 +94,7 @@ namespace Signal { public delegate int IsTrustedIdentityFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data); [Compact] - [CCode (cname = "signal_protocol_pre_key_store", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_protocol_pre_key_store", cheader_filename = "omemo/signal_protocol.h")] public struct NativePreKeyStore { LoadPreKeyFunc load_pre_key; StorePreKeyFunc store_pre_key; @@ -114,7 +114,7 @@ namespace Signal { [Compact] - [CCode (cname = "signal_protocol_signed_pre_key_store", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_protocol_signed_pre_key_store", cheader_filename = "omemo/signal_protocol.h")] public struct NativeSignedPreKeyStore { LoadPreKeyFunc load_signed_pre_key; StorePreKeyFunc store_signed_pre_key; @@ -142,7 +142,7 @@ namespace Signal { public delegate void DestroyFunc(void* user_data); [Compact] - [CCode (cname = "signal_protocol_store_context", cprefix = "signal_protocol_store_context_", free_function="signal_protocol_store_context_destroy", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_protocol_store_context", cprefix = "signal_protocol_store_context_", free_function="signal_protocol_store_context_destroy", cheader_filename = "omemo/signal_protocol.h")] public class NativeStoreContext { public static int create(out NativeStoreContext context, NativeContext global_context); public int set_session_store(NativeSessionStore store); @@ -153,7 +153,7 @@ namespace Signal { } - [CCode (cheader_filename = "signal/signal_protocol.h")] + [CCode (cheader_filename = "omemo/signal_protocol.h")] namespace Protocol { /** @@ -162,7 +162,7 @@ namespace Signal { * signal_protocol_store_context instance and operate in terms of higher level * library data structures. */ - [CCode (cprefix = "signal_protocol_pre_key_")] + [CCode (lower_case_cprefix = "signal_protocol_pre_key_")] namespace PreKey { public int load_key(NativeStoreContext context, out PreKeyRecord pre_key, uint32 pre_key_id); public int store_key(NativeStoreContext context, PreKeyRecord pre_key); @@ -170,7 +170,7 @@ namespace Signal { public int remove_key(NativeStoreContext context, uint32 pre_key_id); } - [CCode (cprefix = "signal_protocol_signed_pre_key_")] + [CCode (lower_case_cprefix = "signal_protocol_signed_pre_key_")] namespace SignedPreKey { public int load_key(NativeStoreContext context, out SignedPreKeyRecord pre_key, uint32 pre_key_id); public int store_key(NativeStoreContext context, SignedPreKeyRecord pre_key); @@ -184,9 +184,9 @@ namespace Signal { * signal_protocol_store_context instance and operate in terms of higher level * library data structures. */ - [CCode (cprefix = "signal_protocol_session_")] + [CCode (lower_case_cprefix = "signal_protocol_session_")] namespace Session { - public int load_session(NativeStoreContext context, out SessionRecord record, Address address); + public int load_session(NativeStoreContext context, out SessionRecord record, Address address, int32 version = 2); public int get_sub_device_sessions(NativeStoreContext context, out IntList sessions, char[] name); public int store_session(NativeStoreContext context, Address address, SessionRecord record); public int contains_session(NativeStoreContext context, Address address); @@ -194,6 +194,7 @@ namespace Signal { public int delete_all_sessions(NativeStoreContext context, char[] name); } + [CCode (lower_case_cprefix = "signal_protocol_identity_")] namespace Identity { public int get_key_pair(NativeStoreContext store_context, out IdentityKeyPair key_pair); public int get_local_registration_id(NativeStoreContext store_context, out uint32 registration_id); @@ -201,7 +202,7 @@ namespace Signal { public int is_trusted_identity(NativeStoreContext store_context, Address address, ECPublicKey identity_key); } - [CCode (cheader_filename = "signal/key_helper.h", cprefix = "signal_protocol_key_helper_")] + [CCode (cheader_filename = "omemo/key_helper.h", lower_case_cprefix = "signal_protocol_key_helper_")] namespace KeyHelper { [Compact] [CCode (cname = "signal_protocol_key_helper_pre_key_list_node", cprefix = "signal_protocol_key_helper_key_list_", free_function="signal_protocol_key_helper_key_list_free")] @@ -222,7 +223,7 @@ namespace Signal { } } - [CCode (cheader_filename = "signal/curve.h")] + [CCode (cheader_filename = "omemo/curve.h")] namespace Curve { [CCode (cname = "curve_calculate_agreement")] public int calculate_agreement([CCode (array_length = false)] out uint8[] shared_key_data, ECPublicKey public_key, ECPrivateKey private_key); @@ -232,35 +233,35 @@ namespace Signal { public int verify_signature(ECPublicKey signing_key, uint8[] message, uint8[] signature); } - [CCode (cname = "session_builder_create", cheader_filename = "signal/session_builder.h")] + [CCode (cname = "session_builder_create", cheader_filename = "omemo/session_builder.h")] public static int session_builder_create(out SessionBuilder builder, NativeStoreContext store, Address remote_address, NativeContext global_context); - [CCode (cname = "session_cipher_create", cheader_filename = "signal/session_cipher.h")] + [CCode (cname = "session_cipher_create", cheader_filename = "omemo/session_cipher.h")] public static int session_cipher_create(out SessionCipher cipher, NativeStoreContext store, Address remote_address, NativeContext global_context); - [CCode (cname = "pre_key_signal_message_deserialize", cheader_filename = "signal/protocol.h")] + [CCode (cname = "pre_key_signal_message_deserialize", cheader_filename = "omemo/protocol.h")] public static int pre_key_signal_message_deserialize(out PreKeySignalMessage message, uint8[] data, NativeContext global_context); - [CCode (cname = "pre_key_signal_message_copy", cheader_filename = "signal/protocol.h")] + [CCode (cname = "pre_key_signal_message_copy", cheader_filename = "omemo/protocol.h")] public static int pre_key_signal_message_copy(out PreKeySignalMessage message, PreKeySignalMessage other_message, NativeContext global_context); - [CCode (cname = "signal_message_create", cheader_filename = "signal/protocol.h")] + [CCode (cname = "signal_message_create", cheader_filename = "omemo/protocol.h")] public static int signal_message_create(out SignalMessage message, uint8 message_version, uint8[] mac_key, ECPublicKey sender_ratchet_key, uint32 counter, uint32 previous_counter, uint8[] ciphertext, ECPublicKey sender_identity_key, ECPublicKey receiver_identity_key, NativeContext global_context); - [CCode (cname = "signal_message_deserialize", cheader_filename = "signal/protocol.h")] + [CCode (cname = "signal_message_deserialize", cheader_filename = "omemo/protocol.h")] public static int signal_message_deserialize(out SignalMessage message, uint8[] data, NativeContext global_context); - [CCode (cname = "signal_message_copy", cheader_filename = "signal/protocol.h")] + [CCode (cname = "signal_message_copy", cheader_filename = "omemo/protocol.h")] public static int signal_message_copy(out SignalMessage message, SignalMessage other_message, NativeContext global_context); - [CCode (cname = "curve_generate_key_pair", cheader_filename = "signal/curve.h")] + [CCode (cname = "curve_generate_key_pair", cheader_filename = "omemo/curve.h")] public static int curve_generate_key_pair(NativeContext context, out ECKeyPair key_pair); - [CCode (cname = "curve_decode_private_point", cheader_filename = "signal/curve.h")] + [CCode (cname = "curve_decode_private_point", cheader_filename = "omemo/curve.h")] public static int curve_decode_private_point(out ECPrivateKey public_key, uint8[] key, NativeContext global_context); - [CCode (cname = "curve_decode_point", cheader_filename = "signal/curve.h")] + [CCode (cname = "curve_decode_point", cheader_filename = "omemo/curve.h")] public static int curve_decode_point(out ECPublicKey public_key, uint8[] key, NativeContext global_context); - [CCode (cname = "curve_generate_private_key", cheader_filename = "signal/curve.h")] + [CCode (cname = "curve_generate_private_key", cheader_filename = "omemo/curve.h")] public static int curve_generate_private_key(NativeContext context, out ECPrivateKey private_key); - [CCode (cname = "ratchet_identity_key_pair_deserialize", cheader_filename = "signal/ratchet.h")] + [CCode (cname = "ratchet_identity_key_pair_deserialize", cheader_filename = "omemo/ratchet.h")] public static int ratchet_identity_key_pair_deserialize(out IdentityKeyPair key_pair, uint8[] data, NativeContext global_context); - [CCode (cname = "session_signed_pre_key_deserialize", cheader_filename = "signal/signed_pre_key.h")] + [CCode (cname = "session_signed_pre_key_deserialize", cheader_filename = "omemo/signed_pre_key.h")] public static int session_signed_pre_key_deserialize(out SignedPreKeyRecord pre_key, uint8[] data, NativeContext global_context); [Compact] - [CCode (cname = "hkdf_context", cprefix = "hkdf_", free_function = "hkdf_destroy", cheader_filename = "signal/hkdf.h")] + [CCode (cname = "hkdf_context", cprefix = "hkdf_", free_function = "hkdf_destroy", cheader_filename = "omemo/hkdf.h")] public class NativeHkdfContext { public static int create(out NativeHkdfContext context, int message_version, NativeContext global_context); public int compare(NativeHkdfContext other); diff --git a/plugins/signal-protocol/vapi/signal-protocol-public.vapi b/plugins/omemo-vala/vapi/omemo-public.vapi similarity index 89% rename from plugins/signal-protocol/vapi/signal-protocol-public.vapi rename to plugins/omemo-vala/vapi/omemo-public.vapi index eaf73c0c..03d5fe0d 100644 --- a/plugins/signal-protocol/vapi/signal-protocol-public.vapi +++ b/plugins/omemo-vala/vapi/omemo-public.vapi @@ -1,6 +1,6 @@ -namespace Signal { +namespace Omemo { - [CCode (cname = "int", cprefix = "SG_ERR_", cheader_filename = "signal/signal_protocol.h", has_type_id = false)] + [CCode (cname = "int", cprefix = "SG_ERR_", cheader_filename = "omemo/signal_protocol.h", has_type_id = false)] public enum ErrorCode { [CCode (cname = "SG_SUCCESS")] SUCCESS, @@ -23,10 +23,10 @@ namespace Signal { FP_IDENT_MISMATCH; } - [CCode (cname = "SG_ERR_MINIMUM", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "SG_ERR_MINIMUM", cheader_filename = "omemo/signal_protocol.h")] public const int MIN_ERROR_CODE; - [CCode (cname = "int", cprefix = "SG_LOG_", cheader_filename = "signal/signal_protocol.h", has_type_id = false)] + [CCode (cname = "int", cprefix = "SG_LOG_", cheader_filename = "omemo/signal_protocol.h", has_type_id = false)] public enum LogLevel { ERROR, WARNING, @@ -35,7 +35,7 @@ namespace Signal { DEBUG } - [CCode (cname = "signal_throw_gerror_by_code_", cheader_filename = "signal/signal_protocol.h")] + [CCode (cname = "signal_throw_gerror_by_code_", cheader_filename = "omemo/signal_protocol.h")] private int throw_by_code(int code, string? message = null) throws GLib.Error { if (code < 0 && code > MIN_ERROR_CODE) { throw new GLib.Error(-1, code, "%s: %s", message ?? "Signal error", ((ErrorCode)code).to_string()); @@ -43,7 +43,7 @@ namespace Signal { return code; } - [CCode (cname = "int", cprefix = "SG_CIPHER_", cheader_filename = "signal/signal_protocol.h", has_type_id = false)] + [CCode (cname = "int", cprefix = "SG_CIPHER_", cheader_filename = "omemo/signal_protocol.h", has_type_id = false)] public enum Cipher { AES_CTR_NOPADDING, AES_CBC_PKCS5, @@ -51,12 +51,12 @@ namespace Signal { } [Compact] - [CCode (cname = "signal_type_base", ref_function="signal_type_ref_vapi", unref_function="signal_type_unref_vapi", cheader_filename="signal/signal_protocol_types.h,signal_helper.h")] + [CCode (cname = "signal_type_base", ref_function="signal_type_ref_vapi", unref_function="signal_type_unref_vapi", cheader_filename="omemo/signal_protocol_types.h,signal_helper.h")] public class TypeBase { } [Compact] - [CCode (cname = "signal_buffer", cheader_filename = "signal/signal_protocol_types.h", free_function="signal_buffer_free")] + [CCode (cname = "signal_buffer", cprefix = "signal_buffer_", cheader_filename = "omemo/signal_protocol_types.h", free_function="signal_buffer_free")] public class Buffer { [CCode (cname = "signal_buffer_alloc")] public Buffer(size_t len); @@ -78,7 +78,7 @@ namespace Signal { } [Compact] - [CCode (cname = "signal_int_list", cheader_filename = "signal/signal_protocol_types.h", free_function="signal_int_list_free")] + [CCode (cname = "signal_int_list", cheader_filename = "omemo/signal_protocol_types.h", free_function="signal_int_list_free")] public class IntList { [CCode (cname = "signal_int_list_alloc")] public IntList(); @@ -90,7 +90,7 @@ namespace Signal { } [Compact] - [CCode (cname = "session_builder", cprefix = "session_builder_", free_function="session_builder_free", cheader_filename = "signal/session_builder.h")] + [CCode (cname = "session_builder", cprefix = "session_builder_", free_function="session_builder_free", cheader_filename = "omemo/session_builder.h")] public class SessionBuilder { [CCode (cname = "session_builder_process_pre_key_bundle")] private int process_pre_key_bundle_(PreKeyBundle pre_key_bundle); @@ -101,7 +101,7 @@ namespace Signal { } [Compact] - [CCode (cname = "session_pre_key_bundle", cprefix = "session_pre_key_bundle_", cheader_filename = "signal/session_pre_key.h")] + [CCode (cname = "session_pre_key_bundle", cprefix = "session_pre_key_bundle_", cheader_filename = "omemo/session_pre_key.h")] public class PreKeyBundle : TypeBase { public static int create(out PreKeyBundle bundle, uint32 registration_id, int device_id, uint32 pre_key_id, ECPublicKey? pre_key_public, uint32 signed_pre_key_id, ECPublicKey? signed_pre_key_public, uint8[]? signed_pre_key_signature, ECPublicKey? identity_key); @@ -116,7 +116,7 @@ namespace Signal { } [Compact] - [CCode (cname = "session_pre_key", cprefix = "session_pre_key_", cheader_filename = "signal/session_pre_key.h,signal_helper.h")] + [CCode (cname = "session_pre_key", cprefix = "session_pre_key_", cheader_filename = "omemo/session_pre_key.h,signal_helper.h")] public class PreKeyRecord : TypeBase { public static int create(out PreKeyRecord pre_key, uint32 id, ECKeyPair key_pair); //public static int deserialize(out PreKeyRecord pre_key, uint8[] data, NativeContext global_context); @@ -127,14 +127,14 @@ namespace Signal { } [Compact] - [CCode (cname = "session_record", cprefix = "session_record_", cheader_filename = "signal/signal_protocol_types.h")] + [CCode (cname = "session_record", cprefix = "session_record_", cheader_filename = "omemo/signal_protocol_types.h")] public class SessionRecord : TypeBase { public SessionState state { get; } public Buffer user_record { get; } } [Compact] - [CCode (cname = "session_state", cprefix = "session_state_", cheader_filename = "signal/session_state.h")] + [CCode (cname = "session_state", cprefix = "session_state_", cheader_filename = "omemo/session_state.h")] public class SessionState : TypeBase { //public static int create(out SessionState state, NativeContext context); //public static int deserialize(out SessionState state, uint8[] data, NativeContext context); @@ -157,7 +157,7 @@ namespace Signal { } [Compact] - [CCode (cname = "session_signed_pre_key", cprefix = "session_signed_pre_key_", cheader_filename = "signal/session_pre_key.h")] + [CCode (cname = "session_signed_pre_key", cprefix = "session_signed_pre_key_", cheader_filename = "omemo/session_pre_key.h")] public class SignedPreKeyRecord : TypeBase { public static int create(out SignedPreKeyRecord pre_key, uint32 id, uint64 timestamp, ECKeyPair key_pair, uint8[] signature); [CCode (instance_pos = 2)] @@ -177,7 +177,7 @@ namespace Signal { * Address of an Signal Protocol message recipient */ [Compact] - [CCode (cname = "signal_protocol_address", cprefix = "signal_protocol_address_", cheader_filename = "signal/signal_protocol.h,signal_helper.h")] + [CCode (cname = "signal_protocol_address", cprefix = "signal_protocol_address_", cheader_filename = "omemo/signal_protocol.h,signal_helper.h")] public class Address { public Address(string name, int32 device_id); public int32 device_id { get; set; } @@ -197,7 +197,7 @@ namespace Signal { } [Compact] - [CCode (cname = "ec_public_key", cprefix = "ec_public_key_", cheader_filename = "signal/curve.h,signal_helper.h")] + [CCode (cname = "ec_public_key", cprefix = "ec_public_key_", cheader_filename = "omemo/curve.h,signal_helper.h")] public class ECPublicKey : TypeBase { [CCode (cname = "curve_generate_public_key")] public static int generate(out ECPublicKey public_key, ECPrivateKey private_key); @@ -218,7 +218,7 @@ namespace Signal { } [Compact] - [CCode (cname = "ec_private_key", cprefix = "ec_private_key_", cheader_filename = "signal/curve.h,signal_helper.h")] + [CCode (cname = "ec_private_key", cprefix = "ec_private_key_", cheader_filename = "omemo/curve.h,signal_helper.h")] public class ECPrivateKey : TypeBase { [CCode (instance_pos = 1, cname = "ec_private_key_serialize")] private int serialize_([CCode (pos = 0)] out Buffer buffer); @@ -236,19 +236,19 @@ namespace Signal { } [Compact] - [CCode (cname = "ec_key_pair", cprefix="ec_key_pair_", cheader_filename = "signal/curve.h,signal_helper.h")] + [CCode (cname = "ec_key_pair", cprefix="ec_key_pair_", cheader_filename = "omemo/curve.h,signal_helper.h")] public class ECKeyPair : TypeBase { public static int create(out ECKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key); public ECPublicKey public { get; } public ECPrivateKey private { get; } } - [CCode (cname = "ratchet_message_keys", cheader_filename = "signal/ratchet.h")] + [CCode (cname = "ratchet_message_keys", cheader_filename = "omemo/ratchet.h")] public class MessageKeys { } [Compact] - [CCode (cname = "ratchet_identity_key_pair", cprefix = "ratchet_identity_key_pair_", cheader_filename = "signal/ratchet.h,signal_helper.h")] + [CCode (cname = "ratchet_identity_key_pair", cprefix = "ratchet_identity_key_pair_", cheader_filename = "omemo/ratchet.h,signal_helper.h")] public class IdentityKeyPair : TypeBase { public static int create(out IdentityKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key); public int serialze(out Buffer buffer); @@ -268,7 +268,7 @@ namespace Signal { * that session. */ [Compact] - [CCode (cname = "session_cipher", cprefix = "session_cipher_", cheader_filename = "signal/session_cipher.h", free_function = "session_cipher_free")] + [CCode (cname = "session_cipher", cprefix = "session_cipher_", cheader_filename = "omemo/session_cipher.h", free_function = "session_cipher_free")] public class SessionCipher { public void* user_data { get; set; } public DecryptionCallback decryption_callback { set; } @@ -303,7 +303,7 @@ namespace Signal { public delegate int DecryptionCallback(SessionCipher cipher, Buffer plaintext, void* decrypt_context); } - [CCode (cname = "int", cheader_filename = "signal/protocol.h", has_type_id = false)] + [CCode (cname = "int", cheader_filename = "omemo/protocol.h", has_type_id = false)] public enum CiphertextType { [CCode (cname = "CIPHERTEXT_SIGNAL_TYPE")] SIGNAL, @@ -316,7 +316,7 @@ namespace Signal { } [Compact] - [CCode (cname = "ciphertext_message", cprefix = "ciphertext_message_", cheader_filename = "signal/protocol.h,signal_helper.h")] + [CCode (cname = "ciphertext_message", cprefix = "ciphertext_message_", cheader_filename = "omemo/protocol.h,signal_helper.h")] public abstract class CiphertextMessage : TypeBase { public CiphertextType type { get; } [CCode (cname = "ciphertext_message_get_serialized")] @@ -326,7 +326,7 @@ namespace Signal { }} } [Compact] - [CCode (cname = "signal_message", cprefix = "signal_message_", cheader_filename = "signal/protocol.h,signal_helper.h")] + [CCode (cname = "signal_message", cprefix = "signal_message_", cheader_filename = "omemo/protocol.h,signal_helper.h")] public class SignalMessage : CiphertextMessage { public ECPublicKey sender_ratchet_key { get; } public uint8 message_version { get; } @@ -336,7 +336,7 @@ namespace Signal { public static int is_legacy(uint8[] data); } [Compact] - [CCode (cname = "pre_key_signal_message", cprefix = "pre_key_signal_message_", cheader_filename = "signal/protocol.h,signal_helper.h")] + [CCode (cname = "pre_key_signal_message", cprefix = "pre_key_signal_message_", cheader_filename = "omemo/protocol.h,signal_helper.h")] public class PreKeySignalMessage : CiphertextMessage { public uint8 message_version { get; } public ECPublicKey identity_key { get; } @@ -347,14 +347,14 @@ namespace Signal { public SignalMessage signal_message { get; } } [Compact] - [CCode (cname = "sender_key_message", cprefix = "sender_key_message_", cheader_filename = "signal/protocol.h,signal_helper.h")] + [CCode (cname = "sender_key_message", cprefix = "sender_key_message_", cheader_filename = "omemo/protocol.h,signal_helper.h")] public class SenderKeyMessage : CiphertextMessage { public uint32 key_id { get; } public uint32 iteration { get; } public Buffer ciphertext { get; } } [Compact] - [CCode (cname = "sender_key_distribution_message", cprefix = "sender_key_distribution_message_", cheader_filename = "signal/protocol.h,signal_helper.h")] + [CCode (cname = "sender_key_distribution_message", cprefix = "sender_key_distribution_message_", cheader_filename = "omemo/protocol.h,signal_helper.h")] public class SenderKeyDistributionMessage : CiphertextMessage { public uint32 id { get; } public uint32 iteration { get; } diff --git a/plugins/omemo/CMakeLists.txt b/plugins/omemo/CMakeLists.txt index ca64b353..33402018 100644 --- a/plugins/omemo/CMakeLists.txt +++ b/plugins/omemo/CMakeLists.txt @@ -63,7 +63,7 @@ SOURCES src/ui/util.vala CUSTOM_VAPIS ${CMAKE_BINARY_DIR}/exports/crypto-vala.vapi - ${CMAKE_BINARY_DIR}/exports/signal-protocol.vapi + ${CMAKE_BINARY_DIR}/exports/omemo.vapi ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi ${CMAKE_BINARY_DIR}/exports/qlite.vapi ${CMAKE_BINARY_DIR}/exports/dino.vapi @@ -78,7 +78,7 @@ OPTIONS add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\" -DG_LOG_DOMAIN="OMEMO") add_library(omemo SHARED ${OMEMO_VALA_C} ${OMEMO_GRESOURCES_TARGET}) add_dependencies(omemo ${GETTEXT_PACKAGE}-translations) -target_link_libraries(omemo libdino signal-protocol-vala crypto-vala ${OMEMO_PACKAGES}) +target_link_libraries(omemo libdino omemo-vala crypto-vala ${OMEMO_PACKAGES}) set_target_properties(omemo PROPERTIES PREFIX "") set_target_properties(omemo PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/) diff --git a/plugins/omemo/src/file_transfer/file_decryptor.vala b/plugins/omemo/src/file_transfer/file_decryptor.vala index 3999d3b8..035e5c2d 100644 --- a/plugins/omemo/src/file_transfer/file_decryptor.vala +++ b/plugins/omemo/src/file_transfer/file_decryptor.vala @@ -1,7 +1,7 @@ using Dino.Entities; using Crypto; -using Signal; +using Omemo; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/file_transfer/file_encryptor.vala b/plugins/omemo/src/file_transfer/file_encryptor.vala index 31c3ad6c..bc98ea29 100644 --- a/plugins/omemo/src/file_transfer/file_encryptor.vala +++ b/plugins/omemo/src/file_transfer/file_encryptor.vala @@ -3,8 +3,8 @@ using Gtk; using Crypto; using Dino.Entities; +using Omemo; using Xmpp; -using Signal; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/jingle/jet_omemo.vala b/plugins/omemo/src/jingle/jet_omemo.vala index 2ddf5d33..f845378a 100644 --- a/plugins/omemo/src/jingle/jet_omemo.vala +++ b/plugins/omemo/src/jingle/jet_omemo.vala @@ -2,7 +2,7 @@ using Crypto; using Dino; using Dino.Entities; using Gee; -using Signal; +using Omemo; using Xmpp; using Xmpp.Xep; diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala index 4bb85d59..a66e7b84 100644 --- a/plugins/omemo/src/logic/manager.vala +++ b/plugins/omemo/src/logic/manager.vala @@ -1,5 +1,5 @@ using Dino.Entities; -using Signal; +using Omemo; using Qlite; using Xmpp; using Gee; @@ -348,7 +348,7 @@ public class Manager : StreamInteractionModule, Object { try { store.identity_key_store.local_registration_id = Random.int_range(1, int32.MAX); - Signal.ECKeyPair key_pair = Plugin.get_context().generate_key_pair(); + ECKeyPair key_pair = Plugin.get_context().generate_key_pair(); store.identity_key_store.identity_key_private = new Bytes(key_pair.private.serialize()); store.identity_key_store.identity_key_public = new Bytes(key_pair.public.serialize()); diff --git a/plugins/omemo/src/logic/pre_key_store.vala b/plugins/omemo/src/logic/pre_key_store.vala index 716fd32f..835fad5b 100644 --- a/plugins/omemo/src/logic/pre_key_store.vala +++ b/plugins/omemo/src/logic/pre_key_store.vala @@ -1,4 +1,4 @@ -using Signal; +using Omemo; using Qlite; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/logic/session_store.vala b/plugins/omemo/src/logic/session_store.vala index 654591d1..114ae757 100644 --- a/plugins/omemo/src/logic/session_store.vala +++ b/plugins/omemo/src/logic/session_store.vala @@ -1,4 +1,4 @@ -using Signal; +using Omemo; using Qlite; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/logic/signed_pre_key_store.vala b/plugins/omemo/src/logic/signed_pre_key_store.vala index 8ff54a93..0443872f 100644 --- a/plugins/omemo/src/logic/signed_pre_key_store.vala +++ b/plugins/omemo/src/logic/signed_pre_key_store.vala @@ -1,5 +1,5 @@ using Qlite; -using Signal; +using Omemo; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/logic/trust_manager.vala b/plugins/omemo/src/logic/trust_manager.vala index 1e77fcdd..1e110bf9 100644 --- a/plugins/omemo/src/logic/trust_manager.vala +++ b/plugins/omemo/src/logic/trust_manager.vala @@ -1,7 +1,7 @@ using Dino.Entities; using Gee; using Xmpp; -using Signal; +using Omemo; using Qlite; namespace Dino.Plugins.Omemo { @@ -181,7 +181,7 @@ public class TrustManager { message.body = "[This message is OMEMO encrypted]"; status.encrypted = true; } catch (Error e) { - warning(@"Signal error while encrypting message: $(e.message)\n"); + warning(@"OMEMO error while encrypting message: $(e.message)\n"); message.body = "[OMEMO encryption failed]"; status.encrypted = false; } diff --git a/plugins/omemo/src/plugin.vala b/plugins/omemo/src/plugin.vala index d928994f..4b287238 100644 --- a/plugins/omemo/src/plugin.vala +++ b/plugins/omemo/src/plugin.vala @@ -1,4 +1,5 @@ using Dino.Entities; +using Omemo; extern const string GETTEXT_PACKAGE; extern const string LOCALE_INSTALL_DIR; @@ -7,8 +8,8 @@ namespace Dino.Plugins.Omemo { public class Plugin : RootInterface, Object { public const bool DEBUG = false; - private static Signal.Context? _context; - public static Signal.Context get_context() { + private static Context? _context; + public static Context get_context() { assert(_context != null); return (!)_context; } @@ -16,7 +17,7 @@ public class Plugin : RootInterface, Object { lock(_context) { try { if (_context == null) { - _context = new Signal.Context(DEBUG); + _context = new Context(DEBUG); } return true; } catch (Error e) { diff --git a/plugins/omemo/src/protocol/bundle.vala b/plugins/omemo/src/protocol/bundle.vala index f3bebfcb..48f7ed0e 100644 --- a/plugins/omemo/src/protocol/bundle.vala +++ b/plugins/omemo/src/protocol/bundle.vala @@ -1,5 +1,5 @@ using Gee; -using Signal; +using Omemo; using Xmpp; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/protocol/stream_module.vala b/plugins/omemo/src/protocol/stream_module.vala index 83822ea2..3b796c9e 100644 --- a/plugins/omemo/src/protocol/stream_module.vala +++ b/plugins/omemo/src/protocol/stream_module.vala @@ -1,7 +1,7 @@ using Gee; +using Omemo; using Xmpp; using Xmpp.Xep; -using Signal; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/ui/contact_details_dialog.vala b/plugins/omemo/src/ui/contact_details_dialog.vala index e80d1514..92eed72f 100644 --- a/plugins/omemo/src/ui/contact_details_dialog.vala +++ b/plugins/omemo/src/ui/contact_details_dialog.vala @@ -5,6 +5,7 @@ using Qlite; using Dino.Entities; using Qrencode; using Gdk; +using Omemo; namespace Dino.Plugins.Omemo { @@ -17,7 +18,7 @@ public class ContactDetailsDialog : Gtk.Dialog { private bool own = false; private int own_id = 0; private int identity_id = 0; - private Signal.Store store; + private Store store; private Set displayed_ids = new HashSet(); [GtkChild] private Label automatically_accept_new_label; @@ -167,8 +168,8 @@ public class ContactDetailsDialog : Gtk.Dialog { bool key_active = device[plugin.db.identity_meta.now_active]; if (store != null) { try { - Signal.Address address = new Signal.Address(jid.to_string(), device[plugin.db.identity_meta.device_id]); - Signal.SessionRecord? session = null; + Address address = new Address(jid.to_string(), device[plugin.db.identity_meta.device_id]); + SessionRecord? session = null; if (store.contains_session(address)) { session = store.load_session(address); string session_key_base64 = Base64.encode(session.state.remote_identity_key.serialize()); diff --git a/plugins/signal-protocol/CMakeLists.txt b/plugins/signal-protocol/CMakeLists.txt deleted file mode 100644 index 0ae84111..00000000 --- a/plugins/signal-protocol/CMakeLists.txt +++ /dev/null @@ -1,135 +0,0 @@ -find_package(GCrypt REQUIRED) -find_packages(SIGNAL_PROTOCOL_PACKAGES REQUIRED - Gee - GLib - GObject -) - -vala_precompile(SIGNAL_PROTOCOL_VALA_C -SOURCES - "src/context.vala" - "src/simple_iks.vala" - "src/simple_ss.vala" - "src/simple_pks.vala" - "src/simple_spks.vala" - "src/store.vala" - "src/util.vala" -CUSTOM_VAPIS - ${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-public.vapi - ${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-native.vapi -PACKAGES - ${SIGNAL_PROTOCOL_PACKAGES} -GENERATE_VAPI - signal-protocol-vala -GENERATE_HEADER - signal-protocol-vala -) - -set(C_HEADERS_SRC "") -set(C_HEADERS_TARGET "") - -if(NOT BUILD_LIBSIGNAL_IN_TREE) - # libsignal-protocol-c has a history of breaking compatibility on the patch level - # we'll have to check compatibility for every new release - # distro maintainers may update this dependency after compatibility tests - find_package(SignalProtocol 2.3.2 EXACT REQUIRED) -else() - add_subdirectory(libsignal-protocol-c EXCLUDE_FROM_ALL) - set_property(TARGET curve25519 PROPERTY POSITION_INDEPENDENT_CODE ON) - set_property(TARGET protobuf-c PROPERTY POSITION_INDEPENDENT_CODE ON) - set_property(TARGET signal-protocol-c PROPERTY POSITION_INDEPENDENT_CODE ON) - - set(SIGNAL_PROTOCOL_C_HEADERS - signal_protocol.h - signal_protocol_types.h - curve.h - hkdf.h - ratchet.h - protocol.h - session_state.h - session_record.h - session_pre_key.h - session_builder.h - session_cipher.h - key_helper.h - sender_key.h - sender_key_state.h - sender_key_record.h - group_session_builder.h - group_cipher.h - fingerprint.h - device_consistency.h - ) - - file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/exports/signal") - - foreach(f ${SIGNAL_PROTOCOL_C_HEADERS}) - list(APPEND C_HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/libsignal-protocol-c/src/${f}") - list(APPEND C_HEADERS_TARGET "${CMAKE_BINARY_DIR}/exports/signal/${f}") - add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/signal/${f}" - COMMAND - cp "${CMAKE_CURRENT_SOURCE_DIR}/libsignal-protocol-c/src/${f}" "${CMAKE_BINARY_DIR}/exports/signal/${f}" - DEPENDS - "${CMAKE_CURRENT_SOURCE_DIR}/libsignal-protocol-c/src/${f}" - COMMENT - Copy header file signal/${f} - ) - endforeach(f) -endif() - -list(APPEND C_HEADERS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.h") -list(APPEND C_HEADERS_TARGET "${CMAKE_BINARY_DIR}/exports/signal_helper.h") - -add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/signal_helper.h" -COMMAND - cp "${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.h" "${CMAKE_BINARY_DIR}/exports/signal_helper.h" -DEPENDS - "${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.h" -COMMENT - Copy header file signal_helper.h -) - -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/exports/signal-protocol.vapi -COMMAND - cat "${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-public.vapi" "${CMAKE_BINARY_DIR}/exports/signal-protocol-vala.vapi" > "${CMAKE_BINARY_DIR}/exports/signal-protocol.vapi" -DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-public.vapi - ${CMAKE_BINARY_DIR}/exports/signal-protocol-vala.vapi -) - -add_custom_target(signal-protocol-vapi -DEPENDS - ${CMAKE_BINARY_DIR}/exports/signal-protocol.vapi - ${CMAKE_BINARY_DIR}/exports/signal-protocol-vala.h - ${C_HEADERS_TARGET} -) - -set(CFLAGS ${VALA_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/libsignal-protocol-c/src -I${CMAKE_CURRENT_SOURCE_DIR}/src) -add_definitions(${CFLAGS}) -add_library(signal-protocol-vala ${SIGNAL_PROTOCOL_VALA_C} ${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.c) -add_dependencies(signal-protocol-vala signal-protocol-vapi) -target_link_libraries(signal-protocol-vala ${SIGNAL_PROTOCOL_PACKAGES} gcrypt signal-protocol-c m) -set_property(TARGET signal-protocol-vala PROPERTY POSITION_INDEPENDENT_CODE ON) - -if(BUILD_TESTS) - vala_precompile(SIGNAL_TEST_VALA_C - SOURCES - "tests/common.vala" - "tests/testcase.vala" - - "tests/curve25519.vala" - "tests/hkdf.vala" - "tests/session_builder.vala" - CUSTOM_VAPIS - ${CMAKE_BINARY_DIR}/exports/signal-protocol-vala_internal.vapi - ${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-public.vapi - ${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-native.vapi - PACKAGES - ${SIGNAL_PROTOCOL_PACKAGES} - ) - - set(CFLAGS ${VALA_CFLAGS} -I${CMAKE_CURRENT_BINARY_DIR}/signal-protocol) - add_executable(signal-protocol-vala-test ${SIGNAL_TEST_VALA_C}) - add_dependencies(signal-protocol-vala-test signal-protocol-vala) - target_link_libraries(signal-protocol-vala-test signal-protocol-vala ${SIGNAL_PROTOCOL_PACKAGES}) -endif(BUILD_TESTS) diff --git a/plugins/signal-protocol/libsignal-protocol-c b/plugins/signal-protocol/libsignal-protocol-c deleted file mode 160000 index 4a137eaf..00000000 --- a/plugins/signal-protocol/libsignal-protocol-c +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4a137eaf4eb4421949e2e1dde9f11ec7bc07b88f