feat: v1.1.13, u2f-register

This commit is contained in:
2022-04-10 21:35:50 +08:00
parent af8a9c3047
commit 088910fb8d
4 changed files with 90 additions and 41 deletions

View File

@@ -58,13 +58,14 @@ pub struct U2fRegistrationData {
pub device_name: Option<String>,
pub client_data: String,
pub registration_data: String,
pub attestation_cert: Option<Vec<u8>>,
pub attestation_cert_pem: Option<String>,
pub pub_key: String,
pub key_handle: String,
pub pub_key: Vec<u8>,
pub key_handle: Vec<u8>,
}
impl U2fRegistrationData {
pub fn from(app_id: &str, client_data: &str, register_result: RegisterResult) -> XResult<Self> {
pub fn from(app_id: &str, client_data: &str, register_result: &RegisterResult) -> XResult<Self> {
let registration = opt_result!(
u2f::register::parse_registration(app_id.to_string(), client_data.as_bytes().to_vec(), register_result.0.to_vec()),
"Parse registration data failed: {}");
@@ -74,11 +75,12 @@ impl U2fRegistrationData {
device_name: registration.device_name,
client_data: client_data.into(),
registration_data: base64::encode(&register_result.0),
attestation_cert_pem: registration.attestation_cert.map(|c| {
bytes_to_pem("CERTIFICATE", c)
attestation_cert: registration.attestation_cert.clone(),
attestation_cert_pem: registration.attestation_cert.map(|cert| {
bytes_to_pem("CERTIFICATE", cert)
}),
pub_key: hex::encode(registration.pub_key),
key_handle: hex::encode(registration.key_handle),
pub_key: registration.pub_key,
key_handle: registration.key_handle,
})
}
}