Commit 7795a68a authored by Matthieu Tanon's avatar Matthieu Tanon
Browse files

Fix security level test and add warning on decryption failure

parent 026510bd
......@@ -310,13 +310,15 @@ ChatMessageModifier::Result LimeV2::processIncomingMessage (const shared_ptr<Cha
vector<uint8_t> decodedCipherMessage = decodeBase64(cipherMessage);
vector<uint8_t> plainMessage{};
lime::PeerDeviceStatus peerStatus = lime::PeerDeviceStatus::fail;
lime::PeerDeviceStatus peerDeviceStatus = lime::PeerDeviceStatus::fail;
try {
peerStatus = belleSipLimeManager->decrypt(localDeviceId, recipientUserId, senderDeviceId, decodedCipherHeader, decodedCipherMessage, plainMessage);
peerDeviceStatus = belleSipLimeManager->decrypt(localDeviceId, recipientUserId, senderDeviceId, decodedCipherHeader, decodedCipherMessage, plainMessage);
} catch (const exception &e) {
lError() << e.what() << " while decrypting message";
}
if (peerDeviceStatus == lime::PeerDeviceStatus::fail) lError() << "Failed to decrypt message from " << senderDeviceId;
// Prepare decrypted message for next modifier
string plainMessageString(plainMessage.begin(), plainMessage.end());
Content finalContent;
......
......@@ -4385,19 +4385,16 @@ static void group_chat_lime_v2_chatroom_security_level_downgrade_resetting_zrtp
linphone_core_set_media_encryption(laure->lc, LinphoneMediaEncryptionZRTP);
// ZRTP verification call between Marie and Pauline
printf("\n[ZRTP] zrtp call between Marie and Pauline\n");
bool_t call_ok = FALSE;
BC_ASSERT_TRUE((call_ok=simple_zrtp_call_with_sas_validation(marie, pauline, TRUE, TRUE)));
if (!call_ok) goto end;
// ZRTP verification call between Marie and Laure
printf("\n[ZRTP] zrtp call between Marie and Laure\n");
call_ok = FALSE;
BC_ASSERT_TRUE((call_ok=simple_zrtp_call_with_sas_validation(marie, laure, TRUE, TRUE)));
if (!call_ok) goto end;
// ZRTP verification call between Pauline and Laure
printf("\n[ZRTP] zrtp call between Pauline and Laure\n");
call_ok = FALSE;
BC_ASSERT_TRUE((call_ok=simple_zrtp_call_with_sas_validation(pauline, laure, TRUE, TRUE)));
if (!call_ok) goto end;
......@@ -4408,11 +4405,14 @@ static void group_chat_lime_v2_chatroom_security_level_downgrade_resetting_zrtp
BC_ASSERT_EQUAL(linphone_chat_room_get_security_level(laureCr), LinphoneChatRoomSecurityLevelSafe, int, "%d");
// New call with ZRTP verification but pauline refuses the SAS
printf("\n[ZRTP] zrtp call between Pauline and Marie where Pauline refuses the SAS\n");
simple_zrtp_call_with_sas_validation(pauline, marie, FALSE, TRUE);
// Marie's chatroom security level is expected to be downgraded too but we are in a state of ZRTP asynchronism
// There is no ZRTP exchange until next call, where SAS can be validated or invalidated again
// Until then Marie trusts Pauline but Pauline doesn't trust Marie so security levels correspond to this state
// Check the chat room security level got downgraded for Marie and Pauline
BC_ASSERT_EQUAL(linphone_chat_room_get_security_level(marieCr), LinphoneChatRoomSecurityLevelEncrypted, int, "%d"); // still safe --> both security levels should be downgraded
BC_ASSERT_EQUAL(linphone_chat_room_get_security_level(marieCr), LinphoneChatRoomSecurityLevelSafe, int, "%d");
BC_ASSERT_EQUAL(linphone_chat_room_get_security_level(paulineCr), LinphoneChatRoomSecurityLevelEncrypted, int, "%d");
BC_ASSERT_EQUAL(linphone_chat_room_get_security_level(laureCr), LinphoneChatRoomSecurityLevelSafe, int, "%d");
......@@ -4613,7 +4613,7 @@ static void group_chat_lime_v2_send_encrypted_message_to_disabled_lime_v2 (void)
linphone_core_manager_destroy(pauline);
}
static void group_chat_lime_v2_send_encrypted_message_to_several_devices (void) {
static void group_chat_lime_v2_send_encrypted_message_to_multidevice_participants (void) {
LinphoneCoreManager *marie1 = linphone_core_manager_create("marie_rc");
LinphoneCoreManager *marie2 = linphone_core_manager_create("marie_rc");
LinphoneCoreManager *pauline1 = linphone_core_manager_create("pauline_tcp_rc");
......@@ -5161,11 +5161,11 @@ test_t group_chat_tests[] = {
TEST_TWO_TAGS("LIMEv2 message with response and composing", group_chat_lime_v2_send_encrypted_message_with_response_and_composing, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 ZRTP verification", group_chat_lime_v2_with_zrtp_verification, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 chatroom security level upgrade", group_chat_lime_v2_chatroom_security_level_upgrade, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 chatroom security level downgrade by adding participant", group_chat_lime_v2_chatroom_security_level_downgrade_adding_participant, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 chatroom security level downgrade by resetting zrtp", group_chat_lime_v2_chatroom_security_level_downgrade_resetting_zrtp, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 chatroom security level downgrade adding participant", group_chat_lime_v2_chatroom_security_level_downgrade_adding_participant, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 chatroom security level downgrade resetting zrtp", group_chat_lime_v2_chatroom_security_level_downgrade_resetting_zrtp, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 multiple successive messages", group_chat_lime_v2_send_multiple_successive_encrypted_messages, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 message to disabled LIMEv2", group_chat_lime_v2_send_encrypted_message_to_disabled_lime_v2, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 message to several devices", group_chat_lime_v2_send_encrypted_message_to_several_devices, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 message to multidevice participants", group_chat_lime_v2_send_encrypted_message_to_multidevice_participants, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 multiple messages while network unreachable", group_chat_lime_v2_multiple_messages_while_network_unreachable, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 message X3DH server unavailable", group_chat_lime_v2_X3DH_server_unavailable, "CreateUserInDb", "LeaksMemory"),
TEST_TWO_TAGS("LIMEv2 message not decrypted", group_chat_lime_v2_encrypted_message_not_decrypted, "CreateUserInDb", "LeaksMemory"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment