summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h26
1 files changed, 5 insertions, 21 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index c5484fba..d285e3fc 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -38,8 +38,7 @@ extern "C" {
38#define TOX_MAX_STATUSMESSAGE_LENGTH 1007 38#define TOX_MAX_STATUSMESSAGE_LENGTH 1007
39#define TOX_CLIENT_ID_SIZE 32 39#define TOX_CLIENT_ID_SIZE 32
40#define TOX_AVATAR_MAX_DATA_LENGTH 16384 40#define TOX_AVATAR_MAX_DATA_LENGTH 16384
41#define TOX_AVATAR_HASH_LENGTH /*crypto_hash_sha256_BYTES*/ 32 41#define TOX_HASH_LENGTH /*crypto_hash_sha256_BYTES*/ 32
42#define TOX_HASH_LENGTH TOX_AVATAR_HASH_LENGTH
43 42
44#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t)) 43#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
45 44
@@ -614,34 +613,19 @@ int tox_get_self_avatar(const Tox *tox, uint8_t *format, uint8_t *buf, uint32_t
614 613
615/* Generates a cryptographic hash of the given data. 614/* Generates a cryptographic hash of the given data.
616 * This function may be used by clients for any purpose, but is provided primarily for 615 * This function may be used by clients for any purpose, but is provided primarily for
617 * validating cached avatars. 616 * validating cached avatars. This use is highly recommended to avoid unnecessary avatar
617 * updates.
618 * This function is a wrapper to internal message-digest functions. 618 * This function is a wrapper to internal message-digest functions.
619 * 619 *
620 * Arguments: 620 * Arguments:
621 * hash - destination buffer for the hash data, it must be exactly TOX_HASH_LENGTH bytes long. 621 * hash - destination buffer for the hash data, it must be exactly TOX_HASH_LENGTH bytes long.
622 * data - data to be hashed; 622 * data - data to be hashed;
623 * datalen - length of the data; 623 * datalen - length of the data; for avatars, should be TOX_AVATAR_MAX_DATA_LENGTH
624 * 624 *
625 * returns 0 on success 625 * returns 0 on success
626 * returns -1 on failure. 626 * returns -1 on failure.
627 */ 627 */
628int m_hash(uint8_t *hash, const uint8_t *data, const uint32_t datalen); 628int tox_hash(const Tox *tox, uint8_t *hash, const uint8_t *data, const uint32_t datalen);
629
630/* Generates a cryptographic hash of the given avatar data.
631 * This function is a wrapper to tox_hash and specifically provided
632 * to generate hashes from user avatars that may be memcmp()ed with the values returned by the
633 * other avatar functions. It is specially important to validate cached avatars.
634 *
635 * Arguments:
636 * hash - destination buffer for the hash data, it must be exactly TOX_AVATAR_HASH_LENGTH bytes long.
637 * data - avatar image data;
638 * datalen - length of the avatar image data; it must be <= MAX_AVATAR_DATA_LENGTH.
639 *
640 * returns 0 on success
641 * returns -1 on failure.
642 */
643int tox_avatar_hash(const Tox *tox, uint8_t *hash, const uint8_t *data, const uint32_t datalen);
644
645 629
646/* Request avatar information from a friend. 630/* Request avatar information from a friend.
647 * Asks a friend to provide their avatar information (image format and hash). The friend may 631 * Asks a friend to provide their avatar information (image format and hash). The friend may