-#define SPTPS_KEX 0 // Waiting for the first Key EXchange record
-#define SPTPS_SECONDARY_KEX 1 // Ready to receive a secondary Key EXchange record
-#define SPTPS_SIG 2 // Waiting for a SIGnature record
-#define SPTPS_ACK 3 // Waiting for an ACKnowledgement record
+typedef enum sptps_state_t {
+ SPTPS_KEX = 1, // Waiting for the first Key EXchange record
+ SPTPS_SECONDARY_KEX = 2, // Ready to receive a secondary Key EXchange record
+ SPTPS_SIG = 3, // Waiting for a SIGnature record
+ SPTPS_ACK = 4, // Waiting for an ACKnowledgement record
+} sptps_state_t;
+
+PACKED(struct sptps_kex_t {
+ uint8_t version;
+ uint8_t nonce[ECDH_SIZE];
+ uint8_t pubkey[ECDH_SIZE];
+});
+
+typedef struct sptps_kex_t sptps_kex_t;
+
+STATIC_ASSERT(sizeof(sptps_kex_t) == 65, "sptps_kex_t has invalid size");
+
+typedef union sptps_key_t {
+ struct {
+ uint8_t key0[CHACHA_POLY1305_KEYLEN];
+ uint8_t key1[CHACHA_POLY1305_KEYLEN];
+ };
+ uint8_t both[CHACHA_POLY1305_KEYLEN * 2];
+} sptps_key_t;