@@ -16,8 +16,8 @@ use crate::{
1616 ctap1:: { Ctap1RegisteredKey , Ctap1Version } ,
1717 ctap2:: {
1818 Ctap2AttestationStatement , Ctap2COSEAlgorithmIdentifier , Ctap2CredentialType ,
19- Ctap2PublicKeyCredentialDescriptor , Ctap2PublicKeyCredentialRpEntity ,
20- Ctap2PublicKeyCredentialUserEntity ,
19+ Ctap2MakeCredentialsResponseExtensions , Ctap2PublicKeyCredentialDescriptor ,
20+ Ctap2PublicKeyCredentialRpEntity , Ctap2PublicKeyCredentialUserEntity ,
2121 } ,
2222 } ,
2323 webauthn:: CtapError ,
@@ -57,7 +57,23 @@ pub struct MakeCredentialResponse {
5757 pub attestation_statement : Ctap2AttestationStatement ,
5858 pub enterprise_attestation : Option < bool > ,
5959 pub large_blob_key : Option < Vec < u8 > > ,
60- pub unsigned_extension_output : Option < BTreeMap < Value , Value > > ,
60+ pub unsigned_extensions_output : Option < MakeCredentialsResponseUnsignedExtensions > ,
61+ }
62+
63+ #[ derive( Debug , Default , Clone , Serialize ) ]
64+ #[ serde( rename_all = "camelCase" ) ]
65+ pub struct MakeCredentialsResponseUnsignedExtensions {
66+ // pub app_id: Option<bool>,
67+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
68+ pub cred_props : Option < CredentialPropsExtension > ,
69+ // #[serde(skip_serializing_if = "Option::is_none")]
70+ // pub cred_blob: Option<bool>,
71+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
72+ pub hmac_create_secret : Option < bool > ,
73+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
74+ pub large_blob : Option < MakeCredentialLargeBlobExtensionOutput > ,
75+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
76+ pub prf : Option < MakeCredentialPrfOutput > ,
6177}
6278
6379#[ derive( Debug , Clone ) ]
@@ -79,7 +95,7 @@ pub struct MakeCredentialRequest {
7995 pub timeout : Duration ,
8096}
8197
82- #[ derive( Debug , Default , Clone ) ]
98+ #[ derive( Debug , Default , Clone , Serialize ) ]
8399pub struct PRFValue {
84100 pub first : [ u8 ; 32 ] ,
85101 pub second : Option < [ u8 ; 32 ] > ,
@@ -103,14 +119,10 @@ pub enum MakeCredentialHmacOrPrfInput {
103119 // },
104120}
105121
106- #[ derive( Debug , Default , Clone ) ]
107- pub enum MakeCredentialHmacOrPrfOutput {
108- #[ default]
109- None ,
110- HmacGetSecret ( bool ) ,
111- Prf {
112- enabled : bool ,
113- } ,
122+ #[ derive( Debug , Default , Clone , Serialize ) ]
123+ pub struct MakeCredentialPrfOutput {
124+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
125+ pub enabled : Option < bool > ,
114126}
115127
116128#[ derive( Debug , Clone ) ]
@@ -159,6 +171,13 @@ impl From<Ctap2CredentialProtectionPolicy> for CredentialProtectionPolicy {
159171 }
160172}
161173
174+ #[ derive( Debug , Default , Clone , Deserialize , Serialize , PartialEq , Eq ) ]
175+ #[ serde( rename_all = "camelCase" ) ]
176+ pub struct CredentialPropsExtension {
177+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
178+ pub rk : Option < bool > ,
179+ }
180+
162181#[ derive( Debug , Default , Clone , Deserialize , Serialize , PartialEq , Eq ) ]
163182#[ serde( rename_all = "camelCase" ) ]
164183pub enum MakeCredentialLargeBlobExtension {
@@ -168,6 +187,12 @@ pub enum MakeCredentialLargeBlobExtension {
168187 Required ,
169188}
170189
190+ #[ derive( Debug , Default , Clone , PartialEq , Eq , Serialize ) ]
191+ pub struct MakeCredentialLargeBlobExtensionOutput {
192+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
193+ pub supported : Option < bool > ,
194+ }
195+
171196#[ derive( Debug , Default , Clone ) ]
172197pub struct MakeCredentialsRequestExtensions {
173198 pub cred_props : Option < bool > ,
@@ -178,21 +203,9 @@ pub struct MakeCredentialsRequestExtensions {
178203 pub hmac_or_prf : MakeCredentialHmacOrPrfInput ,
179204}
180205
181- #[ derive( Debug , Default , Clone ) ]
182- pub struct MakeCredentialsResponseExtensions {
183- pub cred_protect : Option < CredentialProtectionPolicy > ,
184- /// If storing credBlob was successful
185- pub cred_blob : Option < bool > ,
186- /// Current min PIN lenght
187- pub min_pin_length : Option < u32 > ,
188- pub hmac_or_prf : MakeCredentialHmacOrPrfOutput ,
189- // Currently, credProps only returns one value: rk = bool
190- // If these get more in the future, we can use a struct here.
191- pub cred_props_rk : Option < bool > ,
192- }
206+ pub type MakeCredentialsResponseExtensions = Ctap2MakeCredentialsResponseExtensions ;
193207
194208impl MakeCredentialRequest {
195- #[ cfg( test) ]
196209 pub fn dummy ( ) -> Self {
197210 Self {
198211 hash : vec ! [ 0 ; 32 ] ,
@@ -203,7 +216,7 @@ impl MakeCredentialRequest {
203216 extensions : None ,
204217 origin : "example.org" . to_owned ( ) ,
205218 require_resident_key : false ,
206- user_verification : UserVerificationRequirement :: Preferred ,
219+ user_verification : UserVerificationRequirement :: Discouraged ,
207220 timeout : Duration :: from_secs ( 10 ) ,
208221 }
209222 }
@@ -265,9 +278,11 @@ pub struct GetAssertionRequestExtensions {
265278 pub large_blob : GetAssertionLargeBlobExtension ,
266279}
267280
268- #[ derive( Clone , Debug , Default ) ]
281+ #[ derive( Clone , Debug , Default , Serialize ) ]
282+ #[ serde( rename_all = "camelCase" ) ]
269283pub struct HMACGetSecretOutput {
270284 pub output1 : [ u8 ; 32 ] ,
285+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
271286 pub output2 : Option < [ u8 ; 32 ] > ,
272287}
273288
0 commit comments