diff options
author | Marvin W <git@larma.de> | 2020-09-14 21:56:58 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2020-09-14 22:04:06 +0200 |
commit | cd5b639a826ccafe5741a51f10cc8ca76ebfdd14 (patch) | |
tree | f39146eb751f67e99942770c67cf06ca4a912243 /plugins/omemo/src/jingle | |
parent | f6943a4c82ed39b8d6ae866855198596a51dade4 (diff) | |
download | dino-cd5b639a826ccafe5741a51f10cc8ca76ebfdd14.tar.gz dino-cd5b639a826ccafe5741a51f10cc8ca76ebfdd14.zip |
Send OMEMO-encrypted messages and files using 12 byte IV
Diffstat (limited to 'plugins/omemo/src/jingle')
-rw-r--r-- | plugins/omemo/src/jingle/jet_omemo.vala | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/omemo/src/jingle/jet_omemo.vala b/plugins/omemo/src/jingle/jet_omemo.vala index b3343855..14307be2 100644 --- a/plugins/omemo/src/jingle/jet_omemo.vala +++ b/plugins/omemo/src/jingle/jet_omemo.vala @@ -12,6 +12,8 @@ private const string AES_128_GCM_URI = "urn:xmpp:ciphers:aes-128-gcm-nopadding"; public class Module : XmppStreamModule, Jet.EnvelopEncoding { public static Xmpp.ModuleIdentity<Module> IDENTITY = new Xmpp.ModuleIdentity<Module>(NS_URI, "0396_jet_omemo"); private Omemo.Plugin plugin; + const uint KEY_SIZE = 16; + const uint IV_SIZE = 12; public Module(Omemo.Plugin plugin) { this.plugin = plugin; @@ -21,7 +23,7 @@ public class Module : XmppStreamModule, Jet.EnvelopEncoding { if (stream.get_module(Jet.Module.IDENTITY) != null) { stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); stream.get_module(Jet.Module.IDENTITY).register_envelop_encoding(this); - stream.get_module(Jet.Module.IDENTITY).register_cipher(new AesGcmCipher(16, AES_128_GCM_URI)); + stream.get_module(Jet.Module.IDENTITY).register_cipher(new AesGcmCipher(KEY_SIZE, IV_SIZE, AES_128_GCM_URI)); } } @@ -114,17 +116,19 @@ public class Module : XmppStreamModule, Jet.EnvelopEncoding { } public class AesGcmCipher : Jet.Cipher, Object { - private int key_size; + private uint key_size; + private uint default_iv_size; private string uri; - public AesGcmCipher(int key_size, string uri) { + public AesGcmCipher(uint key_size, uint default_iv_size, string uri) { this.key_size = key_size; + this.default_iv_size = default_iv_size; this.uri = uri; } public string get_cipher_uri() { return uri; } public Jet.TransportSecret generate_random_secret() { - uint8[] iv = new uint8[16]; + uint8[] iv = new uint8[default_iv_size]; Omemo.Plugin.get_context().randomize(iv); uint8[] key = new uint8[key_size]; Omemo.Plugin.get_context().randomize(key); |