-
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
Convert SlotId and AlgorithmId into enums #44
Conversation
This matches the C code behaviour.
3DES also has an algorithm ID, but it is completely disjoint from the key algorithms, and can be handled separately later.
src/yubikey.rs
Outdated
// TODO: Decide whether to add it or not. | ||
// match key { | ||
// SlotId::CardManagement => return Err(Error::KeyError), | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should exclude it, because I think it is disjoint from the key algorithms and instead is tied to 3DES.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, go ahead and delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/key.rs
Outdated
|
||
fn try_from(value: u8) -> Result<Self, Self::Error> { | ||
match value { | ||
YKPIV_KEY_RETIRED1 => Ok(RetiredSlotId::R1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places (e.g. StatusWords
, and throughout the yubihsm
crate) I've eliminated these constants in favor of using the literal codes for these conversions between the u8
representation and the enum variants.
I guess it helps statically assert they're the same for the same labels, since you have to write them twice.
I really like the idea of getting rid of a consts.rs
eventually (there's nothing like it in the yubihsm
crate)
We will handle the CardManagement slot separately.
Also includes a minor fix for
Key::list
.