@ -1,10 +1,34 @@
use crate ::registry ::algorithms ;
use crate ::{ authenticator ::Transport , credential } ;
use crate ::{ authenticator ::Transport , credential } ;
use std ::collections ::BTreeSet ;
use std ::collections ::BTreeSet ;
#[ cfg(feature = " serde " ) ]
#[ cfg(feature = " serde " ) ]
use serde ::{ Deserialize , Serialize } ;
use serde ::{ Deserialize , Serialize } ;
#[ cfg(feature = " serde " ) ]
pub ( crate ) mod algorithm {
use coset ::iana ::{ Algorithm , EnumI64 } ;
use serde ::{ Deserialize , Serialize } ;
pub ( crate ) fn serialize < S > ( algorithm : & Algorithm , serializer : S ) -> Result < S ::Ok , S ::Error >
where
S : serde ::Serializer ,
{
let i = algorithm . to_i64 ( ) ;
i64 ::serialize ( & i , serializer )
}
pub ( crate ) fn deserialize < ' de , D > ( deserializer : D ) -> Result < Algorithm , D ::Error >
where
D : serde ::Deserializer < ' de > ,
{
let i = i64 ::deserialize ( deserializer ) ? ;
coset ::iana ::Algorithm ::from_i64 ( i ) . ok_or ( serde ::de ::Error ::invalid_value (
serde ::de ::Unexpected ::Signed ( i ) ,
& "an IANA-registered COSE algorithm value" ,
) )
}
}
/// > This dictionary is used to supply additional parameters when
/// > This dictionary is used to supply additional parameters when
/// > creating a new credential.
/// > creating a new credential.
#[ derive(Debug, Clone, Copy, PartialEq, Eq) ]
#[ derive(Debug, Clone, Copy, PartialEq, Eq) ]
@ -19,8 +43,8 @@ pub struct Parameters {
/// > algorithm with which the newly generated credential will
/// > algorithm with which the newly generated credential will
/// > be used, and thus also the type of asymmetric key pair to
/// > be used, and thus also the type of asymmetric key pair to
/// > be generated, e.g., RSA or Elliptic Curve.
/// > be generated, e.g., RSA or Elliptic Curve.
#[ cfg_attr(feature = " serde " , serde(rename = " alg " ))]
#[ cfg_attr(feature = " serde " , serde(rename = " alg " , with = " algorithm " ))]
pub algorithm : algorithms::Signature ,
pub algorithm : coset::iana ::Algorithm ,
}
}
/// > This dictionary identifies a specific public key credential.
/// > This dictionary identifies a specific public key credential.