modules/woz_aliro/include/aliro_crypto.h
asxeem/openaliro
Module

aliro_crypto.h

Aliro crypto public API: key derivation, AES-GCM secure channels, and wire message…

modules/woz_aliro/include/aliro_crypto.h1 documented symbols

Overview

Aliro crypto public API: key derivation, AES-GCM secure channels, and wire message seal/open framing shared by the reader and device sides of an Aliro session.

used by aliro_stepup.h aliro_crypto.c aliro_ranging.c aliro_reader.c aliro_stepup.c

API

Cstruct aliro_secchan

modules/woz_aliro/include/aliro_crypto.h:134

---- Secure channel (AES-256-GCM, directional per-message counters) ------ Nonce = 8-byte big-endian direction (0 outbound/seal, 1 inbound/open) followed by a 4-byte big-endian per-direction counter. Separate seal/open counters, start at 0, no wrap. SessionCrypto sends no AAD; the BLE channel authenticates a 4-byte AAD (caller-supplied here).

##define ALIRO_URSK_LEN 32u

modules/woz_aliro/include/aliro_crypto.h:29

##define ALIRO_KEY_BLOCK_LEN 160u

modules/woz_aliro/include/aliro_crypto.h:30

##define ALIRO_URSK_OFFSET 128u

modules/woz_aliro/include/aliro_crypto.h:31

##define ALIRO_SESSION_KEY_LEN 32u

modules/woz_aliro/include/aliro_crypto.h:32

##define ALIRO_SHARED_SECRET_LEN 32u

modules/woz_aliro/include/aliro_crypto.h:33

##define ALIRO_TXID_LEN 16u

modules/woz_aliro/include/aliro_crypto.h:34

##define ALIRO_EC_PUBX_LEN 32u

modules/woz_aliro/include/aliro_crypto.h:35

##define ALIRO_GCM_NONCE_LEN 12u

modules/woz_aliro/include/aliro_crypto.h:36

##define ALIRO_GCM_TAG_LEN 16u

modules/woz_aliro/include/aliro_crypto.h:37

##define ALIRO_IFACE_NFC 0x5Eu

modules/woz_aliro/include/aliro_crypto.h:41

##define ALIRO_IFACE_BLE 0xC3u

modules/woz_aliro/include/aliro_crypto.h:42

Fint aliro_crypto_init(void)

modules/woz_aliro/include/aliro_crypto.h:45

Fvoid aliro_crypto_ursk_from_block(const uint8_t block[ALIRO_KEY_BLOCK_LEN], uint8_t ursk[ALIRO_URSK_LEN])

modules/woz_aliro/include/aliro_crypto.h:48

Fvoid aliro_crypto_derive_z(const uint8_t shared_secret[ALIRO_SHARED_SECRET_LEN], const uint8_t txid[ALIRO_TXID_LEN], uint8_t z[32])

modules/woz_aliro/include/aliro_crypto.h:58

Fint aliro_crypto_derive_block(const uint8_t z[32], const uint8_t *salt, size_t salt_len, const uint8_t device_pub_x[ALIRO_EC_PUBX_LEN], uint8_t block[ALIRO_KEY_BLOCK_LEN])

modules/woz_aliro/include/aliro_crypto.h:65

Fint aliro_crypto_derive_key32(const uint8_t z[32], const uint8_t *salt, size_t salt_len, const uint8_t device_pub_x[ALIRO_EC_PUBX_LEN], uint8_t out[32])

modules/woz_aliro/include/aliro_crypto.h:74

Fvoid aliro_crypto_split(const uint8_t block[ALIRO_KEY_BLOCK_LEN], int with_c, uint8_t enc_key[ALIRO_SESSION_KEY_LEN], uint8_t dec_key[ALIRO_SESSION_KEY_LEN], uint8_t ursk[ALIRO_URSK_LEN])

modules/woz_aliro/include/aliro_crypto.h:83

##define ALIRO_CRYPTOGRAM_SK_OFFSET 0u

modules/woz_aliro/include/aliro_crypto.h:113

##define ALIRO_CRYPTOGRAM_LEN 64u

modules/woz_aliro/include/aliro_crypto.h:114

Fint aliro_crypto_verify_cryptogram(const uint8_t cryptogram_sk[ALIRO_SESSION_KEY_LEN], const uint8_t *cryptogram, size_t cryptogram_len, uint8_t *plain_payload)

modules/woz_aliro/include/aliro_crypto.h:122

Fvoid aliro_secchan_init(struct aliro_secchan *sc, const uint8_t enc_key[ALIRO_SESSION_KEY_LEN], const uint8_t dec_key[ALIRO_SESSION_KEY_LEN])

modules/woz_aliro/include/aliro_crypto.h:141

Fvoid aliro_crypto_gcm_nonce(uint64_t direction, uint32_t counter, uint8_t nonce[ALIRO_GCM_NONCE_LEN])

modules/woz_aliro/include/aliro_crypto.h:143

Fint aliro_secchan_seal(struct aliro_secchan *sc, const uint8_t *aad, size_t aad_len, const uint8_t *pt, size_t pt_len, uint8_t *ct, uint8_t tag[ALIRO_GCM_TAG_LEN])

modules/woz_aliro/include/aliro_crypto.h:148

Fint aliro_secchan_open(struct aliro_secchan *sc, const uint8_t *aad, size_t aad_len, const uint8_t *ct, size_t ct_len, const uint8_t tag[ALIRO_GCM_TAG_LEN], uint8_t *pt)

modules/woz_aliro/include/aliro_crypto.h:151

##define ALIRO_BLESK_OFFSET 96u

modules/woz_aliro/include/aliro_crypto.h:166

Fint aliro_crypto_derive_ble_keys(const uint8_t block[ALIRO_KEY_BLOCK_LEN], const uint8_t *salt, size_t salt_len, uint8_t ble_reader[ALIRO_SESSION_KEY_LEN], uint8_t ble_device[ALIRO_SESSION_KEY_LEN])

modules/woz_aliro/include/aliro_crypto.h:171

Fint aliro_msg_seal(struct aliro_secchan *sc, const uint8_t *plain, size_t plain_len, uint8_t *wire, size_t wire_cap, size_t *wire_len)

modules/woz_aliro/include/aliro_crypto.h:178

Fint aliro_msg_open(struct aliro_secchan *sc, const uint8_t *wire, size_t wire_len, uint8_t *plain, size_t plain_cap, size_t *plain_len)

modules/woz_aliro/include/aliro_crypto.h:183

Cenum aliro_salt_type

modules/woz_aliro/include/aliro_crypto.h:198

##define ALIRO_SALT_MAX 256u

modules/woz_aliro/include/aliro_crypto.h:204

Fint aliro_salt_build(enum aliro_salt_type type, const uint8_t txid[ALIRO_TXID_LEN], const uint8_t span_s1[ALIRO_EC_PUBX_LEN], const uint8_t reader_value[ALIRO_EC_PUBX_LEN], const uint8_t reader_id[32], uint8_t interface_byte, uint16_t proto_version, uint8_t exp_phase_type, uint8_t user_auth_policy, const uint8_t s3opt[ALIRO_EC_PUBX_LEN] , const uint8_t *a5_tlv, size_t a5_tlv_len, uint8_t *out, size_t *out_len)

modules/woz_aliro/include/aliro_crypto.h:206