get peer pubkey api

This commit is contained in:
dubslow 2014-11-19 20:36:09 -06:00
parent 4e6f993e7d
commit 6a52b3cb6c
4 changed files with 48 additions and 0 deletions

View File

@ -722,6 +722,26 @@ int del_groupchat(Group_Chats *g_c, int groupnumber)
return wipe_group_chat(g_c, groupnumber);
}
/* Copy the public key of peernumber who is in groupnumber to pk.
* pk must be crypto_box_PUBLICKEYBYTES long.
*
* returns 0 on success
* returns -1 on failure
*/
int group_peer_pubkey(const Group_Chats *g_c, int groupnumber, int peernumber, uint8_t *pk)
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g)
return -1;
if ((uint32_t)peernumber >= g->numpeers)
return -1;
memcpy(pk, g->group[peernumber].real_pk, crypto_box_PUBLICKEYBYTES);
return 0;
}
/* Copy the name of peernumber who is in groupnumber to name.
* name must be at least MAX_NAME_LENGTH long.
*

View File

@ -192,6 +192,14 @@ int add_groupchat(Group_Chats *g_c, uint8_t type);
*/
int del_groupchat(Group_Chats *g_c, int groupnumber);
/* Copy the public key of peernumber who is in groupnumber to pk.
* pk must be crypto_box_PUBLICKEYBYTES long.
*
* returns 0 on success
* returns -1 on failure
*/
int group_peer_pubkey(const Group_Chats *g_c, int groupnumber, int peernumber, uint8_t *pk);
/* Copy the name of peernumber who is in groupnumber to name.
* name must be at least MAX_NAME_LENGTH long.
*

View File

@ -641,6 +641,18 @@ int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t
return group_peername(m->group_chat_object, groupnumber, peernumber, name);
}
/* Copy the public key of peernumber who is in groupnumber to pk.
* pk must be TOX_CLIENT_ID_SIZE long.
*
* returns 0 on success
* returns -1 on failure
*/
int tox_group_peer_pubkey(const Tox *tox, int groupnumber, int peernumber, uint8_t *pk)
{
const Messenger *m = tox;
return group_peer_pubkey(m->group_chat_object, groupnumber, peernumber, pk);
}
/* invite friendnumber to groupnumber
* return 0 on success
* return -1 on failure

View File

@ -496,6 +496,14 @@ int tox_del_groupchat(Tox *tox, int groupnumber);
*/
int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t *name);
/* Copy the public key of peernumber who is in groupnumber to pk.
* pk must be TOX_CLIENT_ID_SIZE long.
*
* returns 0 on success
* returns -1 on failure
*/
int tox_group_peer_pubkey(const Tox *tox, int groupnumber, int peernumber, uint8_t *pk);
/* invite friendnumber to groupnumber
* return 0 on success
* return -1 on failure