aboutsummaryrefslogtreecommitdiff
path: root/plugins/omemo/src/file_transfer
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2020-09-14 21:56:58 +0200
committerMarvin W <git@larma.de>2020-09-14 22:04:06 +0200
commitcd5b639a826ccafe5741a51f10cc8ca76ebfdd14 (patch)
treef39146eb751f67e99942770c67cf06ca4a912243 /plugins/omemo/src/file_transfer
parentf6943a4c82ed39b8d6ae866855198596a51dade4 (diff)
downloaddino-cd5b639a826ccafe5741a51f10cc8ca76ebfdd14.tar.gz
dino-cd5b639a826ccafe5741a51f10cc8ca76ebfdd14.zip
Send OMEMO-encrypted messages and files using 12 byte IV
Diffstat (limited to 'plugins/omemo/src/file_transfer')
-rw-r--r--plugins/omemo/src/file_transfer/file_decryptor.vala10
-rw-r--r--plugins/omemo/src/file_transfer/file_encryptor.vala6
2 files changed, 6 insertions, 10 deletions
diff --git a/plugins/omemo/src/file_transfer/file_decryptor.vala b/plugins/omemo/src/file_transfer/file_decryptor.vala
index 7aec41d5..fedb9397 100644
--- a/plugins/omemo/src/file_transfer/file_decryptor.vala
+++ b/plugins/omemo/src/file_transfer/file_decryptor.vala
@@ -52,14 +52,8 @@ public class OmemoFileDecryptor : FileDecryptor, Object {
MatchInfo match_info;
this.url_regex.match(omemo_http_receive_data.original_url, 0, out match_info);
uint8[] iv_and_key = hex_to_bin(match_info.fetch(2).up());
- uint8[] iv, key;
- if (iv_and_key.length == 44) {
- iv = iv_and_key[0:12];
- key = iv_and_key[12:44];
- } else {
- iv = iv_and_key[0:16];
- key = iv_and_key[16:48];
- }
+ uint8[] iv = iv_and_key[0:iv_and_key.length-16];
+ uint8[] key = iv_and_key[iv_and_key.length-16:iv_and_key.length];
file_transfer.encryption = Encryption.OMEMO;
debug("Decrypting file %s from %s", file_transfer.file_name, file_transfer.server_file_name);
diff --git a/plugins/omemo/src/file_transfer/file_encryptor.vala b/plugins/omemo/src/file_transfer/file_encryptor.vala
index 31c3ad6c..7e79abdc 100644
--- a/plugins/omemo/src/file_transfer/file_encryptor.vala
+++ b/plugins/omemo/src/file_transfer/file_encryptor.vala
@@ -20,13 +20,15 @@ public class OmemoFileEncryptor : Dino.FileEncryptor, Object {
}
public FileMeta encrypt_file(Conversation conversation, FileTransfer file_transfer) throws FileSendError {
+ const uint KEY_SIZE = 32;
+ const uint IV_SIZE = 12;
var omemo_http_file_meta = new OmemoHttpFileMeta();
try {
//Create a key and use it to encrypt the file
- uint8[] iv = new uint8[16];
+ uint8[] iv = new uint8[IV_SIZE];
Plugin.get_context().randomize(iv);
- uint8[] key = new uint8[32];
+ uint8[] key = new uint8[KEY_SIZE];
Plugin.get_context().randomize(key);
SymmetricCipher cipher = new SymmetricCipher("AES-GCM");