https://github.com/r4gus/candy-stick
CTAP2 authenticator implementation in Zig
https://github.com/r4gus/candy-stick
authentication authenticator ctap ctap2 fido fido2 zig ziglang
Last synced: 11 months ago
JSON representation
CTAP2 authenticator implementation in Zig
- Host: GitHub
- URL: https://github.com/r4gus/candy-stick
- Owner: r4gus
- License: mit
- Created: 2022-09-27T20:50:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-21T20:15:25.000Z (over 3 years ago)
- Last Synced: 2025-04-12T03:36:59.336Z (about 1 year ago)
- Topics: authentication, authenticator, ctap, ctap2, fido, fido2, zig, ziglang
- Language: C
- Homepage:
- Size: 7.85 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Candy Stick
There have been some API changes to the fido2 library, i.e., this project will currently not compile. Please see [candy-stick-nrf](https://github.com/r4gus/candy-stick-nrf) for a working example.
CTAP2 firmware
```
src/
|-ctaphid/
| |-response.zig (for generating CTAPHID response packets)
| |-misc.zig (helper functions and constants)
| |-commands.zig (CTAPHID commands)
|-zigusb.zig (entry point and USB callbacks)
```
## Build
To build the project you must have installed the [Zig](https://ziglang.org/) compiler on your system.
You also need the `arm-none-eabi` build tools.
### Arch
```
sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib
```
### Ubuntu
```
sudo apt install gcc-arm-none-eabi
```
> **NOTE**: Without `*-newlib` (Arch) you'll get the `fatal error: stdint.h: No such file or directory
# include_next ` error.
Also make sure that you've `git` installed. Then just run `./build` from the root directory.
## Flash
To flash the firmware install [edbg](https://github.com/ataradov/edbg) and then just run `./flash` from the
root directory.
> Note: This project targets the SAM E51 Curiosity Nano, i.e. the
> ATSAME51J20A (ARM Cortex-M4F) chip.
## Tools
To use the tools you need to install `libfido2`.
### Arch
```
sudo pacman -S libfido2
```
### Ubuntu
```
$ sudo apt install libfido2-1 libfido2-dev libfido2-doc fido2-tools
```
### Build from source
```
git clone https://github.com/Yubico/libfido2.git
cd libfido2
cmake -B build
make -C build
sudo make -C build install
```
## Important Notes
* The `ztap` library doesn't sort keys automatically (due to a bug when calling the Zig sort function - program hangs). One must make sure that the returned CBOR is in CTAP canonical CBOR encoding form, e.g. the keys have to be sorted in a specific way. Otherwise libraries like libfido2 will complain.