diff options
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/tox.c | 5 | ||||
-rw-r--r-- | toxcore/tox.h | 26 |
2 files changed, 5 insertions, 26 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index 819a67dd..21854de4 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -831,11 +831,6 @@ int tox_hash(const Tox *tox, uint8_t *hash, const uint8_t *data, const uint32_t | |||
831 | return m_hash(hash, data, datalen); | 831 | return m_hash(hash, data, datalen); |
832 | } | 832 | } |
833 | 833 | ||
834 | int tox_avatar_hash(const Tox *tox, uint8_t *hash, const uint8_t *data, const uint32_t datalen) | ||
835 | { | ||
836 | return m_hash(hash, data, datalen); | ||
837 | } | ||
838 | |||
839 | int tox_request_avatar_info(const Tox *tox, const int32_t friendnumber) | 834 | int tox_request_avatar_info(const Tox *tox, const int32_t friendnumber) |
840 | { | 835 | { |
841 | const Messenger *m = tox; | 836 | const Messenger *m = tox; |
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 | */ |
628 | int m_hash(uint8_t *hash, const uint8_t *data, const uint32_t datalen); | 628 | int 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 | */ | ||
643 | int 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 |