Use libomemo-c

This commit is contained in:
Marvin W 2020-03-28 14:43:41 +01:00
parent 12cd56612d
commit 615e383786
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
35 changed files with 231 additions and 236 deletions

7
.gitmodules vendored
View file

@ -1,4 +1,3 @@
[submodule "libsignal-protocol-c"] [submodule "libomemo-c"]
path = plugins/signal-protocol/libsignal-protocol-c path = plugins/omemo-vala/libomemo-c
url = https://github.com/WhisperSystems/libsignal-protocol-c.git url = https://github.com/mar-v-in/libomemo-c.git
branch = v2.3.2

View file

@ -9,8 +9,8 @@ endif(DINO_PLUGIN_ENABLED_openpgp)
if(DINO_PLUGIN_ENABLED_omemo) if(DINO_PLUGIN_ENABLED_omemo)
add_subdirectory(crypto-vala) add_subdirectory(crypto-vala)
add_subdirectory(omemo-vala)
add_subdirectory(omemo) add_subdirectory(omemo)
add_subdirectory(signal-protocol)
endif(DINO_PLUGIN_ENABLED_omemo) endif(DINO_PLUGIN_ENABLED_omemo)
if(DINO_PLUGIN_ENABLED_notification-sound) if(DINO_PLUGIN_ENABLED_notification-sound)

View file

@ -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)

@ -0,0 +1 @@
Subproject commit 0c5c9561b7e70d8c643460ef2c069255d15a9619

View file

