From e968e2fba4bb998927aeac828250599cb1853266 Mon Sep 17 00:00:00 2001 From: jfreegman Date: Fri, 1 May 2020 13:26:23 -0400 Subject: [PATCH] Use a fully random public key for group friend connections --- toxcore/Messenger.c | 9 +++------ toxcore/group_chats.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 5ab8a43c661..6acb5bc6249 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -416,12 +416,9 @@ static void try_pack_gc_data(const Messenger *m, GC_Chat *chat, Onion_Friend *on */ int32_t m_add_group(Messenger *m, GC_Chat *chat) { - uint8_t tmp_public_key[ENC_PUBLIC_KEY]; - memcpy(tmp_public_key, get_chat_id(chat->chat_public_key), ENC_PUBLIC_KEY); - random_bytes(tmp_public_key + ENC_PUBLIC_KEY / 2, ENC_PUBLIC_KEY / 2); - memcpy(chat->onion_friend_public_key, tmp_public_key, ENC_PUBLIC_KEY); + random_bytes(chat->m_group_public_key, CRYPTO_PUBLIC_KEY_SIZE); - int group_number = m_add_contact_no_request(m, tmp_public_key, CONTACT_GROUP); + int group_number = m_add_contact_no_request(m, chat->m_group_public_key, CONTACT_GROUP); if (group_number < 0) { return -1; @@ -441,7 +438,7 @@ int32_t m_add_group(Messenger *m, GC_Chat *chat) int32_t m_remove_group(Messenger *m, const GC_Chat *chat) { - int group_number = get_group_id(m, chat->onion_friend_public_key); + int group_number = get_group_id(m, chat->m_group_public_key); if (group_number >= 0) { m_delgroup(m, group_number); diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 623ef6ce48a..af2a2319bf2 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h @@ -296,7 +296,7 @@ typedef struct GC_Chat { int32_t saved_invites[MAX_GC_SAVED_INVITES]; uint8_t saved_invites_index; - uint8_t onion_friend_public_key[ENC_PUBLIC_KEY]; + uint8_t m_group_public_key[CRYPTO_PUBLIC_KEY_SIZE]; // Identifier for group's messenger friend connection bool should_update_self_announces; bool should_start_sending_handshakes;