2022-01-24 03:28:16 +00:00
|
|
|
#ifndef LAIKA_PACKET_H
|
|
|
|
#define LAIKA_PACKET_H
|
|
|
|
|
2022-01-24 16:17:54 +00:00
|
|
|
#define LAIKA_MAGIC "LAI\x12"
|
|
|
|
#define LAIKA_MAGICLEN 4
|
|
|
|
|
2022-01-25 19:53:17 +00:00
|
|
|
#define LAIKA_MAX_PKTSIZE 4096
|
|
|
|
|
2022-01-28 01:55:28 +00:00
|
|
|
#define LAIKA_NONCESIZE 16
|
|
|
|
|
2022-01-25 03:46:29 +00:00
|
|
|
enum {
|
2022-01-24 03:28:16 +00:00
|
|
|
LAIKAPKT_HANDSHAKE_REQ,
|
2022-01-28 01:55:28 +00:00
|
|
|
/* layout of LAIKAPKT_HANDSHAKE_REQ:
|
|
|
|
* uint8_t laikaMagic[LAIKA_MAGICLEN];
|
|
|
|
* uint8_t majorVer;
|
|
|
|
* uint8_t minorVer;
|
2022-01-31 01:10:10 +00:00
|
|
|
* uint8_t peerType;
|
2022-01-29 06:26:15 +00:00
|
|
|
* uint8_t encNonce[LAIKAENC_SIZE(LAIKA_NONCESIZE)]; -- encrypted using shared pubKey
|
2022-01-28 01:55:28 +00:00
|
|
|
* uint8_t pubKey[crypto_box_PUBLICKEYBYTES]; -- freshly generated pubKey to encrypt decrypted nonce with
|
|
|
|
*/
|
2022-01-24 03:28:16 +00:00
|
|
|
LAIKAPKT_HANDSHAKE_RES,
|
2022-01-28 01:55:28 +00:00
|
|
|
/* layout of LAIKAPKT_HANDSHAKE_RES:
|
|
|
|
* uint8_t endian;
|
2022-01-29 06:26:15 +00:00
|
|
|
* uint8_t reEncryptedNonce[LAIKAENC_SIZE(LAIKA_NONCESIZE)]; -- encrypted using received pubKey from LAIKAPKT_AUTH_REQ pkt
|
2022-01-28 01:55:28 +00:00
|
|
|
*/
|
2022-01-25 19:53:17 +00:00
|
|
|
LAIKAPKT_VARPKT_REQ,
|
2022-01-29 06:26:15 +00:00
|
|
|
/* layout of LAIKAPKT_VARPKT_REQ:
|
|
|
|
* uint8_t pktID;
|
|
|
|
* uint16_t pktSize;
|
|
|
|
*/
|
2022-01-31 01:10:10 +00:00
|
|
|
LAIKAPKT_CHALLENGE_REQ,
|
|
|
|
LAIKAPKT_CHALLENGE_RES,
|
2022-01-24 03:28:16 +00:00
|
|
|
LAIKAPKT_MAXNONE
|
2022-01-25 03:46:29 +00:00
|
|
|
};
|
2022-01-24 03:28:16 +00:00
|
|
|
|
2022-01-25 19:53:17 +00:00
|
|
|
typedef uint8_t LAIKAPKT_ID;
|
|
|
|
typedef uint16_t LAIKAPKT_SIZE;
|
|
|
|
|
2022-01-24 03:28:16 +00:00
|
|
|
#endif
|