Skip to content

Commit 6625f7b

Browse files
Address review comments
1 parent 64d5b9a commit 6625f7b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

libwebauthn/src/transport/cable/advertisement.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub(crate) struct DecryptedAdvert {
1919
pub encoded_tunnel_server_domain: u16,
2020
}
2121

22-
impl From<&[u8]> for DecryptedAdvert {
23-
fn from(plaintext: &[u8]) -> Self {
22+
impl From<[u8; 16]> for DecryptedAdvert {
23+
fn from(plaintext: [u8; 16]) -> Self {
2424
let mut nonce = [0u8; 10];
2525
nonce.copy_from_slice(&plaintext[1..11]);
2626
let mut routing_id = [0u8; 3];
@@ -70,7 +70,7 @@ pub(crate) async fn await_advertisement(
7070
};
7171
trace!(?decrypted);
7272

73-
let advert = DecryptedAdvert::from(decrypted.as_slice());
73+
let advert = DecryptedAdvert::from(decrypted);
7474
debug!(
7575
?device,
7676
?decrypted,

libwebauthn/src/transport/cable/crypto.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn reserved_bits_are_zero(plaintext: &[u8]) -> bool {
2828
}
2929

3030
#[instrument]
31-
pub fn trial_decrypt_advert(eid_key: &[u8], candidate_advert: &[u8]) -> Option<Vec<u8>> {
31+
pub fn trial_decrypt_advert(eid_key: &[u8], candidate_advert: &[u8]) -> Option<[u8; 16]> {
3232
if candidate_advert.len() != 20 {
3333
warn!("candidate advert is not 20 bytes");
3434
return None;
@@ -55,7 +55,9 @@ pub fn trial_decrypt_advert(eid_key: &[u8], candidate_advert: &[u8]) -> Option<V
5555
return None;
5656
}
5757

58-
Some(block.to_vec())
58+
let mut plaintext = [0u8; 16];
59+
plaintext.copy_from_slice(&block);
60+
Some(plaintext)
5961
}
6062

6163
#[cfg(test)]

libwebauthn/src/transport/cable/tunnel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub(crate) struct CableLinkingInfo {
108108
pub authenticator_public_key: Vec<u8>,
109109
/// User-friendly name of the authenticator
110110
pub authenticator_name: String,
111-
/// HMAC of the handshake hash (Noise's channel binding value) usinng the
111+
/// HMAC of the handshake hash (Noise's channel binding value) using the
112112
/// shared secret (link_secret) as key
113113
#[allow(dead_code)]
114114
pub handshake_signature: Vec<u8>,

0 commit comments

Comments
 (0)