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

Make more items public #36

Merged
merged 4 commits into from
Nov 13, 2023
Merged

Make more items public #36

merged 4 commits into from
Nov 13, 2023

Conversation

sosthene-nitrokey
Copy link
Contributor

This PR makes more items public to enable other backends to implement the extension interface.
Motivated by the se050 backend, so this will stay as draft until the backend implements the trussed-auth functionality to avoid having many small PR for similar issues.

@sosthene-nitrokey sosthene-nitrokey marked this pull request as draft August 22, 2023 14:48
This is useful for factory resets in other implementations that might need
to parse all the Pin data and don't use the delete_all filestore methods.
src/lib.rs Outdated
Comment on lines 151 to 169
let msb = match path[0] {
b'0' => 0x0,
b'1' => 0x1,
b'2' => 0x2,
b'3' => 0x3,
b'4' => 0x4,
b'5' => 0x5,
b'6' => 0x6,
b'7' => 0x7,
b'8' => 0x8,
b'9' => 0x9,
b'a' => 0xa,
b'b' => 0xb,
b'c' => 0xc,
b'd' => 0xd,
b'e' => 0xe,
b'f' => 0xf,
_ => return Err(PinIdFromStrError),
};
Copy link
Member

Choose a reason for hiding this comment

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

If we are this verbose, can we use a helper function so that we only have to do it once? Or maybe just use something like this:

fn parse_ascii_hex(a: u8) -> Option<u8> {
    match a {
        b'0'..=b'9' => Some(a - b'0'),
        b'a'..=b'f' => Some(a - b'a' + 0xA),
        _ => None,
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This prompted me to look for a std solution and actually u8::from_str_radix is available in core so let's use that instead.

@sosthene-nitrokey sosthene-nitrokey merged commit 9839e90 into main Nov 13, 2023
2 checks passed
@sosthene-nitrokey sosthene-nitrokey deleted the public-items branch November 13, 2023 10:30
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