This is an Ascon/NIST SP 800-232 implementation in the form of a small C library. NIST SP 800-232 is the latest official standard. Every cipher from the official implementation is here. All functions/ciphers are validated against the official KAT vectors. C99 only for compatibility across compilers and systems. There are no dependencies, it is freestanding C. Not even libc is needed!
Use example commands from the project root.
- Required
- C compiler. Tested compilers:
- zig cc
- clang
- gcc
- C compiler. Tested compilers:
- Optional
- Zig 0.16. If you would like to use
zig buildrather than the direct compiler command.
- Zig 0.16. If you would like to use
In your project, you only need to include the public header in include/.
-
include/- ascon.h <-- include this only.
-
src/- Internal headers and source files. No need to import these.- ascon_aead.c
- ascon_hash.c
- ascon_perm.c
- ascon_perm.h
- ascon_sponge.h
- ascon_word.h
- ascon_xof.c
-
demo/- Example C app using the everything in this library.- demo.c
-
tests/- A test app that checks the library functions against the official KAT test vectors, "Known Answer Test". An input-output set provided by the official spec. Passing the input data to a valid implementation will return data matching the expected output data.vectors/...- kat.c
zig build
// Output
./zig-out/
include/ascon.h (library header)
lib/libascon.a (static libary bin)
Include the header file ascon.h and link the static library libascon.a, both from the chart above.
'zig cc', 'clang', 'gcc' are interchangeable for this.
zig cc -std=c99 -I. demo.c ascon_hash.c ascon_xof.c ascon_aead.c ascon_perm.c -o demo
Output at project root.
zig build demo
Output at ./zig-out/bin/.
zig cc -std=c99 -O2 -Iinclude -Isrc tests/kat.c src/*.c -o kat
Output at project root.
zig build kat
Output at ./zig-out/bin/
As mentioned earlier, there is no dependency on libc. It's recommended to use the flag -ffreestanding with zig cc, clang, and gcc. Even though the code does not use libc functions like memset, the compiler will recognize equivalent for loops (for-loops?), and turn it into a memset call anyway. No issue in most cases, but passing -ffreestanding to zig cc or clang saved 632 bytes in the output by using the for loop in the source rather than the call sequence.
There are multiple iterations published for competitions and a NIST draft. This implementation is based on the latest NIST "final" SP (special publication) as of at least 2026-09-26 (ISO 8601 btw, A... Debian Testing btw).