@ -1,4 +1,4 @@
namespace Signal { namespace Omemo {
public class Context { public class Context {
internal NativeContext native_context; internal NativeContext native_context;
@ -30,7 +30,7 @@ public class Context {
} }
public void randomize(uint8[] data) throws Error { 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 { public SignedPreKeyRecord generate_signed_pre_key(IdentityKeyPair identity_key_pair, int32 id, uint64 timestamp = 0) throws Error {

View file

@ -1,6 +1,6 @@
using Gee; using Gee;
namespace Signal { namespace Omemo {
public class SimpleIdentityKeyStore : IdentityKeyStore { public class SimpleIdentityKeyStore : IdentityKeyStore {
public override Bytes identity_key_private { get; set; } public override Bytes identity_key_private { get; set; }

View file

@ -1,6 +1,6 @@
using Gee; using Gee;
namespace Signal { namespace Omemo {
public class SimplePreKeyStore : PreKeyStore { public class SimplePreKeyStore : PreKeyStore {
private Map<uint32, PreKeyStore.Key> pre_key_map = new HashMap<uint32, PreKeyStore.Key>(); private Map<uint32, PreKeyStore.Key> pre_key_map = new HashMap<uint32, PreKeyStore.Key>();

View file

@ -1,6 +1,6 @@
using Gee; using Gee;
namespace Signal { namespace Omemo {
public class SimpleSignedPreKeyStore : SignedPreKeyStore { public class SimpleSignedPreKeyStore : SignedPreKeyStore {
private Map<uint32, SignedPreKeyStore.Key> pre_key_map = new HashMap<uint32, SignedPreKeyStore.Key>(); private Map<uint32, SignedPreKeyStore.Key> pre_key_map = new HashMap<uint32, SignedPreKeyStore.Key>();

View file

@ -1,6 +1,6 @@
using Gee; using Gee;
namespace Signal { namespace Omemo {
public class SimpleSessionStore : SessionStore { public class SimpleSessionStore : SessionStore {

View file

@ -1,4 +1,4 @@
namespace Signal { namespace Omemo {
public abstract class IdentityKeyStore : Object { public abstract class IdentityKeyStore : Object {
public abstract Bytes identity_key_private { get; set; } public abstract Bytes identity_key_private { get; set; }

View file

@ -1,4 +1,4 @@
namespace Signal { namespace Omemo {
public ECPublicKey generate_public_key(ECPrivateKey private_key) throws Error { public ECPublicKey generate_public_key(ECPrivateKey private_key) throws Error {
ECPublicKey public_key; ECPublicKey public_key;

View file

@ -1,4 +1,4 @@
namespace Signal.Test { namespace Omemo.Test {
int main(string[] args) { int main(string[] args) {
GLib.Test.init(ref args); GLib.Test.init(ref args);

View file

@ -1,4 +1,4 @@
namespace Signal.Test { namespace Omemo.Test {
class Curve25519 : Gee.TestCase { class Curve25519 : Gee.TestCase {

View file

@ -1,4 +1,4 @@
namespace Signal.Test { namespace Omemo.Test {
class HKDF : Gee.TestCase { class HKDF : Gee.TestCase {

View file

@ -1,4 +1,4 @@
namespace Signal.Test { namespace Omemo.Test {
class SessionBuilderTest : Gee.TestCase { class SessionBuilderTest : Gee.TestCase {
Address alice_address; Address alice_address;

View file

@ -1,6 +1,6 @@
namespace Signal { namespace Omemo {
[Compact] [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 class NativeContext {
public static int create(out NativeContext context, void* user_data); public static int create(out NativeContext context, void* user_data);
public int set_crypto_provider(NativeCryptoProvider crypto_provider); 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); public delegate void LogFunc(LogLevel level, string message, size_t len, void* user_data);
[Compact] [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 struct NativeCryptoProvider {
public RandomFunc random_func; public RandomFunc random_func;
public HmacSha256Init hmac_sha256_init_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); public delegate int CryptFunc(out Buffer output, Cipher cipher, uint8[] key, uint8[] iv, uint8[] content, void* user_data);
[Compact] [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 struct NativeSessionStore {
public LoadSessionFunc load_session_func; public LoadSessionFunc load_session_func;
public GetSubDeviceSessionsFunc get_sub_device_sessions_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); public delegate int DeleteAllSessionsFunc([CCode (array_length_type = "size_t")] char[] name, void* user_data);
[Compact] [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 { public struct NativeIdentityKeyStore {
GetIdentityKeyPairFunc get_identity_key_pair; GetIdentityKeyPairFunc get_identity_key_pair;
GetLocalRegistrationIdFunc get_local_registration_id; 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); public delegate int IsTrustedIdentityFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data);
[Compact] [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 { public struct NativePreKeyStore {
LoadPreKeyFunc load_pre_key; LoadPreKeyFunc load_pre_key;
StorePreKeyFunc store_pre_key; StorePreKeyFunc store_pre_key;
@ -114,7 +114,7 @@ namespace Signal {
[Compact] [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 { public struct NativeSignedPreKeyStore {
LoadPreKeyFunc load_signed_pre_key; LoadPreKeyFunc load_signed_pre_key;
StorePreKeyFunc store_signed_pre_key; StorePreKeyFunc store_signed_pre_key;
@ -142,7 +142,7 @@ namespace Signal {
public delegate void DestroyFunc(void* user_data); public delegate void DestroyFunc(void* user_data);
[Compact] [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 class NativeStoreContext {
public static int create(out NativeStoreContext context, NativeContext global_context); public static int create(out NativeStoreContext context, NativeContext global_context);
public int set_session_store(NativeSessionStore store); 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 { namespace Protocol {
/** /**
@ -162,7 +162,7 @@ namespace Signal {
* signal_protocol_store_context instance and operate in terms of higher level * signal_protocol_store_context instance and operate in terms of higher level
* library data structures. * library data structures.
*/ */
[CCode (cprefix = "signal_protocol_pre_key_")] [CCode (lower_case_cprefix = "signal_protocol_pre_key_")]
namespace PreKey { namespace PreKey {
public int load_key(NativeStoreContext context, out PreKeyRecord pre_key, uint32 pre_key_id); public int load_key(NativeStoreContext context, out PreKeyRecord pre_key, uint32 pre_key_id);
public int store_key(NativeStoreContext context, PreKeyRecord pre_key); 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); 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 { namespace SignedPreKey {
public int load_key(NativeStoreContext context, out SignedPreKeyRecord pre_key, uint32 pre_key_id); public int load_key(NativeStoreContext context, out SignedPreKeyRecord pre_key, uint32 pre_key_id);
public int store_key(NativeStoreContext context, SignedPreKeyRecord pre_key); 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 * signal_protocol_store_context instance and operate in terms of higher level
* library data structures. * library data structures.
*/ */
[CCode (cprefix = "signal_protocol_session_")] [CCode (lower_case_cprefix = "signal_protocol_session_")]
namespace 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 get_sub_device_sessions(NativeStoreContext context, out IntList sessions, char[] name);
public int store_session(NativeStoreContext context, Address address, SessionRecord record); public int store_session(NativeStoreContext context, Address address, SessionRecord record);
public int contains_session(NativeStoreContext context, Address address); public int contains_session(NativeStoreContext context, Address address);
@ -194,6 +194,7 @@ namespace Signal {
public int delete_all_sessions(NativeStoreContext context, char[] name); public int delete_all_sessions(NativeStoreContext context, char[] name);
} }
[CCode (lower_case_cprefix = "signal_protocol_identity_")]
namespace Identity { namespace Identity {
public int get_key_pair(NativeStoreContext store_context, out IdentityKeyPair key_pair); 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); 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); 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 { namespace KeyHelper {
[Compact] [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")] [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 { namespace Curve {
[CCode (cname = "curve_calculate_agreement")] [CCode (cname = "curve_calculate_agreement")]
public int calculate_agreement([CCode (array_length = false)] out uint8[] shared_key_data, ECPublicKey public_key, ECPrivateKey private_key); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); public static int session_signed_pre_key_deserialize(out SignedPreKeyRecord pre_key, uint8[] data, NativeContext global_context);
[Compact] [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 class NativeHkdfContext {
public static int create(out NativeHkdfContext context, int message_version, NativeContext global_context); public static int create(out NativeHkdfContext context, int message_version, NativeContext global_context);
public int compare(NativeHkdfContext other); public int compare(NativeHkdfContext other);

View file

@ -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 { public enum ErrorCode {
[CCode (cname = "SG_SUCCESS")] [CCode (cname = "SG_SUCCESS")]
SUCCESS, SUCCESS,
@ -23,10 +23,10 @@ namespace Signal {
FP_IDENT_MISMATCH; 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; 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 { public enum LogLevel {
ERROR, ERROR,
WARNING, WARNING,
@ -35,7 +35,7 @@ namespace Signal {
DEBUG 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 { private int throw_by_code(int code, string? message = null) throws GLib.Error {
if (code < 0 && code > MIN_ERROR_CODE) { if (code < 0 && code > MIN_ERROR_CODE) {
throw new GLib.Error(-1, code, "%s: %s", message ?? "Signal error", ((ErrorCode)code).to_string()); throw new GLib.Error(-1, code, "%s: %s", message ?? "Signal error", ((ErrorCode)code).to_string());
@ -43,7 +43,7 @@ namespace Signal {
return code; 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 { public enum Cipher {
AES_CTR_NOPADDING, AES_CTR_NOPADDING,
AES_CBC_PKCS5, AES_CBC_PKCS5,
@ -51,12 +51,12 @@ namespace Signal {
} }
[Compact] [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 { public class TypeBase {
} }
[Compact] [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 { public class Buffer {
[CCode (cname = "signal_buffer_alloc")] [CCode (cname = "signal_buffer_alloc")]
public Buffer(size_t len); public Buffer(size_t len);
@ -78,7 +78,7 @@ namespace Signal {
} }
[Compact] [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 { public class IntList {
[CCode (cname = "signal_int_list_alloc")] [CCode (cname = "signal_int_list_alloc")]
public IntList(); public IntList();
@ -90,7 +90,7 @@ namespace Signal {
} }
[Compact] [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 { public class SessionBuilder {
[CCode (cname = "session_builder_process_pre_key_bundle")] [CCode (cname = "session_builder_process_pre_key_bundle")]
private int process_pre_key_bundle_(PreKeyBundle pre_key_bundle); private int process_pre_key_bundle_(PreKeyBundle pre_key_bundle);
@ -101,7 +101,7 @@ namespace Signal {
} }
[Compact] [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 class PreKeyBundle : TypeBase {
public static int create(out PreKeyBundle bundle, uint32 registration_id, int device_id, uint32 pre_key_id, ECPublicKey? pre_key_public, 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); 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] [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 class PreKeyRecord : TypeBase {
public static int create(out PreKeyRecord pre_key, uint32 id, ECKeyPair key_pair); 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); //public static int deserialize(out PreKeyRecord pre_key, uint8[] data, NativeContext global_context);
@ -127,14 +127,14 @@ namespace Signal {
} }
[Compact] [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 class SessionRecord : TypeBase {
public SessionState state { get; } public SessionState state { get; }
public Buffer user_record { get; } public Buffer user_record { get; }
} }
[Compact] [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 class SessionState : TypeBase {
//public static int create(out SessionState state, NativeContext context); //public static int create(out SessionState state, NativeContext context);
//public static int deserialize(out SessionState state, uint8[] data, NativeContext context); //public static int deserialize(out SessionState state, uint8[] data, NativeContext context);
@ -157,7 +157,7 @@ namespace Signal {
} }
[Compact] [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 class SignedPreKeyRecord : TypeBase {
public static int create(out SignedPreKeyRecord pre_key, uint32 id, uint64 timestamp, ECKeyPair key_pair, uint8[] signature); public static int create(out SignedPreKeyRecord pre_key, uint32 id, uint64 timestamp, ECKeyPair key_pair, uint8[] signature);
[CCode (instance_pos = 2)] [CCode (instance_pos = 2)]
@ -177,7 +177,7 @@ namespace Signal {
* Address of an Signal Protocol message recipient * Address of an Signal Protocol message recipient
*/ */
[Compact] [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 class Address {
public Address(string name, int32 device_id); public Address(string name, int32 device_id);
public int32 device_id { get; set; } public int32 device_id { get; set; }
@ -197,7 +197,7 @@ namespace Signal {
} }
[Compact] [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 { public class ECPublicKey : TypeBase {
[CCode (cname = "curve_generate_public_key")] [CCode (cname = "curve_generate_public_key")]
public static int generate(out ECPublicKey public_key, ECPrivateKey private_key); public static int generate(out ECPublicKey public_key, ECPrivateKey private_key);
@ -218,7 +218,7 @@ namespace Signal {
} }
[Compact] [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 { public class ECPrivateKey : TypeBase {
[CCode (instance_pos = 1, cname = "ec_private_key_serialize")] [CCode (instance_pos = 1, cname = "ec_private_key_serialize")]
private int serialize_([CCode (pos = 0)] out Buffer buffer); private int serialize_([CCode (pos = 0)] out Buffer buffer);
@ -236,19 +236,19 @@ namespace Signal {
} }
[Compact] [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 class ECKeyPair : TypeBase {
public static int create(out ECKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key); public static int create(out ECKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
public ECPublicKey public { get; } public ECPublicKey public { get; }
public ECPrivateKey private { 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 { public class MessageKeys {
} }
[Compact] [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 class IdentityKeyPair : TypeBase {
public static int create(out IdentityKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key); public static int create(out IdentityKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
public int serialze(out Buffer buffer); public int serialze(out Buffer buffer);
@ -268,7 +268,7 @@ namespace Signal {
* that session. * that session.
*/ */
[Compact] [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 class SessionCipher {
public void* user_data { get; set; } public void* user_data { get; set; }
public DecryptionCallback decryption_callback { set; } public DecryptionCallback decryption_callback { set; }
@ -303,7 +303,7 @@ namespace Signal {
public delegate int DecryptionCallback(SessionCipher cipher, Buffer plaintext, void* decrypt_context); 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 { public enum CiphertextType {
[CCode (cname = "CIPHERTEXT_SIGNAL_TYPE")] [CCode (cname = "CIPHERTEXT_SIGNAL_TYPE")]
SIGNAL, SIGNAL,
@ -316,7 +316,7 @@ namespace Signal {
} }
[Compact] [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 abstract class CiphertextMessage : TypeBase {
public CiphertextType type { get; } public CiphertextType type { get; }
[CCode (cname = "ciphertext_message_get_serialized")] [CCode (cname = "ciphertext_message_get_serialized")]
@ -326,7 +326,7 @@ namespace Signal {
}} }}
} }
[Compact] [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 class SignalMessage : CiphertextMessage {
public ECPublicKey sender_ratchet_key { get; } public ECPublicKey sender_ratchet_key { get; }
public uint8 message_version { get; } public uint8 message_version { get; }
@ -336,7 +336,7 @@ namespace Signal {
public static int is_legacy(uint8[] data); public static int is_legacy(uint8[] data);
} }
[Compact] [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 class PreKeySignalMessage : CiphertextMessage {
public uint8 message_version { get; } public uint8 message_version { get; }
public ECPublicKey identity_key { get; } public ECPublicKey identity_key { get; }
@ -347,14 +347,14 @@ namespace Signal {
public SignalMessage signal_message { get; } public SignalMessage signal_message { get; }
} }
[Compact] [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 class SenderKeyMessage : CiphertextMessage {
public uint32 key_id { get; } public uint32 key_id { get; }
public uint32 iteration { get; } public uint32 iteration { get; }
public Buffer ciphertext { get; } public Buffer ciphertext { get; }
} }
[Compact] [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 class SenderKeyDistributionMessage : CiphertextMessage {
public uint32 id { get; } public uint32 id { get; }
public uint32 iteration { get; } public uint32 iteration { get; }

View file

@ -63,7 +63,7 @@ SOURCES
src/ui/util.vala src/ui/util.vala
CUSTOM_VAPIS CUSTOM_VAPIS
${CMAKE_BINARY_DIR}/exports/crypto-vala.vapi ${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/xmpp-vala.vapi
${CMAKE_BINARY_DIR}/exports/qlite.vapi ${CMAKE_BINARY_DIR}/exports/qlite.vapi
${CMAKE_BINARY_DIR}/exports/dino.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_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_library(omemo SHARED ${OMEMO_VALA_C} ${OMEMO_GRESOURCES_TARGET})
add_dependencies(omemo ${GETTEXT_PACKAGE}-translations) 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 PREFIX "")
set_target_properties(omemo PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/) set_target_properties(omemo PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/)

View file

@ -1,7 +1,7 @@
using Dino.Entities; using Dino.Entities;
using Crypto; using Crypto;
using Signal; using Omemo;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {

View file

@ -3,8 +3,8 @@ using Gtk;
using Crypto; using Crypto;
using Dino.Entities; using Dino.Entities;
using Omemo;
using Xmpp; using Xmpp;
using Signal;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {

View file

@ -2,7 +2,7 @@ using Crypto;
using Dino; using Dino;
using Dino.Entities; using Dino.Entities;
using Gee; using Gee;
using Signal; using Omemo;
using Xmpp; using Xmpp;
using Xmpp.Xep; using Xmpp.Xep;

View file

@ -1,5 +1,5 @@
using Dino.Entities; using Dino.Entities;
using Signal; using Omemo;
using Qlite; using Qlite;
using Xmpp; using Xmpp;
using Gee; using Gee;
@ -348,7 +348,7 @@ public class Manager : StreamInteractionModule, Object {
try { try {
store.identity_key_store.local_registration_id = Random.int_range(1, int32.MAX); 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_private = new Bytes(key_pair.private.serialize());
store.identity_key_store.identity_key_public = new Bytes(key_pair.public.serialize()); store.identity_key_store.identity_key_public = new Bytes(key_pair.public.serialize());

View file

@ -1,4 +1,4 @@
using Signal; using Omemo;
using Qlite; using Qlite;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {

View file

@ -1,4 +1,4 @@
using Signal; using Omemo;
using Qlite; using Qlite;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {

View file

@ -1,5 +1,5 @@
using Qlite; using Qlite;
using Signal; using Omemo;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {

View file

@ -1,7 +1,7 @@
using Dino.Entities; using Dino.Entities;
using Gee; using Gee;
using Xmpp; using Xmpp;
using Signal; using Omemo;
using Qlite; using Qlite;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {
@ -181,7 +181,7 @@ public class TrustManager {
message.body = "[This message is OMEMO encrypted]"; message.body = "[This message is OMEMO encrypted]";
status.encrypted = true; status.encrypted = true;
} catch (Error e) { } 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]"; message.body = "[OMEMO encryption failed]";
status.encrypted = false; status.encrypted = false;
} }

View file

@ -1,4 +1,5 @@
using Dino.Entities; using Dino.Entities;
using Omemo;
extern const string GETTEXT_PACKAGE; extern const string GETTEXT_PACKAGE;
extern const string LOCALE_INSTALL_DIR; extern const string LOCALE_INSTALL_DIR;
@ -7,8 +8,8 @@ namespace Dino.Plugins.Omemo {
public class Plugin : RootInterface, Object { public class Plugin : RootInterface, Object {
public const bool DEBUG = false; public const bool DEBUG = false;
private static Signal.Context? _context; private static Context? _context;
public static Signal.Context get_context() { public static Context get_context() {
assert(_context != null); assert(_context != null);
return (!)_context; return (!)_context;
} }
@ -16,7 +17,7 @@ public class Plugin : RootInterface, Object {
lock(_context) { lock(_context) {
try { try {
if (_context == null) { if (_context == null) {
_context = new Signal.Context(DEBUG); _context = new Context(DEBUG);
} }
return true; return true;
} catch (Error e) { } catch (Error e) {

View file

@ -1,5 +1,5 @@
using Gee; using Gee;
using Signal; using Omemo;
using Xmpp; using Xmpp;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {

View file

@ -1,7 +1,7 @@
using Gee; using Gee;
using Omemo;
using Xmpp; using Xmpp;
using Xmpp.Xep; using Xmpp.Xep;
using Signal;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {

View file

@ -5,6 +5,7 @@ using Qlite;
using Dino.Entities; using Dino.Entities;
using Qrencode; using Qrencode;
using Gdk; using Gdk;
using Omemo;
namespace Dino.Plugins.Omemo { namespace Dino.Plugins.Omemo {
@ -17,7 +18,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
private bool own = false; private bool own = false;
private int own_id = 0; private int own_id = 0;
private int identity_id = 0; private int identity_id = 0;
private Signal.Store store; private Store store;
private Set<uint32> displayed_ids = new HashSet<uint32>(); private Set<uint32> displayed_ids = new HashSet<uint32>();
[GtkChild] private Label automatically_accept_new_label; [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]; bool key_active = device[plugin.db.identity_meta.now_active];
if (store != null) { if (store != null) {
try { try {
Signal.Address address = new Signal.Address(jid.to_string(), device[plugin.db.identity_meta.device_id]); Address address = new Address(jid.to_string(), device[plugin.db.identity_meta.device_id]);
Signal.SessionRecord? session = null; SessionRecord? session = null;
if (store.contains_session(address)) { if (store.contains_session(address)) {
session = store.load_session(address); session = store.load_session(address);
string session_key_base64 = Base64.encode(session.state.remote_identity_key.serialize()); string session_key_base64 = Base64.encode(session.state.remote_identity_key.serialize());

View file

@ -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)

@ -1 +0,0 @@
Subproject commit 4a137eaf4eb4421949e2e1dde9f11ec7bc07b88f