Skip to content

Commit

Permalink
Add TOX_NOSPAM_SIZE to the public API.
Browse files Browse the repository at this point in the history
Fixes #456.
  • Loading branch information
iphydf committed Mar 26, 2017
1 parent d4414ff commit eb851a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion toxcore/tox.api.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ const PUBLIC_KEY_SIZE = 32;
*/
const SECRET_KEY_SIZE = 32;

/**
* The size of the nospam in bytes when written in a Tox address.
*/
const NOSPAM_SIZE = sizeof(uint32_t);

/**
* The size of a Tox address in bytes. Tox addresses are in the format
* [Public Key ($PUBLIC_KEY_SIZE bytes)][nospam (4 bytes)][checksum (2 bytes)].
Expand All @@ -248,7 +253,7 @@ const SECRET_KEY_SIZE = 32;
* byte is an XOR of all the even bytes (0, 2, 4, ...), the second byte is an
* XOR of all the odd bytes (1, 3, 5, ...) of the Public Key and nospam.
*/
const ADDRESS_SIZE = PUBLIC_KEY_SIZE + sizeof(uint32_t) + sizeof(uint16_t);
const ADDRESS_SIZE = PUBLIC_KEY_SIZE + NOSPAM_SIZE + sizeof(uint16_t);

/**
* Maximum length of a nickname in bytes.
Expand Down
10 changes: 9 additions & 1 deletion toxcore/tox.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ uint32_t tox_public_key_size(void);

uint32_t tox_secret_key_size(void);

/**
* The size of the nospam in bytes when written in a Tox address.
*/
#define TOX_NOSPAM_SIZE (sizeof(uint32_t))

uint32_t tox_nospam_size(void);

/**
* The size of a Tox address in bytes. Tox addresses are in the format
* [Public Key (TOX_PUBLIC_KEY_SIZE bytes)][nospam (4 bytes)][checksum (2 bytes)].
Expand All @@ -253,7 +260,7 @@ uint32_t tox_secret_key_size(void);
* byte is an XOR of all the even bytes (0, 2, 4, ...), the second byte is an
* XOR of all the odd bytes (1, 3, 5, ...) of the Public Key and nospam.
*/
#define TOX_ADDRESS_SIZE (TOX_PUBLIC_KEY_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
#define TOX_ADDRESS_SIZE (TOX_PUBLIC_KEY_SIZE + TOX_NOSPAM_SIZE + sizeof(uint16_t))

uint32_t tox_address_size(void);

Expand Down Expand Up @@ -2938,3 +2945,4 @@ uint16_t tox_self_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error);
#endif

#endif

0 comments on commit eb851a7

Please sign in to comment.