@@ -10,7 +10,7 @@ use libwebauthn::{
1010} ;
1111use serde:: { Deserialize , Serialize } ;
1212use serde_json:: json;
13- use tracing:: debug;
13+ use tracing:: { debug, error } ;
1414
1515use crate :: cose:: { CoseKeyAlgorithmIdentifier , CoseKeyType } ;
1616
@@ -55,6 +55,19 @@ pub(crate) fn create_attestation_object(
5555 }
5656 }
5757 }
58+ AttestationStatement :: U2F {
59+ signature,
60+ certificate,
61+ } => {
62+ cbor_writer. write_text ( "fido-u2f" ) . unwrap ( ) ;
63+ cbor_writer. write_text ( "attStmt" ) . unwrap ( ) ;
64+ cbor_writer. write_map_start ( 2 ) . unwrap ( ) ;
65+ cbor_writer. write_text ( "x5c" ) . unwrap ( ) ;
66+ cbor_writer. write_array_start ( 1 ) . unwrap ( ) ;
67+ cbor_writer. write_bytes ( certificate) . unwrap ( ) ;
68+ cbor_writer. write_text ( "sig" ) . unwrap ( ) ;
69+ cbor_writer. write_bytes ( signature) . unwrap ( ) ;
70+ }
5871 AttestationStatement :: None => {
5972 cbor_writer. write_text ( "none" ) . unwrap ( ) ;
6073 cbor_writer. write_text ( "attStmt" ) . unwrap ( ) ;
@@ -318,6 +331,10 @@ impl TryFrom<PublicKeyCredentialParameters> for CoseKeyType {
318331#[ derive( Debug , PartialEq ) ]
319332pub ( crate ) enum AttestationStatement {
320333 None ,
334+ U2F {
335+ signature : Vec < u8 > ,
336+ certificate : Vec < u8 > ,
337+ } ,
321338 Packed {
322339 algorithm : CoseKeyAlgorithmIdentifier ,
323340 signature : Vec < u8 > ,
@@ -346,6 +363,16 @@ impl TryFrom<&Ctap2AttestationStatement> for AttestationStatement {
346363 . collect ( ) ,
347364 } )
348365 }
366+ Ctap2AttestationStatement :: FidoU2F ( att_stmt) => {
367+ if att_stmt. certificates . len ( ) != 1 {
368+ error ! ( "fido-u2f attestation statement has to have one certificate, but we received {}!" , att_stmt. certificates. len( ) ) ;
369+ return Err ( Error :: InvalidState ) ;
370+ }
371+ Ok ( Self :: U2F {
372+ signature : att_stmt. signature . as_ref ( ) . to_vec ( ) ,
373+ certificate : att_stmt. certificates [ 0 ] . to_vec ( ) ,
374+ } )
375+ }
349376 _ => {
350377 debug ! ( "Unsupported attestation type: {:?}" , value) ;
351378 Err ( Error :: NotSupported )
0 commit comments