aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CMakeLists.txt6
-rw-r--r--plugins/gpgme-vala/CMakeLists.txt52
-rw-r--r--plugins/gpgme-vala/vapi/gpgme.deps1
-rw-r--r--plugins/gpgme-vala/vapi/gpgme_public.vapi162
-rw-r--r--plugins/http-files/meson.build22
-rw-r--r--plugins/ice/meson.build28
-rw-r--r--plugins/meson.build6
-rw-r--r--plugins/notification-sound/meson.build19
-rw-r--r--plugins/omemo/CMakeLists.txt51
-rw-r--r--plugins/omemo/data/gresource.xml7
-rw-r--r--plugins/omemo/meson.build68
-rw-r--r--plugins/omemo/po/meson.build1
-rw-r--r--plugins/omemo/src/signal/context.vala (renamed from plugins/signal-protocol/src/context.vala)0
-rw-r--r--plugins/omemo/src/signal/signal_helper.c (renamed from plugins/signal-protocol/src/signal_helper.c)2
-rw-r--r--plugins/omemo/src/signal/signal_helper.h (renamed from plugins/signal-protocol/src/signal_helper.h)0
-rw-r--r--plugins/omemo/src/signal/simple_iks.vala (renamed from plugins/signal-protocol/src/simple_iks.vala)0
-rw-r--r--plugins/omemo/src/signal/simple_pks.vala (renamed from plugins/signal-protocol/src/simple_pks.vala)0
-rw-r--r--plugins/omemo/src/signal/simple_spks.vala (renamed from plugins/signal-protocol/src/simple_spks.vala)0
-rw-r--r--plugins/omemo/src/signal/simple_ss.vala (renamed from plugins/signal-protocol/src/simple_ss.vala)0
-rw-r--r--plugins/omemo/src/signal/store.vala (renamed from plugins/signal-protocol/src/store.vala)0
-rw-r--r--plugins/omemo/src/signal/util.vala (renamed from plugins/signal-protocol/src/util.vala)0
-rw-r--r--plugins/omemo/tests/signal/common.vala (renamed from plugins/signal-protocol/tests/common.vala)0
-rw-r--r--plugins/omemo/tests/signal/curve25519.vala (renamed from plugins/signal-protocol/tests/curve25519.vala)0
-rw-r--r--plugins/omemo/tests/signal/hkdf.vala (renamed from plugins/signal-protocol/tests/hkdf.vala)0
-rw-r--r--plugins/omemo/tests/signal/session_builder.vala (renamed from plugins/signal-protocol/tests/session_builder.vala)0
-rw-r--r--plugins/omemo/tests/signal/testcase.vala (renamed from plugins/signal-protocol/tests/testcase.vala)0
-rw-r--r--plugins/omemo/vapi/libgcrypt.vapi0
-rw-r--r--plugins/omemo/vapi/libsignal-protocol-c.vapi657
-rw-r--r--plugins/openpgp/CMakeLists.txt12
-rw-r--r--plugins/openpgp/data/gresource.xml6
-rw-r--r--plugins/openpgp/meson.build43
-rw-r--r--plugins/openpgp/po/meson.build1
-rw-r--r--plugins/openpgp/src/account_settings_entry.vala6
-rw-r--r--plugins/openpgp/src/gpgme_fix.c (renamed from plugins/gpgme-vala/src/gpgme_fix.c)4
-rw-r--r--plugins/openpgp/src/gpgme_fix.h (renamed from plugins/gpgme-vala/src/gpgme_fix.h)4
-rw-r--r--plugins/openpgp/src/gpgme_helper.vala (renamed from plugins/gpgme-vala/src/gpgme_helper.vala)1
-rw-r--r--plugins/openpgp/vapi/gpg-error.vapi (renamed from plugins/gpgme-vala/vapi/gpg-error.vapi)8
-rw-r--r--plugins/openpgp/vapi/gpgme.vapi (renamed from plugins/gpgme-vala/vapi/gpgme.vapi)210
-rw-r--r--plugins/rtp/meson.build64
-rw-r--r--plugins/rtp/src/video_widget.vala2
-rw-r--r--plugins/rtp/vapi/webrtc-audio-processing.vapi0
-rw-r--r--plugins/signal-protocol/CMakeLists.txt91
-rw-r--r--plugins/signal-protocol/vapi/signal-protocol-native.vapi274
-rw-r--r--plugins/signal-protocol/vapi/signal-protocol-public.vapi384
44 files changed, 1172 insertions, 1020 deletions
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 4322232b..03d7f575 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -1,9 +1,3 @@
foreach(plugin ${PLUGINS})
- if ("omemo" STREQUAL ${plugin})
- add_subdirectory(signal-protocol)
- endif ()
- if ("openpgp" STREQUAL ${plugin})
- add_subdirectory(gpgme-vala)
- endif ()
add_subdirectory(${plugin})
endforeach(plugin)
diff --git a/plugins/gpgme-vala/CMakeLists.txt b/plugins/gpgme-vala/CMakeLists.txt
deleted file mode 100644
index 5255bac4..00000000
--- a/plugins/gpgme-vala/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-find_package(GPGME REQUIRED)
-find_packages(GPGME_VALA_PACKAGES REQUIRED
- Gee
- GLib
- GObject
-)
-
-vala_precompile(GPGME_VALA_C
-SOURCES
- "src/gpgme_helper.vala"
-CUSTOM_VAPIS
- "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme.vapi"
- "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi"
- "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpg-error.vapi"
-PACKAGES
- ${GPGME_VALA_PACKAGES}
-GENERATE_VAPI
- gpgme-vala
-GENERATE_HEADER
- gpgme-vala
-)
-
-add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/gpgme_fix.h"
-COMMAND
- cp "${CMAKE_CURRENT_SOURCE_DIR}/src/gpgme_fix.h" "${CMAKE_BINARY_DIR}/exports/gpgme_fix.h"
-DEPENDS
- "${CMAKE_CURRENT_SOURCE_DIR}/src/gpgme_fix.h"
-COMMENT
- Copy header file gpgme_fix.h
-)
-
-add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/exports/gpgme.vapi
-COMMAND
- cat "${CMAKE_BINARY_DIR}/exports/gpgme-vala.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi" > "${CMAKE_BINARY_DIR}/exports/gpgme.vapi"
-DEPENDS
- ${CMAKE_BINARY_DIR}/exports/gpgme-vala.vapi
- ${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi
-)
-
-add_custom_target(gpgme-vapi
-DEPENDS
- ${CMAKE_BINARY_DIR}/exports/gpgme_fix.h
- ${CMAKE_BINARY_DIR}/exports/gpgme.vapi
-)
-
-set(CFLAGS ${VALA_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/src)
-add_definitions(${CFLAGS})
-add_library(gpgme-vala STATIC ${GPGME_VALA_C} src/gpgme_fix.c)
-add_dependencies(gpgme-vala gpgme-vapi)
-target_link_libraries(gpgme-vala ${GPGME_VALA_PACKAGES} gpgme)
-set_property(TARGET gpgme-vala PROPERTY POSITION_INDEPENDENT_CODE ON)
-
diff --git a/plugins/gpgme-vala/vapi/gpgme.deps b/plugins/gpgme-vala/vapi/gpgme.deps
deleted file mode 100644
index a0f4f82b..00000000
--- a/plugins/gpgme-vala/vapi/gpgme.deps
+++ /dev/null
@@ -1 +0,0 @@
-gpg-error
diff --git a/plugins/gpgme-vala/vapi/gpgme_public.vapi b/plugins/gpgme-vala/vapi/gpgme_public.vapi
deleted file mode 100644
index bcf12569..00000000
--- a/plugins/gpgme-vala/vapi/gpgme_public.vapi
+++ /dev/null
@@ -1,162 +0,0 @@
-[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h,gpgme_fix.h")]
-namespace GPG {
-
-[CCode (cname = "gpgme_check_version")]
-public unowned string check_version(string? required_version = null);
-
-[Compact]
-[CCode (cname = "struct _gpgme_key", ref_function = "gpgme_key_ref_vapi", unref_function = "gpgme_key_unref_vapi", free_function = "gpgme_key_release")]
-public class Key {
- public bool revoked;
- public bool expired;
- public bool disabled;
- public bool invalid;
- public bool can_encrypt;
- public bool can_sign;
- public bool can_certify;
- public bool can_authenticate;
- public bool is_qualified;
- public bool secret;
- public Protocol protocol;
- public string issuer_serial;
- public string issuer_name;
- public string chain_id;
- public Validity owner_trust;
- [CCode(array_null_terminated = true)]
- public SubKey[] subkeys;
- [CCode(array_null_terminated = true)]
- public UserID[] uids;
- public KeylistMode keylist_mode;
- // public string fpr; // requires gpgme >= 1.7.0
- public string fpr { get { return subkeys[0].fpr; } }
-}
-
-[CCode (cname = "struct _gpgme_user_id")]
-public struct UserID {
- UserID* next;
-
- bool revoked;
- bool invalid;
- Validity validity;
- string uid;
- string name;
- string email;
- string comment;
- KeySig signatures;
-}
-
-[CCode (cname = "struct _gpgme_key_sig")]
-public struct KeySig {
- KeySig* next;
- bool invoked;
- bool expired;
- bool invalid;
- bool exportable;
- PublicKeyAlgorithm algo;
- string keyid;
- long timestamp;
- long expires;
-// GPGError.Error status;
- string uid;
- string name;
- string email;
- string comment;
- uint sig_class;
- SigNotation notations;
-}
-
-[CCode (cname = "struct _gpgme_subkey")]
-public struct SubKey {
- SubKey* next;
- bool revoked;
- bool expired;
- bool disabled;
- bool invalid;
- bool can_encrypt;
- bool can_sign;
- bool can_certify;
- bool secret;
- bool can_authenticate;
- bool is_qualified;
- bool is_cardkey;
- PublicKeyAlgorithm algo;
- uint length;
- string keyid;
-
- string fpr;
- long timestamp;
- long expires;
- string? cardnumber;
-}
-
-[CCode (cname = "struct _gpgme_sig_notation")]
-public struct SigNotation {
- SigNotation* next;
- string? name;
- string value;
- int name_len;
- int value_len;
- SigNotationFlags flags;
- bool human_readable;
- bool critical;
-}
-
-[CCode (cname = "gpgme_sig_notation_flags_t", cprefix = "GPGME_SIG_NOTATION_")]
-public enum SigNotationFlags {
- HUMAN_READABLE,
- CRITICAL
-}
-
-[CCode (cname = "gpgme_sig_mode_t", cprefix = "GPGME_SIG_MODE_")]
-public enum SigMode {
- NORMAL,
- DETACH,
- CLEAR
-}
-
-[CCode (cname = "gpgme_encrypt_flags_t", cprefix = "GPGME_ENCRYPT_")]
-public enum EncryptFlags {
- ALWAYS_TRUST,
- NO_ENCRYPT_TO
-}
-
-[CCode (cname = "gpgme_pubkey_algo_t", cprefix = "GPGME_PK_")]
-public enum PublicKeyAlgorithm {
- RSA,
- RSA_E,
- RSA_S,
- ELG_E,
- DSA,
- ELG
-}
-
-[CCode (cname = "gpgme_protocol_t", cprefix = "GPGME_PROTOCOL_")]
-public enum Protocol {
- OpenPGP,
- CMS,
- GPGCONF,
- ASSUAN,
- UNKNOWN
-}
-
-[CCode (cname = "gpgme_keylist_mode_t", cprefix = "GPGME_KEYLIST_MODE_")]
-public enum KeylistMode {
- LOCAL,
- EXTERN,
- SIGS,
- SIG_NOTATIONS,
- EPHEMERAL,
- VALIDATE
-}
-
-[CCode (cname = "gpgme_validity_t", cprefix = "GPGME_VALIDITY_")]
-public enum Validity {
- UNKNOWN,
- UNDEFINED,
- NEVER,
- MARGINAL,
- FULL,
- ULTIMATE
-}
-
-} \ No newline at end of file
diff --git a/plugins/http-files/meson.build b/plugins/http-files/meson.build
new file mode 100644
index 00000000..6b0f3820
--- /dev/null
+++ b/plugins/http-files/meson.build
@@ -0,0 +1,22 @@
+dependencies = [
+ dep_dino,
+ dep_gee,
+ dep_glib,
+ dep_gmodule,
+ dep_gtk4,
+ dep_libsoup,
+ dep_qlite,
+ dep_xmpp_vala,
+]
+sources = files(
+ 'src/file_provider.vala',
+ 'src/file_sender.vala',
+ 'src/plugin.vala',
+ 'src/register_plugin.vala',
+)
+
+vala_args = [
+ '--define=SOUP_3_0',
+]
+lib_http_files = shared_library('http-files', sources, name_prefix: '', vala_args: vala_args, dependencies: dependencies, install: true, install_dir: get_option('libdir') / 'dino/plugins')
+dep_http_files = declare_dependency(link_with: lib_http_files, include_directories: include_directories('.'))
diff --git a/plugins/ice/meson.build b/plugins/ice/meson.build
new file mode 100644
index 00000000..40e54ce3
--- /dev/null
+++ b/plugins/ice/meson.build
@@ -0,0 +1,28 @@
+dependencies = [
+ dep_crypto_vala,
+ dep_dino,
+ dep_gdk_pixbuf,
+ dep_gee,
+ dep_glib,
+ dep_gmodule,
+ dep_gnutls,
+ dep_nice,
+ dep_qlite,
+ dep_xmpp_vala,
+]
+sources = files(
+ 'src/dtls_srtp.vala',
+ 'src/module.vala',
+ 'src/plugin.vala',
+ 'src/transport_parameters.vala',
+ 'src/util.vala',
+ 'src/register_plugin.vala',
+)
+c_args = [
+ '-DG_LOG_DOMAIN="ice"',
+]
+vala_args = [
+ '--vapidir', meson.current_source_dir() / 'vapi',
+]
+lib_ice = shared_library('ice', sources, name_prefix: '', c_args: c_args, vala_args: vala_args, dependencies: dependencies, install: true, install_dir: get_option('libdir') / 'dino/plugins')
+dep_ice = declare_dependency(link_with: lib_ice, include_directories: include_directories('.'))
diff --git a/plugins/meson.build b/plugins/meson.build
new file mode 100644
index 00000000..196e3634
--- /dev/null
+++ b/plugins/meson.build
@@ -0,0 +1,6 @@
+subdir('http-files')
+subdir('ice')
+subdir('notification-sound')
+subdir('omemo')
+subdir('openpgp')
+subdir('rtp')
diff --git a/plugins/notification-sound/meson.build b/plugins/notification-sound/meson.build
new file mode 100644
index 00000000..5a114d86
--- /dev/null
+++ b/plugins/notification-sound/meson.build
@@ -0,0 +1,19 @@
+dependencies = [
+ dep_dino,
+ dep_gdk_pixbuf,
+ dep_gee,
+ dep_glib,
+ dep_gmodule,
+ dep_libcanberra,
+ dep_qlite,
+ dep_xmpp_vala,
+]
+sources = files(
+ 'src/plugin.vala',
+ 'src/register_plugin.vala',
+)
+vala_args = [
+ '--vapidir', meson.current_source_dir() / 'vapi',
+]
+lib_notification_sound = shared_library('notification-sound', sources, name_prefix: '', vala_args: vala_args, dependencies: dependencies, install: true, install_dir: get_option('libdir') / 'dino/plugins')
+dep_notification_sound = declare_dependency(link_with: lib_notification_sound, include_directories: include_directories('.'))
diff --git a/plugins/omemo/CMakeLists.txt b/plugins/omemo/CMakeLists.txt
index dc9a93b0..7ecaa0b8 100644
--- a/plugins/omemo/CMakeLists.txt
+++ b/plugins/omemo/CMakeLists.txt
@@ -12,6 +12,11 @@ find_packages(OMEMO_PACKAGES REQUIRED
GTK4
)
+# 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 REQUIRED)
+
set(RESOURCE_LIST
contact_details_dialog.ui
manage_key_dialog.ui
@@ -52,6 +57,14 @@ SOURCES
src/protocol/message_flag.vala
src/protocol/stream_module.vala
+ src/signal/context.vala
+ src/signal/simple_iks.vala
+ src/signal/simple_ss.vala
+ src/signal/simple_pks.vala
+ src/signal/simple_spks.vala
+ src/signal/store.vala
+ src/signal/util.vala
+
src/ui/account_settings_entry.vala
src/ui/bad_messages_populator.vala
src/ui/call_encryption_entry.vala
@@ -64,22 +77,52 @@ SOURCES
src/ui/util.vala
CUSTOM_VAPIS
${CMAKE_BINARY_DIR}/exports/crypto-vala.vapi
- ${CMAKE_BINARY_DIR}/exports/signal-protocol.vapi
${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi
${CMAKE_BINARY_DIR}/exports/qlite.vapi
${CMAKE_BINARY_DIR}/exports/dino.vapi
${CMAKE_CURRENT_SOURCE_DIR}/vapi/libqrencode.vapi
+ ${CMAKE_CURRENT_SOURCE_DIR}/vapi/libsignal-protocol-c.vapi
PACKAGES
${OMEMO_PACKAGES}
GRESOURCES
${OMEMO_GRESOURCES_XML}
+GENERATE_VAPI
+ omemo
+GENERATE_HEADER
+ 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_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} ${CMAKE_CURRENT_SOURCE_DIR}/src/signal/signal_helper.c)
add_dependencies(omemo ${GETTEXT_PACKAGE}-translations)
-target_link_libraries(omemo libdino signal-protocol-vala crypto-vala ${OMEMO_PACKAGES} libqrencode)
+target_include_directories(omemo PUBLIC src)
+target_link_libraries(omemo libdino crypto-vala gcrypt ${OMEMO_PACKAGES} libqrencode signal-protocol-c)
set_target_properties(omemo PROPERTIES PREFIX "")
set_target_properties(omemo PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/)
install(TARGETS omemo ${PLUGIN_INSTALL})
+
+if(BUILD_TESTS)
+ vala_precompile(OMEMO_TEST_VALA_C
+ SOURCES
+ "tests/signal/common.vala"
+ "tests/signal/testcase.vala"
+
+ "tests/signal/curve25519.vala"
+ "tests/signal/hkdf.vala"
+ "tests/signal/session_builder.vala"
+ CUSTOM_VAPIS
+ ${CMAKE_BINARY_DIR}/exports/omemo_internal.vapi
+ ${CMAKE_BINARY_DIR}/exports/qlite.vapi
+ ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi
+ ${CMAKE_BINARY_DIR}/exports/dino.vapi
+ ${CMAKE_CURRENT_SOURCE_DIR}/vapi/libsignal-protocol-c.vapi
+ PACKAGES
+ ${OMEMO_PACKAGES}
+ )
+
+ set(CFLAGS ${VALA_CFLAGS})
+ add_executable(omemo-test ${OMEMO_TEST_VALA_C})
+ add_dependencies(omemo-test omemo)
+ target_link_libraries(omemo-test omemo ${OMEMO_PACKAGES})
+endif(BUILD_TESTS)
diff --git a/plugins/omemo/data/gresource.xml b/plugins/omemo/data/gresource.xml
new file mode 100644
index 00000000..616dcdc1
--- /dev/null
+++ b/plugins/omemo/data/gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/im/dino/Dino/omemo">
+ <file>contact_details_dialog.ui</file>
+ <file>manage_key_dialog.ui</file>
+ </gresource>
+</gresources>
diff --git a/plugins/omemo/meson.build b/plugins/omemo/meson.build
new file mode 100644
index 00000000..57eec2ce
--- /dev/null
+++ b/plugins/omemo/meson.build
@@ -0,0 +1,68 @@
+subdir('po')
+dependencies = [
+ dep_crypto_vala,
+ dep_dino,
+ dep_gee,
+ dep_glib,
+ dep_gmodule,
+ dep_gtk4,
+ dep_libgcrypt,
+ dep_libqrencode,
+ dep_libsignal_protocol_c,
+ dep_qlite,
+ dep_xmpp_vala,
+]
+sources = files(
+ 'src/dtls_srtp_verification_draft.vala',
+ 'src/file_transfer/file_decryptor.vala',
+ 'src/file_transfer/file_encryptor.vala',
+ 'src/jingle/jet_omemo.vala',
+ 'src/jingle/jingle_helper.vala',
+ 'src/logic/database.vala',
+ 'src/logic/decrypt.vala',
+ 'src/logic/encrypt.vala',
+ 'src/logic/manager.vala',
+ 'src/logic/pre_key_store.vala',
+ 'src/logic/session_store.vala',
+ 'src/logic/signed_pre_key_store.vala',
+ 'src/logic/trust_manager.vala',
+ 'src/plugin.vala',
+ 'src/protocol/bundle.vala',
+ '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/trust_level.vala',
+ 'src/ui/account_settings_entry.vala',
+ 'src/ui/bad_messages_populator.vala',
+ 'src/ui/call_encryption_entry.vala',
+ 'src/ui/contact_details_dialog.vala',
+ 'src/ui/contact_details_provider.vala',
+ 'src/ui/device_notification_populator.vala',
+ 'src/ui/encryption_list_entry.vala',
+ 'src/ui/manage_key_dialog.vala',
+ 'src/ui/own_notifications.vala',
+ 'src/ui/util.vala',
+)
+sources += gnome.compile_resources(
+ 'resources',
+ 'data/gresource.xml',
+ source_dir: 'data',
+)
+c_args = [
+ '-DG_LOG_DOMAIN="OMEMO"',
+ '-DGETTEXT_PACKAGE="dino-omemo"',
+ '-DLOCALE_INSTALL_DIR="@0@"'.format(get_option('prefix') / get_option('localedir')),
+]
+vala_args = [
+ '--vapidir', meson.current_source_dir() / 'vapi',
+]
+lib_omemo = shared_library('omemo', sources, name_prefix: '', c_args: c_args, vala_args: vala_args, include_directories: include_directories('src'), dependencies: dependencies, install: true, install_dir: get_option('libdir') / 'dino/plugins')
+dep_omemo = declare_dependency(link_with: lib_omemo, include_directories: include_directories('.'))
diff --git a/plugins/omemo/po/meson.build b/plugins/omemo/po/meson.build
new file mode 100644
index 00000000..fa22f211
--- /dev/null
+++ b/plugins/omemo/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext('dino-omemo')
diff --git a/plugins/signal-protocol/src/context.vala b/plugins/omemo/src/signal/context.vala
index 40a07b0f..40a07b0f 100644
--- a/plugins/signal-protocol/src/context.vala
+++ b/plugins/omemo/src/signal/context.vala
diff --git a/plugins/signal-protocol/src/signal_helper.c b/plugins/omemo/src/signal/signal_helper.c
index 1a428c44..17682929 100644
--- a/plugins/signal-protocol/src/signal_helper.c
+++ b/plugins/omemo/src/signal/signal_helper.c
@@ -1,4 +1,4 @@
-#include <signal_helper.h>
+#include "signal_helper.h"
#include <gcrypt.h>
diff --git a/plugins/signal-protocol/src/signal_helper.h b/plugins/omemo/src/signal/signal_helper.h
index 949a3c7b..949a3c7b 100644
--- a/plugins/signal-protocol/src/signal_helper.h
+++ b/plugins/omemo/src/signal/signal_helper.h
diff --git a/plugins/signal-protocol/src/simple_iks.vala b/plugins/omemo/src/signal/simple_iks.vala
index 5247c455..5247c455 100644
--- a/plugins/signal-protocol/src/simple_iks.vala
+++ b/plugins/omemo/src/signal/simple_iks.vala
diff --git a/plugins/signal-protocol/src/simple_pks.vala b/plugins/omemo/src/signal/simple_pks.vala
index 1f059fda..1f059fda 100644
--- a/plugins/signal-protocol/src/simple_pks.vala
+++ b/plugins/omemo/src/signal/simple_pks.vala
diff --git a/plugins/signal-protocol/src/simple_spks.vala b/plugins/omemo/src/signal/simple_spks.vala
index f0fe09ab..f0fe09ab 100644
--- a/plugins/signal-protocol/src/simple_spks.vala
+++ b/plugins/omemo/src/signal/simple_spks.vala
diff --git a/plugins/signal-protocol/src/simple_ss.vala b/plugins/omemo/src/signal/simple_ss.vala
index 5213f736..5213f736 100644
--- a/plugins/signal-protocol/src/simple_ss.vala
+++ b/plugins/omemo/src/signal/simple_ss.vala
diff --git a/plugins/signal-protocol/src/store.vala b/plugins/omemo/src/signal/store.vala
index b440d838..b440d838 100644
--- a/plugins/signal-protocol/src/store.vala
+++ b/plugins/omemo/src/signal/store.vala
diff --git a/plugins/signal-protocol/src/util.vala b/plugins/omemo/src/signal/util.vala
index 4c0ae72d..4c0ae72d 100644
--- a/plugins/signal-protocol/src/util.vala
+++ b/plugins/omemo/src/signal/util.vala
diff --git a/plugins/signal-protocol/tests/common.vala b/plugins/omemo/tests/signal/common.vala
index 9bb9b1dc..9bb9b1dc 100644
--- a/plugins/signal-protocol/tests/common.vala
+++ b/plugins/omemo/tests/signal/common.vala
diff --git a/plugins/signal-protocol/tests/curve25519.vala b/plugins/omemo/tests/signal/curve25519.vala
index 6dfae62f..6dfae62f 100644
--- a/plugins/signal-protocol/tests/curve25519.vala
+++ b/plugins/omemo/tests/signal/curve25519.vala
diff --git a/plugins/signal-protocol/tests/hkdf.vala b/plugins/omemo/tests/signal/hkdf.vala
index c30af275..c30af275 100644
--- a/plugins/signal-protocol/tests/hkdf.vala
+++ b/plugins/omemo/tests/signal/hkdf.vala
diff --git a/plugins/signal-protocol/tests/session_builder.vala b/plugins/omemo/tests/signal/session_builder.vala
index 7e2448e1..7e2448e1 100644
--- a/plugins/signal-protocol/tests/session_builder.vala
+++ b/plugins/omemo/tests/signal/session_builder.vala
diff --git a/plugins/signal-protocol/tests/testcase.vala b/plugins/omemo/tests/signal/testcase.vala
index 59fcf193..59fcf193 100644
--- a/plugins/signal-protocol/tests/testcase.vala
+++ b/plugins/omemo/tests/signal/testcase.vala
diff --git a/plugins/omemo/vapi/libgcrypt.vapi b/plugins/omemo/vapi/libgcrypt.vapi
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/plugins/omemo/vapi/libgcrypt.vapi
diff --git a/plugins/omemo/vapi/libsignal-protocol-c.vapi b/plugins/omemo/vapi/libsignal-protocol-c.vapi
new file mode 100644
index 00000000..7c63d418
--- /dev/null
+++ b/plugins/omemo/vapi/libsignal-protocol-c.vapi
@@ -0,0 +1,657 @@
+namespace Signal {
+
+ [CCode (cname = "int", cprefix = "SG_ERR_", cheader_filename = "signal/signal_protocol.h", has_type_id = false)]
+ public enum ErrorCode {
+ [CCode (cname = "SG_SUCCESS")]
+ SUCCESS,
+ NOMEM,
+ INVAL,
+ UNKNOWN,
+ DUPLICATE_MESSAGE,
+ INVALID_KEY,
+ INVALID_KEY_ID,
+ INVALID_MAC,
+ INVALID_MESSAGE,
+ INVALID_VERSION,
+ LEGACY_MESSAGE,
+ NO_SESSION,
+ STALE_KEY_EXCHANGE,
+ UNTRUSTED_IDENTITY,
+ VRF_SIG_VERIF_FAILED,
+ INVALID_PROTO_BUF,
+ FP_VERSION_MISMATCH,
+ FP_IDENT_MISMATCH;
+ }
+
+ [CCode (cname = "SG_ERR_MINIMUM", cheader_filename = "signal/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)]
+ public enum LogLevel {
+ ERROR,
+ WARNING,
+ NOTICE,
+ INFO,
+ DEBUG
+ }
+
+ [CCode (cname = "signal_throw_gerror_by_code_", cheader_filename = "signal/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());
+ }
+ return code;
+ }
+
+ [CCode (cname = "int", cprefix = "SG_CIPHER_", cheader_filename = "signal/signal_protocol.h", has_type_id = false)]
+ public enum Cipher {
+ AES_CTR_NOPADDING,
+ AES_CBC_PKCS5,
+ AES_GCM_NOPADDING
+ }
+
+ [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")]
+ public class TypeBase {
+ }
+
+ [Compact]
+ [CCode (cname = "signal_buffer", cheader_filename = "signal/signal_protocol_types.h", free_function="signal_buffer_free")]
+ public class Buffer {
+ [CCode (cname = "signal_buffer_alloc")]
+ public Buffer(size_t len);
+ [CCode (cname = "signal_buffer_create")]
+ public Buffer.from(uint8[] data);
+
+ public Buffer copy();
+ public Buffer append(uint8[] data);
+ public int compare(Buffer other);
+
+ public uint8 get(int i) { return data[i]; }
+ public void set(int i, uint8 val) { data[i] = val; }
+
+ public uint8[] data { get { int x = (int)len(); unowned uint8[] res = _data(); res.length = x; return res; } }
+
+ [CCode (array_length = false, cname = "signal_buffer_data")]
+ private unowned uint8[] _data();
+ private size_t len();
+ }
+
+ [Compact]
+ [CCode (cname = "signal_int_list", cheader_filename = "signal/signal_protocol_types.h", free_function="signal_int_list_free")]
+ public class IntList {
+ [CCode (cname = "signal_int_list_alloc")]
+ public IntList();
+ [CCode (cname = "signal_int_list_push_back")]
+ public int add(int value);
+ public uint size { [CCode (cname = "signal_int_list_size")] get; }
+ [CCode (cname = "signal_int_list_at")]
+ public int get(uint index);
+ }
+
+ [Compact]
+ [CCode (cname = "session_builder", cprefix = "session_builder_", free_function="session_builder_free", cheader_filename = "signal/session_builder.h")]
+ public class SessionBuilder {
+ [CCode (cname = "session_builder_process_pre_key_bundle")]
+ private int process_pre_key_bundle_(PreKeyBundle pre_key_bundle);
+ [CCode (cname = "session_builder_process_pre_key_bundle_")]
+ public void process_pre_key_bundle(PreKeyBundle pre_key_bundle) throws GLib.Error {
+ throw_by_code(process_pre_key_bundle_(pre_key_bundle));
+ }
+ }
+
+ [Compact]
+ [CCode (cname = "session_pre_key_bundle", cprefix = "session_pre_key_bundle_", cheader_filename = "signal/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);
+ public uint32 registration_id { get; }
+ public int device_id { get; }
+ public uint32 pre_key_id { get; }
+ public ECPublicKey pre_key { owned get; }
+ public uint32 signed_pre_key_id { get; }
+ public ECPublicKey signed_pre_key { owned get; }
+ public Buffer signed_pre_key_signature { owned get; }
+ public ECPublicKey identity_key { owned get; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_pre_key", cprefix = "session_pre_key_", cheader_filename = "signal/session_pre_key.h,signal/signal_helper.h")]
+ public class PreKeyRecord : TypeBase {
+ public static int create(out PreKeyRecord pre_key, uint32 id, ECKeyPair key_pair);
+ //public static int deserialize(out PreKeyRecord pre_key, uint8[] data, NativeContext global_context);
+ [CCode (instance_pos = 2)]
+ public int serialze(out Buffer buffer);
+ public uint32 id { get; }
+ public ECKeyPair key_pair { get; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_record", cprefix = "session_record_", cheader_filename = "signal/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")]
+ public class SessionState : TypeBase {
+ //public static int create(out SessionState state, NativeContext context);
+ //public static int deserialize(out SessionState state, uint8[] data, NativeContext context);
+ //public static int copy(out SessionState state, SessionState other_state, NativeContext context);
+ [CCode (instance_pos = 2)]
+ public int serialze(out Buffer buffer);
+
+ public uint32 session_version { get; set; }
+ public ECPublicKey local_identity_key { get; set; }
+ public ECPublicKey remote_identity_key { get; set; }
+ //public Ratchet.RootKey root_key { get; set; }
+ public uint32 previous_counter { get; set; }
+ public ECPublicKey sender_ratchet_key { get; }
+ public ECKeyPair sender_ratchet_key_pair { get; }
+ //public Ratchet.ChainKey sender_chain_key { get; set; }
+ public uint32 remote_registration_id { get; set; }
+ public uint32 local_registration_id { get; set; }
+ public int needs_refresh { get; set; }
+ public ECPublicKey alice_base_key { get; set; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_signed_pre_key", cprefix = "session_signed_pre_key_", cheader_filename = "signal/session_pre_key.h")]
+ public class SignedPreKeyRecord : TypeBase {
+ public static int create(out SignedPreKeyRecord pre_key, uint32 id, uint64 timestamp, ECKeyPair key_pair, uint8[] signature);
+ [CCode (instance_pos = 2)]
+ public int serialze(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; } }
+
+ [CCode (array_length = false, cname = "session_signed_pre_key_get_signature")]
+ private unowned uint8[] get_signature();
+ private size_t get_signature_len();
+ }
+
+ /**
+ * Address of an Signal Protocol message recipient
+ */
+ [Compact]
+ [CCode (cname = "signal_protocol_address", cprefix = "signal_protocol_address_", cheader_filename = "signal/signal_protocol.h,signal/signal_helper.h")]
+ public class Address {
+ public Address(string name, int32 device_id);
+ public int32 device_id { get; set; }
+ public string name { owned get; set; }
+ }
+
+ /**
+ * A representation of a (group + sender + device) tuple
+ */
+ [Compact]
+ [CCode (cname = "signal_protocol_sender_key_name")]
+ public class SenderKeyName {
+ [CCode (cname = "group_id", array_length_cname="group_id_len")]
+ private char* group_id_;
+ private size_t group_id_len;
+ public Address sender;
+ }
+
+ [Compact]
+ [CCode (cname = "ec_public_key", cprefix = "ec_public_key_", cheader_filename = "signal/curve.h,signal/signal_helper.h")]
+ public class ECPublicKey : TypeBase {
+ [CCode (cname = "curve_generate_public_key")]
+ public static int generate(out ECPublicKey public_key, ECPrivateKey private_key);
+ [CCode (instance_pos = 1, cname = "ec_public_key_serialize")]
+ private int serialize_([CCode (pos = 0)] out Buffer buffer);
+ [CCode (cname = "ec_public_key_serialize_")]
+ public uint8[] serialize() {
+ Buffer buffer;
+ int code = serialize_(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 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")]
+ public class ECPrivateKey : TypeBase {
+ [CCode (instance_pos = 1, cname = "ec_private_key_serialize")]
+ private int serialize_([CCode (pos = 0)] out Buffer buffer);
+ [CCode (cname = "ec_private_key_serialize_")]
+ public uint8[] serialize() throws GLib.Error {
+ Buffer buffer;
+ int code = serialize_(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 int compare(ECPublicKey other);
+ }
+
+ [Compact]
+ [CCode (cname = "ec_key_pair", cprefix="ec_key_pair_", cheader_filename = "signal/curve.h,signal/signal_helper.h")]
+ public class ECKeyPair : TypeBase {
+ public static int create(out ECKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
+ public ECPublicKey public { get; }
+ public ECPrivateKey private { get; }
+ }
+
+ [CCode (cname = "ratchet_message_keys", cheader_filename = "signal/ratchet.h")]
+ public class MessageKeys {
+ }
+
+ [Compact]
+ [CCode (cname = "ratchet_identity_key_pair", cprefix = "ratchet_identity_key_pair_", cheader_filename = "signal/ratchet.h,signal/signal_helper.h")]
+ public class IdentityKeyPair : TypeBase {
+ public static int create(out IdentityKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
+ public int serialze(out Buffer buffer);
+ public ECPublicKey public { get; }
+ public ECPrivateKey private { get; }
+ }
+
+ [Compact]
+ [CCode (cname = "ec_public_key_list")]
+ public class PublicKeyList {}
+
+ /**
+ * The main entry point for Signal Protocol 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")]
+ public class SessionCipher {
+ public void* user_data { get; set; }
+ public DecryptionCallback decryption_callback { set; }
+ [CCode (cname = "session_cipher_encrypt")]
+ private int encrypt_(uint8[] padded_message, out CiphertextMessage encrypted_message);
+ [CCode (cname = "session_cipher_encrypt_")]
+ public CiphertextMessage encrypt(uint8[] padded_message) throws GLib.Error {
+ CiphertextMessage res;
+ throw_by_code(encrypt_(padded_message, out res));
+ 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);
+ [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 {
+ Buffer res;
+ throw_by_code(decrypt_pre_key_signal_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);
+ [CCode (cname = "session_cipher_decrypt_signal_message_")]
+ public uint8[] decrypt_signal_message(SignalMessage ciphertext, void* decrypt_context = null) throws GLib.Error {
+ Buffer res;
+ throw_by_code(decrypt_signal_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 (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)]
+ public enum CiphertextType {
+ [CCode (cname = "CIPHERTEXT_SIGNAL_TYPE")]
+ SIGNAL,
+ [CCode (cname = "CIPHERTEXT_PREKEY_TYPE")]
+ PREKEY,
+ [CCode (cname = "CIPHERTEXT_SENDERKEY_TYPE")]
+ SENDERKEY,
+ [CCode (cname = "CIPHERTEXT_SENDERKEY_DISTRIBUTION_TYPE")]
+ SENDERKEY_DISTRIBUTION
+ }
+
+ [Compact]
+ [CCode (cname = "ciphertext_message", cprefix = "ciphertext_message_", cheader_filename = "signal/protocol.h,signal/signal_helper.h")]
+ public abstract class CiphertextMessage : TypeBase {
+ public CiphertextType type { get; }
+ [CCode (cname = "ciphertext_message_get_serialized")]
+ private unowned Buffer get_serialized_();
+ public uint8[] serialized { [CCode (cname = "ciphertext_message_get_serialized_")] get {
+ return get_serialized_().data;
+ }}
+ }
+ [Compact]
+ [CCode (cname = "signal_message", cprefix = "signal_message_", cheader_filename = "signal/protocol.h,signal/signal_helper.h")]
+ public class SignalMessage : CiphertextMessage {
+ public ECPublicKey sender_ratchet_key { get; }
+ public uint8 message_version { get; }
+ public uint32 counter { get; }
+ public Buffer body { get; }
+ //public int verify_mac(uint8 message_version, ECPublicKey sender_identity_key, ECPublicKey receiver_identity_key, uint8[] mac, NativeContext global_context);
+ 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 {
+ 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; }
+ }
+ [Compact]
+ [CCode (cname = "sender_key_message", cprefix = "sender_key_message_", cheader_filename = "signal/protocol.h,signal/signal_helper.h")]
+ public class SenderKeyMessage : CiphertextMessage {
+ public uint32 key_id { get; }
+ public uint32 iteration { get; }
+ public Buffer ciphertext { get; }
+ }
+ [Compact]
+ [CCode (cname = "sender_key_distribution_message", cprefix = "sender_key_distribution_message_", cheader_filename = "signal/protocol.h,signal/signal_helper.h")]
+ public class SenderKeyDistributionMessage : CiphertextMessage {
+ public uint32 id { get; }
+ public uint32 iteration { get; }
+ public Buffer chain_key { get; }
+ public ECPublicKey signature_key { get; }
+ }
+
+ [CCode (cname = "signal_vala_encrypt", cheader_filename = "signal/signal_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_")]
+ public uint8[] aes_encrypt(int cipher, uint8[] key, uint8[] iv, uint8[] plaintext) throws GLib.Error {
+ Buffer buf;
+ throw_by_code(aes_encrypt_(out buf, cipher, key, iv, plaintext, null));
+ return buf.data;
+ }
+
+ [CCode (cname = "signal_vala_decrypt", cheader_filename = "signal/signal_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_")]
+ public uint8[] aes_decrypt(int cipher, uint8[] key, uint8[] iv, uint8[] ciphertext) throws GLib.Error {
+ Buffer buf;
+ throw_by_code(aes_decrypt_(out buf, cipher, key, iv, ciphertext, null));
+ return buf.data;
+ }
+
+ [Compact]
+ [CCode (cname = "signal_context", cprefix="signal_context_", free_function="signal_context_destroy", cheader_filename = "signal/signal_protocol.h")]
+ public class NativeContext {
+ public static int create(out NativeContext context, void* user_data);
+ public int set_crypto_provider(NativeCryptoProvider crypto_provider);
+ public int set_locking_functions(LockingFunc lock, LockingFunc unlock);
+ public int set_log_function(LogFunc log);
+ }
+ [CCode (has_target = false)]
+ public delegate void LockingFunc(void* user_data);
+ [CCode (has_target = false)]
+ 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")]
+ public struct NativeCryptoProvider {
+ public RandomFunc random_func;
+ public HmacSha256Init hmac_sha256_init_func;
+ public HmacSha256Update hmac_sha256_update_func;
+ public HmacSha256Final hmac_sha256_final_func;
+ public HmacSha256Cleanup hmac_sha256_cleanup_func;
+ public Sha512DigestInit sha512_digest_init_func;
+ public Sha512DigestUpdate sha512_digest_update_func;
+ public Sha512DigestFinal sha512_digest_final_func;
+ public Sha512DigestCleanup sha512_digest_cleanup_func;
+ public CryptFunc encrypt_func;
+ public CryptFunc decrypt_func;
+ public void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int RandomFunc(uint8[] data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Init(out void* hmac_context, uint8[] key, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Update(void* hmac_context, uint8[] data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Final(void* hmac_context, out Buffer buffer, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Cleanup(void* hmac_context, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestInit(out void* digest_context, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestUpdate(void* digest_context, uint8[] data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestFinal(void* digest_context, out Buffer buffer, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestCleanup(void* digest_context, void* user_data);
+ [CCode (has_target = false)]
+ 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")]
+ public struct NativeSessionStore {
+ public LoadSessionFunc load_session_func;
+ public GetSubDeviceSessionsFunc get_sub_device_sessions_func;
+ public StoreSessionFunc store_session_func;
+ public ContainsSessionFunc contains_session_func;
+ public DeleteSessionFunc delete_session_func;
+ public DeleteAllSessionsFunc delete_all_sessions_func;
+ public DestroyFunc destroy_func;
+ public void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int LoadSessionFunc(out Buffer record, out Buffer user_record, Address address, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int GetSubDeviceSessionsFunc(out IntList sessions, [CCode (array_length_type = "size_t")] char[] name, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int StoreSessionFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int ContainsSessionFunc(Address address, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int DeleteSessionFunc(Address address, void* user_data);
+ [CCode (has_target = false)]
+ 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")]
+ public struct NativeIdentityKeyStore {
+ GetIdentityKeyPairFunc get_identity_key_pair;
+ GetLocalRegistrationIdFunc get_local_registration_id;
+ SaveIdentityFunc save_identity;
+ IsTrustedIdentityFunc is_trusted_identity;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int GetIdentityKeyPairFunc(out Buffer public_data, out Buffer private_data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int GetLocalRegistrationIdFunc(void* user_data, out uint32 registration_id);
+ [CCode (has_target = false)]
+ public delegate int SaveIdentityFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data);
+ [CCode (has_target = false)]
+ 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")]
+ public struct NativePreKeyStore {
+ LoadPreKeyFunc load_pre_key;
+ StorePreKeyFunc store_pre_key;
+ ContainsPreKeyFunc contains_pre_key;
+ RemovePreKeyFunc remove_pre_key;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int LoadPreKeyFunc(out Buffer record, uint32 pre_key_id, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int StorePreKeyFunc(uint32 pre_key_id, [CCode (array_length_type = "size_t")] uint8[] record, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int ContainsPreKeyFunc(uint32 pre_key_id, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int RemovePreKeyFunc(uint32 pre_key_id, void* user_data);
+
+
+ [Compact]
+ [CCode (cname = "signal_protocol_signed_pre_key_store", cheader_filename = "signal/signal_protocol.h")]
+ public struct NativeSignedPreKeyStore {
+ LoadPreKeyFunc load_signed_pre_key;
+ StorePreKeyFunc store_signed_pre_key;
+ ContainsPreKeyFunc contains_signed_pre_key;
+ RemovePreKeyFunc remove_signed_pre_key;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+
+
+ [Compact]
+ [CCode (cname = "signal_protocol_sender_key_store")]
+ public struct NativeSenderKeyStore {
+ StoreSenderKeyFunc store_sender_key;
+ LoadSenderKeyFunc load_sender_key;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int StoreSenderKeyFunc(SenderKeyName sender_key_name, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int LoadSenderKeyFunc(out Buffer record, out Buffer user_record, SenderKeyName sender_key_name, void* user_data);
+
+ [CCode (has_target = false)]
+ 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")]
+ public class NativeStoreContext {
+ public static int create(out NativeStoreContext context, NativeContext global_context);
+ public int set_session_store(NativeSessionStore store);
+ public int set_pre_key_store(NativePreKeyStore store);
+ public int set_signed_pre_key_store(NativeSignedPreKeyStore store);
+ public int set_identity_key_store(NativeIdentityKeyStore store);
+ public int set_sender_key_store(NativeSenderKeyStore store);
+ }
+
+
+ [CCode (cheader_filename = "signal/signal_protocol.h")]
+ namespace Protocol {
+
+ /**
+ * Interface to the pre-key store.
+ * These functions will use the callbacks in the provided
+ * signal_protocol_store_context instance and operate in terms of higher level
+ * library data structures.
+ */
+ [CCode (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);
+ public int contains_key(NativeStoreContext context, uint32 pre_key_id);
+ public int remove_key(NativeStoreContext context, uint32 pre_key_id);
+ }
+
+ [CCode (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);
+ public int contains_key(NativeStoreContext context, uint32 pre_key_id);
+ public int remove_key(NativeStoreContext context, uint32 pre_key_id);
+ }
+
+ /**
+ * Interface to the session store.
+ * These functions will use the callbacks in the provided
+ * signal_protocol_store_context instance and operate in terms of higher level
+ * library data structures.
+ */
+ [CCode (cprefix = "signal_protocol_session_")]
+ namespace Session {
+ public int load_session(NativeStoreContext context, out SessionRecord record, Address address);
+ 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);
+ public int delete_session(NativeStoreContext context, Address address);
+ public int delete_all_sessions(NativeStoreContext context, char[] name);
+ }
+
+ 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);
+ public int save_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_")]
+ 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")]
+ public class PreKeyListNode {
+ public PreKeyRecord element();
+ public PreKeyListNode next();
+ }
+
+ public int generate_identity_key_pair(out IdentityKeyPair key_pair, NativeContext global_context);
+ public int generate_registration_id(out int32 registration_id, int extended_range, NativeContext global_context);
+ public int get_random_sequence(out int value, int max, NativeContext global_context);
+ 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 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")]
+ 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);
+ [CCode (cname = "curve_calculate_signature")]
+ public int calculate_signature(NativeContext context, out Buffer signature, ECPrivateKey signing_key, uint8[] message);
+ [CCode (cname = "curve_verify_signature")]
+ public int verify_signature(ECPublicKey signing_key, uint8[] message, uint8[] signature);
+ }
+
+ [CCode (cname = "session_builder_create", cheader_filename = "signal/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")]
+ 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")]
+ public static int curve_generate_key_pair(NativeContext context, out ECKeyPair key_pair);
+ [CCode (cname = "curve_decode_private_point", cheader_filename = "signal/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")]
+ 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")]
+ 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")]
+ 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")]
+ 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")]
+ 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")]
+ public static void setup_crypto_provider(NativeContext context);
+ [CCode (cname = "signal_vala_randomize", cheader_filename = "signal/signal_helper.h")]
+ public static int native_random(uint8[] data);
+}
diff --git a/plugins/openpgp/CMakeLists.txt b/plugins/openpgp/CMakeLists.txt
index 649a55ad..6ed7bf53 100644
--- a/plugins/openpgp/CMakeLists.txt
+++ b/plugins/openpgp/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(GPGME REQUIRED)
+
set(GETTEXT_PACKAGE "dino-openpgp")
find_package(Gettext)
include(${GETTEXT_USE_FILE})
@@ -28,6 +30,8 @@ compile_gresources(
vala_precompile(OPENPGP_VALA_C
SOURCES
+ src/gpgme_helper.vala
+
src/file_transfer/file_decryptor.vala
src/file_transfer/file_encryptor.vala
@@ -42,7 +46,8 @@ SOURCES
src/stream_module.vala
src/util.vala
CUSTOM_VAPIS
- ${CMAKE_BINARY_DIR}/exports/gpgme.vapi
+ ${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme.vapi
+ ${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpg-error.vapi
${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi
${CMAKE_BINARY_DIR}/exports/qlite.vapi
${CMAKE_BINARY_DIR}/exports/dino.vapi
@@ -53,9 +58,10 @@ GRESOURCES
)
add_definitions(${VALA_CFLAGS} -DG_LOG_DOMAIN="OpenPGP" -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\")
-add_library(openpgp SHARED ${OPENPGP_VALA_C} ${OPENPGP_GRESOURCES_TARGET})
+add_library(openpgp SHARED ${OPENPGP_VALA_C} ${OPENPGP_GRESOURCES_TARGET} src/gpgme_fix.c)
add_dependencies(openpgp ${GETTEXT_PACKAGE}-translations)
-target_link_libraries(openpgp libdino gpgme-vala ${OPENPGP_PACKAGES})
+target_include_directories(openpgp PRIVATE src)
+target_link_libraries(openpgp libdino gpgme ${OPENPGP_PACKAGES})
set_target_properties(openpgp PROPERTIES PREFIX "")
set_target_properties(openpgp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/)
diff --git a/plugins/openpgp/data/gresource.xml b/plugins/openpgp/data/gresource.xml
new file mode 100644
index 00000000..fbe2e8e9
--- /dev/null
+++ b/plugins/openpgp/data/gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/im/dino/Dino/openpgp">
+ <file>account_settings_item.ui</file>
+ </gresource>
+</gresources>
diff --git a/plugins/openpgp/meson.build b/plugins/openpgp/meson.build
new file mode 100644
index 00000000..806494f2
--- /dev/null
+++ b/plugins/openpgp/meson.build
@@ -0,0 +1,43 @@
+subdir('po')
+dependencies = [
+ dep_dino,
+ dep_gee,
+ dep_glib,
+ dep_gmodule,
+ dep_gpgme,
+ dep_gtk4,
+ dep_qlite,
+ dep_xmpp_vala,
+]
+sources = files(
+ 'src/account_settings_entry.vala',
+ 'src/contact_details_provider.vala',
+ 'src/database.vala',
+ 'src/encryption_list_entry.vala',
+ 'src/file_transfer/file_decryptor.vala',
+ 'src/file_transfer/file_encryptor.vala',
+ 'src/gpgme_fix.c',
+ 'src/gpgme_helper.vala',
+ 'src/manager.vala',
+ 'src/plugin.vala',
+ 'src/register_plugin.vala',
+ 'src/stream_flag.vala',
+ 'src/stream_module.vala',
+ 'src/util.vala',
+ 'vapi/gpg-error.vapi',
+)
+sources += gnome.compile_resources(
+ 'resources',
+ 'data/gresource.xml',
+ source_dir: 'data',
+)
+c_args = [
+ '-DG_LOG_DOMAIN="OpenPGP"',
+ '-DGETTEXT_PACKAGE="dino-openpgp"',
+ '-DLOCALE_INSTALL_DIR="@0@"'.format(get_option('prefix') / get_option('localedir')),
+]
+vala_args = [
+ '--vapidir', meson.current_source_dir() / 'vapi',
+]
+lib_openpgp = shared_library('openpgp', sources, name_prefix: '', c_args: c_args, vala_args: vala_args, include_directories: include_directories('src'), dependencies: dependencies, install: true, install_dir: get_option('libdir') / 'dino/plugins')
+dep_openpgp = declare_dependency(link_with: lib_openpgp, include_directories: include_directories('.'))
diff --git a/plugins/openpgp/po/meson.build b/plugins/openpgp/po/meson.build
new file mode 100644
index 00000000..ac755b55
--- /dev/null
+++ b/plugins/openpgp/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext('dino-openpgp')
diff --git a/plugins/openpgp/src/account_settings_entry.vala b/plugins/openpgp/src/account_settings_entry.vala
index d2e5ac23..7c99942f 100644
--- a/plugins/openpgp/src/account_settings_entry.vala
+++ b/plugins/openpgp/src/account_settings_entry.vala
@@ -116,8 +116,10 @@ public class AccountSettingsEntry : Plugins.AccountSettingsEntry {
SourceFunc callback = fetch_keys.callback;
new Thread<void*> (null, () => { // Querying GnuPG might take some time
try {
- keys = GPGHelper.get_keylist(null, true);
- } catch (Error e) { }
+ keys = GPGHelper.get_keylist(null, true);
+ } catch (Error e) {
+ warning(e.message);
+ }
Idle.add((owned)callback);
return null;
});
diff --git a/plugins/gpgme-vala/src/gpgme_fix.c b/plugins/openpgp/src/gpgme_fix.c
index 2bc139e9..bf457a6c 100644
--- a/plugins/gpgme-vala/src/gpgme_fix.c
+++ b/plugins/openpgp/src/gpgme_fix.c
@@ -1,6 +1,6 @@
#include <gpgme_fix.h>
-static GRecMutex gpgme_global_mutex = {0};
+GRecMutex gpgme_global_mutex = {0};
gpgme_key_t gpgme_key_ref_vapi (gpgme_key_t key) {
gpgme_key_ref(key);
@@ -9,4 +9,4 @@ gpgme_key_t gpgme_key_ref_vapi (gpgme_key_t key) {
gpgme_key_t gpgme_key_unref_vapi (gpgme_key_t key) {
gpgme_key_unref(key);
return key;
-} \ No newline at end of file
+}
diff --git a/plugins/gpgme-vala/src/gpgme_fix.h b/plugins/openpgp/src/gpgme_fix.h
index 3daa7db0..714614fc 100644
--- a/plugins/gpgme-vala/src/gpgme_fix.h
+++ b/plugins/openpgp/src/gpgme_fix.h
@@ -4,9 +4,9 @@
#include <glib.h>
#include <gpgme.h>
-static GRecMutex gpgme_global_mutex;
+extern GRecMutex gpgme_global_mutex;
gpgme_key_t gpgme_key_ref_vapi (gpgme_key_t key);
gpgme_key_t gpgme_key_unref_vapi (gpgme_key_t key);
-#endif \ No newline at end of file
+#endif
diff --git a/plugins/gpgme-vala/src/gpgme_helper.vala b/plugins/openpgp/src/gpgme_helper.vala
index f28bc6d6..18d07c06 100644
--- a/plugins/gpgme-vala/src/gpgme_helper.vala
+++ b/plugins/openpgp/src/gpgme_helper.vala
@@ -117,6 +117,7 @@ public static Gee.List<Key> get_keylist(string? pattern = null, bool secret_only
} catch (Error e) {
if (e.code != GPGError.ErrorCode.EOF) throw e;
}
+ context.op_keylist_end();
return keys;
} finally {
global_mutex.unlock();
diff --git a/plugins/gpgme-vala/vapi/gpg-error.vapi b/plugins/openpgp/vapi/gpg-error.vapi
index 2c915c8a..3ad6c580 100644
--- a/plugins/gpgme-vala/vapi/gpg-error.vapi
+++ b/plugins/openpgp/vapi/gpg-error.vapi
@@ -441,11 +441,5 @@ namespace GPGError {
public Error.from_errno (ErrorSource source, int err);
public ErrorCode code { [CCode (cname = "gpg_err_code")] get; }
public ErrorSource source { [CCode (cname = "gpg_err_source")] get; }
-
- [CCode (cname = "gpg_strerror")]
- public unowned string to_string ();
-
- [CCode (cname = "gpg_strsource")]
- public unowned string source_to_string ();
}
-} \ No newline at end of file
+}
diff --git a/plugins/gpgme-vala/vapi/gpgme.vapi b/plugins/openpgp/vapi/gpgme.vapi
index 8723bd81..2fc27c65 100644
--- a/plugins/gpgme-vala/vapi/gpgme.vapi
+++ b/plugins/openpgp/vapi/gpgme.vapi
@@ -1,6 +1,7 @@
/* libgpgme.vapi
*
* Copyright (C) 2009 Sebastian Reichel <sre@ring0.de>
+ * Copyright (C) 2022 Itay Grudev <itay+git2022@grudev.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -36,6 +37,100 @@ namespace GPG {
string? home_dir;
}
+ [Compact]
+ [CCode (cname = "struct _gpgme_key", ref_function = "gpgme_key_ref_vapi", unref_function = "gpgme_key_unref_vapi", free_function = "gpgme_key_release")]
+ public class Key {
+ public bool revoked;
+ public bool expired;
+ public bool disabled;
+ public bool invalid;
+ public bool can_encrypt;
+ public bool can_sign;
+ public bool can_certify;
+ public bool secret;
+ public bool can_authenticate;
+ public bool is_qualified;
+ public Protocol protocol;
+ public string issuer_serial;
+ public string issuer_name;
+ public string chain_id;
+ public Validity owner_trust;
+ [CCode(array_null_terminated = true)]
+ public SubKey[] subkeys;
+ [CCode(array_null_terminated = true)]
+ public UserID[] uids;
+ public KeylistMode keylist_mode;
+ public string fpr { get { return subkeys[0].fpr; } }
+ }
+
+ [CCode (cname = "struct _gpgme_sig_notation")]
+ public struct SigNotation {
+ SigNotation* next;
+ string? name;
+ string value;
+ int name_len;
+ int value_len;
+ SigNotationFlags flags;
+ bool human_readable;
+ bool critical;
+ }
+
+ [CCode (cname = "struct _gpgme_subkey")]
+ public struct SubKey {
+ SubKey* next;
+ bool revoked;
+ bool expired;
+ bool disabled;
+ bool invalid;
+ bool can_encrypt;
+ bool can_sign;
+ bool can_certify;
+ bool secret;
+ bool can_authenticate;
+ bool is_qualified;
+ bool is_cardkey;
+ PublicKeyAlgorithm algo;
+ uint length;
+ string keyid;
+ string fpr;
+ long timestamp;
+ long expires;
+ string? card_number;
+ }
+
+ [CCode (cname = "struct _gpgme_key_sig")]
+ public struct KeySig {
+ KeySig* next;
+ bool revoked;
+ bool expired;
+ bool invalid;
+ bool exportable;
+ PublicKeyAlgorithm algo;
+ string keyid;
+ long timestamp;
+ long expires;
+ GPGError.Error status;
+ string uid;
+ string name;
+ string email;
+ string comment;
+ uint sig_class;
+ SigNotation notations;
+ }
+
+ [CCode (cname = "struct _gpgme_user_id")]
+ public struct UserID {
+ UserID* next;
+ bool revoked;
+ bool invalid;
+ Validity validity;
+ string uid;
+ string name;
+ string email;
+ string comment;
+ KeySig signatures;
+ }
+
[CCode (cname = "struct _gpgme_op_verify_result")]
public struct VerifyResult {
Signature* signatures;
@@ -92,7 +187,7 @@ namespace GPG {
GPGError.Error validity_reason;
PublicKeyAlgorithm pubkey_algo;
HashAlgorithm hash_algo;
- string? pka_adress;
+ string? pka_address;
}
public enum PKAStatus {
@@ -128,6 +223,16 @@ namespace GPG {
URL0
}
+ [CCode (cname = "gpgme_pubkey_algo_t", cprefix = "GPGME_PK_")]
+ public enum PublicKeyAlgorithm {
+ RSA,
+ RSA_E,
+ RSA_S,
+ ELG_E,
+ DSA,
+ ELG
+ }
+
[CCode (cname = "gpgme_hash_algo_t", cprefix = "GPGME_MD_")]
public enum HashAlgorithm {
NONE,
@@ -141,9 +246,45 @@ namespace GPG {
SHA384,
SHA512,
MD4,
- MD_CRC32,
- MD_CRC32_RFC1510,
- MD_CRC24_RFC2440
+ CRC32,
+ CRC32_RFC1510,
+ CRC24_RFC2440
+ }
+
+ [CCode (cname = "gpgme_sig_mode_t", cprefix = "GPGME_SIG_MODE_")]
+ public enum SigMode {
+ NORMAL,
+ DETACH,
+ CLEAR
+ }
+
+ [CCode (cname = "gpgme_validity_t", cprefix = "GPGME_VALIDITY_")]
+ public enum Validity {
+ UNKNOWN,
+ UNDEFINED,
+ NEVER,
+ MARGINAL,
+ FULL,
+ ULTIMATE
+ }
+
+ [CCode (cname = "gpgme_protocol_t", cprefix = "GPGME_PROTOCOL_")]
+ public enum Protocol {
+ OpenPGP,
+ CMS,
+ GPGCONF,
+ ASSUAN,
+ UNKNOWN
+ }
+
+ [CCode (cname = "gpgme_keylist_mode_t", cprefix = "GPGME_KEYLIST_MODE_")]
+ public enum KeylistMode {
+ LOCAL,
+ EXTERN,
+ SIGS,
+ SIG_NOTATIONS,
+ EPHEMERAL,
+ VALIDATE
}
[CCode (cname = "gpgme_export_mode_t", cprefix = "GPGME_EXPORT_MODE_")]
@@ -157,6 +298,18 @@ namespace GPG {
WITH_HELP
}
+ [CCode (cname = "gpgme_sig_notation_flags_t", cprefix = "GPGME_SIG_NOTATION_")]
+ public enum SigNotationFlags {
+ HUMAN_READABLE,
+ CRITICAL
+ }
+
+ [CCode (cname = "gpgme_encrypt_flags_t", cprefix = "GPGME_ENCRYPT_")]
+ public enum EncryptFlags {
+ ALWAYS_TRUST,
+ NO_ENCRYPT_TO
+ }
+
[CCode (cname = "gpgme_status_code_t", cprefix = "GPGME_STATUS_")]
public enum StatusCode {
EOF,
@@ -244,21 +397,6 @@ namespace GPG {
PLAINTEXT
}
- [Flags]
- [CCode (cname="unsigned int")]
- public enum ImportStatusFlags {
- [CCode (cname = "GPGME_IMPORT_NEW")]
- NEW,
- [CCode (cname = "GPGME_IMPORT_UID")]
- UID,
- [CCode (cname = "GPGME_IMPORT_SIG")]
- SIG,
- [CCode (cname = "GPGME_IMPORT_SUBKEY")]
- SUBKEY,
- [CCode (cname = "GPGME_IMPORT_SECRET")]
- SECRET
- }
-
[Compact]
[CCode (cname = "struct gpgme_context", free_function = "gpgme_release", cprefix = "gpgme_")]
public class Context {
@@ -305,11 +443,11 @@ namespace GPG {
public Key* signers_enum(int n);
public void sig_notation_clear();
-
+
public GPGError.Error sig_notation_add(string name, string val, SigNotationFlags flags);
public SigNotation* sig_notation_get();
-
+
[CCode (cname = "gpgme_get_key")]
private GPGError.Error get_key_(string fpr, out Key key, bool secret);
@@ -319,7 +457,7 @@ namespace GPG {
throw_if_error(get_key_(fpr, out key, secret));
return key;
}
-
+
public Context* wait(out GPGError.Error status, bool hang);
public SignResult* op_sign_result();
@@ -405,10 +543,24 @@ namespace GPG {
public KeylistResult op_keylist_result();
}
+ [Flags]
+ [CCode (cname="unsigned int")]
+ public enum ImportStatusFlags {
+ [CCode (cname = "GPGME_IMPORT_NEW")]
+ NEW,
+ [CCode (cname = "GPGME_IMPORT_UID")]
+ UID,
+ [CCode (cname = "GPGME_IMPORT_SIG")]
+ SIG,
+ [CCode (cname = "GPGME_IMPORT_SUBKEY")]
+ SUBKEY,
+ [CCode (cname = "GPGME_IMPORT_SECRET")]
+ SECRET
+ }
+
[Compact]
[CCode (cname = "struct _gpgme_import_status")]
public class ImportStatus {
-
public ImportStatus? next;
public string fpr;
public GPGError.Error result;
@@ -443,7 +595,7 @@ namespace GPG {
[Compact]
[CCode (cname = "struct gpgme_data", free_function = "gpgme_data_release", cprefix = "gpgme_data_")]
public class Data {
-
+
public static GPGError.Error new(out Data d);
public static Data create() throws GLib.Error {
@@ -452,7 +604,6 @@ namespace GPG {
return data;
}
-
[CCode (cname = "gpgme_data_new_from_mem")]
public static GPGError.Error new_from_memory(out Data d, char[] buffer, bool copy);
@@ -482,7 +633,7 @@ namespace GPG {
public GPGError.Error set_file_name(string file_name);
- public DataEncoding* get_encoding();
+ public DataEncoding *get_encoding();
public GPGError.Error set_encoding(DataEncoding enc);
}
@@ -499,11 +650,14 @@ namespace GPG {
[CCode (cname = "gpgme_passphrase_cb_t", has_target = false)]
public delegate GPGError.Error passphrase_callback(void* hook, string uid_hint, string passphrase_info, bool prev_was_bad, int fd);
+ [CCode (cname = "gpgme_check_version")]
+ public unowned string check_version(string? required_version = null);
+
[CCode (cname = "gpgme_engine_check_version")]
public GPGError.Error engine_check_version(Protocol proto);
- [CCode (cname = "gpgme_get_engine_information")]
- public GPGError.Error get_engine_information(out EngineInfo engine_info);
+ [CCode (cname = "gpgme_get_engine_info")]
+ public GPGError.Error get_engine_info(out EngineInfo? engine_info);
[CCode (cname = "gpgme_strerror_r")]
public int strerror_r(GPGError.Error err, uint8[] buf);
diff --git a/plugins/rtp/meson.build b/plugins/rtp/meson.build
new file mode 100644
index 00000000..06821c91
--- /dev/null
+++ b/plugins/rtp/meson.build
@@ -0,0 +1,64 @@
+dependencies = [
+ dep_crypto_vala,
+ dep_dino,
+ dep_gee,
+ dep_glib,
+ dep_gmodule,
+ dep_gnutls,
+ dep_gstreamer,
+ dep_gstreamer_app,
+ dep_gstreamer_audio,
+ dep_gstreamer_rtp,
+ dep_gstreamer_video,
+ dep_gtk4,
+ dep_m,
+ dep_qlite,
+ dep_xmpp_vala,
+]
+sources = files(
+ 'src/codec_util.vala',
+ 'src/device.vala',
+ 'src/gst_fixes.c',
+ 'src/module.vala',
+ 'src/plugin.vala',
+ 'src/register_plugin.vala',
+ 'src/stream.vala',
+ 'src/video_widget.vala',
+)
+c_args = [
+ '-DG_LOG_DOMAIN="rtp"',
+]
+vala_args = [
+ '--vapidir', meson.current_source_dir() / 'vapi',
+]
+if dep_webrtc_audio_processing.found()
+ dependencies += [dep_webrtc_audio_processing]
+ sources += files(
+ 'src/voice_processor.vala',
+ 'src/voice_processor_native.cpp',
+ )
+ vala_args += ['-D', 'WITH_VOICE_PROCESSOR']
+endif
+if dep_gstreamer_rtp.version() == 'unknown' or dep_gstreamer_rtp.version().version_compare('>=1.16')
+ vala_args += ['-D', 'GST_1_16']
+endif
+if dep_gstreamer_rtp.version() == 'unknown' or dep_gstreamer_rtp.version().version_compare('>=1.18')
+ vala_args += ['-D', 'GST_1_18']
+endif
+if dep_gstreamer_rtp.version() == 'unknown' or dep_gstreamer_rtp.version().version_compare('>=1.20')
+ vala_args += ['-D', 'GST_1_20']
+endif
+if get_option('plugin-rtp-h264').allowed()
+ vala_args += ['-D', 'ENABLE_H264']
+endif
+if get_option('plugin-rtp-msdk').allowed()
+ vala_args += ['-D', 'ENABLE_MSDK']
+endif
+if get_option('plugin-rtp-vaapi').allowed()
+ vala_args += ['-D', 'ENABLE_VAAPI']
+endif
+if get_option('plugin-rtp-vp9').allowed()
+ vala_args += ['-D', 'ENABLE_VP9']
+endif
+lib_rtp = shared_library('rtp', sources, name_prefix: '', c_args: c_args, vala_args: vala_args, include_directories: include_directories('src'), dependencies: dependencies, install: true, install_dir: get_option('libdir') / 'dino/plugins')
+dep_rtp = declare_dependency(link_with: lib_rtp, include_directories: include_directories('.'))
diff --git a/plugins/rtp/src/video_widget.vala b/plugins/rtp/src/video_widget.vala
index f69a2ba7..05cc5a6c 100644
--- a/plugins/rtp/src/video_widget.vala
+++ b/plugins/rtp/src/video_widget.vala
@@ -16,7 +16,7 @@ public class Dino.Plugins.Rtp.Paintable : Gdk.Paintable, Object {
public override Gdk.Paintable get_current_image() {
if (image != null) return image;
- return Gdk.Paintable.new_empty(0, 0);
+ return Gdk.Paintable.empty(0, 0);
}
public override int get_intrinsic_width() {
diff --git a/plugins/rtp/vapi/webrtc-audio-processing.vapi b/plugins/rtp/vapi/webrtc-audio-processing.vapi
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/plugins/rtp/vapi/webrtc-audio-processing.vapi
diff --git a/plugins/signal-protocol/CMakeLists.txt b/plugins/signal-protocol/CMakeLists.txt
deleted file mode 100644
index b3cfae9d..00000000
--- a/plugins/signal-protocol/CMakeLists.txt
+++ /dev/null
@@ -1,91 +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 "")
-
-# 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 REQUIRED)
-
-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 STATIC ${SIGNAL_PROTOCOL_VALA_C} ${CMAKE_CURRENT_SOURCE_DIR}/src/signal_helper.c)
-add_dependencies(signal-protocol-vala signal-protocol-vapi)
-target_link_libraries(signal-protocol-vala ${SIGNAL_PROTOCOL_PACKAGES} gcrypt signal-protocol-c m)
-set_property(TARGET signal-protocol-vala PROPERTY POSITION_INDEPENDENT_CODE ON)
-
-if(BUILD_TESTS)
- vala_precompile(SIGNAL_TEST_VALA_C
- SOURCES
- "tests/common.vala"
- "tests/testcase.vala"
-
- "tests/curve25519.vala"
- "tests/hkdf.vala"
- "tests/session_builder.vala"
- CUSTOM_VAPIS
- ${CMAKE_BINARY_DIR}/exports/signal-protocol-vala_internal.vapi
- ${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-public.vapi
- ${CMAKE_CURRENT_SOURCE_DIR}/vapi/signal-protocol-native.vapi
- PACKAGES
- ${SIGNAL_PROTOCOL_PACKAGES}
- )
-
- set(CFLAGS ${VALA_CFLAGS} -I${CMAKE_CURRENT_BINARY_DIR}/signal-protocol)
- add_executable(signal-protocol-vala-test ${SIGNAL_TEST_VALA_C})
- add_dependencies(signal-protocol-vala-test signal-protocol-vala)
- target_link_libraries(signal-protocol-vala-test signal-protocol-vala ${SIGNAL_PROTOCOL_PACKAGES})
-endif(BUILD_TESTS)
diff --git a/plugins/signal-protocol/vapi/signal-protocol-native.vapi b/plugins/signal-protocol/vapi/signal-protocol-native.vapi
deleted file mode 100644
index 0bac0317..00000000
--- a/plugins/signal-protocol/vapi/signal-protocol-native.vapi
+++ /dev/null
@@ -1,274 +0,0 @@
-namespace Signal {
- [Compact]
- [CCode (cname = "signal_context", cprefix="signal_context_", free_function="signal_context_destroy", cheader_filename = "signal/signal_protocol.h")]
- public class NativeContext {
- public static int create(out NativeContext context, void* user_data);
- public int set_crypto_provider(NativeCryptoProvider crypto_provider);
- public int set_locking_functions(LockingFunc lock, LockingFunc unlock);
- public int set_log_function(LogFunc log);
- }
- [CCode (has_target = false)]
- public delegate void LockingFunc(void* user_data);
- [CCode (has_target = false)]
- 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")]
- public struct NativeCryptoProvider {
- public RandomFunc random_func;
- public HmacSha256Init hmac_sha256_init_func;
- public HmacSha256Update hmac_sha256_update_func;
- public HmacSha256Final hmac_sha256_final_func;
- public HmacSha256Cleanup hmac_sha256_cleanup_func;
- public Sha512DigestInit sha512_digest_init_func;
- public Sha512DigestUpdate sha512_digest_update_func;
- public Sha512DigestFinal sha512_digest_final_func;
- public Sha512DigestCleanup sha512_digest_cleanup_func;
- public CryptFunc encrypt_func;
- public CryptFunc decrypt_func;
- public void* user_data;
- }
- [CCode (has_target = false)]
- public delegate int RandomFunc(uint8[] data, void* user_data);
- [CCode (has_target = false)]
- public delegate int HmacSha256Init(out void* hmac_context, uint8[] key, void* user_data);
- [CCode (has_target = false)]
- public delegate int HmacSha256Update(void* hmac_context, uint8[] data, void* user_data);
- [CCode (has_target = false)]
- public delegate int HmacSha256Final(void* hmac_context, out Buffer buffer, void* user_data);
- [CCode (has_target = false)]
- public delegate int HmacSha256Cleanup(void* hmac_context, void* user_data);
- [CCode (has_target = false)]
- public delegate int Sha512DigestInit(out void* digest_context, void* user_data);
- [CCode (has_target = false)]
- public delegate int Sha512DigestUpdate(void* digest_context, uint8[] data, void* user_data);
- [CCode (has_target = false)]
- public delegate int Sha512DigestFinal(void* digest_context, out Buffer buffer, void* user_data);
- [CCode (has_target = false)]
- public delegate int Sha512DigestCleanup(void* digest_context, void* user_data);
- [CCode (has_target = false)]
- 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")]
- public struct NativeSessionStore {
- public LoadSessionFunc load_session_func;
- public GetSubDeviceSessionsFunc get_sub_device_sessions_func;
- public StoreSessionFunc store_session_func;
- public ContainsSessionFunc contains_session_func;
- public DeleteSessionFunc delete_session_func;
- public DeleteAllSessionsFunc delete_all_sessions_func;
- public DestroyFunc destroy_func;
- public void* user_data;
- }
- [CCode (has_target = false)]
- public delegate int LoadSessionFunc(out Buffer record, out Buffer user_record, Address address, void* user_data);
- [CCode (has_target = false)]
- public delegate int GetSubDeviceSessionsFunc(out IntList sessions, [CCode (array_length_type = "size_t")] char[] name, void* user_data);
- [CCode (has_target = false)]
- public delegate int StoreSessionFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data);
- [CCode (has_target = false)]
- public delegate int ContainsSessionFunc(Address address, void* user_data);
- [CCode (has_target = false)]
- public delegate int DeleteSessionFunc(Address address, void* user_data);
- [CCode (has_target = false)]
- 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")]
- public struct NativeIdentityKeyStore {
- GetIdentityKeyPairFunc get_identity_key_pair;
- GetLocalRegistrationIdFunc get_local_registration_id;
- SaveIdentityFunc save_identity;
- IsTrustedIdentityFunc is_trusted_identity;
- DestroyFunc destroy_func;
- void* user_data;
- }
- [CCode (has_target = false)]
- public delegate int GetIdentityKeyPairFunc(out Buffer public_data, out Buffer private_data, void* user_data);
- [CCode (has_target = false)]
- public delegate int GetLocalRegistrationIdFunc(void* user_data, out uint32 registration_id);
- [CCode (has_target = false)]
- public delegate int SaveIdentityFunc(Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data);
- [CCode (has_target = false)]
- 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")]
- public struct NativePreKeyStore {
- LoadPreKeyFunc load_pre_key;
- StorePreKeyFunc store_pre_key;
- ContainsPreKeyFunc contains_pre_key;
- RemovePreKeyFunc remove_pre_key;
- DestroyFunc destroy_func;
- void* user_data;
- }
- [CCode (has_target = false)]
- public delegate int LoadPreKeyFunc(out Buffer record, uint32 pre_key_id, void* user_data);
- [CCode (has_target = false)]
- public delegate int StorePreKeyFunc(uint32 pre_key_id, [CCode (array_length_type = "size_t")] uint8[] record, void* user_data);
- [CCode (has_target = false)]
- public delegate int ContainsPreKeyFunc(uint32 pre_key_id, void* user_data);
- [CCode (has_target = false)]
- public delegate int RemovePreKeyFunc(uint32 pre_key_id, void* user_data);
-
-
- [Compact]
- [CCode (cname = "signal_protocol_signed_pre_key_store", cheader_filename = "signal/signal_protocol.h")]
- public struct NativeSignedPreKeyStore {
- LoadPreKeyFunc load_signed_pre_key;
- StorePreKeyFunc store_signed_pre_key;
- ContainsPreKeyFunc contains_signed_pre_key;
- RemovePreKeyFunc remove_signed_pre_key;
- DestroyFunc destroy_func;
- void* user_data;
- }
-
-
- [Compact]
- [CCode (cname = "signal_protocol_sender_key_store")]
- public struct NativeSenderKeyStore {
- StoreSenderKeyFunc store_sender_key;
- LoadSenderKeyFunc load_sender_key;
- DestroyFunc destroy_func;
- void* user_data;
- }
- [CCode (has_target = false)]
- public delegate int StoreSenderKeyFunc(SenderKeyName sender_key_name, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data);
- [CCode (has_target = false)]
- public delegate int LoadSenderKeyFunc(out Buffer record, out Buffer user_record, SenderKeyName sender_key_name, void* user_data);
-
- [CCode (has_target = false)]
- 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")]
- public class NativeStoreContext {
- public static int create(out NativeStoreContext context, NativeContext global_context);
- public int set_session_store(NativeSessionStore store);
- public int set_pre_key_store(NativePreKeyStore store);
- public int set_signed_pre_key_store(NativeSignedPreKeyStore store);
- public int set_identity_key_store(NativeIdentityKeyStore store);
- public int set_sender_key_store(NativeSenderKeyStore store);
- }
-
-
- [CCode (cheader_filename = "signal/signal_protocol.h")]
- namespace Protocol {
-
- /**
- * Interface to the pre-key store.
- * These functions will use the callbacks in the provided
- * signal_protocol_store_context instance and operate in terms of higher level
- * library data structures.
- */
- [CCode (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);
- public int contains_key(NativeStoreContext context, uint32 pre_key_id);
- public int remove_key(NativeStoreContext context, uint32 pre_key_id);
- }
-
- [CCode (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);
- public int contains_key(NativeStoreContext context, uint32 pre_key_id);
- public int remove_key(NativeStoreContext context, uint32 pre_key_id);
- }
-
- /**
- * Interface to the session store.
- * These functions will use the callbacks in the provided
- * signal_protocol_store_context instance and operate in terms of higher level
- * library data structures.
- */
- [CCode (cprefix = "signal_protocol_session_")]
- namespace Session {
- public int load_session(NativeStoreContext context, out SessionRecord record, Address address);
- 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);
- public int delete_session(NativeStoreContext context, Address address);
- public int delete_all_sessions(NativeStoreContext context, char[] name);
- }
-
- 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);
- public int save_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_")]
- 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")]
- public class PreKeyListNode {
- public PreKeyRecord element();
- public PreKeyListNode next();
- }
-
- public int generate_identity_key_pair(out IdentityKeyPair key_pair, NativeContext global_context);
- public int generate_registration_id(out int32 registration_id, int extended_range, NativeContext global_context);
- public int get_random_sequence(out int value, int max, NativeContext global_context);
- 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 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")]
- 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);
- [CCode (cname = "curve_calculate_signature")]
- public int calculate_signature(NativeContext context, out Buffer signature, ECPrivateKey signing_key, uint8[] message);
- [CCode (cname = "curve_verify_signature")]
- public int verify_signature(ECPublicKey signing_key, uint8[] message, uint8[] signature);
- }
-
- [CCode (cname = "session_builder_create", cheader_filename = "signal/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")]
- 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")]
- public static int curve_generate_key_pair(NativeContext context, out ECKeyPair key_pair);
- [CCode (cname = "curve_decode_private_point", cheader_filename = "signal/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")]
- 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")]
- 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")]
- 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")]
- 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")]
- 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_helper.h")]
- public static void setup_crypto_provider(NativeContext context);
- [CCode (cname = "signal_vala_randomize", cheader_filename = "signal_helper.h")]
- public static int native_random(uint8[] data);
-}
diff --git a/plugins/signal-protocol/vapi/signal-protocol-public.vapi b/plugins/signal-protocol/vapi/signal-protocol-public.vapi
deleted file mode 100644
index eaf73c0c..00000000
--- a/plugins/signal-protocol/vapi/signal-protocol-public.vapi
+++ /dev/null
@@ -1,384 +0,0 @@
-namespace Signal {
-
- [CCode (cname = "int", cprefix = "SG_ERR_", cheader_filename = "signal/signal_protocol.h", has_type_id = false)]
- public enum ErrorCode {
- [CCode (cname = "SG_SUCCESS")]
- SUCCESS,
- NOMEM,
- INVAL,
- UNKNOWN,
- DUPLICATE_MESSAGE,
- INVALID_KEY,
- INVALID_KEY_ID,
- INVALID_MAC,
- INVALID_MESSAGE,
- INVALID_VERSION,
- LEGACY_MESSAGE,
- NO_SESSION,
- STALE_KEY_EXCHANGE,
- UNTRUSTED_IDENTITY,
- VRF_SIG_VERIF_FAILED,
- INVALID_PROTO_BUF,
- FP_VERSION_MISMATCH,
- FP_IDENT_MISMATCH;
- }
-
- [CCode (cname = "SG_ERR_MINIMUM", cheader_filename = "signal/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)]
- public enum LogLevel {
- ERROR,
- WARNING,
- NOTICE,
- INFO,
- DEBUG
- }
-
- [CCode (cname = "signal_throw_gerror_by_code_", cheader_filename = "signal/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());
- }
- return code;
- }
-
- [CCode (cname = "int", cprefix = "SG_CIPHER_", cheader_filename = "signal/signal_protocol.h", has_type_id = false)]
- public enum Cipher {
- AES_CTR_NOPADDING,
- AES_CBC_PKCS5,
- AES_GCM_NOPADDING
- }
-
- [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")]
- public class TypeBase {
- }
-
- [Compact]
- [CCode (cname = "signal_buffer", cheader_filename = "signal/signal_protocol_types.h", free_function="signal_buffer_free")]
- public class Buffer {
- [CCode (cname = "signal_buffer_alloc")]
- public Buffer(size_t len);
- [CCode (cname = "signal_buffer_create")]
- public Buffer.from(uint8[] data);
-
- public Buffer copy();
- public Buffer append(uint8[] data);
- public int compare(Buffer other);
-
- public uint8 get(int i) { return data[i]; }
- public void set(int i, uint8 val) { data[i] = val; }
-
- public uint8[] data { get { int x = (int)len(); unowned uint8[] res = _data(); res.length = x; return res; } }
-
- [CCode (array_length = false, cname = "signal_buffer_data")]
- private unowned uint8[] _data();
- private size_t len();
- }
-
- [Compact]
- [CCode (cname = "signal_int_list", cheader_filename = "signal/signal_protocol_types.h", free_function="signal_int_list_free")]
- public class IntList {
- [CCode (cname = "signal_int_list_alloc")]
- public IntList();
- [CCode (cname = "signal_int_list_push_back")]
- public int add(int value);
- public uint size { [CCode (cname = "signal_int_list_size")] get; }
- [CCode (cname = "signal_int_list_at")]
- public int get(uint index);
- }
-
- [Compact]
- [CCode (cname = "session_builder", cprefix = "session_builder_", free_function="session_builder_free", cheader_filename = "signal/session_builder.h")]
- public class SessionBuilder {
- [CCode (cname = "session_builder_process_pre_key_bundle")]
- private int process_pre_key_bundle_(PreKeyBundle pre_key_bundle);
- [CCode (cname = "session_builder_process_pre_key_bundle_")]
- public void process_pre_key_bundle(PreKeyBundle pre_key_bundle) throws GLib.Error {
- throw_by_code(process_pre_key_bundle_(pre_key_bundle));
- }
- }
-
- [Compact]
- [CCode (cname = "session_pre_key_bundle", cprefix = "session_pre_key_bundle_", cheader_filename = "signal/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);
- public uint32 registration_id { get; }
- public int device_id { get; }
- public uint32 pre_key_id { get; }
- public ECPublicKey pre_key { owned get; }
- public uint32 signed_pre_key_id { get; }
- public ECPublicKey signed_pre_key { owned get; }
- public Buffer signed_pre_key_signature { owned get; }
- public ECPublicKey identity_key { owned get; }
- }
-
- [Compact]
- [CCode (cname = "session_pre_key", cprefix = "session_pre_key_", cheader_filename = "signal/session_pre_key.h,signal_helper.h")]
- public class PreKeyRecord : TypeBase {
- public static int create(out PreKeyRecord pre_key, uint32 id, ECKeyPair key_pair);
- //public static int deserialize(out PreKeyRecord pre_key, uint8[] data, NativeContext global_context);
- [CCode (instance_pos = 2)]
- public int serialze(out Buffer buffer);
- public uint32 id { get; }
- public ECKeyPair key_pair { get; }
- }
-
- [Compact]
- [CCode (cname = "session_record", cprefix = "session_record_", cheader_filename = "signal/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")]
- public class SessionState : TypeBase {
- //public static int create(out SessionState state, NativeContext context);
- //public static int deserialize(out SessionState state, uint8[] data, NativeContext context);
- //public static int copy(out SessionState state, SessionState other_state, NativeContext context);
- [CCode (instance_pos = 2)]
- public int serialze(out Buffer buffer);
-
- public uint32 session_version { get; set; }
- public ECPublicKey local_identity_key { get; set; }
- public ECPublicKey remote_identity_key { get; set; }
- //public Ratchet.RootKey root_key { get; set; }
- public uint32 previous_counter { get; set; }
- public ECPublicKey sender_ratchet_key { get; }
- public ECKeyPair sender_ratchet_key_pair { get; }
- //public Ratchet.ChainKey sender_chain_key { get; set; }
- public uint32 remote_registration_id { get; set; }
- public uint32 local_registration_id { get; set; }
- public int needs_refresh { get; set; }
- public ECPublicKey alice_base_key { get; set; }
- }
-
- [Compact]
- [CCode (cname = "session_signed_pre_key", cprefix = "session_signed_pre_key_", cheader_filename = "signal/session_pre_key.h")]
- public class SignedPreKeyRecord : TypeBase {
- public static int create(out SignedPreKeyRecord pre_key, uint32 id, uint64 timestamp, ECKeyPair key_pair, uint8[] signature);
- [CCode (instance_pos = 2)]
- public int serialze(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; } }
-
- [CCode (array_length = false, cname = "session_signed_pre_key_get_signature")]
- private unowned uint8[] get_signature();
- private size_t get_signature_len();
- }
-
- /**
- * Address of an Signal Protocol message recipient
- */
- [Compact]
- [CCode (cname = "signal_protocol_address", cprefix = "signal_protocol_address_", cheader_filename = "signal/signal_protocol.h,signal_helper.h")]
- public class Address {
- public Address(string name, int32 device_id);
- public int32 device_id { get; set; }
- public string name { owned get; set; }
- }
-
- /**
- * A representation of a (group + sender + device) tuple
- */
- [Compact]
- [CCode (cname = "signal_protocol_sender_key_name")]
- public class SenderKeyName {
- [CCode (cname = "group_id", array_length_cname="group_id_len")]
- private char* group_id_;
- private size_t group_id_len;
- public Address sender;
- }
-
- [Compact]
- [CCode (cname = "ec_public_key", cprefix = "ec_public_key_", cheader_filename = "signal/curve.h,signal_helper.h")]
- public class ECPublicKey : TypeBase {
- [CCode (cname = "curve_generate_public_key")]
- public static int generate(out ECPublicKey public_key, ECPrivateKey private_key);
- [CCode (instance_pos = 1, cname = "ec_public_key_serialize")]
- private int serialize_([CCode (pos = 0)] out Buffer buffer);
- [CCode (cname = "ec_public_key_serialize_")]
- public uint8[] serialize() {
- Buffer buffer;
- int code = serialize_(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 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_helper.h")]
- public class ECPrivateKey : TypeBase {
- [CCode (instance_pos = 1, cname = "ec_private_key_serialize")]
- private int serialize_([CCode (pos = 0)] out Buffer buffer);
- [CCode (cname = "ec_private_key_serialize_")]
- public uint8[] serialize() throws GLib.Error {
- Buffer buffer;
- int code = serialize_(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 int compare(ECPublicKey other);
- }
-
- [Compact]
- [CCode (cname = "ec_key_pair", cprefix="ec_key_pair_", cheader_filename = "signal/curve.h,signal_helper.h")]
- public class ECKeyPair : TypeBase {
- public static int create(out ECKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
- public ECPublicKey public { get; }
- public ECPrivateKey private { get; }
- }
-
- [CCode (cname = "ratchet_message_keys", cheader_filename = "signal/ratchet.h")]
- public class MessageKeys {
- }
-
- [Compact]
- [CCode (cname = "ratchet_identity_key_pair", cprefix = "ratchet_identity_key_pair_", cheader_filename = "signal/ratchet.h,signal_helper.h")]
- public class IdentityKeyPair : TypeBase {
- public static int create(out IdentityKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
- public int serialze(out Buffer buffer);
- public ECPublicKey public { get; }
- public ECPrivateKey private { get; }
- }
-
- [Compact]
- [CCode (cname = "ec_public_key_list")]
- public class PublicKeyList {}
-
- /**
- * The main entry point for Signal Protocol 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")]
- public class SessionCipher {
- public void* user_data { get; set; }
- public DecryptionCallback decryption_callback { set; }
- [CCode (cname = "session_cipher_encrypt")]
- private int encrypt_(uint8[] padded_message, out CiphertextMessage encrypted_message);
- [CCode (cname = "session_cipher_encrypt_")]
- public CiphertextMessage encrypt(uint8[] padded_message) throws GLib.Error {
- CiphertextMessage res;
- throw_by_code(encrypt_(padded_message, out res));
- 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);
- [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 {
- Buffer res;
- throw_by_code(decrypt_pre_key_signal_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);
- [CCode (cname = "session_cipher_decrypt_signal_message_")]
- public uint8[] decrypt_signal_message(SignalMessage ciphertext, void* decrypt_context = null) throws GLib.Error {
- Buffer res;
- throw_by_code(decrypt_signal_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 (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)]
- public enum CiphertextType {
- [CCode (cname = "CIPHERTEXT_SIGNAL_TYPE")]
- SIGNAL,
- [CCode (cname = "CIPHERTEXT_PREKEY_TYPE")]
- PREKEY,
- [CCode (cname = "CIPHERTEXT_SENDERKEY_TYPE")]
- SENDERKEY,
- [CCode (cname = "CIPHERTEXT_SENDERKEY_DISTRIBUTION_TYPE")]
- SENDERKEY_DISTRIBUTION
- }
-
- [Compact]
- [CCode (cname = "ciphertext_message", cprefix = "ciphertext_message_", cheader_filename = "signal/protocol.h,signal_helper.h")]
- public abstract class CiphertextMessage : TypeBase {
- public CiphertextType type { get; }
- [CCode (cname = "ciphertext_message_get_serialized")]
- private unowned Buffer get_serialized_();
- public uint8[] serialized { [CCode (cname = "ciphertext_message_get_serialized_")] get {
- return get_serialized_().data;
- }}
- }
- [Compact]
- [CCode (cname = "signal_message", cprefix = "signal_message_", cheader_filename = "signal/protocol.h,signal_helper.h")]
- public class SignalMessage : CiphertextMessage {
- public ECPublicKey sender_ratchet_key { get; }
- public uint8 message_version { get; }
- public uint32 counter { get; }
- public Buffer body { get; }
- //public int verify_mac(uint8 message_version, ECPublicKey sender_identity_key, ECPublicKey receiver_identity_key, uint8[] mac, NativeContext global_context);
- public static int is_legacy(uint8[] data);
- }
- [Compact]
- [CCode (cname = "pre_key_signal_message", cprefix = "pre_key_signal_message_", cheader_filename = "signal/protocol.h,signal_helper.h")]
- public class PreKeySignalMessage : 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; }
- }
- [Compact]
- [CCode (cname = "sender_key_message", cprefix = "sender_key_message_", cheader_filename = "signal/protocol.h,signal_helper.h")]
- public class SenderKeyMessage : CiphertextMessage {
- public uint32 key_id { get; }
- public uint32 iteration { get; }
- public Buffer ciphertext { get; }
- }
- [Compact]
- [CCode (cname = "sender_key_distribution_message", cprefix = "sender_key_distribution_message_", cheader_filename = "signal/protocol.h,signal_helper.h")]
- public class SenderKeyDistributionMessage : CiphertextMessage {
- public uint32 id { get; }
- public uint32 iteration { get; }
- public Buffer chain_key { get; }
- public ECPublicKey signature_key { get; }
- }
-
- [CCode (cname = "signal_vala_encrypt", cheader_filename = "signal_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_")]
- public uint8[] aes_encrypt(int cipher, uint8[] key, uint8[] iv, uint8[] plaintext) throws GLib.Error {
- Buffer buf;
- throw_by_code(aes_encrypt_(out buf, cipher, key, iv, plaintext, null));
- return buf.data;
- }
-
- [CCode (cname = "signal_vala_decrypt", cheader_filename = "signal_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_")]
- public uint8[] aes_decrypt(int cipher, uint8[] key, uint8[] iv, uint8[] ciphertext) throws GLib.Error {
- Buffer buf;
- throw_by_code(aes_decrypt_(out buf, cipher, key, iv, ciphertext, null));
- return buf.data;
- }
-}