From ad2451f5486bd7f66a48b485fdb6acf7ecc5cfe2 Mon Sep 17 00:00:00 2001 From: shimun Date: Sun, 5 Apr 2020 23:24:18 +0200 Subject: [PATCH] add timeout --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- src/cli.rs | 4 ++-- src/device.rs | 4 ++++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5d23f5..a069def 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -223,8 +223,8 @@ dependencies = [ [[package]] name = "ctap_hmac" -version = "0.3.0" -source = "git+https://git.shimun.net/shimun/ctap.git?branch=assert_multiple#65ef57403182fce13b5266ba7838558ba2ad008f" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cbor-codec 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -337,7 +337,7 @@ dependencies = [ name = "fido2luks" version = "0.2.6" dependencies = [ - "ctap_hmac 0.3.0 (git+https://git.shimun.net/shimun/ctap.git?branch=assert_multiple)", + "ctap_hmac 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libcryptsetup-rs 0.3.0 (git+https://github.com/shimunn/libcryptsetup-rs.git?branch=crypt_load_ptr_null)", @@ -1024,7 +1024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" "checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" "checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" -"checksum ctap_hmac 0.3.0 (git+https://git.shimun.net/shimun/ctap.git?branch=assert_multiple)" = "" +"checksum ctap_hmac 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6b22457233b74539c53c10658eb3effb7c3d50907276dab6b5fbd8391d2b4351" "checksum darling 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" "checksum darling_core 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" "checksum darling_macro 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" diff --git a/Cargo.toml b/Cargo.toml index fc8f4db..6a22747 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ categories = ["command-line-utilities"] license-file = "LICENSE" [dependencies] -ctap_hmac = { git = "https://git.shimun.net/shimun/ctap.git", branch = "assert_multiple", features = ["request_multiple"] } +ctap_hmac = { version="0.4.1", features = ["request_multiple"] } hex = "0.3.2" ring = "0.13.5" failure = "0.1.5" diff --git a/src/cli.rs b/src/cli.rs index fe459b2..20e7f01 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -48,7 +48,7 @@ impl FromStr for CommaSeparated { fn from_str(s: &str) -> Result { Ok(CommaSeparated( s.split(',') - .map(|part| ::from_str(dbg!(part))) + .map(|part| ::from_str(part)) .collect::, _>>()?, )) } @@ -144,7 +144,7 @@ impl SecretGeneration { .collect::>(); let credentials = credentials.iter().collect::>(); Ok(assemble_secret( - &perform_challenge(&credentials[..], &salt)?, + &perform_challenge(&credentials[..], &salt, timeout - start.elapsed().unwrap())?, &salt, )) } diff --git a/src/device.rs b/src/device.rs index e71dfb0..0290496 100644 --- a/src/device.rs +++ b/src/device.rs @@ -4,6 +4,7 @@ use ctap::{ self, extensions::hmac::HmacExtension, request_multiple_devices, FidoAssertionRequestBuilder, FidoCredential, FidoCredentialRequestBuilder, FidoDevice, FidoError, FidoErrorKind, }; +use std::time::Duration; const RP_ID: &'static str = "fido2luks"; @@ -18,12 +19,14 @@ pub fn make_credential_id(name: Option<&str>) -> Fido2LuksResult get_devices()? .iter_mut() .map(|device| (device, &make_credential)), + None, )?) } pub fn perform_challenge( credentials: &[&FidoCredential], salt: &[u8; 32], + timeout: Duration, ) -> Fido2LuksResult<[u8; 32]> { let request = FidoAssertionRequestBuilder::default() .rp_id(RP_ID) @@ -35,6 +38,7 @@ pub fn perform_challenge( get_devices()? .iter_mut() .map(|device| (device, &get_assertion)), + Some(timeout), )?; Ok(secret) }