Encode credentials as a protocol buffer message
This permits to decode a credential of a different version without failing.
This commit is contained in:
@@ -16,9 +16,9 @@ use crate::crypto::rng256::Rng256;
|
||||
use crate::ctap::data_formats::PublicKeyCredentialSource;
|
||||
use crate::ctap::status_code::Ctap2StatusCode;
|
||||
use crate::ctap::PIN_AUTH_LENGTH;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
use core::convert::TryInto;
|
||||
use ctap2::embedded_flash::{self, StoreConfig, StoreEntry, StoreError, StoreIndex};
|
||||
|
||||
#[cfg(any(test, feature = "ram_storage"))]
|
||||
@@ -420,8 +420,7 @@ impl From<StoreError> for Ctap2StatusCode {
|
||||
}
|
||||
|
||||
fn deserialize_credential(data: &[u8]) -> Option<PublicKeyCredentialSource> {
|
||||
let cbor = cbor::read(data).ok()?;
|
||||
cbor.try_into().ok()
|
||||
PublicKeyCredentialSource::parse_cbor(cbor::read(data).ok()?)
|
||||
}
|
||||
|
||||
fn serialize_credential(credential: PublicKeyCredentialSource) -> Result<Vec<u8>, Ctap2StatusCode> {
|
||||
@@ -454,6 +453,7 @@ mod test {
|
||||
user_handle,
|
||||
other_ui: None,
|
||||
cred_random: None,
|
||||
unknown_fields: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,6 +623,7 @@ mod test {
|
||||
user_handle: vec![0x00],
|
||||
other_ui: None,
|
||||
cred_random: None,
|
||||
unknown_fields: BTreeMap::new(),
|
||||
};
|
||||
assert_eq!(found_credential, Some(expected_credential));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user