fix warnings
This commit is contained in:
parent
822cebd6ff
commit
9440271d90
@ -3,7 +3,8 @@ extern crate ctap_hmac as ctap;
|
||||
use crypto::digest::Digest;
|
||||
use crypto::sha2::Sha256;
|
||||
use ctap::extensions::hmac::HmacExtension;
|
||||
use ctap::{FidoCredential, FidoCredentialRequestBuilder, AuthenticatorOptions};
|
||||
use ctap::{FidoAssertionRequestBuilder, FidoCredential, FidoCredentialRequestBuilder};
|
||||
|
||||
use hex;
|
||||
use std::env::args;
|
||||
use std::io::prelude::*;
|
||||
@ -17,23 +18,30 @@ fn main() -> ctap::FidoResult<()> {
|
||||
let device_info = &mut devices.next().expect("No authenticator found");
|
||||
let mut device = ctap::FidoDevice::new(device_info)?;
|
||||
|
||||
let mut credential = match args().skip(1).next().map(|h| FidoCredential {
|
||||
let credential = match args().skip(1).next().map(|h| FidoCredential {
|
||||
id: hex::decode(&h).expect("Invalid credential"),
|
||||
public_key: None,
|
||||
}) {
|
||||
Some(cred) => cred,
|
||||
_ => {
|
||||
let req = FidoCredentialRequestBuilder::default().rp_id(RP_ID).rp_name("ctap_hmac crate").user_name("example").uv(false).build().unwrap();
|
||||
let req = FidoCredentialRequestBuilder::default()
|
||||
.rp_id(RP_ID)
|
||||
.rp_name("ctap_hmac crate")
|
||||
.user_name("example")
|
||||
.uv(false)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
println!("Authorize using your device");
|
||||
let cred = device.make_hmac_credential(req).expect("Failed to request credential");
|
||||
let cred = device
|
||||
.make_hmac_credential(&req)
|
||||
.expect("Failed to request credential");
|
||||
println!("Credential: {}\nNote: You can pass this credential as first argument in order to reproduce results", hex::encode(&cred.id));
|
||||
cred
|
||||
}
|
||||
};
|
||||
let credential = credential;
|
||||
print!("Type in your message: ");
|
||||
stdout().flush();
|
||||
stdout().flush().unwrap();
|
||||
let mut message = String::new();
|
||||
stdin()
|
||||
.read_line(&mut message)
|
||||
@ -44,7 +52,13 @@ fn main() -> ctap::FidoResult<()> {
|
||||
let mut digest = Sha256::new();
|
||||
digest.input(&message.as_bytes());
|
||||
digest.result(&mut salt);
|
||||
let (cred, (hash1, _hash2)) = device.get_hmac_assertion(RP_ID, &[&credential], &salt, None, None)?;
|
||||
let credential = &&credential;
|
||||
let request = FidoAssertionRequestBuilder::default()
|
||||
.rp_id(RP_ID)
|
||||
.credential(credential)
|
||||
.build()
|
||||
.unwrap();
|
||||
let (_cred, (hash1, _hash2)) = device.get_hmac_assertion(&request, &salt, None)?;
|
||||
println!("Hash: {}", hex::encode(&hash1));
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,24 +1,16 @@
|
||||
extern crate ctap_hmac as ctap;
|
||||
|
||||
use crossbeam::thread;
|
||||
use crypto::digest::Digest;
|
||||
use crypto::sha2::Sha256;
|
||||
use ctap::{
|
||||
FidoAssertionRequestBuilder, FidoCredential, FidoCredentialRequestBuilder, FidoDevice,
|
||||
FidoError, FidoResult,
|
||||
FidoResult,
|
||||
};
|
||||
use failure::_core::time::Duration;
|
||||
|
||||
use hex;
|
||||
use std::env::args;
|
||||
use std::io::prelude::*;
|
||||
use std::io::stdin;
|
||||
use std::io::stdout;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::Mutex;
|
||||
|
||||
const RP_ID: &str = "ctap_demo";
|
||||
|
||||
fn run() -> ctap::FidoResult<()> {
|
||||
fn main() -> ctap::FidoResult<()> {
|
||||
let mut credentials = args()
|
||||
.skip(1)
|
||||
.map(|id| FidoCredential {
|
||||
@ -48,11 +40,8 @@ fn run() -> ctap::FidoResult<()> {
|
||||
let mut devices = ctap::get_devices()?
|
||||
.map(|handle| FidoDevice::new(&handle))
|
||||
.collect::<FidoResult<Vec<_>>>()?;
|
||||
// run with --features request_multiple
|
||||
let (cred, _) = ctap::get_assertion_devices(&req, devices.iter_mut())?;
|
||||
println!("Success, got assertion for: {}", hex::encode(&cred.id));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
dbg!(run());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user