-
Notifications
You must be signed in to change notification settings - Fork 30
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
Rewrite translated code to use the pcsc
crate
#17
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Nov 25, 2019
Closed
tarcieri
force-pushed
the
pcsc
branch
2 times, most recently
from
November 25, 2019 00:22
6fc9b8c
to
f992391
Compare
This commit contains a "big bang" refactor/rewrite which does the following: - Replaces all `SCard*` FFI calls with the `pcsc` crate, which provides a safe, portable PC/SC API across Windows, macOS, and Linux - Refactors the `util` module into modules representing the various device functions and concepts, e.g. `certificate`, `key`, `mgm` - Replaces all usage of `libc` with `std` functionality, and in many places rewriting functionality to use safe code. - Removes `ykpiv_` from all function names, and `Piv*` from type names. In 20/20 hindsight I wish I had done this commit more incrementally so as to make it easier to review. Que sera sera. However, realistically we need to test all functionality on the device to ensure that it actually works. Going forward I would like to put pretty much all of the current code behind an `untested` cargo feature, and then remove it for each bit of functionality we test.
str4d
reviewed
Nov 25, 2019
str4d
reviewed
Nov 25, 2019
@str4d's suggested fixes Co-Authored-By: str4d <[email protected]>
More of @str4d's suggested changes Co-Authored-By: str4d <[email protected]>
It seems like given we're inside a while loop which also has this conditional, the original code should've been fine, but this change makes it closer to the original C code.
Callers of this function always pad up to `CB_PIN_MAX` with `0xFF`. The logic being changed here was previously identical to the `_verify` function in `ykpiv.c`: https://github.com/Yubico/yubico-piv-tool/blob/8ba243f/lib/ykpiv.c#L1299 ...but @str4d noticed this potentially allows a caller to send an unpadded PIN, which may (or may not) be an issue.
Also the same one @str4d made originally, guess I should've listened! #17 (comment)
...replacing them with `CB_BUF_MAX`. Both constants are 3072, however `CB_BUF_MAX` is what the original code was using. See discussion here: #17 (comment)
Needs to match the original C code: memmove(data, data + 1 + offs, outlen);
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit contains a "big bang" refactor/rewrite which does the following:
SCard*
FFI calls with thepcsc
crate, which provides a safe, portable PC/SC API across Windows, macOS, and Linux: https://github.com/bluetech/pcsc-rustutil
module into modules representing the various device functions and concepts, e.g.certificate
,key
,mgm
libc
withstd
functionality, and in many places rewriting functionality to use safe codeykpiv_
from all function names, andPiv*
from type namesIn 20/20 hindsight I wish I had done this commit more incrementally so as to make it easier to review. Que sera sera.
However, realistically we need to test all functionality on the device to ensure that it actually works. Going forward I would like to put pretty much all of the current code behind an
untested
cargo feature, and then remove it for each bit of functionality we test.