Skip to content

Commit 4b45601

Browse files
Merge remote-tracking branch 'nitrokey/main'
This pulls in all changes from the Nitrokey/fido-authenticator repository, improving compliance with the CTAP spec, adding support for CTAP 2.1 and implementing new features like the largeBlob extension.
2 parents 59ca62a + 01a2653 commit 4b45601

File tree

30 files changed

+8035
-1366
lines changed

30 files changed

+8035
-1366
lines changed

.cargo/config

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
check-fuzz:
11+
name: Check fuzz targets
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@master
15+
- uses: actions-rs/toolchain@v1
16+
with:
17+
profile: minimal
18+
toolchain: nightly
19+
override: true
20+
- name: Check fuzz targets
21+
run: |
22+
cargo check --manifest-path fuzz/Cargo.toml
23+
24+
build:
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
target:
29+
- x86_64-unknown-linux-gnu
30+
- thumbv7em-none-eabi
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v2
35+
36+
- name: Install Rust toolchain
37+
run: |
38+
rustup show
39+
rustup target add ${{ matrix.target }}
40+
41+
- name: Install build dependencies
42+
run: >
43+
sudo apt-get update -y -qq &&
44+
sudo apt-get install -y -qq llvm libc6-dev-i386 libclang-dev
45+
46+
- uses: fiam/arm-none-eabi-gcc@v1
47+
with:
48+
release: "9-2020-q2"
49+
50+
- name: Build
51+
run: cargo build --verbose --target ${{ matrix.target }}
52+
53+
- name: Check all targets without default features
54+
run: cargo check --all-targets --no-default-features
55+
if: matrix.target == 'x86_64-unknown-linux-gnu'
56+
57+
- name: Check all targets with default features
58+
run: cargo check --all-targets
59+
if: matrix.target == 'x86_64-unknown-linux-gnu'
60+
61+
- name: Check all features and targets
62+
run: cargo check --all-features --all-targets
63+
if: matrix.target == 'x86_64-unknown-linux-gnu'
64+
65+
- name: Run tests
66+
run: cargo test --verbose --features dispatch
67+
if: matrix.target == 'x86_64-unknown-linux-gnu'
68+
69+
- name: Check formatting
70+
run: cargo fmt -- --check
71+
if: matrix.target == 'x86_64-unknown-linux-gnu'
72+
73+
- name: Check clippy lints
74+
run: cargo clippy --all-features --all-targets -- --deny warnings
75+
if: matrix.target == 'x86_64-unknown-linux-gnu'
76+
77+
- name: Check documentation
78+
run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
79+
if: matrix.target == 'x86_64-unknown-linux-gnu'

