refractor
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-09-17 14:49:57 +02:00
parent 243a9d1167
commit b9f3f793a7
3 changed files with 30 additions and 24 deletions

25
src/device.rs Normal file
View File

@@ -0,0 +1,25 @@
use crate::error::*;
use ctap;
use ctap::extensions::hmac::{FidoHmacCredential, HmacExtension};
use ctap::FidoDevice;
pub fn perform_challenge(credential_id: &str, salt: &[u8; 32]) -> Fido2LuksResult<[u8; 32]> {
let cred = FidoHmacCredential {
id: hex::decode(credential_id).unwrap(),
rp_id: "hmac".to_string(),
};
let mut errs = Vec::new();
for di in ctap::get_devices()? {
let mut dev = FidoDevice::new(&di)?;
match dev.hmac_challange(&cred, &salt[..]) {
Ok(secret) => {
return Ok(secret);
}
Err(e) => {
errs.push(e);
}
}
}
Err(errs.pop().ok_or(Fido2LuksError::NoAuthenticatorError)?)?
}