Skip to content

Commit

Permalink
fixup! Reduce ID length for new credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-nitrokey committed Jul 13, 2023
1 parent 4a9ca5c commit b61d477
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ pub struct CredentialData {
// newer app versions, we strip unnecessary fields to generate a shorter credential ID. To
// make sure that the credential ID does not change for an existing credential, this field is
// used as a marker for new credentials.
#[serde(default)]
use_short_id: bool,
#[serde(skip_serializing_if = "Option::is_none")]
use_short_id: Option<bool>,
}

// TODO: figure out sizes
Expand Down Expand Up @@ -342,7 +342,7 @@ impl FullCredential {
hmac_secret,
cred_protect,

use_short_id: true,
use_short_id: Some(true),
};

FullCredential {
Expand Down Expand Up @@ -379,7 +379,7 @@ impl FullCredential {
.to_bytes()
.map_err(|_| Error::Other)?
};
if self.use_short_id {
if self.use_short_id.unwrap_or_default() {
StrippedCredential::from(self).id(trussed, key_encryption_key, &rp_id_hash)
} else {
let stripped_credential = self.strip();
Expand Down Expand Up @@ -509,7 +509,7 @@ mod test {
key: Key::WrappedKey(Bytes::from_slice(&[1, 2, 3]).unwrap()),
hmac_secret: Some(false),
cred_protect: None,
use_short_id: true,
use_short_id: Some(true),
}
}

Expand Down Expand Up @@ -589,7 +589,7 @@ mod test {
key: Key::WrappedKey(random_bytes()),
hmac_secret: Some(false),
cred_protect: None,
use_short_id: true,
use_short_id: Some(true),
}
}

Expand Down

0 comments on commit b61d477

Please sign in to comment.