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

Convert SlotId and AlgorithmId into enums #44

Merged
merged 5 commits into from
Nov 30, 2019

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Nov 30, 2019

Also includes a minor fix for Key::list.

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),
// }
Copy link
Contributor Author

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.

Copy link
Collaborator

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

Copy link
Contributor Author

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),
Copy link
Collaborator

@tarcieri tarcieri Nov 30, 2019

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.
@tarcieri tarcieri merged commit 2bdeca0 into iqlusioninc:develop Nov 30, 2019
@str4d str4d deleted the more-enums branch November 30, 2019 22:29
@tarcieri tarcieri mentioned this pull request Dec 2, 2019
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