A from-scratch LoRaWAN 1.0.3 Class A crypto + frame codec (AES-128, CMAC/MIC, payload encryption, PHYPayload encode/decode) running on top of Zephyr's SX1276 LoRa PHY driver, targeting an nRF52840-DK + RFM95W module. Sends periodic ABP-mode uplinks.
Crypto and frame codec are functionally complete for ABP-mode uplinks. See docs/VERIFICATION.md for an honest breakdown of what's host-tested against published FIPS-197/RFC 4493 test vectors versus what has only been design-reviewed against the LoRaWAN spec and not yet validated against real hardware or a real network server -- including a real MType bug caught and fixed during development, disclosed there in detail.
Full parts list, RFM95W wiring, and network-server registration steps:
docs/hardware/BOM.md. Short version: an
nRF52840-DK ($40-50) + an RFM95W breakout ($8-12) + an antenna
matching your region + jumper wires. ~$55-70 total.
# Host tests (no hardware/Zephyr toolchain needed)
cd tests/host && make test
# Independent Python AES-128 cross-check against the FIPS-197 vector
python3 tools/lorawan_ref.py
# Full Zephyr firmware build + flash (needs west + Zephyr SDK)
west init -l .
west update
west build -b nrf52840dk_nrf52840 .
west flashinclude/lorawan_node/lorawan_node.h Public API
src/crypto/ AES-128 + CMAC (host-testable)
src/mac/ LoRaWAN frame codec + payload encryption (host-testable)
src/app/main.c Zephyr application: ABP uplink demo
boards/nrf52840dk_nrf52840.overlay RFM95W wiring
tests/host/ Host-run crypto/frame-codec unit tests
tools/lorawan_ref.py Independent Python AES-128 reference (FIPS-197 vector)
docs/ARCHITECTURE.md Frame format, crypto design, why Zephyr/why ABP
docs/VERIFICATION.md What's tested vs. design-reviewed-only, the MType bug found
docs/hardware/BOM.md Parts list, wiring diagram, network-server registration
void lw_aes128_init(lw_aes128_ctx_t *ctx, const uint8_t key[16]);
void lw_aes128_encrypt_block(const lw_aes128_ctx_t *ctx, const uint8_t in[16], uint8_t out[16]);
void lw_cmac(const uint8_t key[16], const uint8_t *msg, size_t msg_len, uint8_t mac_out[16]);
void lw_encrypt_payload(const uint8_t key[16], uint32_t dev_addr, uint32_t fcnt,
uint8_t dir, uint8_t *data, size_t len);
size_t lw_encode_data_frame(const lw_data_frame_t *frame,
const uint8_t nwk_s_key[16], const uint8_t app_s_key[16],
uint8_t dir, uint8_t *out, size_t out_cap);
lw_status_t lw_decode_data_frame(const uint8_t *phy, size_t phy_len,
const uint8_t nwk_s_key[16], const uint8_t app_s_key[16],
uint32_t fcnt, uint8_t dir, lw_data_frame_t *out_frame,
uint8_t *decrypted_payload, size_t payload_cap);See include/lorawan_node/lorawan_node.h for full documentation.
- ABP only -- no OTAA join procedure.
- No ADR, Class B/C, confirmed-uplink retry, or downlink processing.
- Single fixed EU868 channel; no region-specific channel plan.
- FCnt resets to 0 on reboot (not persisted) -- can trigger network- server replay-protection rejections after a device reset.
MIT — see LICENSE.