|
1 | 1 | use std::fmt::{Debug, Display}; |
2 | | -use std::time::Duration; |
| 2 | +use std::time::{Duration, SystemTime}; |
3 | 3 |
|
4 | 4 | use async_trait::async_trait; |
5 | 5 | use p256::ecdh::EphemeralSecret; |
@@ -70,6 +70,9 @@ pub struct CableQrCode { |
70 | 70 | /// prior to the authenticator receiving any CTAP message. While this hint SHOULD be as accurate as |
71 | 71 | /// possible, it does not constrain the subsequent CTAP messages that the platform may send. |
72 | 72 | pub operation_hint: QrCodeOperationHint, |
| 73 | + #[serde(default)] |
| 74 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 75 | + pub supports_non_discoverable_mc: Option<bool>, |
73 | 76 | } |
74 | 77 |
|
75 | 78 | impl ToString for CableQrCode { |
@@ -146,14 +149,23 @@ impl<'d> CableQrCodeDevice<'d> { |
146 | 149 | let mut qr_secret = [0u8; 16]; |
147 | 150 | OsRng::default().fill_bytes(&mut qr_secret); |
148 | 151 |
|
| 152 | + let current_unix_time = SystemTime::now() |
| 153 | + .duration_since(SystemTime::UNIX_EPOCH) |
| 154 | + .ok() |
| 155 | + .map(|t| t.as_secs()); |
| 156 | + |
149 | 157 | Self { |
150 | 158 | qr_code: CableQrCode { |
151 | 159 | public_key: ByteBuf::from(public_key.as_bytes()), |
152 | 160 | qr_secret: ByteBuf::from(qr_secret), |
153 | 161 | known_tunnel_domains_count: KNOWN_TUNNEL_DOMAINS.len() as u8, |
154 | | - current_time: None, |
| 162 | + current_time: current_unix_time, |
155 | 163 | operation_hint: hint, |
156 | 164 | state_assisted: Some(state_assisted), |
| 165 | + supports_non_discoverable_mc: match hint { |
| 166 | + QrCodeOperationHint::MakeCredential => Some(true), |
| 167 | + _ => None, |
| 168 | + }, |
157 | 169 | }, |
158 | 170 | private_key: private_key_scalar, |
159 | 171 | store, |
|
0 commit comments