Skip to content

Commit

Permalink
Add largeBlobKey to stripped credential
Browse files Browse the repository at this point in the history
If a resident credential is passed in the allowlist, we don’t
deserialize the full credential.  This means that we previously did not
have access to the largeBlobKey in that case.  Therefore, this patch
adds the largeBlobKey to the StrippedCredential so that we can always
access it.

The downside is that this inceases the size of the credential ID.  So a
better alternative would be to load the full credential from the
filesystem instead.
  • Loading branch information
robin-nitrokey committed Nov 28, 2023
1 parent aa9bb35 commit 019a5d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ pub struct StrippedCredential {
pub hmac_secret: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cred_protect: Option<CredentialProtectionPolicy>,
// TODO: HACK -- remove
#[serde(skip_serializing_if = "Option::is_none")]
pub large_blob_key: Option<Bytes<32>>,
}

impl StrippedCredential {
Expand Down Expand Up @@ -484,6 +487,7 @@ impl From<&FullCredential> for StrippedCredential {
nonce: credential.nonce.clone(),
hmac_secret: credential.data.hmac_secret,
cred_protect: credential.data.cred_protect,
large_blob_key: credential.data.large_blob_key.clone(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ctap1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl<UP: UserPresence, T: TrussedRequirements> Authenticator for crate::Authenti
nonce,
hmac_secret: None,
cred_protect: None,
large_blob_key: None,
};

// info!("made credential {:?}", &credential);
Expand Down
12 changes: 8 additions & 4 deletions src/ctap2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {

// User with empty IDs are ignored for compatibility
if is_rk {
if let Credential::Full(credential) = credential {
if let Credential::Full(credential) = &credential {
if !credential.user.id.is_empty() {
let mut user = credential.user.clone();
// User identifiable information (name, DisplayName, icon) MUST not
Expand All @@ -1665,10 +1665,14 @@ impl<UP: UserPresence, T: TrussedRequirements> crate::Authenticator<UP, T> {
}
response.user = Some(user);
}
}

if large_blob_key_requested {
response.large_blob_key = credential.large_blob_key.clone();
}
if large_blob_key_requested {
debug!("Sending largeBlobKey in getAssertion");
response.large_blob_key = match credential {
Credential::Stripped(stripped) => stripped.large_blob_key,
Credential::Full(full) => full.data.large_blob_key,
};
}
}

Expand Down

0 comments on commit 019a5d1

Please sign in to comment.