diff options
Diffstat (limited to 'plugins/omemo/src')
24 files changed, 67 insertions, 53 deletions
diff --git a/plugins/omemo/src/dtls_srtp_verification_draft.vala b/plugins/omemo/src/dtls_srtp_verification_draft.vala index cc775977..c0b76524 100644 --- a/plugins/omemo/src/dtls_srtp_verification_draft.vala +++ b/plugins/omemo/src/dtls_srtp_verification_draft.vala @@ -1,4 +1,4 @@ -using Signal; +using Omemo; using Gee; using Xmpp; diff --git a/plugins/omemo/src/file_transfer/file_decryptor.vala b/plugins/omemo/src/file_transfer/file_decryptor.vala index 97d61899..80303789 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 39af8292..53e394b7 100644 --- a/plugins/omemo/src/file_transfer/file_encryptor.vala +++ b/plugins/omemo/src/file_transfer/file_encryptor.vala @@ -4,7 +4,7 @@ using Gtk; using Crypto; using Dino.Entities; using Xmpp; -using Signal; +using Omemo; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/jingle/jet_omemo.vala b/plugins/omemo/src/jingle/jet_omemo.vala index afcdfcd6..2c364625 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/decrypt.vala b/plugins/omemo/src/logic/decrypt.vala index 04339c93..9e5b739a 100644 --- a/plugins/omemo/src/logic/decrypt.vala +++ b/plugins/omemo/src/logic/decrypt.vala @@ -1,7 +1,7 @@ using Dino.Entities; using Qlite; using Gee; -using Signal; +using Omemo; using Xmpp; namespace Dino.Plugins.Omemo { @@ -91,7 +91,7 @@ namespace Dino.Plugins.Omemo { possible_jids.add(message.real_jid.bare_jid); } else if (data.is_prekey) { // pre key messages do store the identity key, so we can use that to find the real jid - PreKeySignalMessage msg = Plugin.get_context().deserialize_pre_key_signal_message(data.encrypted_key); + PreKeyOmemoMessage msg = Plugin.get_context().deserialize_signal_pre_key_message(data.encrypted_key); string identity_key = Base64.encode(msg.identity_key.serialize()); foreach (Row row in db.identity_meta.get_with_device_id(identity_id, data.sid).with(db.identity_meta.identity_key_public_base64, "=", identity_key)) { try { @@ -124,7 +124,7 @@ namespace Dino.Plugins.Omemo { if (data.is_prekey) { int identity_id = db.identity.get_id(account.id); - PreKeySignalMessage msg = Plugin.get_context().deserialize_pre_key_signal_message(encrypted_key); + PreKeyOmemoMessage msg = Plugin.get_context().deserialize_signal_pre_key_message(encrypted_key); string identity_key = Base64.encode(msg.identity_key.serialize()); bool ok = update_db_for_prekey(identity_id, identity_key, from_jid, sid); @@ -132,13 +132,13 @@ namespace Dino.Plugins.Omemo { debug("Starting new session for decryption with device from %s/%d", from_jid.to_string(), sid); SessionCipher cipher = store.create_session_cipher(address); - key = cipher.decrypt_pre_key_signal_message(msg); + key = cipher.decrypt_pre_key_message(msg); // TODO: Finish session } else { debug("Continuing session for decryption with device from %s/%d", from_jid.to_string(), sid); - SignalMessage msg = Plugin.get_context().deserialize_signal_message(encrypted_key); + OmemoMessage msg = Plugin.get_context().deserialize_signal_message(encrypted_key); SessionCipher cipher = store.create_session_cipher(address); - key = cipher.decrypt_signal_message(msg); + key = cipher.decrypt_message(msg); } if (key.length >= 32) { diff --git a/plugins/omemo/src/logic/encrypt.vala b/plugins/omemo/src/logic/encrypt.vala index cd994c3a..e5d11c69 100644 --- a/plugins/omemo/src/logic/encrypt.vala +++ b/plugins/omemo/src/logic/encrypt.vala @@ -1,5 +1,5 @@ using Gee; -using Signal; +using Omemo; using Dino.Entities; using Xmpp; using Xmpp.Xep.Omemo; @@ -59,7 +59,7 @@ namespace Dino.Plugins.Omemo { message.body = "[This message is OMEMO encrypted]"; status.encrypted = true; } catch (Error e) { - warning(@"Signal error while encrypting message: $(e.message)\n"); + warning(@"error while encrypting message: $(e.message)\n"); message.body = "[OMEMO encryption failed]"; status.encrypted = false; } diff --git a/plugins/omemo/src/logic/manager.vala b/plugins/omemo/src/logic/manager.vala index ba02bab5..cad6729e 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; @@ -361,7 +361,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 27e5c01d..c15acc84 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 2c7ef642..ea5738fd 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 08f115c9..d73cbe71 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 cae88eef..8cf1ddeb 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 { diff --git a/plugins/omemo/src/signal/context.vala b/plugins/omemo/src/native/context.vala index 40a07b0f..b1f5945b 100644 --- a/plugins/omemo/src/signal/context.vala +++ b/plugins/omemo/src/native/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 { @@ -75,27 +75,39 @@ public class Context { return signature.data; } - public SignalMessage deserialize_signal_message(uint8[] data) throws Error { - SignalMessage res; - throw_by_code(signal_message_deserialize(out res, data, native_context)); + public OmemoMessage deserialize_signal_message(uint8[] data) throws Error { + OmemoMessage res; + throw_by_code(message_deserialize(out res, data, native_context)); return res; } - public SignalMessage copy_signal_message(CiphertextMessage original) throws Error { - SignalMessage res; - throw_by_code(signal_message_copy(out res, (SignalMessage) original, native_context)); + public OmemoMessage deserialize_omemo_message(uint8[] data) throws Error { + OmemoMessage res; + throw_by_code(message_deserialize_omemo(out res, data, native_context)); return res; } - public PreKeySignalMessage deserialize_pre_key_signal_message(uint8[] data) throws Error { - PreKeySignalMessage res; - throw_by_code(pre_key_signal_message_deserialize(out res, data, native_context)); + public OmemoMessage copy_message(CiphertextMessage original) throws Error { + OmemoMessage res; + throw_by_code(message_copy(out res, (OmemoMessage) original, native_context)); return res; } - public PreKeySignalMessage copy_pre_key_signal_message(CiphertextMessage original) throws Error { - PreKeySignalMessage res; - throw_by_code(pre_key_signal_message_copy(out res, (PreKeySignalMessage) original, native_context)); + public PreKeyOmemoMessage deserialize_signal_pre_key_message(uint8[] data) throws Error { + PreKeyOmemoMessage res; + throw_by_code(pre_key_message_deserialize(out res, data, native_context)); + return res; + } + + public PreKeyOmemoMessage deserialize_omemo_pre_key_message(uint8[] data, uint32 remote_registration_id) throws Error { + PreKeyOmemoMessage res; + throw_by_code(pre_key_message_deserialize_omemo(out res, data, remote_registration_id, native_context)); + return res; + } + + public PreKeyOmemoMessage copy_pre_key_message(CiphertextMessage original) throws Error { + PreKeyOmemoMessage res; + throw_by_code(pre_key_message_copy(out res, (PreKeyOmemoMessage) original, native_context)); return res; } } diff --git a/plugins/omemo/src/signal/signal_helper.c b/plugins/omemo/src/native/helper.c index 17682929..c6af15e3 100644 --- a/plugins/omemo/src/signal/signal_helper.c +++ b/plugins/omemo/src/native/helper.c @@ -1,4 +1,4 @@ -#include "signal_helper.h" +#include "helper.h" #include <gcrypt.h> diff --git a/plugins/omemo/src/signal/signal_helper.h b/plugins/omemo/src/native/helper.h index 949a3c7b..98c96dfb 100644 --- a/plugins/omemo/src/signal/signal_helper.h +++ b/plugins/omemo/src/native/helper.h @@ -1,7 +1,7 @@ #ifndef SIGNAL_PROTOCOL_VALA_HELPER #define SIGNAL_PROTOCOL_VALA_HELPER 1 -#include <signal/signal_protocol.h> +#include <omemo/signal_protocol.h> #include <string.h> #include <glib.h> diff --git a/plugins/omemo/src/signal/simple_iks.vala b/plugins/omemo/src/native/simple_iks.vala index 5247c455..6f752d33 100644 --- a/plugins/omemo/src/signal/simple_iks.vala +++ b/plugins/omemo/src/native/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/omemo/src/signal/simple_pks.vala b/plugins/omemo/src/native/simple_pks.vala index 1f059fda..900985ea 100644 --- a/plugins/omemo/src/signal/simple_pks.vala +++ b/plugins/omemo/src/native/simple_pks.vala @@ -1,6 +1,6 @@ using Gee; -namespace Signal { +namespace Omemo { public class SimplePreKeyStore : PreKeyStore { private Map<uint32, PreKeyStore.Key> pre_key_map = new HashMap<uint32, PreKeyStore.Key>(); diff --git a/plugins/omemo/src/signal/simple_spks.vala b/plugins/omemo/src/native/simple_spks.vala index f0fe09ab..772a7322 100644 --- a/plugins/omemo/src/signal/simple_spks.vala +++ b/plugins/omemo/src/native/simple_spks.vala @@ -1,6 +1,6 @@ using Gee; -namespace Signal { +namespace Omemo { public class SimpleSignedPreKeyStore : SignedPreKeyStore { private Map<uint32, SignedPreKeyStore.Key> pre_key_map = new HashMap<uint32, SignedPreKeyStore.Key>(); diff --git a/plugins/omemo/src/signal/simple_ss.vala b/plugins/omemo/src/native/simple_ss.vala index 5213f736..26bc8e56 100644 --- a/plugins/omemo/src/signal/simple_ss.vala +++ b/plugins/omemo/src/native/simple_ss.vala @@ -1,6 +1,6 @@ using Gee; -namespace Signal { +namespace Omemo { public class SimpleSessionStore : SessionStore { diff --git a/plugins/omemo/src/signal/store.vala b/plugins/omemo/src/native/store.vala index b440d838..b1861d93 100644 --- a/plugins/omemo/src/signal/store.vala +++ b/plugins/omemo/src/native/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/omemo/src/signal/util.vala b/plugins/omemo/src/native/util.vala index 4c0ae72d..be43668d 100644 --- a/plugins/omemo/src/signal/util.vala +++ b/plugins/omemo/src/native/util.vala @@ -1,4 +1,4 @@ -namespace Signal { +namespace Omemo { public ECPublicKey generate_public_key(ECPrivateKey private_key) throws Error { ECPublicKey public_key; diff --git a/plugins/omemo/src/plugin.vala b/plugins/omemo/src/plugin.vala index b6142ba6..7b7034c8 100644 --- a/plugins/omemo/src/plugin.vala +++ b/plugins/omemo/src/plugin.vala @@ -1,5 +1,6 @@ using Gee; using Dino.Entities; +using Omemo; extern const string GETTEXT_PACKAGE; extern const string LOCALE_INSTALL_DIR; @@ -8,8 +9,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; } @@ -17,11 +18,11 @@ 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) { - warning("Error initializing Signal Context %s", e.message); + warning("Error initializing libomemo-c Context %s", e.message); return false; } } @@ -54,11 +55,11 @@ public class Plugin : RootInterface, Object { this.app.plugin_registry.register_call_entryption_entry(DtlsSrtpVerificationDraft.NS_URI, new CallEncryptionEntry(db)); this.app.stream_interactor.module_manager.initialize_account_modules.connect((account, list) => { - Signal.Store signal_store = Plugin.get_context().create_store(); - list.add(new StreamModule(signal_store)); - decryptors[account] = new OmemoDecryptor(account, app.stream_interactor, trust_manager, db, signal_store); + Store store = Plugin.get_context().create_store(); + list.add(new StreamModule(store)); + decryptors[account] = new OmemoDecryptor(account, app.stream_interactor, trust_manager, db, store); list.add(decryptors[account]); - encryptors[account] = new OmemoEncryptor(account, trust_manager,signal_store); + encryptors[account] = new OmemoEncryptor(account, trust_manager, store); list.add(encryptors[account]); list.add(new JetOmemo.Module()); list.add(new DtlsSrtpVerificationDraft.StreamModule()); 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 4e97b1e6..cb68d4b4 100644 --- a/plugins/omemo/src/protocol/stream_module.vala +++ b/plugins/omemo/src/protocol/stream_module.vala @@ -1,7 +1,7 @@ using Gee; using Xmpp; using Xmpp.Xep; -using Signal; +using Omemo; namespace Dino.Plugins.Omemo { diff --git a/plugins/omemo/src/ui/encryption_preferences_entry.vala b/plugins/omemo/src/ui/encryption_preferences_entry.vala index 0f9456d9..5bfeb340 100644 --- a/plugins/omemo/src/ui/encryption_preferences_entry.vala +++ b/plugins/omemo/src/ui/encryption_preferences_entry.vala @@ -4,6 +4,7 @@ using Gee; using Xmpp; using Dino.Entities; using Gtk; +using Omemo; namespace Dino.Plugins.Omemo { @@ -32,7 +33,7 @@ public class OmemoPreferencesWidget : Adw.PreferencesGroup { private Account account; private Jid jid; private int identity_id = 0; - private Signal.Store store; + private Store store; private Set<uint32> displayed_ids = new HashSet<uint32>(); [GtkChild] private unowned Adw.ActionRow automatically_accept_new_row; @@ -190,8 +191,8 @@ public class OmemoPreferencesWidget : Adw.PreferencesGroup { 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()); |
