From a0bd1c9e018597c870ce9c22e7601fd6eb8d2bdd Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Tue, 16 May 2023 16:23:34 -0400 Subject: [PATCH] fido-common: De/serialize credential::public_key::UserEntity::id as bytes Uses serde_with to serialize and deseriailze the UserEntity::id field as a byte string instead of a sequence (array) of bytes. --- crates/fido-common/src/credential/public_key.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/fido-common/src/credential/public_key.rs b/crates/fido-common/src/credential/public_key.rs index 06f73f8..75b2699 100644 --- a/crates/fido-common/src/credential/public_key.rs +++ b/crates/fido-common/src/credential/public_key.rs @@ -33,6 +33,7 @@ pub(crate) mod algorithm { /// > This dictionary is used to supply additional parameters when /// > creating a new credential. +#[cfg_eval] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Parameters { @@ -79,9 +80,12 @@ pub struct Descriptor { /// > account to which the new public key credential will be associated at /// > the RP. /// Due to deprecation, the `icon` URL is omitted. See . -#[derive(Debug)] +#[cfg_eval] +#[derive(Debug, Clone)] #[cfg_attr( feature = "serde", + serde_as, + skip_serializing_none, derive(Serialize, Deserialize), serde(rename_all = "camelCase") )] @@ -97,6 +101,8 @@ pub struct UserEntity { // // WebAuthn says that "The user handle MUST NOT be empty." To maximimize compatibility, the // definition from the CTAP specs is used. + // Bounds: [0, 64] bytes + #[cfg_attr(feature = "serde", serde_as(as = "Bytes"))] pub id: Vec, /// > a human-palatable identifier for a user account. It is intended /// > only for display, i.e., aiding the user in determining the