29 #if defined(__linux__) || defined(__CYGWIN__)
30 #include <arpa/inet.h>
41 sts->their_public_key.ready =
true;
48 sts->my_private_key.ready =
true;
56 memset(&
sts->their_public_ephemeral, 0,
sizeof(
struct gec_pubkey));
57 sts->their_public_ephemeral.ready =
false;
59 sts->my_private_ephemeral.ready =
false;
61 sts->rx_sym_key.ready =
false;
63 sts->tx_sym_key.ready =
false;
84 Hacl_Curve25519_crypto_scalarmult(sk->
pub, sk->
priv, basepoint);
99 Hacl_SHA2_512_hash(tmp, input,
sizeof(input));
107 Hacl_SHA2_512_hash(tmp, input,
sizeof(input));
120 uint32_t x = (bytes[3] << 24) + (bytes[2] << 16) + (bytes[1] << 8) + bytes[0];
123 #if defined(__linux__) || defined(__CYGWIN__)
126 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
130 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
135 #pragma message "Please define __BYTE_ORDER__!"
146 #if defined(__linux__) || defined(__CYGWIN__)
149 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
153 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
158 #pragma message "Error: Please define __BYTE_ORDER__!"
161 bytes[3] = (n >> 24) & 0xFF;
162 bytes[2] = (n >> 16) & 0xFF;
163 bytes[1] = (n >> 8) & 0xFF;
uint32_t rng_wait_and_get(void)
void gec_counter_to_bytes(uint32_t n, uint8_t *bytes)
Convert counter to bytes in network byte order.
void gec_clear_sts(struct gec_sts_ctx *sts)
void gec_sts_init(struct gec_sts_ctx *sts)
void gec_generate_ephemeral_keys(struct gec_privkey *sk)
Generate private and public key pairs for future use.
void gec_derive_key_material(struct gec_sts_ctx *ctx, uint8_t *z)
Derive key material for both sender and receiver.
uint32_t gec_bytes_to_counter(uint8_t *bytes)
Convert from network byte order (big endian) to the machine byte order.
Galois embedded crypto implementation.
uint8_t pub[PPRZ_KEY_LEN]
struct gec_sym_key tx_sym_key
uint8_t nonce[PPRZ_NONCE_LEN]
uint8_t priv[PPRZ_KEY_LEN]
struct gec_sym_key rx_sym_key
uint8_t key[PPRZ_KEY_LEN]
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.