Skip to content

Commit 833b1b2

Browse files
Use libwebauthn for JSON parsing
1 parent 5b1ccb9 commit 833b1b2

8 files changed

Lines changed: 7633 additions & 738 deletions

File tree

Cargo.lock

Lines changed: 381 additions & 144 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

credentialsd-common/Cargo.lock

Lines changed: 3178 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

credentialsd/Cargo.lock

Lines changed: 3915 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

credentialsd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async-stream = "0.3.6"
1010
base64 = "0.22.1"
1111
credentialsd-common = { path = "../credentialsd-common" }
1212
futures-lite.workspace = true
13-
libwebauthn = { git = "https://github.com/linux-credentials/libwebauthn.git", rev="80545bff16c4e89a930221e90d3141a76303b84b", features = ["libnfc","pcsc"] }
13+
libwebauthn = { git = "https://github.com/linux-credentials/libwebauthn.git", rev="d97c80d25bdb974472c40de5e5031db5946ad532", features = ["libnfc","pcsc"] }
1414
# TODO: split nfc and pcsc into separate features
1515
# Also, 0.6.1 fails to build with non-vendored library.
1616
# https://github.com/alexrsagen/rs-nfc1/issues/15

credentialsd/src/credential_service/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ impl From<GetAssertionResponse> for AuthenticatorResponse {
377377
mod test {
378378
use std::{sync::Arc, time::Duration};
379379

380+
use base64::Engine as _;
380381
use libwebauthn::{
381382
ops::webauthn::{
382383
MakeCredentialRequest, ResidentKeyRequirement, UserVerificationRequirement,
@@ -395,6 +396,7 @@ mod test {
395396
webauthn,
396397
};
397398
use credentialsd_common::model::Operation;
399+
use credentialsd_common::model::{CredentialRequest, MakeCredentialRequest};
398400

399401
use super::{
400402
hybrid::{test::DummyHybridHandler, HybridStateInternal},
@@ -454,16 +456,14 @@ mod test {
454456
let challenge = "Ox0AXQz7WUER7BGQFzvVrQbReTkS3sepVGj26qfUhhrWSarkDbGF4T4NuCY1aAwHYzOzKMJJ2YRSatetl0D9bQ";
455457
let origin = "webauthn.io".to_string();
456458
let is_cross_origin = false;
457-
let client_data_json = webauthn::format_client_data_json(
458-
Operation::Create,
459-
challenge,
460-
&origin,
461-
is_cross_origin,
462-
);
463-
let client_data_hash = webauthn::create_client_data_hash(&client_data_json);
459+
// Decode the challenge from base64url
460+
let challenge_bytes = base64::engine::general_purpose::URL_SAFE_NO_PAD
461+
.decode(challenge)
462+
.expect("valid base64url challenge");
464463
let make_request = MakeCredentialRequest {
465-
hash: client_data_hash,
466-
origin: "webauthn.io".to_string(),
464+
challenge: challenge_bytes,
465+
origin: origin.clone(),
466+
cross_origin: Some(is_cross_origin),
467467
relying_party: Ctap2PublicKeyCredentialRpEntity {
468468
id: "webauthn.io".to_string(),
469469
name: Some("webauthn.io".to_string()),

credentialsd/src/credential_service/nfc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ impl InProcessNfcHandler {
3636
prev_nfc_state: &NfcStateInternal,
3737
) -> Result<NfcStateInternal, Error> {
3838
match libwebauthn::transport::nfc::get_nfc_device().await {
39-
Ok(None) => Ok(NfcStateInternal::Waiting),
40-
Ok(Some(hid_device)) => Ok(NfcStateInternal::Connected(hid_device)),
39+
Ok(Some(nfc_device)) => Ok(NfcStateInternal::Connected(nfc_device)),
40+
Ok(None) => {
41+
let state = NfcStateInternal::Waiting;
42+
Ok(state)
43+
}
4144
Err(err) => {
4245
*failures += 1;
4346
if *failures == 5 {

0 commit comments

Comments
 (0)