X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fsptps.h;h=95209e5d2702f21499d5c619e613781d0d67dda1;hp=96edc366ab659cd4e837753e6e3ad8c841ded0ca;hb=c44b08613508c993e7fd9f625e0b1b4775efffed;hpb=efca41606d4083eade90047d57cb963eb3b7e731 diff --git a/src/sptps.h b/src/sptps.h index 96edc366..95209e5d 100644 --- a/src/sptps.h +++ b/src/sptps.h @@ -47,6 +47,26 @@ typedef enum sptps_state_t { 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; + +STATIC_ASSERT(sizeof(sptps_key_t) == 128, "sptps_key_t has invalid size"); + typedef struct sptps { bool initiator; bool datagram; @@ -72,9 +92,9 @@ typedef struct sptps { ecdsa_t *hiskey; ecdh_t *ecdh; - uint8_t *mykex; - uint8_t *hiskex; - uint8_t *key; + sptps_kex_t *mykex; + sptps_kex_t *hiskex; + sptps_key_t *key; uint8_t *label; size_t labellen;