Set key size for omemo http file transfers to 256 bits

Fixes #909
This commit is contained in:
Marvin W 2020-09-15 17:33:40 +02:00 committed by fiaxh
parent 7bb4e4ef62
commit d6d4e5eb0a

View file

@ -40,6 +40,7 @@ public class OmemoFileDecryptor : FileDecryptor, Object {
} }
public async InputStream decrypt_file(InputStream encrypted_stream, Conversation conversation, FileTransfer file_transfer, FileReceiveData receive_data) throws FileReceiveError { public async InputStream decrypt_file(InputStream encrypted_stream, Conversation conversation, FileTransfer file_transfer, FileReceiveData receive_data) throws FileReceiveError {
const uint KEY_SIZE = 32;
try { try {
OmemoHttpFileReceiveData? omemo_http_receive_data = receive_data as OmemoHttpFileReceiveData; OmemoHttpFileReceiveData? omemo_http_receive_data = receive_data as OmemoHttpFileReceiveData;
if (omemo_http_receive_data == null) assert(false); if (omemo_http_receive_data == null) assert(false);
@ -48,8 +49,8 @@ public class OmemoFileDecryptor : FileDecryptor, Object {
MatchInfo match_info; MatchInfo match_info;
this.url_regex.match(omemo_http_receive_data.original_url, 0, out 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_and_key = hex_to_bin(match_info.fetch(2).up());
uint8[] iv = iv_and_key[0:iv_and_key.length-16]; uint8[] iv = iv_and_key[0:iv_and_key.length-KEY_SIZE];
uint8[] key = iv_and_key[iv_and_key.length-16:iv_and_key.length]; uint8[] key = iv_and_key[iv_and_key.length-KEY_SIZE:iv_and_key.length];
file_transfer.encryption = Encryption.OMEMO; file_transfer.encryption = Encryption.OMEMO;
debug("Decrypting file %s from %s", file_transfer.file_name, file_transfer.server_file_name); debug("Decrypting file %s from %s", file_transfer.file_name, file_transfer.server_file_name);