libwebauthn 0.5.1

FIDO2 (WebAuthn) and FIDO U2F platform library for Linux written in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
use std::collections::HashMap;

use serde_bytes::ByteBuf;
use serde_indexed::DeserializeIndexed;
#[cfg(test)]
use serde_indexed::SerializeIndexed;
use tracing::debug;

use super::{Ctap2CredentialType, Ctap2UserVerificationOperation};

#[cfg_attr(test, derive(SerializeIndexed))]
#[derive(Debug, Clone, DeserializeIndexed, Default)]
pub struct Ctap2GetInfoResponse {
    /// versions (0x01)
    #[serde(index = 0x01)]
    pub versions: Vec<String>,

    /// extensions (0x02)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x02)]
    pub extensions: Option<Vec<String>>,

    /// aaguid (0x03)
    #[serde(index = 0x03)]
    pub aaguid: ByteBuf,

    /// options (0x04)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x04)]
    pub options: Option<HashMap<String, bool>>,

    /// maxMsgSize (0x05)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x05)]
    pub max_msg_size: Option<u32>,

    /// pinUvAuthProtocols (0x06)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x06)]
    pub pin_auth_protos: Option<Vec<u32>>,

    /// maxCredentialCountInList (0x07)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x07)]
    pub max_credential_count: Option<u32>,

    /// maxCredentialIdLength (0x08)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x08)]
    pub max_credential_id_length: Option<u32>,

    /// transports (0x09)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x09)]
    pub transports: Option<Vec<String>>,

    /// algorithms (0x0A)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x0A)]
    pub algorithms: Option<Vec<Ctap2CredentialType>>,

    /// maxSerializedLargeBlobArray (0x0B)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x0B)]
    pub max_blob_array: Option<u32>,

    /// forcePINChange (0x0C)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x0C)]
    pub force_pin_change: Option<bool>,

    /// minPINLength (0x0D)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x0D)]
    pub min_pin_length: Option<u32>,

    /// firmwareVersion (0x0E)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x0E)]
    pub firmware_version: Option<u32>,

    /// maxCredBlobLength (0x0F)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x0F)]
    pub max_cred_blob_length: Option<u32>,

    /// maxRPIDsForSetMinPINLength (0x10)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x10)]
    pub max_rpids_for_setminpinlength: Option<u32>,

    /// preferredPlatformUvAttempts (0x11)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x11)]
    pub preferred_platform_uv_attempts: Option<u32>,

    /// uvModality (0x12)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x12)]
    pub uv_modality: Option<u32>,

    /// certifications (0x13)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x13)]
    pub certifications: Option<HashMap<String, u32>>,

    /// remainingDiscoverableCredentials (0x14)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x14)]
    pub remaining_discoverable_creds: Option<u32>,

    /// vendorPrototypeConfigCommands (0x15)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x15)]
    pub vendor_proto_config_cmds: Option<Vec<u32>>,

    /// attestationFormats (0x16)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x16)]
    pub attestation_formats: Option<Vec<String>>,

    /// uvCountSinceLastPinEntry (0x17)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x17)]
    pub uv_count_since_last_pin_entry: Option<u32>,

    /// longTouchForReset (0x18)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x18)]
    pub long_touch_for_reset: Option<bool>,

    /// encIdentifier (0x19)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x19)]
    pub enc_identifier: Option<ByteBuf>,

    /// transportsForReset (0x1A)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x1A)]
    pub transports_for_reset: Option<Vec<String>>,

    /// pinComplexityPolicy (0x1B)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x1B)]
    pub pin_complexity_policy: Option<bool>,

    /// pinComplexityPolicyURL (0x1C)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x1C)]
    pub pin_complexity_policy_url: Option<ByteBuf>,

    /// maxPINLength (0x1D)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(index = 0x1D)]
    pub max_pin_length: Option<u32>,
}

impl Ctap2GetInfoResponse {
    /// Only checks if the option exists, i.e. is not None
    /// but does not check if the option is enabled (true)
    /// or disabled (false)
    pub fn option_exists(&self, name: &str) -> bool {
        let Some(options) = self.options.as_ref() else {
            return false;
        };
        options.get(name).is_some()
    }

    /// Checks if the option exists and is set to true
    pub fn option_enabled(&self, name: &str) -> bool {
        let Some(options) = self.options.as_ref() else {
            return false;
        };
        options.get(name) == Some(&true)
    }

    pub fn supports_fido_2_1(&self) -> bool {
        self.versions.iter().any(|v| v == "FIDO_2_1")
    }

    pub fn supports_extension(&self, name: &str) -> bool {
        self.extensions
            .as_ref()
            .is_some_and(|exts| exts.iter().any(|e| e == name))
    }

    pub fn supports_credential_management(&self) -> bool {
        self.option_enabled("credMgmt") || self.option_enabled("credentialMgmtPreview")
    }

    pub fn supports_bio_enrollment(&self) -> bool {
        if let Some(options) = &self.options {
            return options.get("bioEnroll").is_some()
                || options.get("userVerificationMgmtPreview").is_some();
        }
        false
    }

    pub fn has_bio_enrollments(&self) -> bool {
        if let Some(options) = &self.options {
            return options.get("bioEnroll") == Some(&true)
                || options.get("userVerificationMgmtPreview") == Some(&true);
        }
        false
    }

    /// Implements check for "Protected by some form of User Verification":
    ///   Either or both clientPin or built-in user verification methods are supported and enabled.
    ///   I.e., in the authenticatorGetInfo response the pinUvAuthToken option ID is present and set to true,
    ///   and either clientPin option ID is present and set to true or uv option ID is present and set to true or both.
    pub fn is_uv_protected(&self) -> bool {
        self.option_enabled("uv") || // Deprecated no-op UV
            self.option_enabled("clientPin") ||
            (self.option_enabled("pinUvAuthToken") && self.option_enabled("uv"))
    }

    pub fn can_establish_shared_secret(&self) -> bool {
        // clientPin exists: clientPin command is supported, so we can establish a shared secret
        // uv exists and pinUvAuthToken is enabled: clientPin command partially supported. Enough to establish shared secret
        self.option_exists("clientPin")
            || (self.option_exists("uv") && self.option_enabled("pinUvAuthToken"))
    }

    pub fn uv_operation(&self, uv_blocked: bool) -> Option<Ctap2UserVerificationOperation> {
        if self.option_enabled("uv") && !uv_blocked {
            if self.option_enabled("pinUvAuthToken") {
                debug!("getPinUvAuthTokenUsingUvWithPermissions");
                Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingUvWithPermissions)
            } else {
                debug!("Deprecated FIDO 2.0 behaviour: populating 'uv' flag");
                Some(Ctap2UserVerificationOperation::LegacyUv)
            }
        } else {
            // !uv

            // clientPIN exists, but is not enabled, aka PIN is not yet set on the device
            // We can use it for establishing a shared secret, but not for creating a pinUvAuthToken
            if self.option_exists("clientPin") && !self.option_enabled("clientPin") {
                return Some(Ctap2UserVerificationOperation::OnlyForSharedSecret);
            }

            // clientPin is not enabled (not supported or Pin not set) and
            // UV + pinUvAuthToken is supported, but UV is blocked (maybe too many retries)
            // or it is not set yet.
            // We can still use it for establishing a shared secret, but not for creating a pinUvAuthToken
            if !self.option_enabled("clientPin")
                && self.option_exists("uv")
                && self.option_enabled("pinUvAuthToken")
            {
                return Some(Ctap2UserVerificationOperation::OnlyForSharedSecret);
            }

            // If we do have a PIN, check if we need to use legacy getPinToken or new getPinUvAuthToken..-command
            if self.option_enabled("pinUvAuthToken") {
                // `pinUvAuthToken` and `clientPin` are independent options
                // (CTAP 2.2 §6.4). Tolerate the combination without `clientPin`
                // and fall back to a shared-secret-only flow.
                if !self.option_enabled("clientPin") {
                    debug!(
                        "Device advertises pinUvAuthToken without clientPin; \
                         falling back to OnlyForSharedSecret"
                    );
                    return Some(Ctap2UserVerificationOperation::OnlyForSharedSecret);
                }
                debug!("getPinUvAuthTokenUsingPinWithPermissions");
                Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingPinWithPermissions)
            } else if self.option_enabled("clientPin") {
                // !pinUvAuthToken
                debug!("getPinToken");
                Some(Ctap2UserVerificationOperation::GetPinToken)
            } else {
                debug!("No UV and no PIN (e.g. maybe UV was blocked and no PIN available)");
                None
            }
        }
    }
}

#[cfg(test)]
mod test {
    use std::collections::HashMap;

    use crate::proto::ctap2::Ctap2UserVerificationOperation;

    use super::Ctap2GetInfoResponse;

    fn create_info(options: &[(&str, bool)]) -> Ctap2GetInfoResponse {
        let mut info = Ctap2GetInfoResponse::default();
        let mut input = HashMap::new();
        for (key, val) in options {
            input.insert(key.to_string(), *val);
        }
        info.options = Some(input);
        info
    }

    #[test]
    fn device_no_options() {
        let info = Ctap2GetInfoResponse::default();
        assert!(!info.supports_fido_2_1());
        assert!(!info.supports_credential_management());
        assert!(!info.supports_bio_enrollment());
        assert!(!info.is_uv_protected());
        assert!(!info.can_establish_shared_secret());
        assert_eq!(info.uv_operation(false), None);
        assert_eq!(info.uv_operation(true), None);
    }

    #[test]
    fn device_empty_options() {
        let info = create_info(&[]);
        assert!(!info.supports_fido_2_1());
        assert!(!info.supports_credential_management());
        assert!(!info.supports_bio_enrollment());
        assert!(!info.is_uv_protected());
        assert!(!info.can_establish_shared_secret());
        assert_eq!(info.uv_operation(false), None);
        assert_eq!(info.uv_operation(true), None);
    }

    #[test]
    fn device_legacy_uv() {
        // Support legacy UV of CTAP2.0
        // Meaning: "uv" option is supported, but not clientPin or pinUvAuthToken
        // So, it supports built in UV, but no way to establish a pinUvAuthToken or shared secret
        let info = create_info(&[("uv", true)]);
        assert!(info.is_uv_protected());
        assert!(!info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::LegacyUv)
        );
        // If UV is blocked, no other option is available
        assert_eq!(info.uv_operation(true), None);
    }

    #[test]
    fn device_legacy_uv_but_not_set() {
        // Support legacy UV of CTAP2.0, but not activated yet
        let info = create_info(&[("uv", false)]);
        // We are currently NOT protected
        assert!(!info.is_uv_protected());
        assert!(!info.can_establish_shared_secret());
        assert_eq!(info.uv_operation(false), None);
        assert_eq!(info.uv_operation(true), None);
    }

    #[test]
    fn device_ctap20_pin_only() {
        // Support CTAP 2.0 PIN operation
        // Meaning: "clientPin", but not "pinUvAuthToken"
        let info = create_info(&[("clientPin", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::GetPinToken)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::GetPinToken)
        );
    }

    #[test]
    fn device_ctap20_pin_only_but_not_set() {
        // Support CTAP 2.0 PIN operation
        // Meaning: "clientPin", but not "pinUvAuthToken", but the Pin is not set
        let info = create_info(&[("clientPin", false)]);
        // We are currently NOT protected
        assert!(!info.is_uv_protected());
        // We CAN establish a shared secret this way
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_ctap20_pin_and_uv() {
        // Support CTAP 2.0 PIN operation and CTAP 2.0 UV
        // Meaning: "clientPin" and "uv"
        let info = create_info(&[("clientPin", true), ("uv", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::LegacyUv)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::GetPinToken)
        );
    }

    #[test]
    fn device_ctap20_pin_and_uv_but_only_pin_set() {
        // Support CTAP 2.0 PIN operation and CTAP 2.0 UV
        // Meaning: "clientPin" and "uv"
        let info = create_info(&[("clientPin", true), ("uv", false)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::GetPinToken)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::GetPinToken)
        );
    }

    #[test]
    fn device_ctap20_pin_and_uv_but_only_uv_set() {
        // Support CTAP 2.0 PIN operation and CTAP 2.0 UV
        // Meaning: "clientPin" and "uv"
        let info = create_info(&[("clientPin", false), ("uv", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::LegacyUv)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_ctap20_pin_and_uv_but_neither_set() {
        // Support CTAP 2.0 PIN operation and CTAP 2.0 UV
        // Meaning: "clientPin" and "uv"
        let info = create_info(&[("clientPin", false), ("uv", false)]);
        // We are currently NOT protected
        assert!(!info.is_uv_protected());
        // But we should be able to establish a shared secret
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_ctap21_pin_only() {
        // Support CTAP 2.1 PIN operation
        // Meaning: "clientPin" and "pinUvAuthToken"
        let info = create_info(&[("clientPin", true), ("pinUvAuthToken", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingPinWithPermissions)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingPinWithPermissions)
        );
    }

    #[test]
    fn device_ctap21_uv_only() {
        // Support CTAP 2.1 UV operation
        // Meaning: "uv" and "pinUvAuthToken"
        let info = create_info(&[("uv", true), ("pinUvAuthToken", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingUvWithPermissions)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_ctap21_pin_and_uv() {
        // Support CTAP 2.1 PIN+UV operation
        // Meaning: "clientPin", "uv" and "pinUvAuthToken"
        let info = create_info(&[("clientPin", true), ("uv", true), ("pinUvAuthToken", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingUvWithPermissions)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingPinWithPermissions)
        );
    }

    #[test]
    fn device_ctap21_pin_only_but_not_set() {
        // Support CTAP 2.1 PIN operation
        // Meaning: "clientPin" and "pinUvAuthToken", but Pin not set
        let info = create_info(&[("clientPin", false), ("pinUvAuthToken", true)]);
        // We are currently NOT protected
        assert!(!info.is_uv_protected());
        // But we should be able to establish a shared secret
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_ctap21_uv_only_but_not_set() {
        // Support CTAP 2.1 UV operation
        let info = create_info(&[("uv", false), ("pinUvAuthToken", true)]);
        // We are currently NOT protected
        assert!(!info.is_uv_protected());
        // But we should be able to establish a shared secret
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_ctap21_pin_and_uv_but_only_pin_set() {
        let info = create_info(&[("clientPin", true), ("uv", false), ("pinUvAuthToken", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingPinWithPermissions)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingPinWithPermissions)
        );
    }

    #[test]
    fn device_ctap21_pin_and_uv_but_only_uv_set() {
        let info = create_info(&[("clientPin", false), ("uv", true), ("pinUvAuthToken", true)]);
        assert!(info.is_uv_protected());
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::GetPinUvAuthTokenUsingUvWithPermissions)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_ctap21_pin_and_uv_but_neither_set() {
        let info = create_info(&[
            ("clientPin", false),
            ("uv", false),
            ("pinUvAuthToken", true),
        ]);
        // We are currently NOT protected
        assert!(!info.is_uv_protected());
        // But we should be able to establish a shared secret
        assert!(info.can_establish_shared_secret());
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }

    #[test]
    fn device_pin_uv_auth_token_without_client_pin_does_not_panic() {
        let info = create_info(&[("pinUvAuthToken", true)]);
        assert_eq!(
            info.uv_operation(false),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
        assert_eq!(
            info.uv_operation(true),
            Some(Ctap2UserVerificationOperation::OnlyForSharedSecret)
        );
    }
}