diff options
| author | Marvin W <git@larma.de> | 2025-04-05 14:33:42 +0200 |
|---|---|---|
| committer | Marvin W <git@larma.de> | 2025-04-06 13:58:06 +0200 |
| commit | 7fa44a6ff691b2787a8232cb3174e679667c270b (patch) | |
| tree | de875e72eab993b51da0d854c47d78a1c2213923 /plugins/omemo | |
| parent | 12c0d27814bf6079b7a86da7796fb89271c416eb (diff) | |
OMEMO: Use libomemo-c instead of libsignal-protocol-c
Diffstat (limited to 'plugins/omemo')
31 files changed, 393 insertions, 178 deletions
diff --git a/plugins/omemo/meson.build b/plugins/omemo/meson.build index bdf6ec5b..273d8831 100644 --- a/plugins/omemo/meson.build +++ b/plugins/omemo/meson.build @@ -9,7 +9,7 @@ dependencies = [ dep_gtk4, dep_libgcrypt, dep_libqrencode, - dep_libsignal_protocol_c, + dep_libomemo_c, dep_m, dep_qlite, dep_xmpp_vala, @@ -33,14 +33,14 @@ sources = files( 'src/protocol/message_flag.vala', 'src/protocol/stream_module.vala', 'src/register_plugin.vala', - 'src/signal/context.vala', - 'src/signal/signal_helper.c', - 'src/signal/simple_iks.vala', - 'src/signal/simple_pks.vala', - 'src/signal/simple_spks.vala', - 'src/signal/simple_ss.vala', - 'src/signal/store.vala', - 'src/signal/util.vala', + 'src/native/context.vala', + 'src/native/helper.c', + 'src/native/simple_iks.vala', + 'src/native/simple_pks.vala', + 'src/native/simple_spks.vala', + 'src/native/simple_ss.vala', + 'src/native/store.vala', + 'src/native/util.vala', 'src/trust_level.vala', 'src/ui/bad_messages_populator.vala', 'src/ui/call_encryption_entry.vala', @@ -77,12 +77,12 @@ vapi_omemo_internal = custom_target('omemo-internal-vapi', command: [find_progra dep_omemo_internal = declare_dependency(link_args: [lib_omemo.full_path()], include_directories: include_directories('.', 'src'), sources: [vapi_omemo_internal]) test_sources = [ - 'tests/signal/common.vala', - 'tests/signal/testcase.vala', + 'tests/native/common.vala', + 'tests/native/testcase.vala', - 'tests/signal/curve25519.vala', - 'tests/signal/hkdf.vala', - 'tests/signal/session_builder.vala', + 'tests/native/curve25519.vala', + 'tests/native/hkdf.vala', + 'tests/native/session_builder.vala', ] test_vala_args = [ '--vapidir', meson.current_source_dir() / 'vapi', 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()); diff --git a/plugins/omemo/tests/signal/common.vala b/plugins/omemo/tests/native/common.vala index 9bb9b1dc..af0f7250 100644 --- a/plugins/omemo/tests/signal/common.vala +++ b/plugins/omemo/tests/native/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/omemo/tests/signal/curve25519.vala b/plugins/omemo/tests/native/curve25519.vala index 6dfae62f..84c244d2 100644 --- a/plugins/omemo/tests/signal/curve25519.vala +++ b/plugins/omemo/tests/native/curve25519.vala @@ -1,4 +1,4 @@ -namespace Signal.Test { +namespace Omemo.Test { class Curve25519 : Gee.TestCase { diff --git a/plugins/omemo/tests/signal/hkdf.vala b/plugins/omemo/tests/native/hkdf.vala index c30af275..84257054 100644 --- a/plugins/omemo/tests/signal/hkdf.vala +++ b/plugins/omemo/tests/native/hkdf.vala @@ -1,4 +1,4 @@ -namespace Signal.Test { +namespace Omemo.Test { class HKDF : Gee.TestCase { diff --git a/plugins/omemo/tests/signal/session_builder.vala b/plugins/omemo/tests/native/session_builder.vala index 7e2448e1..2215db86 100644 --- a/plugins/omemo/tests/signal/session_builder.vala +++ b/plugins/omemo/tests/native/session_builder.vala @@ -1,4 +1,4 @@ -namespace Signal.Test { +namespace Omemo.Test { class SessionBuilderTest : Gee.TestCase { Address alice_address; @@ -9,6 +9,7 @@ class SessionBuilderTest : Gee.TestCase { add_test("basic_pre_key_v2", test_basic_pre_key_v2); add_test("basic_pre_key_v3", test_basic_pre_key_v3); + add_test("basic_pre_key_omemo", test_basic_pre_key_omemo); add_test("bad_signed_pre_key_signature", test_bad_signed_pre_key_signature); add_test("repeat_bundle_message_v2", test_repeat_bundle_message_v2); } @@ -89,7 +90,7 @@ class SessionBuilderTest : Gee.TestCase { fail_if_not_eq_int(outgoing_message.type, CiphertextType.PREKEY); /* Convert to an incoming message for Bob */ - PreKeySignalMessage incoming_message = global_context.deserialize_pre_key_signal_message(outgoing_message.serialized); + PreKeyOmemoMessage incoming_message = global_context.deserialize_signal_pre_key_message(outgoing_message.serialized); /* Save the pre key and signed pre key in Bob's data store */ PreKeyRecord bob_pre_key_record; @@ -97,7 +98,7 @@ class SessionBuilderTest : Gee.TestCase { bob_store.store_pre_key(bob_pre_key_record); SignedPreKeyRecord bob_signed_pre_key_record; - throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature)); + throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature, null)); bob_store.store_signed_pre_key(bob_signed_pre_key_record); /* Create Bob's session cipher and decrypt the message from Alice */ @@ -107,7 +108,7 @@ class SessionBuilderTest : Gee.TestCase { //int callback_context = 1234; //bob_session_cipher.user_data = //bob_session_cipher.decryption_callback = - uint8[] plaintext = bob_session_cipher.decrypt_pre_key_signal_message(incoming_message); + uint8[] plaintext = bob_session_cipher.decrypt_pre_key_message(incoming_message); /* Clean up callback data */ bob_session_cipher.user_data = null; @@ -129,9 +130,9 @@ class SessionBuilderTest : Gee.TestCase { fail_if_not_eq_int(bob_outgoing_message.type, CiphertextType.SIGNAL); /* Verify that Alice can decrypt it */ - SignalMessage bob_outgoing_message_copy = global_context.copy_signal_message(bob_outgoing_message); + OmemoMessage bob_outgoing_message_copy = global_context.copy_message(bob_outgoing_message); - uint8[] alice_plaintext = alice_session_cipher.decrypt_signal_message(bob_outgoing_message_copy); + uint8[] alice_plaintext = alice_session_cipher.decrypt_message(bob_outgoing_message_copy); fail_if_not_eq_uint8_arr(original_message.data, alice_plaintext); @@ -165,7 +166,7 @@ class SessionBuilderTest : Gee.TestCase { throw_by_code(PreKeyRecord.create(out bob_pre_key_record, bob_pre_key.pre_key_id, bob_pre_key_pair)); bob_store.store_pre_key(bob_pre_key_record); - throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 23, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature)); + throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 23, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature, null)); bob_store.store_signed_pre_key(bob_signed_pre_key_record); /* Have Alice process Bob's pre key bundle */ @@ -176,19 +177,178 @@ class SessionBuilderTest : Gee.TestCase { fail_if_not_eq_int(outgoing_message.type, CiphertextType.PREKEY); /* Have Bob try to decrypt the message */ - PreKeySignalMessage outgoing_message_copy = global_context.copy_pre_key_signal_message(outgoing_message); + PreKeyOmemoMessage outgoing_message_copy = global_context.copy_pre_key_message(outgoing_message); /* The decrypt should fail with a specific error */ - fail_if_not_error_code(() => bob_session_cipher.decrypt_pre_key_signal_message(outgoing_message_copy), ErrorCode.UNTRUSTED_IDENTITY); + fail_if_not_error_code(() => bob_session_cipher.decrypt_pre_key_message(outgoing_message_copy), ErrorCode.UNTRUSTED_IDENTITY); - outgoing_message_copy = global_context.copy_pre_key_signal_message(outgoing_message); + outgoing_message_copy = global_context.copy_pre_key_message(outgoing_message); /* Save the identity key to Bob's store */ bob_store.save_identity(alice_address, outgoing_message_copy.identity_key); /* Try the decrypt again, this time it should succeed */ - outgoing_message_copy = global_context.copy_pre_key_signal_message(outgoing_message); - plaintext = bob_session_cipher.decrypt_pre_key_signal_message(outgoing_message_copy); + outgoing_message_copy = global_context.copy_pre_key_message(outgoing_message); + plaintext = bob_session_cipher.decrypt_pre_key_message(outgoing_message_copy); + + fail_if_not_eq_uint8_arr(original_message.data, plaintext); + + /* Create a new pre key for Bob */ + ECPublicKey test_public_key = create_test_ec_public_key(global_context); + + IdentityKeyPair alice_identity_key_pair = alice_store.identity_key_pair; + + bob_pre_key = create_pre_key_bundle(bob_local_registration_id, 1, 31337, test_public_key, 23, bob_signed_pre_key_pair.public, bob_signed_pre_key_signature, alice_identity_key_pair.public); + + /* Have Alice process Bob's new pre key bundle, which should fail */ + fail_if_not_error_code(() => alice_session_builder.process_pre_key_bundle(bob_pre_key), ErrorCode.UNTRUSTED_IDENTITY); + + GLib.Test.message("Post-interaction tests complete"); + } catch(Error e) { + fail_if_reached(@"Unexpected error: $(e.message)"); + } + } + + + void test_basic_pre_key_omemo() { + try { + /* Create Alice's data store and session builder */ + Store alice_store = setup_test_store_context(global_context); + SessionBuilder alice_session_builder = alice_store.create_session_builder(bob_address); + alice_session_builder.version = 4; + + /* Create Bob's data store and pre key bundle */ + Store bob_store = setup_test_store_context(global_context); + uint32 bob_local_registration_id = bob_store.local_registration_id; + ECKeyPair bob_pre_key_pair = global_context.generate_key_pair(); + ECKeyPair bob_signed_pre_key_pair = global_context.generate_key_pair(); + IdentityKeyPair bob_identity_key_pair = bob_store.identity_key_pair; + + uint8[] bob_signed_pre_key_signature = global_context.calculate_signature(bob_identity_key_pair.private, bob_signed_pre_key_pair.public.serialize_omemo()); + + PreKeyBundle bob_pre_key = create_pre_key_bundle(bob_local_registration_id, 1, 31337, bob_pre_key_pair.public, 22, bob_signed_pre_key_pair.public, bob_signed_pre_key_signature, bob_identity_key_pair.public); + + /* Have Alice process Bob's pre key bundle */ + alice_session_builder.process_pre_key_bundle(bob_pre_key); + + /* Check that we can load the session state and verify its version */ + fail_if_not(alice_store.contains_session(bob_address)); + + SessionRecord loaded_record = alice_store.load_session(bob_address); + fail_if_not_eq_int((int)loaded_record.state.session_version, 4); + + /* Encrypt an outgoing message to send to Bob */ + string original_message = "L'homme est condamné à être libre"; + SessionCipher alice_session_cipher = alice_store.create_session_cipher(bob_address); + alice_session_cipher.version = 4; + + CiphertextMessage outgoing_message = alice_session_cipher.encrypt(original_message.data); + fail_if_not_eq_int(outgoing_message.type, CiphertextType.PREKEY); + + /* Convert to an incoming message for Bob */ + PreKeyOmemoMessage incoming_message = global_context.deserialize_omemo_pre_key_message(outgoing_message.serialized, bob_local_registration_id); + + /* Save the pre key and signed pre key in Bob's data store */ + PreKeyRecord bob_pre_key_record; + throw_by_code(PreKeyRecord.create(out bob_pre_key_record, bob_pre_key.pre_key_id, bob_pre_key_pair)); + bob_store.store_pre_key(bob_pre_key_record); + + SignedPreKeyRecord bob_signed_pre_key_record; + throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, new uint8[1], bob_signed_pre_key_signature)); + bob_store.store_signed_pre_key(bob_signed_pre_key_record); + + /* Create Bob's session cipher and decrypt the message from Alice */ + SessionCipher bob_session_cipher = bob_store.create_session_cipher(alice_address); + bob_session_cipher.version = 4; + + /* Prepare the data for the callback test */ + //int callback_context = 1234; + //bob_session_cipher.user_data = + //bob_session_cipher.decryption_callback = + uint8[] plaintext = bob_session_cipher.decrypt_pre_key_message(incoming_message); + + /* Clean up callback data */ + bob_session_cipher.user_data = null; + bob_session_cipher.decryption_callback = null; + + /* Verify Bob's session state and the decrypted message */ + fail_if_not(bob_store.contains_session(alice_address)); + + SessionRecord alice_recipient_session_record = bob_store.load_session(alice_address); + + SessionState alice_recipient_session_state = alice_recipient_session_record.state; + fail_if_not_eq_int((int)alice_recipient_session_state.session_version, 4); + fail_if_null(alice_recipient_session_state.alice_base_key); + + fail_if_not_eq_uint8_arr(original_message.data, plaintext); + + /* Have Bob send a reply to Alice */ + CiphertextMessage bob_outgoing_message = bob_session_cipher.encrypt(original_message.data); + fail_if_not_eq_int(bob_outgoing_message.type, CiphertextType.SIGNAL); + + /* Verify that Alice can decrypt it */ + OmemoMessage bob_outgoing_message_copy = global_context.copy_message(bob_outgoing_message); + + uint8[] alice_plaintext = alice_session_cipher.decrypt_message(bob_outgoing_message_copy); + + fail_if_not_eq_uint8_arr(original_message.data, alice_plaintext); + + GLib.Test.message("Pre-interaction tests complete"); + + /* Interaction tests */ + run_interaction(alice_store, bob_store, 4); + + /* Cleanup state from previous tests that we need to replace */ + alice_store = null; + bob_pre_key_pair = null; + bob_signed_pre_key_pair = null; + bob_identity_key_pair = null; + bob_signed_pre_key_signature = null; + bob_pre_key_record = null; + bob_signed_pre_key_record = null; + + /* Create Alice's new session data */ + alice_store = setup_test_store_context(global_context); + alice_session_builder = alice_store.create_session_builder(bob_address); + alice_session_builder.version = 4; + alice_session_cipher = alice_store.create_session_cipher(bob_address); + alice_session_cipher.version = 4; + + /* Create Bob's new pre key bundle */ + bob_pre_key_pair = global_context.generate_key_pair(); + bob_signed_pre_key_pair = global_context.generate_key_pair(); + bob_identity_key_pair = bob_store.identity_key_pair; + bob_signed_pre_key_signature = global_context.calculate_signature(bob_identity_key_pair.private, bob_signed_pre_key_pair.public.serialize_omemo()); + bob_pre_key = create_pre_key_bundle(bob_local_registration_id, 1, 31338, bob_pre_key_pair.public, 23, bob_signed_pre_key_pair.public, bob_signed_pre_key_signature, bob_identity_key_pair.public); + + /* Save the new pre key and signed pre key in Bob's data store */ + throw_by_code(PreKeyRecord.create(out bob_pre_key_record, bob_pre_key.pre_key_id, bob_pre_key_pair)); + bob_store.store_pre_key(bob_pre_key_record); + + throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 23, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, new uint8[1], bob_signed_pre_key_signature)); + bob_store.store_signed_pre_key(bob_signed_pre_key_record); + + /* Have Alice process Bob's pre key bundle */ + alice_session_builder.process_pre_key_bundle(bob_pre_key); + + /* Have Alice encrypt a message for Bob */ + outgoing_message = alice_session_cipher.encrypt(original_message.data); + fail_if_not_eq_int(outgoing_message.type, CiphertextType.PREKEY); + + /* Have Bob try to decrypt the message */ + PreKeyOmemoMessage outgoing_message_copy = global_context.copy_pre_key_message(outgoing_message); + + /* The decrypt should fail with a specific error */ + fail_if_not_error_code(() => bob_session_cipher.decrypt_pre_key_message(outgoing_message_copy), ErrorCode.UNTRUSTED_IDENTITY); + + outgoing_message_copy = global_context.copy_pre_key_message(outgoing_message); + + /* Save the identity key to Bob's store */ + bob_store.save_identity(alice_address, outgoing_message_copy.identity_key); + + /* Try the decrypt again, this time it should succeed */ + outgoing_message_copy = global_context.copy_pre_key_message(outgoing_message); + plaintext = bob_session_cipher.decrypt_pre_key_message(outgoing_message_copy); fail_if_not_eq_uint8_arr(original_message.data, plaintext); @@ -266,7 +426,7 @@ class SessionBuilderTest : Gee.TestCase { throw_by_code(PreKeyRecord.create(out bob_pre_key_record, bob_pre_key.pre_key_id, bob_pre_key_pair)); bob_store.store_pre_key(bob_pre_key_record); SignedPreKeyRecord bob_signed_pre_key_record; - throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature)); + throw_by_code(SignedPreKeyRecord.create(out bob_signed_pre_key_record, 22, new DateTime.now_utc().to_unix(), bob_signed_pre_key_pair, bob_signed_pre_key_signature, null)); bob_store.store_signed_pre_key(bob_signed_pre_key_record); /* @@ -287,11 +447,13 @@ class SessionBuilderTest : Gee.TestCase { } } - void run_interaction(Store alice_store, Store bob_store) throws Error { + void run_interaction(Store alice_store, Store bob_store, uint32 version = 3) throws Error { /* Create the session ciphers */ SessionCipher alice_session_cipher = alice_store.create_session_cipher(bob_address); + alice_session_cipher.version = version; SessionCipher bob_session_cipher = bob_store.create_session_cipher(alice_address); + bob_session_cipher.version = version; /* Create a test message */ string original_message = "smert ze smert"; @@ -300,8 +462,8 @@ class SessionBuilderTest : Gee.TestCase { CiphertextMessage alice_message = alice_session_cipher.encrypt(original_message.data); fail_if_not_eq_int(alice_message.type, CiphertextType.SIGNAL); - SignalMessage alice_message_copy = global_context.copy_signal_message(alice_message); - uint8[] plaintext = bob_session_cipher.decrypt_signal_message(alice_message_copy); + OmemoMessage alice_message_copy = global_context.copy_message(alice_message); + uint8[] plaintext = bob_session_cipher.decrypt_message(alice_message_copy); fail_if_not_eq_uint8_arr(original_message.data, plaintext); GLib.Test.message("Interaction complete: Alice -> Bob"); @@ -310,8 +472,8 @@ class SessionBuilderTest : Gee.TestCase { CiphertextMessage bob_message = bob_session_cipher.encrypt(original_message.data); fail_if_not_eq_int(alice_message.type, CiphertextType.SIGNAL); - SignalMessage bob_message_copy = global_context.copy_signal_message(bob_message); - plaintext = alice_session_cipher.decrypt_signal_message(bob_message_copy); + OmemoMessage bob_message_copy = global_context.copy_message(bob_message); + plaintext = alice_session_cipher.decrypt_message(bob_message_copy); fail_if_not_eq_uint8_arr(original_message.data, plaintext); GLib.Test.message("Interaction complete: Bob -> Alice"); @@ -320,8 +482,8 @@ class SessionBuilderTest : Gee.TestCase { for (int i = 0; i < 10; i++) { uint8[] looping_message = create_looping_message(i); CiphertextMessage alice_looping_message = alice_session_cipher.encrypt(looping_message); - SignalMessage alice_looping_message_copy = global_context.copy_signal_message(alice_looping_message); - uint8[] looping_plaintext = bob_session_cipher.decrypt_signal_message(alice_looping_message_copy); + OmemoMessage alice_looping_message_copy = global_context.copy_message(alice_looping_message); + uint8[] looping_plaintext = bob_session_cipher.decrypt_message(alice_looping_message_copy); fail_if_not_eq_uint8_arr(looping_message, looping_plaintext); } GLib.Test.message("Interaction complete: Alice -> Bob (looping)"); @@ -330,8 +492,8 @@ class SessionBuilderTest : Gee.TestCase { for (int i = 0; i < 10; i++) { uint8[] looping_message = create_looping_message(i); CiphertextMessage bob_looping_message = bob_session_cipher.encrypt(looping_message); - SignalMessage bob_looping_message_copy = global_context.copy_signal_message(bob_looping_message); - uint8[] looping_plaintext = alice_session_cipher.decrypt_signal_message(bob_looping_message_copy); + OmemoMessage bob_looping_message_copy = global_context.copy_message(bob_looping_message); + uint8[] looping_plaintext = alice_session_cipher.decrypt_message(bob_looping_message_copy); fail_if_not_eq_uint8_arr(looping_message, looping_plaintext); } GLib.Test.message("Interaction complete: Bob -> Alice (looping)"); @@ -359,8 +521,8 @@ class SessionBuilderTest : Gee.TestCase { for (int i = 0; i < 10; i++) { uint8[] looping_message = create_looping_message(i); CiphertextMessage alice_looping_message = alice_session_cipher.encrypt(looping_message); - SignalMessage alice_looping_message_copy = global_context.copy_signal_message(alice_looping_message); - uint8[] looping_plaintext = bob_session_cipher.decrypt_signal_message(alice_looping_message_copy); + OmemoMessage alice_looping_message_copy = global_context.copy_message(alice_looping_message); + uint8[] looping_plaintext = bob_session_cipher.decrypt_message(alice_looping_message_copy); fail_if_not_eq_uint8_arr(looping_message, looping_plaintext); } GLib.Test.message("Interaction complete: Alice -> Bob (looping, repeated)"); @@ -369,16 +531,18 @@ class SessionBuilderTest : Gee.TestCase { for (int i = 0; i < 10; i++) { uint8[] looping_message = create_looping_message(i); CiphertextMessage bob_looping_message = bob_session_cipher.encrypt(looping_message); - SignalMessage bob_looping_message_copy = global_context.copy_signal_message(bob_looping_message); - uint8[] looping_plaintext = alice_session_cipher.decrypt_signal_message(bob_looping_message_copy); + OmemoMessage bob_looping_message_copy = global_context.copy_message(bob_looping_message); + uint8[] looping_plaintext = alice_session_cipher.decrypt_message(bob_looping_message_copy); fail_if_not_eq_uint8_arr(looping_message, looping_plaintext); } GLib.Test.message("Interaction complete: Bob -> Alice (looping, repeated)"); /* Shuffled Alice -> Bob */ for (int i = 0; i < 10; i++) { - SignalMessage ooo_message_deserialized = global_context.deserialize_signal_message(alice_ooo_ciphertext[i].data); - uint8[] ooo_plaintext = bob_session_cipher.decrypt_signal_message(ooo_message_deserialized); + OmemoMessage ooo_message_deserialized = version >= 4 + ? global_context.deserialize_omemo_message(alice_ooo_ciphertext[i].data) + : global_context.deserialize_signal_message(alice_ooo_ciphertext[i].data); + uint8[] ooo_plaintext = bob_session_cipher.decrypt_message(ooo_message_deserialized); fail_if_not_eq_uint8_arr(alice_ooo_plaintext[i].data, ooo_plaintext); } GLib.Test.message("Interaction complete: Alice -> Bob (shuffled)"); diff --git a/plugins/omemo/tests/signal/testcase.vala b/plugins/omemo/tests/native/testcase.vala index 59fcf193..59fcf193 100644 --- a/plugins/omemo/tests/signal/testcase.vala +++ b/plugins/omemo/tests/native/testcase.vala diff --git a/plugins/omemo/vapi/libsignal-protocol-c.vapi b/plugins/omemo/vapi/libomemo-c.vapi index 7c63d418..34bb0202 100644 --- a/plugins/omemo/vapi/libsignal-protocol-c.vapi +++ b/plugins/omemo/vapi/libomemo-c.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,15 +35,15 @@ 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()); + throw new GLib.Error(-1, code, "%s: %s", message ?? "libomemo-c error", ((ErrorCode)code).to_string()); } 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/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,native/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); @@ -98,10 +98,11 @@ namespace Signal { public void process_pre_key_bundle(PreKeyBundle pre_key_bundle) throws GLib.Error { throw_by_code(process_pre_key_bundle_(pre_key_bundle)); } + public int version { get; set; } } [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 +117,7 @@ namespace Signal { } [Compact] - [CCode (cname = "session_pre_key", cprefix = "session_pre_key_", cheader_filename = "signal/session_pre_key.h,signal/signal_helper.h")] + [CCode (cname = "session_pre_key", cprefix = "session_pre_key_", cheader_filename = "omemo/session_pre_key.h,native/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 +128,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,27 +158,31 @@ 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); + public static int create(out SignedPreKeyRecord pre_key, uint32 id, uint64 timestamp, ECKeyPair key_pair, uint8[] signature, uint8[]? signature_omemo); [CCode (instance_pos = 2)] - public int serialze(out Buffer buffer); + public int serialize(out Buffer buffer); public uint32 id { get; } public uint64 timestamp { get; } public ECKeyPair key_pair { get; } public uint8[] signature { [CCode (cname = "session_signed_pre_key_get_signature_")] get { int x = (int)get_signature_len(); unowned uint8[] res = get_signature(); res.length = x; return res; } } + public uint8[] signature_omemo { [CCode (cname = "session_signed_pre_key_get_signature_omemo_")] get { int x = (int)get_signature_omemo_len(); unowned uint8[] res = get_signature_omemo(); res.length = x; return res; } } [CCode (array_length = false, cname = "session_signed_pre_key_get_signature")] private unowned uint8[] get_signature(); private size_t get_signature_len(); + [CCode (array_length = false, cname = "session_signed_pre_key_get_signature_omemo")] + private unowned uint8[] get_signature_omemo(); + private size_t get_signature_omemo_len(); } /** - * Address of an Signal Protocol message recipient + * Address of an OMEMO message recipient */ [Compact] - [CCode (cname = "signal_protocol_address", cprefix = "signal_protocol_address_", cheader_filename = "signal/signal_protocol.h,signal/signal_helper.h")] + [CCode (cname = "signal_protocol_address", cprefix = "signal_protocol_address_", cheader_filename = "omemo/signal_protocol.h,native/helper.h")] public class Address { public Address(string name, int32 device_id); public int32 device_id { get; set; } @@ -197,7 +202,7 @@ namespace Signal { } [Compact] - [CCode (cname = "ec_public_key", cprefix = "ec_public_key_", cheader_filename = "signal/curve.h,signal/signal_helper.h")] + [CCode (cname = "ec_public_key", cprefix = "ec_public_key_", cheader_filename = "omemo/curve.h,native/helper.h")] public class ECPublicKey : TypeBase { [CCode (cname = "curve_generate_public_key")] public static int generate(out ECPublicKey public_key, ECPrivateKey private_key); @@ -213,12 +218,26 @@ namespace Signal { } return buffer.data; } + [CCode (instance_pos = 1, cname = "ec_public_key_serialize_omemo")] + private int serialize_omemo_([CCode (pos = 0)] out Buffer buffer); + [CCode (cname = "ec_public_key_serialize_omemo_")] + public uint8[] serialize_omemo() { + Buffer buffer; + int code = serialize_omemo_(out buffer); + if (code < 0 && code > MIN_ERROR_CODE) { + // Can only throw for invalid arguments or out of memory. + GLib.assert_not_reached(); + } + return buffer.data; + } + public Buffer ed { owned get; } + public Buffer mont { owned get; } public int compare(ECPublicKey other); public int memcmp(ECPublicKey other); } [Compact] - [CCode (cname = "ec_private_key", cprefix = "ec_private_key_", cheader_filename = "signal/curve.h,signal/signal_helper.h")] + [CCode (cname = "ec_private_key", cprefix = "ec_private_key_", cheader_filename = "omemo/curve.h,native/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 +255,19 @@ namespace Signal { } [Compact] - [CCode (cname = "ec_key_pair", cprefix="ec_key_pair_", cheader_filename = "signal/curve.h,signal/signal_helper.h")] + [CCode (cname = "ec_key_pair", cprefix="ec_key_pair_", cheader_filename = "omemo/curve.h,native/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/signal_helper.h")] + [CCode (cname = "ratchet_identity_key_pair", cprefix = "ratchet_identity_key_pair_", cheader_filename = "omemo/ratchet.h,native/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); @@ -261,14 +280,14 @@ namespace Signal { public class PublicKeyList {} /** - * The main entry point for Signal Protocol encrypt/decrypt operations. + * The main entry point for OMEMO encrypt/decrypt operations. * * Once a session has been established with session_builder, * this class can be used for all encrypt/decrypt operations within * 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; } @@ -281,29 +300,37 @@ namespace Signal { return res; } [CCode (cname = "session_cipher_decrypt_pre_key_signal_message")] - private int decrypt_pre_key_signal_message_(PreKeySignalMessage ciphertext, void* decrypt_context, out Buffer plaintext); + private int decrypt_pre_key_message_(PreKeyOmemoMessage ciphertext, void* decrypt_context, out Buffer plaintext); [CCode (cname = "session_cipher_decrypt_pre_key_signal_message_")] - public uint8[] decrypt_pre_key_signal_message(PreKeySignalMessage ciphertext, void* decrypt_context = null) throws GLib.Error { + public uint8[] decrypt_pre_key_message(PreKeyOmemoMessage ciphertext, void* decrypt_context = null) throws GLib.Error { Buffer res; - throw_by_code(decrypt_pre_key_signal_message_(ciphertext, decrypt_context, out res)); + throw_by_code(decrypt_pre_key_message_(ciphertext, decrypt_context, out res)); return res.data; } [CCode (cname = "session_cipher_decrypt_signal_message")] - private int decrypt_signal_message_(SignalMessage ciphertext, void* decrypt_context, out Buffer plaintext); + private int decrypt_message_(OmemoMessage ciphertext, void* decrypt_context, out Buffer plaintext); [CCode (cname = "session_cipher_decrypt_signal_message_")] - public uint8[] decrypt_signal_message(SignalMessage ciphertext, void* decrypt_context = null) throws GLib.Error { + public uint8[] decrypt_message(OmemoMessage ciphertext, void* decrypt_context = null) throws GLib.Error { Buffer res; - throw_by_code(decrypt_signal_message_(ciphertext, decrypt_context, out res)); + throw_by_code(decrypt_message_(ciphertext, decrypt_context, out res)); return res.data; } public int get_remote_registration_id(out uint32 remote_id); - public int get_session_version(uint32 version); + [CCode (cname = "session_cipher_get_session_version")] + private int get_session_version_(out uint32 version); + [CCode (cname = "session_cipher_get_session_version_")] + public uint32 get_session_version() throws GLib.Error { + uint32 res; + throw_by_code(get_session_version_(out res)); + return res; + } + public uint32 version { get; set; } [CCode (has_target = false)] 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 +343,7 @@ namespace Signal { } [Compact] - [CCode (cname = "ciphertext_message", cprefix = "ciphertext_message_", cheader_filename = "signal/protocol.h,signal/signal_helper.h")] + [CCode (cname = "ciphertext_message", cprefix = "ciphertext_message_", cheader_filename = "omemo/protocol.h,native/helper.h")] public abstract class CiphertextMessage : TypeBase { public CiphertextType type { get; } [CCode (cname = "ciphertext_message_get_serialized")] @@ -326,8 +353,8 @@ namespace Signal { }} } [Compact] - [CCode (cname = "signal_message", cprefix = "signal_message_", cheader_filename = "signal/protocol.h,signal/signal_helper.h")] - public class SignalMessage : CiphertextMessage { + [CCode (cname = "signal_message", cprefix = "signal_message_", cheader_filename = "omemo/protocol.h,native/helper.h")] + public class OmemoMessage : CiphertextMessage { public ECPublicKey sender_ratchet_key { get; } public uint8 message_version { get; } public uint32 counter { get; } @@ -336,25 +363,25 @@ 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/signal_helper.h")] - public class PreKeySignalMessage : CiphertextMessage { + [CCode (cname = "pre_key_signal_message", cprefix = "pre_key_signal_message_", cheader_filename = "omemo/protocol.h,native/helper.h")] + public class PreKeyOmemoMessage : CiphertextMessage { public uint8 message_version { get; } public ECPublicKey identity_key { get; } public uint32 registration_id { get; } public uint32 pre_key_id { get; } public uint32 signed_pre_key_id { get; } public ECPublicKey base_key { get; } - public SignalMessage signal_message { get; } + public OmemoMessage message { get; } } [Compact] - [CCode (cname = "sender_key_message", cprefix = "sender_key_message_", cheader_filename = "signal/protocol.h,signal/signal_helper.h")] + [CCode (cname = "sender_key_message", cprefix = "sender_key_message_", cheader_filename = "omemo/protocol.h,native/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/signal_helper.h")] + [CCode (cname = "sender_key_distribution_message", cprefix = "sender_key_distribution_message_", cheader_filename = "omemo/protocol.h,native/helper.h")] public class SenderKeyDistributionMessage : CiphertextMessage { public uint32 id { get; } public uint32 iteration { get; } @@ -362,7 +389,7 @@ namespace Signal { public ECPublicKey signature_key { get; } } - [CCode (cname = "signal_vala_encrypt", cheader_filename = "signal/signal_helper.h")] + [CCode (cname = "signal_vala_encrypt", cheader_filename = "native/helper.h")] private static int aes_encrypt_(out Buffer output, int cipher, uint8[] key, uint8[] iv, uint8[] plaintext, void *user_data); [CCode (cname = "signal_vala_encrypt_")] @@ -372,7 +399,7 @@ namespace Signal { return buf.data; } - [CCode (cname = "signal_vala_decrypt", cheader_filename = "signal/signal_helper.h")] + [CCode (cname = "signal_vala_decrypt", cheader_filename = "native/helper.h")] private static int aes_decrypt_(out Buffer output, int cipher, uint8[] key, uint8[] iv, uint8[] ciphertext, void *user_data); [CCode (cname = "signal_vala_decrypt_")] @@ -383,7 +410,7 @@ namespace Signal { } [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); @@ -396,7 +423,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; @@ -433,7 +460,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; @@ -458,7 +485,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; @@ -477,7 +504,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; @@ -497,7 +524,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; @@ -525,7 +552,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); @@ -536,7 +563,7 @@ namespace Signal { } - [CCode (cheader_filename = "signal/signal_protocol.h")] + [CCode (cheader_filename = "omemo/signal_protocol.h")] namespace Protocol { /** @@ -545,7 +572,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); @@ -553,7 +580,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); @@ -567,9 +594,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 = 3); 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); @@ -577,6 +604,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); @@ -584,7 +612,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")] @@ -599,13 +627,14 @@ namespace Signal { public int generate_pre_keys(out PreKeyListNode head, uint start, uint count, NativeContext global_context); public int generate_last_resort_pre_key(out PreKeyRecord pre_key, NativeContext global_context); public int generate_signed_pre_key(out SignedPreKeyRecord signed_pre_key, IdentityKeyPair identity_key_pair, uint32 signed_pre_key_id, uint64 timestamp, NativeContext global_context); + public int upgrade_signed_pre_key(ref SignedPreKeyRecord signed_pre_key, IdentityKeyPair identity_key_pair, NativeContext global_context); public int generate_sender_signing_key(out ECKeyPair key_pair, NativeContext global_context); public int generate_sender_key(out Buffer key_buffer, NativeContext global_context); public int generate_sender_key_id(out int32 key_id, NativeContext global_context); } } - [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); @@ -615,43 +644,51 @@ 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")] - 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")] - 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")] - 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")] - public static int signal_message_deserialize(out SignalMessage message, uint8[] data, NativeContext global_context); - [CCode (cname = "signal_message_copy", cheader_filename = "signal/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 = "pre_key_signal_message_deserialize", cheader_filename = "omemo/protocol.h")] + public static int pre_key_message_deserialize(out PreKeyOmemoMessage message, uint8[] data, NativeContext global_context); + [CCode (cname = "pre_key_signal_message_deserialize_omemo", cheader_filename = "omemo/protocol.h")] + public static int pre_key_message_deserialize_omemo(out PreKeyOmemoMessage message, uint8[] data, uint32 remote_registration_id, NativeContext global_context); + [CCode (cname = "pre_key_signal_message_copy", cheader_filename = "omemo/protocol.h")] + public static int pre_key_message_copy(out PreKeyOmemoMessage message, PreKeyOmemoMessage other_message, NativeContext global_context); + [CCode (cname = "signal_message_create", cheader_filename = "omemo/protocol.h")] + public static int message_create(out OmemoMessage 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 = "omemo/protocol.h")] + public static int message_deserialize(out OmemoMessage message, uint8[] data, NativeContext global_context); + [CCode (cname = "signal_message_deserialize_omemo", cheader_filename = "omemo/protocol.h")] + public static int message_deserialize_omemo(out OmemoMessage message, uint8[] data, NativeContext global_context); + [CCode (cname = "signal_message_copy", cheader_filename = "omemo/protocol.h")] + public static int message_copy(out OmemoMessage message, OmemoMessage other_message, NativeContext global_context); + [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_decode_point_ed", cheader_filename = "omemo/curve.h")] + public static int curve_decode_point_ed(out ECPublicKey public_key, uint8[] key, NativeContext global_context); + [CCode (cname = "curve_decode_point_mont", cheader_filename = "omemo/curve.h")] + public static int curve_decode_point_mont(out ECPublicKey public_key, uint8[] key, NativeContext global_context); + [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); public ssize_t derive_secrets([CCode (array_length = false)] out uint8[] output, uint8[] input_key_material, uint8[] salt, uint8[] info, size_t output_len); } - [CCode (cname = "setup_signal_vala_crypto_provider", cheader_filename = "signal/signal_helper.h")] + [CCode (cname = "setup_signal_vala_crypto_provider", cheader_filename = "native/helper.h")] public static void setup_crypto_provider(NativeContext context); - [CCode (cname = "signal_vala_randomize", cheader_filename = "signal/signal_helper.h")] + [CCode (cname = "signal_vala_randomize", cheader_filename = "native/helper.h")] public static int native_random(uint8[] data); } |
