Skip to content

Optionally replace Chacha8Poly1305 with Aes256Gcm#65

Merged
robin-nitrokey merged 5 commits into
mainfrom
credential-id-format
Jun 1, 2026
Merged

Optionally replace Chacha8Poly1305 with Aes256Gcm#65
robin-nitrokey merged 5 commits into
mainfrom
credential-id-format

Conversation

@robin-nitrokey
Copy link
Copy Markdown
Member

The goal of this PR is to optionally replace Chacha8Poly1305 with Aes256Gcm. This is implemented in three steps:

  1. As a preparation for step 2, the existing code for the credential ID generation and parsing and for the key wrapping for non-discoverable credentials is refactored to use a new CredentialIdFormat enum (where V1 is the existing implementation with Chacha8).
  2. CredentialIdFormat::V2 is added, replacing Chacha8 with Aes256Gcm. The runner can select the format that is used for new credentials (default: V1). To avoid invalidating existing credentials, this value is only applied if the state is empty, i. e. on the first boot or after a reset.
  3. To make it possible to identify whether a devices has switched the format, a FirmwareVersion struct is added to make the firmware version configurable based on the current credential ID format.

Depends on:

@robin-nitrokey robin-nitrokey added the skip-publish-check Skip the check that tests publishing to crates.io for this PR label May 30, 2026
@robin-nitrokey robin-nitrokey marked this pull request as ready for review May 31, 2026 12:37
@robin-nitrokey robin-nitrokey force-pushed the credential-id-format branch from 704e1cc to 6f704a6 Compare June 1, 2026 07:42
Copy link
Copy Markdown
Contributor

@sosthene-nitrokey sosthene-nitrokey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would prefer "version" instead of "format", but all is good.

It would be nice to also have tests that updating without reset doesn't lead to failing to parse existing credentials.

Currently, the credential encoding and decoding is located in different
parts of the codebase. This patch introduces the CredentialIdVersion to
unify all relevant code in one place. It also introduces the
KeyEncryptionKey and KeyWrappingKey helper types to ensure that these
keys are only used for the designated steps and cannot be confused with
any other key.
This patch adds the credential_id_version field to Config, making it
possible to select the credential ID version for new credentials. To
avoid invalidating existing credentials, this value is only used on the
first boot or after a factory reset.
@robin-nitrokey robin-nitrokey force-pushed the credential-id-format branch from 6f704a6 to 2eba541 Compare June 1, 2026 11:19
@robin-nitrokey
Copy link
Copy Markdown
Member Author

Updated to use the trussed-core release and renamed CredentialIdFormat to CredentialIdVersion.

@robin-nitrokey robin-nitrokey force-pushed the credential-id-format branch from 2eba541 to 5457b01 Compare June 1, 2026 11:21
@robin-nitrokey robin-nitrokey removed the skip-publish-check Skip the check that tests publishing to crates.io for this PR label Jun 1, 2026
@robin-nitrokey robin-nitrokey force-pushed the credential-id-format branch from 5457b01 to 4c38096 Compare June 1, 2026 11:26
@robin-nitrokey robin-nitrokey merged commit 4c38096 into main Jun 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants