189 Commits

Author SHA1 Message Date
Robin Krahl
01a2653c37 Update trussed to use new virtual store 2025-05-15 11:52:59 +02:00
Robin Krahl
5ebb4a4830 clientPin: Support getRetries without PIN protocol
This fixes compatibility with CTAP 2.1.

Fixes: https://github.com/Nitrokey/fido-authenticator/issues/118
2025-05-12 17:42:26 +02:00
Robin Krahl
4554cb866e make_credential: Support non-discoverable credentials without PIN
Currently, we always require the PIN to be used for make_credential
operations if it is set.  This patch implements the makeCredUvNotRqd
option that allows non-discoverable credentials to be created without
using the PIN according to § 6.1.2 Step 6 of the specification, see:

https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-makeCred-authnr-alg
https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#getinfo-makecreduvnotrqd

Fixes: https://github.com/Nitrokey/fido-authenticator/issues/34
2025-05-07 22:20:20 +02:00
Robin Krahl
223bc11eec Always reject uv = true in make_credential and get_assertion
This changes the error code if uv = true to InvalidOption even if a PIN
is set.  Previously, we returned PinRequired if a PIN is set.  The new
implementation follows § 6.1.2 Step 5 of the specification more closely.

https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-makeCred-authnr-alg
2025-05-07 21:57:44 +02:00
Robin Krahl
7ff0518b68 hmac-secret: Forbid up=false
Fixes: https://github.com/Nitrokey/fido-authenticator/issues/19
2025-05-07 16:04:44 +02:00
Robin Krahl
ba17bc506c Replace core::iter::repeat(_).take(_) with core::iter::repeat_n(_, _)
This fixes a new clippy lint.
2025-05-06 21:48:40 +02:00
Robin Krahl
8b8a773831 Reduce duplicated key generation and signing logic
This patch moves the key generation and signing logic into the
SigningAlgorithm enum, removing some duplicated code from the ctap2 and
ctap2::credential_management modules.
2025-05-06 21:47:02 +02:00
Robin Krahl
e21d8687fc Remove references to totp signing algorithm 2025-05-06 21:29:13 +02:00
Sosthène Guédon
443eca1787 Make credential: change the path of rks to rp_id_hash.credential_id_hash from rp_id_hash/credential_id_hash
The goal is to make credential storage more efficient, by making use of littlefs's
ability to inline file contents into the directory metadata when the file is small.
2025-02-20 13:44:22 +01:00
Robin Krahl
d61a9ac7d3 Update dependencies for trussed-core and ctaphid-app 2025-01-08 11:28:43 +01:00
Robin Krahl
3095b8cff0 Replace EncryptedSerializedCredential with EncryptedData
Previously, EncryptedSerializedCredential was a wrapper for
trussed::api::reply::Encrypt.  As we whave removed the serde trait
implementations for the Trussed request and reply structs, this patch
replaces the EncryptedSerializedCredential struct with the new
trussed_core::types::EncryptedData helper type.

See also: https://github.com/trussed-dev/trussed/issues/183
2024-12-17 10:37:44 +01:00
Robin Krahl
63a1479387 Remove LocalPublicKeyCredential*Entity structs
To simplify the Rp and User types introduced in the last commit and to
reduce code duplication, this patch removes the
LocalPublicKeyCredential*Entity types.  Instead the Rp and User types
always store a PublicKeyCredential*Entity together with the
serialization format.
2024-12-02 18:00:08 +01:00
Robin Krahl
5c3aa0b8af Keep old credential ID for existing credentials
In #59, we changed the format for serialized credentials to use shorter
field names for the RP and user entities.  This has an unintended side
effect:  For non-discoverable credentials that were generated with older
crate versions, the stripped data embedded into the credential ID
includes the RP and user.  If we change their serialization format, we
also change these credential IDs.

We already supported deserializing both formats using a serde alias.
This patch introduces helper enums that deserialize both formats using a
custom Deserialize implementation and keep track of the used format.
This format is then also used for serialization (using serde’s untagged
mechanism that is not available for deserialization in no-std contexts).

https://github.com/Nitrokey/fido-authenticator/pull/59

Fixes: https://github.com/Nitrokey/fido-authenticator/issues/111
2024-12-02 14:33:29 +01:00
Robin Krahl
86403fa9f2 Add test case for credential ID stability
This patch adds a test case that ensures that the calculated credential
ID for a credential that was created using the old (unstripped) format
is the same as the one generated originally.  Otherwise, the platform or
the RP could reject assertions because of a changed credential ID.
2024-12-02 12:01:06 +01:00
Robin Krahl
c145a451ef Remove cbor_serialize_message helper
The cbor_serialize_message helper mixed re-exports of cbor-smol from
trussed and ctap-types.  This can be problematic if both select
different versions.  It could be fixed by keeping both in sync, but to
avoid this problem entirely, we can also just use cbor_serialize_bytes
from Trussed directly.
2024-10-25 13:50:57 +02:00
Robin Krahl
5b6ae97b5f Update littlefs2 to v0.5.0 2024-10-25 11:33:31 +02:00
Robin Krahl
94cb2fb0e6 Check credential limit in get_creds_metadata
We have two limits for the credential count:  a fixed limit determined
by the configuration and an estimated limit based on the remaining
filesystem size.  When creating a new credential, we check both.  But
previously we only returned the estimated limit from get_creds_metadata.
This patch adds the fixed limit to get_creds_metadata.
2024-10-24 14:58:54 +02:00
Robin Krahl
629a75f189 Use apdu-app instead of apdu-dispatch 2024-10-18 18:13:48 +02:00
Robin Krahl
b34fa475c0 get_assertion: Skip attStmt unless requested
For makeCredential, a missing attestation format preference list
means that we should use the default format (packed).  For getAssertion,
it means that we should skip the attestation statement entirely.
Previously, we implemented the makeCredential algorithm for both cases.
This caused an incompatibility with firefox because it fails on
unexpected fields in the response (in this case, the attestation
statement).  This patch fixes this issue and applies the correct default
for getAssertion requests.

Fixes: https://github.com/Nitrokey/fido-authenticator/issues/98
2024-10-08 16:06:43 +02:00
Robin Krahl
125d38e1ea Fix clippy lints 2024-10-02 16:24:07 +02:00
sosthene-nitrokey
0fdecc93df Merge pull request #59 from Nitrokey/serde-name-one-char
Serialize credential with fields names using only 1 bytes
2024-08-01 17:08:14 +02:00
Sosthène Guédon
5ee16d115f Fix delog and use ctap-types 0.3.0 2024-08-01 15:57:33 +02:00
Sosthène Guédon
0f51cb707e Fix CI 2024-08-01 11:26:11 +02:00
Sosthène Guédon
e763a713ac Apply suggestion 2024-08-01 11:10:49 +02:00
Sosthène Guédon
741348fd50 Don't use estimate if block size is not available 2024-08-01 11:02:54 +02:00