← Home
Download Free Switch to Italian

For Developers

Build compatible devices and integrations using the open WFAS protocol, then try the real handshake and the real encryption, live, in the lab below.

Why the protocol is separate from the apps

The WFAS apps (Desktop and Android) are released under the EUPL, a strong copyleft license that ensures the apps themselves remain free and open source forever.

The core protocol library, however, is released under the MIT license, a permissive license that lets you use it in any project, including commercial and closed-source ones. No royalties, no attribution requirements beyond the license notice.

The rationale: we want anyone to be able to build compatible devices, commercial products, embedded firmware, closed-source clients, without having to rewrite everything from scratch, while the official apps remain free forever for end users.

The wfas-protocol library

A self-contained C99 library designed for resource-constrained environments. It implements the full WFAS v2 protocol, from handshake and authentication to audio packetization and encryption.

Zero dynamic allocation

No malloc/free calls anywhere in the library. All state is stack-allocated or provided by the caller, safe for microcontrollers with limited or no heap.

A1 B2
Endianness-safe

All multi-byte fields are explicitly encoded in network byte order. Works correctly on both little-endian (x86, ARM Cortex-M) and big-endian architectures.

Tested against official RFC vectors

HMAC-SHA256 (RFC 4231), ChaCha20-Poly1305 (RFC 8439) and HKDF-SHA256 (RFC 5869) are validated against the official test vectors from their respective IETF standards, the lab below runs the same three vectors live in your browser.

No external dependencies

Pure C99 standard library only. No third-party crypto libraries to link, no platform SDKs required beyond what your target already provides.

Targets: ESP32, STM32, RP2040, embedded Linux

Designed and tested on common embedded platforms. Works with FreeRTOS and bare-metal, as well as embedded Linux (Raspberry Pi, OpenWrt).

View on GitHub Read the protocol spec

Protocol lab

Everything below runs live in this page, real HMAC-SHA256 and HKDF-SHA256 via the browser's Web Crypto API, and a from-scratch ChaCha20-Poly1305 implementation checked against the exact RFC 8439 vector used in wfas_test.c. Nothing is sent over the network.

Every WFAS audio packet starts with the same 10-byte header. Edit the hex below (or generate a sample) and watch it decode field by field, exactly like wfas_parse_header().

WFAS uses symmetric (pre-shared key) authentication, not asymmetric/public-key like SSH or TLS certificates. The exact same secret must already be configured on the server, before it starts streaming, and on the client, when it tries to connect. Nothing publishable, nothing exchanged automatically: you tell both devices the same passphrase yourself.

Try changing just one of the two keys above, then run it again.

Encrypts a short message as if it were a PCM payload, using the same packet layout as wfas_encrypt_packet(): [header 10B][counter 8B][ciphertext][tag 16B]. The demo key is SHA-256 of your passphrase, simplified for the browser, not the real HKDF session-key derivation.

The same seven checks as wfas_test.c selftest(), HMAC, AEAD and HKDF against their official RFC vectors, plus a full encrypt/decrypt roundtrip, an anti-replay drop, and a multicast beacon epoch check, run here in JavaScript instead of C. Each line below prints the number this page actually computed, view the unminified source running it.

This lab is a from-scratch JavaScript port for teaching purposes, verified against the same test vectors as the C library, it is not the compiled wfas.c running as WebAssembly. For production use, link the actual C library from wfas-protocol.

Quick start example

Building and parsing an unencrypted audio packet with the real API from wfas.h:

wfas_example.c, C99
#include "wfas.h"

wfas_sender tx;
wfas_sender_init(&tx);

uint8_t packet[WFAS_MTU];
int len = wfas_build_audio(&tx, packet, sizeof(packet), pcm_samples, frame_count, 2);
if (len > 0) udp_send(packet, len);

/* On the receiving end: */
wfas_header hdr;
const uint8_t *pcm; size_t pcm_len;
if (wfas_parse_audio(rx_buf, n, &hdr, &pcm, &pcm_len) == 0) {
    audio_output_write(pcm, pcm_len, hdr.seq, hdr.sample_pos);
}

Real function names and signatures from wfas.h, not a placeholder API.

Inside the handshake proof

What the lab above is actually computing, straight from wfas.c:

wfas.c, wfas_auth_proof()
void wfas_auth_proof(const char *key, char side,
                     const char *cn, const char *sn, char *out) {
    /* in = "WFAS-" + side + ":" + cnonce + ":" + snonce */
    uint8_t mac[32];
    wfas_hmac_sha256((const uint8_t *)key, strlen(key),
                     (const uint8_t *)in, n, mac);
    to_hex(mac, 32, out);
}

Build it yourself

The library is a single .c/.h pair, no build system required beyond a C99 compiler.

terminal
$ cc -std=c99 -Wall -Wextra -O2 -o wfas_test wfas.c wfas_test.c -lm
$ ./wfas_test selftest
HMAC-SHA256 RFC4231 TC1: OK
domain separation (S != C): OK
ChaCha20-Poly1305 AEAD RFC8439: OK
HKDF-SHA256 RFC5869: OK
encrypted packet roundtrip: OK
anti-replay drops duplicate: OK
multicast beacon + ghost-replay guard: OK

$ ./wfas_test server --key mysecret
$ ./wfas_test client 192.168.1.42 --key mysecret

Note: the repository's Makefile currently targets an example.c entry point rather than wfas_test.c, if you're following along from the source tree, build with the command above until that's reconciled.

Project ideas

Things the community has built or is building with the open protocol:

ESP32 I2S

DIY Wi-Fi Speaker on ESP32

Hardware

Pair an ESP32 with an I2S DAC and a small amplifier. Flash a WFAS receiver built on wfas.c and you have a wireless speaker that streams from your PC, total cost under €15.

automation room 1 room 2

Home Assistant integration

Smart Home

Build a custom component that lets Home Assistant receive or relay WFAS audio streams, enabling announcements or multi-room audio triggered by automations.

BCM wfas.service active (running)

Headless Raspberry Pi receiver

Linux

Run the WFAS receiver as a systemd service on a Raspberry Pi connected to your stereo. No screen, no keyboard, just audio over Wi-Fi.

WFAS protocol tvOS wear kiosk ???

Custom client for another platform

Ecosystem

Want WFAS on tvOS, watchOS, or a custom Linux kiosk? The protocol library gives you a compliant starting point without reverse engineering the wire format.

Start building