Skip to content

Commit

Permalink
Use a fully random public key for group friend connections
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman authored and iphydf committed May 1, 2020
1 parent de9a70c commit e968e2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion toxcore/group_chats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e968e2f

Please sign in to comment.