Skip to content

Commit 5ca4760

Browse files
caBLE progress: add timestamp, MC hint to QR code
1 parent dfa1875 commit 5ca4760

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

libwebauthn/src/transport/cable/qr_code_device.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::fmt::{Debug, Display};
2-
use std::time::Duration;
2+
use std::time::{Duration, SystemTime};
33

44
use async_trait::async_trait;
55
use p256::ecdh::EphemeralSecret;
@@ -70,6 +70,9 @@ pub struct CableQrCode {
7070
/// prior to the authenticator receiving any CTAP message. While this hint SHOULD be as accurate as
7171
/// possible, it does not constrain the subsequent CTAP messages that the platform may send.
7272
pub operation_hint: QrCodeOperationHint,
73+
#[serde(default)]
74+
#[serde(skip_serializing_if = "Option::is_none")]
75+
pub supports_non_discoverable_mc: Option<bool>,
7376
}
7477

7578
impl ToString for CableQrCode {
@@ -146,14 +149,23 @@ impl<'d> CableQrCodeDevice<'d> {
146149
let mut qr_secret = [0u8; 16];
147150
OsRng::default().fill_bytes(&mut qr_secret);
148151

152+
let current_unix_time = SystemTime::now()
153+
.duration_since(SystemTime::UNIX_EPOCH)
154+
.ok()
155+
.map(|t| t.as_secs());
156+
149157
Self {
150158
qr_code: CableQrCode {
151159
public_key: ByteBuf::from(public_key.as_bytes()),
152160
qr_secret: ByteBuf::from(qr_secret),
153161
known_tunnel_domains_count: KNOWN_TUNNEL_DOMAINS.len() as u8,
154-
current_time: None,
162+
current_time: current_unix_time,
155163
operation_hint: hint,
156164
state_assisted: Some(state_assisted),
165+
supports_non_discoverable_mc: match hint {
166+
QrCodeOperationHint::MakeCredential => Some(true),
167+
_ => None,
168+
},
157169
},
158170
private_key: private_key_scalar,
159171
store,

0 commit comments

Comments
 (0)