mirror of
https://github.com/trussed-dev/fido-authenticator.git
synced 2026-06-20 04:16:16 -07:00
use fast logs
This commit is contained in:
committed by
Nicolas Stalder
parent
a901607bb6
commit
b146c415a8
@@ -80,7 +80,7 @@ where UP: UserPresence,
|
||||
+ client::P256
|
||||
{
|
||||
pub fn get_creds_metadata(&mut self) -> Result<Response> {
|
||||
info_now!("get metadata");
|
||||
info!("get metadata");
|
||||
let mut response: ctap2::credential_management::Response =
|
||||
Default::default();
|
||||
|
||||
@@ -132,7 +132,7 @@ where UP: UserPresence,
|
||||
}
|
||||
|
||||
pub fn first_relying_party(&mut self) -> Result<Response> {
|
||||
info_now!("first rp");
|
||||
info!("first rp");
|
||||
|
||||
// rp (0x03): PublicKeyCredentialRpEntity
|
||||
// rpIDHash (0x04) : RP ID SHA-256 hash.
|
||||
@@ -205,7 +205,7 @@ where UP: UserPresence,
|
||||
}
|
||||
|
||||
pub fn next_relying_party(&mut self) -> Result<Response> {
|
||||
info_now!("next rp");
|
||||
info!("next rp");
|
||||
|
||||
let (remaining, last_rp_id_hash) = match self.state.runtime.cache {
|
||||
Some(CommandCache::CredentialManagementEnumerateRps(
|
||||
@@ -289,7 +289,7 @@ where UP: UserPresence,
|
||||
}
|
||||
|
||||
pub fn first_credential(&mut self, rp_id_hash: &Bytes32) -> Result<Response> {
|
||||
info_now!("first credential");
|
||||
info!("first credential");
|
||||
|
||||
self.state.runtime.cache = None;
|
||||
|
||||
@@ -323,7 +323,7 @@ where UP: UserPresence,
|
||||
}
|
||||
|
||||
pub fn next_credential(&mut self) -> Result<Response> {
|
||||
info_now!("next credential");
|
||||
info!("next credential");
|
||||
|
||||
let (remaining, rp_dir, prev_filename) = match self.state.runtime.cache {
|
||||
Some(CommandCache::CredentialManagementEnumerateCredentials(
|
||||
@@ -447,7 +447,7 @@ where UP: UserPresence,
|
||||
)
|
||||
-> Result<Response>
|
||||
{
|
||||
info_now!("delete credential");
|
||||
info!("delete credential");
|
||||
let credential_id_hash = self.hash(&credential_descriptor.id[..]);
|
||||
let mut hex = [b'0'; 16];
|
||||
super::format_hex(&credential_id_hash[..8], &mut hex);
|
||||
@@ -476,14 +476,14 @@ where UP: UserPresence,
|
||||
)).entry;
|
||||
|
||||
if maybe_first_remaining_rk.is_none() {
|
||||
info_now!("deleting parent {:?} as this was its last RK",
|
||||
info!("deleting parent {:?} as this was its last RK",
|
||||
&rp_path);
|
||||
syscall!(self.trussed.remove_dir(
|
||||
Location::Internal,
|
||||
rp_path,
|
||||
));
|
||||
} else {
|
||||
info_now!("not deleting deleting parent {:?} as there is {:?}",
|
||||
info!("not deleting deleting parent {:?} as there is {:?}",
|
||||
&rp_path,
|
||||
&maybe_first_remaining_rk.unwrap().path(),
|
||||
);
|
||||
@@ -706,7 +706,7 @@ where UP: UserPresence,
|
||||
// )).entry;
|
||||
|
||||
// if maybe_first_remaining_rk.is_none() {
|
||||
// // info_now!("deleting parent {:?} as this was its last RK",
|
||||
// // info!("deleting parent {:?} as this was its last RK",
|
||||
// // &rp_path);
|
||||
// syscall!(self.trussed.remove_dir(
|
||||
// Location::Internal,
|
||||
|
||||
+25
-26
@@ -227,7 +227,7 @@ where UP: UserPresence,
|
||||
nonce,
|
||||
);
|
||||
|
||||
// info_now!("made credential {:?}", &credential);
|
||||
// info!("made credential {:?}", &credential);
|
||||
|
||||
// 12.b generate credential ID { = AEAD(Serialize(Credential)) }
|
||||
let kek = self.state.persistent.key_encryption_key(&mut self.trussed).map_err(|_| U2fError::NotEnoughMemory)?;
|
||||
@@ -249,7 +249,7 @@ where UP: UserPresence,
|
||||
|
||||
let (signature, cert) = match attestation {
|
||||
(Some((key, cert)), _aaguid) => {
|
||||
info_now!("aaguid: {}", hex_str!(&_aaguid));
|
||||
info!("aaguid: {}", hex_str!(&_aaguid));
|
||||
(
|
||||
syscall!(
|
||||
self.trussed.sign(Mechanism::P256,
|
||||
@@ -434,7 +434,7 @@ where UP: UserPresence,
|
||||
match response {
|
||||
Ok(response) => {
|
||||
// let mut buf = [0u8; 512];
|
||||
// info_now!("{:?}", ctap_types::serde::cbor_serialize(&response, &mut buf));
|
||||
// info!("{:?}", ctap_types::serde::cbor_serialize(&response, &mut buf));
|
||||
Ok(Response::Ctap2(ctap2::Response::CredentialManagement(response)))
|
||||
}
|
||||
Err(error) => Err(error)
|
||||
@@ -469,7 +469,7 @@ where UP: UserPresence,
|
||||
fn client_pin(&mut self, parameters: &ctap2::client_pin::Parameters) -> Result<ctap2::client_pin::Response> {
|
||||
use ctap2::client_pin::PinV1Subcommand as Subcommand;
|
||||
debug!("processing CP");
|
||||
// info_now!("{:?}", parameters);
|
||||
// info!("{:?}", parameters);
|
||||
|
||||
if parameters.pin_protocol != 1{
|
||||
return Err(Error::InvalidParameter);
|
||||
@@ -640,7 +640,7 @@ where UP: UserPresence,
|
||||
// 7. return encrypted pinToken
|
||||
let pin_token = self.state.runtime.pin_token(&mut self.trussed);
|
||||
debug!("wrapping pin token");
|
||||
// info_now!("exists? {}", syscall!(self.trussed.exists(shared_secret)).exists);
|
||||
// info!("exists? {}", syscall!(self.trussed.exists(shared_secret)).exists);
|
||||
let pin_token_enc = syscall!(self.trussed.wrap_key_aes256cbc(shared_secret, pin_token)).wrapped_key;
|
||||
|
||||
syscall!(self.trussed.delete(shared_secret));
|
||||
@@ -707,7 +707,7 @@ where UP: UserPresence,
|
||||
|
||||
// // temp
|
||||
// let pin_length = pin.iter().position(|&b| b == b'\0').unwrap_or(pin.len());
|
||||
// info_now!("pin.len() = {}, pin_length = {}, = {:?}",
|
||||
// info!("pin.len() = {}, pin_length = {}, = {:?}",
|
||||
// pin.len(), pin_length, &pin);
|
||||
// chop off null bytes
|
||||
let pin_length = pin.iter().position(|&b| b == b'\0').unwrap_or(pin.len());
|
||||
@@ -750,7 +750,7 @@ where UP: UserPresence,
|
||||
parameters: &ctap2::credential_management::Parameters
|
||||
) -> Result<()> {
|
||||
|
||||
// info_now!("CM params: {:?}", parameters);
|
||||
// info!("CM params: {:?}", parameters);
|
||||
use ctap2::credential_management::Subcommand;
|
||||
match parameters.sub_command {
|
||||
// are we Haskell yet lol
|
||||
@@ -786,7 +786,7 @@ where UP: UserPresence,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
// info_now!("input to hmacsha256: {:?}", &data[..len]);
|
||||
// info!("input to hmacsha256: {:?}", &data[..len]);
|
||||
let expected_pin_auth = syscall!(self.trussed.sign_hmacsha256(
|
||||
pin_token,
|
||||
&data[..len],
|
||||
@@ -925,7 +925,7 @@ where UP: UserPresence,
|
||||
let cred_maybe = Credential::try_from(
|
||||
self, rp_id_hash, credential_descriptor)
|
||||
.ok();
|
||||
info_now!("cred_maybe: {:?}", &cred_maybe);
|
||||
info!("cred_maybe: {:?}", &cred_maybe);
|
||||
cred_maybe
|
||||
} )
|
||||
.collect()
|
||||
@@ -996,8 +996,8 @@ where UP: UserPresence,
|
||||
};
|
||||
|
||||
|
||||
info_now!("added volatile cred: {:?}", ×tamp_path);
|
||||
info_now!("{}",hex_str!(&serialized));
|
||||
info!("added volatile cred: {:?}", ×tamp_path);
|
||||
info!("{}",hex_str!(&serialized));
|
||||
|
||||
|
||||
try_syscall!(self.trussed.write_file(
|
||||
@@ -1086,7 +1086,7 @@ where UP: UserPresence,
|
||||
};
|
||||
|
||||
min_heap.push(timestamp_path).map_err(drop).unwrap();
|
||||
// info_now!("first: {:?}", &self.hash(&id.0));
|
||||
// info!("first: {:?}", &self.hash(&id.0));
|
||||
}
|
||||
|
||||
loop {
|
||||
@@ -1258,8 +1258,8 @@ where UP: UserPresence,
|
||||
0 => None,
|
||||
n => Some(n as u32 + 1),
|
||||
};
|
||||
info_now!("FIRST cred: {:?}",&credential);
|
||||
info_now!("FIRST NUM creds: {:?}",num_credentials);
|
||||
info!("FIRST cred: {:?}",&credential);
|
||||
info!("FIRST NUM creds: {:?}",num_credentials);
|
||||
|
||||
// NB: misleading, if we have "1" we return "None"
|
||||
let human_num_credentials = match num_credentials {
|
||||
@@ -1387,7 +1387,7 @@ where UP: UserPresence,
|
||||
Key::ResidentKey(key) => (key, true),
|
||||
Key::WrappedKey(bytes) => {
|
||||
let wrapping_key = self.state.persistent.key_wrapping_key(&mut self.trussed)?;
|
||||
// info_now!("unwrapping {:?} with wrapping key {:?}", &bytes, &wrapping_key);
|
||||
// info!("unwrapping {:?} with wrapping key {:?}", &bytes, &wrapping_key);
|
||||
let key_result = syscall!(self.trussed.unwrap_key_chacha8poly1305(
|
||||
wrapping_key,
|
||||
&bytes,
|
||||
@@ -1413,7 +1413,7 @@ where UP: UserPresence,
|
||||
|
||||
// 9./10. sign clientDataHash || authData with "first" credential
|
||||
|
||||
// info_now!("signing with credential {:?}", &credential);
|
||||
// info!("signing with credential {:?}", &credential);
|
||||
let kek = self.state.persistent.key_encryption_key(&mut self.trussed)?;
|
||||
let credential_id = credential.id_using_hash(&mut self.trussed, kek, &rp_id_hash)?;
|
||||
|
||||
@@ -1550,7 +1550,7 @@ where UP: UserPresence,
|
||||
)).entry;
|
||||
|
||||
loop {
|
||||
info_now!("this may be an RK: {:?}", &entry);
|
||||
info!("this may be an RK: {:?}", &entry);
|
||||
let rk_path = match entry {
|
||||
// no more RKs left
|
||||
// break breaks inner loop here
|
||||
@@ -1558,7 +1558,7 @@ where UP: UserPresence,
|
||||
Some(entry) => PathBuf::from(entry.path()),
|
||||
};
|
||||
|
||||
info_now!("checking RK {:?} for userId ", &rk_path);
|
||||
info!("checking RK {:?} for userId ", &rk_path);
|
||||
let credential_data = syscall!(self.trussed.read_file(
|
||||
Location::Internal,
|
||||
PathBuf::from(rk_path.clone()),
|
||||
@@ -1569,7 +1569,7 @@ where UP: UserPresence,
|
||||
if old_credential.user.id == user_id {
|
||||
match old_credential.key {
|
||||
credential::Key::ResidentKey(key) => {
|
||||
info_now!(":: deleting resident key");
|
||||
info!(":: deleting resident key");
|
||||
syscall!(self.trussed.delete(key));
|
||||
}
|
||||
_ => {
|
||||
@@ -1581,7 +1581,7 @@ where UP: UserPresence,
|
||||
PathBuf::from(rk_path),
|
||||
));
|
||||
|
||||
info_now!("Overwriting previous rk tied to this userId.");
|
||||
info!("Overwriting previous rk tied to this userId.");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -1611,7 +1611,7 @@ where UP: UserPresence,
|
||||
PathBuf::from(rk_path),
|
||||
)).data;
|
||||
let credential_maybe = Credential::deserialize(&credential_data);
|
||||
// info_now!("deleting credential {:?}", &credential);
|
||||
// info!("deleting credential {:?}", &credential);
|
||||
|
||||
|
||||
if let Ok(credential) = credential_maybe {
|
||||
@@ -1626,7 +1626,7 @@ where UP: UserPresence,
|
||||
} else {
|
||||
// If for some reason there becomes a corrupt credential,
|
||||
// we can still at least orphan the key rather then crash.
|
||||
info_now!("Warning! Orpaning a key.");
|
||||
info!("Warning! Orpaning a key.");
|
||||
}
|
||||
|
||||
info!(":: deleting RK file {:?} itself", &rk_path);
|
||||
@@ -1776,7 +1776,7 @@ where UP: UserPresence,
|
||||
let totp_secret: [u8; 20] = parameters.client_data_hash[6..26].try_into().unwrap();
|
||||
private_key = syscall!(self.trussed.unsafe_inject_shared_key(
|
||||
&totp_secret, Location::Internal)).key;
|
||||
// info_now!("totes injected");
|
||||
// info!("totes injected");
|
||||
let fake_cose_pk = ctap_types::cose::TotpPublicKey {};
|
||||
let fake_serialized_cose_pk = trussed::cbor_serialize_bytes(&fake_cose_pk)
|
||||
.map_err(|_| Error::NotAllowed)?;
|
||||
@@ -1828,7 +1828,7 @@ where UP: UserPresence,
|
||||
nonce,
|
||||
);
|
||||
|
||||
// info_now!("made credential {:?}", &credential);
|
||||
// info!("made credential {:?}", &credential);
|
||||
|
||||
// 12.b generate credential ID { = AEAD(Serialize(Credential)) }
|
||||
let kek = self.state.persistent.key_encryption_key(&mut self.trussed)?;
|
||||
@@ -1858,8 +1858,7 @@ where UP: UserPresence,
|
||||
|
||||
// 13.a AuthenticatorData and its serialization
|
||||
use ctap2::AuthenticatorDataFlags as Flags;
|
||||
info!("MC created cred id:");
|
||||
info!("{}", hex_str!(&credential_id.0));
|
||||
info!("MC created cred id");
|
||||
|
||||
let (attestation_maybe, aaguid)= self.state.identity.attestation(&mut self.trussed);
|
||||
|
||||
|
||||
+4
-5
@@ -117,7 +117,6 @@ impl Identity {
|
||||
for i in 0 .. 16 {
|
||||
aaguid[i] = cert_reader[i]
|
||||
}
|
||||
|
||||
Some(aaguid)
|
||||
}
|
||||
|
||||
@@ -232,7 +231,7 @@ impl PersistentState {
|
||||
)).map_err(|_| Error::Other);
|
||||
|
||||
if result.is_err() {
|
||||
info_now!("err loading: {:?}", result.err().unwrap());
|
||||
info!("err loading: {:?}", result.err().unwrap());
|
||||
return Err(Error::Other);
|
||||
}
|
||||
|
||||
@@ -241,8 +240,8 @@ impl PersistentState {
|
||||
let result = trussed::cbor_deserialize(&data);
|
||||
|
||||
if result.is_err() {
|
||||
info_now!("err deser'ing: {:?}", result.err().unwrap());
|
||||
info_now!("{}", hex_str!(&data));
|
||||
info!("err deser'ing: {:?}", result.err().unwrap());
|
||||
info!("{}", hex_str!(&data));
|
||||
return Err(Error::Other);
|
||||
}
|
||||
|
||||
@@ -435,7 +434,7 @@ impl RuntimeState {
|
||||
pub fn pop_credential_from_heap<T: client::FilesystemClient>(&mut self, trussed: &mut T) -> crate::Credential {
|
||||
let max_heap = self.credential_heap();
|
||||
let timestamp_hash = max_heap.pop().unwrap();
|
||||
info_now!("{:?} @ {} {:?}", ×tamp_hash.path, timestamp_hash.timestamp, timestamp_hash.location);
|
||||
info!("{:?} @ {} {:?}", ×tamp_hash.path, timestamp_hash.timestamp, timestamp_hash.location);
|
||||
let data = syscall!(trussed.read_file(
|
||||
timestamp_hash.location,
|
||||
timestamp_hash.path.clone(),
|
||||
|
||||
Reference in New Issue
Block a user