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

Fix PIN length check #64

Open
robin-nitrokey opened this issue Feb 29, 2024 · 0 comments
Open

Fix PIN length check #64

robin-nitrokey opened this issue Feb 29, 2024 · 0 comments

Comments

@robin-nitrokey
Copy link
Member

@sosthene-nitrokey in #62 (comment):

Minor issue of spec compliance:

Minimum PIN Length: 4 code points.

In decrypt_pin_check_length we check 4 bytes, not 4 code points. The max is still 63 bytes, so the check should be:

        let pin_length = pin.iter().position(|&b| b == b'\0').unwrap_or(pin.len());
        let pin_data = &pin[..pin_length];
        let pin_utf8 = core::str::from_utf8(pin_data)?;
        let pin_len_codepoints = pin_utf8.chars().count();

        if pin_len_codepoints < 4 || pin_length > 63{
            return Err(Error::PinPolicyViolation);
        }
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

No branches or pull requests

1 participant