From 88b9677e7acabb6243299ce8be907178b80a2f08 Mon Sep 17 00:00:00 2001 From: shimun Date: Sun, 11 Oct 2020 22:23:45 +0200 Subject: [PATCH] 4 --- src/cli.rs | 3 +++ src/error.rs | 2 ++ src/luks.rs | 4 ---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 1584be6..bcffa7f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -33,6 +33,9 @@ fn derive_secret( timeout: u64, pin: Option<&str>, ) -> Fido2LuksResult<([u8; 32], FidoCredential)> { + if credentials.len() == 0 { + return Err(Fido2LuksError::InsufficientCredentials); + } let timeout = Duration::from_secs(timeout); let start = SystemTime::now(); diff --git a/src/error.rs b/src/error.rs index f0f1f76..dc29d3d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -31,6 +31,8 @@ pub enum Fido2LuksError { StringEncodingError { cause: FromUtf8Error }, #[fail(display = "not an hex string: {}", string)] HexEncodingError { string: String }, + #[fail(display = "couldn't obtain at least one credential")] + InsufficientCredentials, } impl Fido2LuksError { diff --git a/src/luks.rs b/src/luks.rs index 4a91e73..7b024ca 100644 --- a/src/luks.rs +++ b/src/luks.rs @@ -103,10 +103,6 @@ impl LuksDevice { Ok(()) } - pub fn add_credential(&mut self, slot: u32, credential: Vec) -> Fido2LuksResult<()> { - self.add_token(&Fido2LuksToken::with_credentials(&[credential], slot)) - } - pub fn remove_token(&mut self, token: u32) -> Fido2LuksResult<()> { self.require_luks2()?; self.device