Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
#include "std.h"
#include "mcu_periph/rng.h"
#include "generated/keys_uav.h"
#include "../ext/hacl-c/Hacl_Ed25519.h"
#include "../ext/hacl-c/Hacl_Curve25519.h"
#include "../ext/hacl-c/Hacl_SHA2_512.h"
#include "../ext/hacl-c/Hacl_Chacha20Poly1305.h"
#include "../ext/hacl-c/kremlib.h"
Go to the source code of this file.
Data Structures | |
struct | gec_privkey |
struct | gec_pubkey |
struct | gec_sym_key |
struct | gec_sts_ctx |
Macros | |
#define | PPRZ_MSG_TYPE_PLAINTEXT 0xaa |
#define | PPRZ_MSG_TYPE_ENCRYPTED 0x55 |
#define | PPRZ_GEC_IDX 0 |
#define | PPRZ_CNTR_IDX 1 |
#define | PPRZ_AUTH_IDX 5 |
#define | PPRZ_SIGN_LEN 64 |
#define | PPRZ_HASH_LEN 64 |
#define | PPRZ_KEY_LEN 32 |
#define | PPRZ_MAC_LEN 16 |
#define | PPRZ_NONCE_LEN 12 |
#define | PPRZ_COUNTER_LEN 4 |
#define | PPRZ_CRYPTO_OVERHEAD 20 |
#define | PPRZ_CURVE_BASEPOINT 9 |
Typedefs | |
typedef unsigned char | ed25519_signature[64] |
Enumerations | |
enum | stage_t { INIT, WAIT_MSG1, WAIT_MSG2, WAIT_MSG3, CRYPTO_OK } |
enum | party_t { INITIATOR, RESPONDER, CLIENT, INVALID_PARTY } |
enum | gec_sts_msg_type_t { P_AE, P_BE, SIG } |
enum | sts_error_t { ERROR_NONE, MSG1_TIMEOUT_ERROR, MSG1_ENCRYPT_ERROR, MSG3_TIMEOUT_ERROR, MSG3_DECRYPT_ERROR, MSG3_SIGNVERIFY_ERROR, MSG2_TIMEOUT_ERROR, MSG2_DECRYPT_ERROR, MSG2_SIGNVERIFY_ERROR, MSG3_ENCRYPT_ERROR, UNEXPECTED_MSG_TYPE_ERROR, UNEXPECTED_MSG_DATA_ERROR, UNEXPECTED_MSG_ERROR } |
Functions | |
void | gec_sts_init (struct gec_sts_ctx *sts) |
void | gec_clear_sts (struct gec_sts_ctx *sts) |
void | gec_generate_ephemeral_keys (struct gec_privkey *sk) |
Generate private and public key pairs for future use. More... | |
void | gec_derive_key_material (struct gec_sts_ctx *sts, uint8_t *z) |
Derive key material for both sender and receiver. More... | |
void | gec_counter_to_bytes (uint32_t n, uint8_t *bytes) |
Convert counter to bytes in network byte order. More... | |
uint32_t | gec_bytes_to_counter (uint8_t *bytes) |
Convert from network byte order (big endian) to the machine byte order. More... | |
Galois embedded crypto implementation
Definition in file gec.h.
struct gec_privkey |
Data Fields | ||
---|---|---|
uint8_t | priv[PPRZ_KEY_LEN] | |
uint8_t | pub[PPRZ_KEY_LEN] | |
bool | ready |
struct gec_pubkey |
Data Fields | ||
---|---|---|
uint8_t | pub[PPRZ_KEY_LEN] | |
bool | ready |
struct gec_sym_key |
Data Fields | ||
---|---|---|
uint32_t | counter | |
uint8_t | key[PPRZ_KEY_LEN] | |
uint8_t | nonce[PPRZ_NONCE_LEN] | |
bool | ready |
struct gec_sts_ctx |
Data Fields | ||
---|---|---|
uint32_t | decrypt_err | |
uint32_t | encrypt_err | |
sts_error_t | last_error | |
struct gec_privkey | my_private_ephemeral | |
struct gec_privkey | my_private_key | |
party_t | party | |
stage_t | protocol_stage | |
uint32_t | rx_counter_err | |
struct gec_sym_key | rx_sym_key | |
struct gec_pubkey | their_public_ephemeral | |
struct gec_pubkey | their_public_key | |
struct gec_sym_key | tx_sym_key |
enum gec_sts_msg_type_t |
enum party_t |
enum stage_t |
enum sts_error_t |
Convert from network byte order (big endian) to the machine byte order.
Definition at line 117 of file gec.c.
Referenced by gec_decrypt_message().
void gec_clear_sts | ( | struct gec_sts_ctx * | sts | ) |
Definition at line 54 of file gec.c.
References ERROR_NONE, gec_sts_ctx::last_error, gec_sts_ctx::my_private_ephemeral, gec_sts_ctx::party, gec_sts_ctx::protocol_stage, gec_privkey::ready, gec_pubkey::ready, gec_sym_key::ready, RESPONDER, gec_sts_ctx::rx_sym_key, gec_sts_ctx::their_public_ephemeral, gec_sts_ctx::tx_sym_key, and WAIT_MSG1.
Referenced by gec_sts_init().
Convert counter to bytes in network byte order.
Definition at line 142 of file gec.c.
Referenced by gec_encrypt_message().
void gec_derive_key_material | ( | struct gec_sts_ctx * | sts, |
uint8_t * | z | ||
) |
Derive key material for both sender and receiver.
Definition at line 91 of file gec.c.
References gec_sym_key::counter, gec_sym_key::key, gec_sym_key::nonce, PPRZ_KEY_LEN, PPRZ_NONCE_LEN, gec_sym_key::ready, gec_sts_ctx::rx_sym_key, and gec_sts_ctx::tx_sym_key.
Referenced by gec_process_msg1().
void gec_generate_ephemeral_keys | ( | struct gec_privkey * | sk | ) |
Generate private and public key pairs for future use.
Definition at line 73 of file gec.c.
References PPRZ_KEY_LEN, gec_privkey::priv, gec_privkey::pub, gec_privkey::ready, and rng_wait_and_get().
Referenced by gec_process_msg1(), and gec_sts_init().
void gec_sts_init | ( | struct gec_sts_ctx * | sts | ) |
Definition at line 33 of file gec.c.
References gec_clear_sts(), gec_generate_ephemeral_keys(), gec_sts_ctx::my_private_ephemeral, gec_sts_ctx::my_private_key, PPRZ_KEY_LEN, gec_privkey::priv, gec_privkey::pub, gec_privkey::ready, gec_pubkey::ready, and gec_sts_ctx::their_public_key.
Referenced by gec_dl_init().