Skip to content
Snippets Groups Projects
Commit 19459528 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Fix encryption bug, which made media unencryptable in Riot

parent a54d7343
No related branches found
No related tags found
No related merge requests found
......@@ -203,9 +203,9 @@ encrypt_file(const std::string &plaintext)
{
mtx::crypto::EncryptedFile encryption_info;
// not sure if 16 bytes would be enough, 32 seems to be safe though
// iv has to be 16 bytes, key 32!
BinaryBuf key = create_buffer(32);
BinaryBuf iv = create_buffer(32);
BinaryBuf iv = create_buffer(16);
BinaryBuf cyphertext = AES_CTR_256_Encrypt(plaintext, key, iv);
......
......@@ -1139,6 +1139,10 @@ TEST(Encryption, EncryptedFile)
ASSERT_EQ(plaintext,
mtx::crypto::to_string(mtx::crypto::decrypt_file(
mtx::crypto::to_string(encryption_data.first), encryption_data.second)));
// IV needs to be 16 bytes/128 bits
ASSERT_EQ(16, encryption_data.second.iv.size());
// key needs to be 32 bytes/256 bits
ASSERT_EQ(32, encryption_data.second.key.k.size());
json j = R"({
"type": "m.room.message",
......
......@@ -347,7 +347,7 @@ TEST(StateEvents, JoinRules)
"type": "m.room.join_rules"
})"_json;
EXPECT_EQ(data, json(ns::StateEvent<ns::state::JoinRules>(data)));
EXPECT_EQ(data, json(ns::StateEvent<ns::state::JoinRules>(data)));
data = R"({
"origin_server_ts": 1506761924018,
......@@ -363,7 +363,7 @@ TEST(StateEvents, JoinRules)
"type": "m.room.join_rules"
})"_json;
EXPECT_EQ(data, json(ns::StateEvent<ns::state::JoinRules>(data)));
EXPECT_EQ(data, json(ns::StateEvent<ns::state::JoinRules>(data)));
data = R"({
"origin_server_ts": 1506761924018,
......@@ -379,7 +379,7 @@ TEST(StateEvents, JoinRules)
"type": "m.room.join_rules"
})"_json;
EXPECT_EQ(data, json(ns::StateEvent<ns::state::JoinRules>(data)));
EXPECT_EQ(data, json(ns::StateEvent<ns::state::JoinRules>(data)));
}
TEST(StateEvents, Member)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment