passkey_types/ctap2/extensions/
prf.rs1use std::collections::HashMap;
6
7use serde::{Deserialize, Serialize};
8
9use crate::{webauthn, Bytes};
10
11#[cfg(doc)]
12use crate::ctap2::{get_assertion, make_credential};
13
14#[derive(Debug, Serialize, Deserialize, Clone)]
16pub struct AuthenticatorPrfInputs {
17 #[serde(default, skip_serializing_if = "Option::is_none")]
19 pub eval: Option<AuthenticatorPrfValues>,
20
21 #[serde(default, skip_serializing_if = "Option::is_none")]
23 pub eval_by_credential: Option<HashMap<Bytes, AuthenticatorPrfValues>>,
24}
25
26#[derive(Debug, Serialize, Deserialize, Clone)]
28pub struct AuthenticatorPrfValues {
29 pub first: [u8; 32],
31
32 #[serde(default, skip_serializing_if = "Option::is_none")]
34 pub second: Option<[u8; 32]>,
35}
36
37impl From<AuthenticatorPrfValues> for webauthn::AuthenticationExtensionsPrfValues {
38 fn from(value: AuthenticatorPrfValues) -> Self {
39 Self {
40 first: value.first.to_vec().into(),
41 second: value.second.map(|b| b.to_vec().into()),
42 }
43 }
44}
45
46#[derive(Debug, Serialize, Deserialize, Clone)]
49pub struct AuthenticatorPrfMakeOutputs {
50 pub enabled: bool,
52
53 #[serde(default, skip_serializing_if = "Option::is_none")]
55 pub results: Option<AuthenticatorPrfValues>,
56}
57
58impl From<AuthenticatorPrfMakeOutputs> for webauthn::AuthenticationExtensionsPrfOutputs {
59 fn from(value: AuthenticatorPrfMakeOutputs) -> Self {
60 Self {
61 enabled: Some(value.enabled),
62 results: value.results.map(Into::into),
63 }
64 }
65}
66
67#[derive(Debug, Serialize, Deserialize, Clone)]
70pub struct AuthenticatorPrfGetOutputs {
71 pub results: AuthenticatorPrfValues,
73}
74
75impl From<AuthenticatorPrfGetOutputs> for webauthn::AuthenticationExtensionsPrfOutputs {
76 fn from(value: AuthenticatorPrfGetOutputs) -> Self {
77 Self {
78 enabled: None,
79 results: Some(value.results.into()),
80 }
81 }
82}