1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-06 03:50:08 +02:00

allow joining a normal-group on qr-code scan and allow vg-member-added to be sent unencrypted in this case

This commit is contained in:
B. Petersen 2019-01-08 22:17:33 +01:00
parent 4d1f40761a
commit 0fac8600be
No known key found for this signature in database
GPG key ID: 3B88E92DEA8E9AFC

View file

@ -666,14 +666,13 @@ int dc_handle_securejoin_handshake(dc_context_t* context, dc_mimeparser_t* mimep
if (join_vg) { if (join_vg) {
// the vg-member-added message is special: this is a normal Chat-Group-Member-Added message with an additional Secure-Join header // the vg-member-added message is special: this is a normal Chat-Group-Member-Added message with an additional Secure-Join header
grpid = dc_strdup(lookup_field(mimeparser, "Secure-Join-Group")); grpid = dc_strdup(lookup_field(mimeparser, "Secure-Join-Group"));
int is_verified = 0; uint32_t group_chat_id = dc_get_chat_id_by_grpid(context, grpid, NULL, NULL);
uint32_t verified_chat_id = dc_get_chat_id_by_grpid(context, grpid, NULL, &is_verified); if (group_chat_id==0) {
if (verified_chat_id==0 || !is_verified) { dc_log_error(context, 0, "Chat %s not found.", grpid);
dc_log_error(context, 0, "Verified chat not found.");
goto cleanup; goto cleanup;
} }
dc_add_contact_to_chat_ex(context, verified_chat_id, contact_id, DC_FROM_HANDSHAKE); // Alice -> Bob and all members dc_add_contact_to_chat_ex(context, group_chat_id, contact_id, DC_FROM_HANDSHAKE); // Alice -> Bob and all members
} }
else { else {
send_handshake_msg(context, contact_chat_id, "vc-contact-confirm", send_handshake_msg(context, contact_chat_id, "vc-contact-confirm",
@ -704,12 +703,30 @@ int dc_handle_securejoin_handshake(dc_context_t* context, dc_mimeparser_t* mimep
goto cleanup; goto cleanup;
} }
scanned_fingerprint_of_alice = dc_strdup(context->bobs_qr_scan->fingerprint); scanned_fingerprint_of_alice = dc_strdup(context->bobs_qr_scan->fingerprint);
if (join_vg) {
grpid = dc_strdup(context->bobs_qr_scan->text2);
}
UNLOCK_QR UNLOCK_QR
if (!encrypted_and_signed(mimeparser, scanned_fingerprint_of_alice)) { int vg_expect_encrypted = 1;
could_not_establish_secure_connection(context, contact_chat_id, "Contact confirm message not encrypted."); if (join_vg) {
end_bobs_joining(context, DC_BOB_ERROR); int is_verified_group = 0;
goto cleanup; dc_get_chat_id_by_grpid(context, grpid, NULL, &is_verified_group);
if (!is_verified_group) {
// when joining a normal group after verification,
// the vg-member-added message may be unencrypted
// when not all group members have keys or prefer encryption.
// this does not affect the contact verification as such.
vg_expect_encrypted = 0;
}
}
if (vg_expect_encrypted) {
if (!encrypted_and_signed(mimeparser, scanned_fingerprint_of_alice)) {
could_not_establish_secure_connection(context, contact_chat_id, "Contact confirm message not encrypted.");
end_bobs_joining(context, DC_BOB_ERROR);
goto cleanup;
}
} }
if (!mark_peer_as_verified(context, scanned_fingerprint_of_alice)) { if (!mark_peer_as_verified(context, scanned_fingerprint_of_alice)) {