CHANGELOG.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## Unreleased
88
- Set the `makeCredUvNotRqd` CTAP option to `true` to indicate that we support
99
makeCredential operations without user verification ([#26][])
10-
- Ignore public key credential parameters with an unknown type, as required by
10+
- Ignore public key credential paramters with an unknown type, as required by
1111
the Webauthn spec ([#28][])
1212
- Reject `rk` option in getAssertion ([#31][])
1313
- Ignore user data with empty ID in getAssertion ([#32][])
1414
- Allow three instead of two PIN retries per boot ([#35][])
1515
- Add log messages for requests, responses and errors
16+
- Add config option for setting a maximum number of resident credentials.
17+
- Reduce ID length for new credentials ([#37][])
18+
- Update apdu-dispatch and reject calls to `select` ([#40][])
19+
- Implement the `largeBlobKey` extension and the `largeBlobs` command ([#38][])
20+
- Fix error type for third invalid PIN entry ([#60][])
21+
- Fix error type for cancelled user presence ([#61][])
22+
- PIN protocol changes:
23+
- Extract PIN protocol implementation into separate module ([#62][])
24+
- Implement PIN protocol 2 ([#63][])
25+
- Implement PIN token permissions ([#63][])
26+
- Implement UpdateUserInformation subcommand for CredentialManagement
27+
- Support CTAP 2.1
28+
- Serialize PIN hash with `serde-bytes` ([#52][])
29+
- Reduce the space taken by credential serialization ([#59][])
30+
- Update dependencies:
31+
- Replace `trussed` dependency with `trussed-core`
32+
- Replace `ctaphid-dispatch` dependeny with `ctaphid-app`
33+
- Remove the per-relying party directory to save space ([#55][])
1634

1735
[#26]: https://github.com/solokeys/fido-authenticator/issues/26
1836
[#28]: https://github.com/solokeys/fido-authenticator/issues/28
1937
[#31]: https://github.com/solokeys/fido-authenticator/issues/31
2038
[#32]: https://github.com/solokeys/fido-authenticator/issues/32
2139
[#35]: https://github.com/solokeys/fido-authenticator/issues/35
40+
[#37]: https://github.com/solokeys/fido-authenticator/issues/37
41+
[#40]: https://github.com/nitrokey/fido-authenticator/pull/40
42+
[#38]: https://github.com/Nitrokey/fido-authenticator/issues/38
43+
[#60]: https://github.com/Nitrokey/fido-authenticator/pull/60
44+
[#61]: https://github.com/Nitrokey/fido-authenticator/pull/61
45+
[#62]: https://github.com/Nitrokey/fido-authenticator/pull/62
46+
[#63]: https://github.com/Nitrokey/fido-authenticator/pull/63
47+
[#52]: https://github.com/Nitrokey/fido-authenticator/issues/52
48+
[#59]: https://github.com/Nitrokey/fido-authenticator/issues/59
49+
[#55]: https://github.com/Nitrokey/fido-authenticator/issues/55
2250

2351
## [0.1.1] - 2022-08-22
2452
- Fix bug that treated U2F payloads as APDU over APDU in NFC transport @conorpp
2553
- Add config option to skip UP when device was just booted,
2654
as insertion is a kind of UP check @robin-nitrokey
2755

28-
## [Unreleased]
56+
## [0.1.0] - 2022-03-17
2957

3058
- use 2021 edition
3159
- use @szszszsz's credential ID shortening

Cargo.toml

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,80 @@ repository = "https://github.com/solokeys/fido-authenticator"
88
documentation = "https://docs.rs/fido-authenticator"
99
description = "FIDO authenticator Trussed app"
1010

11-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12-
1311
[dependencies]
14-
ctap-types = "0.1.0"
12+
cbor-smol = { version = "0.5" }
13+
ctap-types = { version = "0.4", features = ["get-info-full", "large-blobs", "third-party-payment"] }
14+
cosey = "0.3"
1515
delog = "0.1.0"
1616
heapless = "0.7"
17-
interchange = "0.2.0"
18-
littlefs2 = "0.3.1"
17+
heapless-bytes = "0.3"
18+
littlefs2-core = "0.1"
1919
serde = { version = "1.0", default-features = false }
20-
serde_cbor = { version = "0.11.0", default-features = false }
20+
serde_bytes = { version = "0.11.14", default-features = false }
2121
serde-indexed = "0.1.0"
22-
trussed = "0.1"
22+
sha2 = { version = "0.10", default-features = false }
23+
trussed-core = { version = "0.1.0", features = ["aes256-cbc", "certificate-client", "chacha8-poly1305", "crypto-client", "ed255", "filesystem-client", "hmac-sha256", "management-client", "p256", "sha256", "ui-client"] }
24+
trussed-fs-info = "0.2.0"
25+
trussed-hkdf = { version = "0.3.0" }
26+
trussed-chunked = { version = "0.2.0", optional = true }
2327

24-
apdu-dispatch = { version = "0.1", optional = true }
25-
ctaphid-dispatch = { version = "0.1", optional = true }
26-
iso7816 = { version = "0.1", optional = true }
28+
apdu-app = { version = "0.1", optional = true }
29+
ctaphid-app = { version = "0.1.0-rc.1", optional = true }
30+
iso7816 = { version = "0.1.2", optional = true }
2731

2832
[features]
29-
default = []
3033
dispatch = ["apdu-dispatch", "ctaphid-dispatch", "iso7816"]
34+
apdu-dispatch = ["dep:apdu-app"]
35+
ctaphid-dispatch = ["dep:ctaphid-app"]
3136
disable-reset-time-window = []
32-
enable-fido-pre = []
37+
38+
# enables support for a large-blob array longer than 1024 bytes
39+
chunked = ["trussed-chunked"]
3340

3441
log-all = []
3542
log-none = []
43+
log-trace = []
3644
log-info = []
3745
log-debug = []
3846
log-warn = []
3947
log-error = []
4048

4149
[dev-dependencies]
42-
# quickcheck = "1"
50+
admin-app = { version = "0.1.0", features = ["migration-tests"] }
51+
aes = "0.8.4"
52+
cbc = { version = "0.1.2", features = ["alloc"] }
53+
ciborium = { version = "0.2.2" }
54+
ciborium-io = "0.2.2"
55+
cipher = "0.4.4"
56+
ctaphid = { version = "0.3.1", default-features = false }
57+
ctaphid-dispatch = "0.3"
58+
delog = { version = "0.1.6", features = ["std-log"] }
59+
env_logger = "0.11.0"
60+
hex-literal = "0.4.1"
61+
hmac = "0.12.1"
62+
interchange = "0.3.0"
63+
itertools = "0.14.0"
64+
littlefs2 = "0.6.0"
65+
log = "0.4.21"
66+
p256 = { version = "0.13.2", features = ["ecdh"] }
4367
rand = "0.8.4"
68+
rand_chacha = "0.3"
69+
sha2 = "0.10"
70+
serde_test = "1.0.176"
71+
trussed = { version = "0.1", features = ["virt"] }
72+
trussed-staging = { version = "0.3.0", features = ["chunked", "hkdf", "virt", "fs-info"] }
73+
trussed-usbip = { version = "0.0.1", default-features = false, features = ["ctaphid"] }
74+
usbd-ctaphid = "0.3.0"
75+
x509-parser = "0.16.0"
4476

4577
[package.metadata.docs.rs]
4678
features = ["dispatch"]
79+
80+
[patch.crates-io]
81+
admin-app = { git = "https://github.com/Nitrokey/admin-app.git", tag = "v0.1.0-nitrokey.20" }
82+
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "024e0eca5fb7dbd2457831f7c7bffe4341e08775" }
83+
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "7922d67e9637a87e5625aaff9e5111f0d4ec0346" }
84+
trussed-usbip = { git = "https://github.com/trussed-dev/pc-usbip-runner.git", rev = "504674453c9573a30aa2f155101df49eb2af1ba7" }
85+
86+
[profile.test]
87+
opt-level = 2

fuzz/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target
2+
corpus
3+
artifacts
4+
coverage

fuzz/Cargo.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "fido-authenticator-fuzz"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2021"
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[dependencies]
11+
ctap-types = { version = "0.4", features = ["arbitrary"] }
12+
libfuzzer-sys = "0.4"
13+
trussed = { version = "0.1", features = ["clients-1", "certificate-client", "crypto-client", "filesystem-client", "management-client", "aes256-cbc", "ed255", "p256", "sha256"] }
14+
trussed-staging = { version = "0.3.0", features = ["chunked", "hkdf", "virt", "fs-info"] }
15+
16+
[dependencies.fido-authenticator]
17+
path = ".."
18+
19+
[[bin]]
20+
name = "ctap"
21+
path = "fuzz_targets/ctap.rs"
22+
test = false
23+
doc = false
24+
bench = false
25+
26+
[patch.crates-io]
27+
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" }
28+
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", rev = "1e1ca03a3a62ea9b802f4070ea4bce002eeb4bec" }

fuzz/fuzz_targets/ctap.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![no_main]
2+
3+
use ctap_types::{authenticator::Request, ctap1::Authenticator as _, ctap2::Authenticator as _};
4+
use fido_authenticator::{Authenticator, Config, Conforming};
5+
use trussed_staging::virt;
6+
7+
use libfuzzer_sys::fuzz_target;
8+
9+
fuzz_target!(|requests: Vec<Request<'_>>| {
10+
virt::with_ram_client("fido", |client| {
11+
let mut authenticator = Authenticator::new(
12+
client,
13+
Conforming {},
14+
Config {
15+
max_msg_size: 0,
16+
skip_up_timeout: None,
17+
max_resident_credential_count: None,
18+
large_blobs: None,
19+
nfc_transport: false,
20+
},
21+
);
22+
23+
for request in requests {
24+
match request {
25+
Request::Ctap1(request) => {
26+
authenticator.call_ctap1(&request).ok();
27+
}
28+
Request::Ctap2(request) => {
29+
authenticator.call_ctap2(&request).ok();
30+
}
31+
}
32+
}
33+
});
34+
});

src/constants.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//! Constants.
22
3-
use trussed::types::{CertId, KeyId};
3+
use trussed_core::types::{CertId, KeyId};
44

55
pub const FIDO2_UP_TIMEOUT: u32 = 30_000;
66
pub const U2F_UP_TIMEOUT: u32 = 250;
77

88
pub const ATTESTATION_CERT_ID: CertId = CertId::from_special(0);
99
pub const ATTESTATION_KEY_ID: KeyId = KeyId::from_special(0);
10+
11+
pub const MAX_RESIDENT_CREDENTIALS_GUESSTIMATE: u32 = 100;

0 commit comments

Comments
 (0)