Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review corrections for KeepassXC support #71

Closed
wants to merge 7 commits into from

Conversation

szszszsz
Copy link
Member

@szszszsz szszszsz commented May 17, 2023

Review corrections for KeepassXC support #64.

In the end the unpadding crate was used without modifications - it does not matter in this case, as payload bigger than 63 bytes can't be used anyway.

szszszsz added 4 commits May 17, 2023 19:05
This PKCS#7 padding version is possibly incompatible with Yubikey's PKCS#7 version, as it expects
the last byte to always be the padding byte value. See KeepassXC implementation comments
for the details.
Everything works with the challenge length up to 63 bytes though, and YK implementation
would not handle more anyway, hence accepting this potential incompatibility.
@szszszsz szszszsz changed the base branch from main to 68-list-metadata May 17, 2023 17:41
Copy link
Collaborator

@sosthene-nitrokey sosthene-nitrokey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look to me like the Kind/Algorithm matching is actually checked?

CredentialFlat::try_from does not appear to check the max lengh of the secret, or that the algorithm is Sha1:

CredentialData::HmacData(data) => {
    cred.kind = Kind::Hmac;
    cred.secret = ShortData::from_slice(data.secret)?;
    cred.algorithm = data.algorithm;
}

src/authenticator.rs Outdated Show resolved Hide resolved
src/command.rs Show resolved Hide resolved
@szszszsz
Copy link
Member Author

CredentialFlat is meant to be a simple struct for data serialization. All checks should be done on construction in the upstream. The check for the secret length and Algo kind is done here:

pub fn try_from(algorithm: oath::Algorithm, secret: &'l [u8]) -> Result<Self, ()> {
const SHA1_SECRET_EXPECTED_SIZE: usize = 20;
// Currently only SHA1 is supported, hence the expected SECRET length
if !(secret.len() == SHA1_SECRET_EXPECTED_SIZE && algorithm == oath::Algorithm::Sha1) {
return Err(());
}
Ok(Self { algorithm, secret })
}
}
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub struct PasswordSafeData<'l> {
pub login: &'l [u8],
pub password: &'l [u8],
pub metadata: &'l [u8],
}
impl<'l> PasswordSafeData<'l> {
pub fn non_empty(&self) -> bool {
!self.login.is_empty() || !self.password.is_empty() || !self.metadata.is_empty()
}

@sosthene-nitrokey
Copy link
Collaborator

Ok, I missed it sorry.

@szszszsz szszszsz closed this in 76b9367 May 24, 2023
@szszszsz szszszsz deleted the 64-review-fixes branch May 25, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants