Jump to Navigation

toxcore几个常量记录

toxcore几个常量记录:

crypto_*常量定义在头文件sodium/crypto_box.h:
#define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES 32U
#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U
#define crypto_box_curve25519xsalsa20poly1305_MACBYTES \
(crypto_box_curve25519xsalsa20poly1305_ZEROBYTES - \
crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES)
#define crypto_box_MACBYTES crypto_box_curve25519xsalsa20poly1305_MACBYTES
#define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U
#define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES

从以上几个常量可以推导出 ===> crypto_box_MACBYTES=16

以下几个常量定义在头文件toxcore/net_crypto.h
#define CRYPTO_DATA_PACKET_MIN_SIZE (1 + sizeof(uint16_t) + (sizeof(uint32_t) + sizeof(uint32_t)) + crypto_box_MACBYTES)
===> CRYPTO_DATA_PACKET_MIN_SIZE=(3 + 8 + 16) = 27
#define MAX_CRYPTO_PACKET_SIZE 1400
#define MAX_CRYPTO_DATA_SIZE (MAX_CRYPTO_PACKET_SIZE - CRYPTO_DATA_PACKET_MIN_SIZE)
===> MAX_CRYPTO_DATA_SIZE = (1400 - 27) = 1373

这个常量好像用的地方比较少,直接定义了在toxcore/Messenger.c实现文件中,
#define MAX_FILE_DATA_SIZE (MAX_CRYPTO_DATA_SIZE - 2)
===> MAX_FILE_DATA_SIZE=1371

也就是说文件流每次发送都是1371字节。
这个值和一个message消息的大小一样。

添加新评论

Plain text

  • 不允许HTML标记。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.


Main menu 2

Story | by Dr. Radut