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

Use new PWS access API #138

Closed
wants to merge 2 commits into from
Closed

Conversation

robinkrahl
Copy link
Collaborator

In previous versions of nitrokey-rs, the getters for the name, login and
password fields of a PWS slot would return an error for empty strings as
libnitrokey uses empty strings to indicate unprogrammed slots. But as
the user might have deliberately specified an empty value, nitrokey-rs
v0.9.0 introduces a new PWS API that makes it possible to distinguish
unprogrammed slots and empty values.

This patch updates the nitrokey-rs dependency and refactors the pws
status and pws get commands to use the new PWS API.

Fixes #133.

To discuss:

  • Do we want to support writing completely empty PWS slots, i. e. no name, login or password?

In previous versions of nitrokey-rs, the getters for the name, login and
password fields of a PWS slot would return an error for empty strings as
libnitrokey uses empty strings to indicate unprogrammed slots.  But as
the user might have deliberately specified an empty value, nitrokey-rs
v0.9.0 introduces a new PWS API that makes it possible to distinguish
unprogrammed slots and empty values.

This patch updates the nitrokey-rs dependency and refactors the pws
status and pws get commands to use the new PWS API.
@robinkrahl robinkrahl requested a review from d-e-s-o March 26, 2021 16:10
@robinkrahl
Copy link
Collaborator Author

@d-e-s-o Could you please review the changes? If you don’t have any objections, I’ll release a new nitrokey-rs version soon and then convert this draft into a PR.

@d-e-s-o
Copy link
Owner

d-e-s-o commented Mar 27, 2021

Thanks for the pull request, Robin! I'll take a closer look hopefully tomorrow morning and will hopefully have an answer to your question by then.

@d-e-s-o d-e-s-o self-assigned this Mar 27, 2021
Copy link
Owner

@d-e-s-o d-e-s-o left a comment

Choose a reason for hiding this comment

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

Looks great to me and like the right step. I'd think we can just support setting everything empty like you added a test case for. As long as nothing bad will happen, the UI seems reasonably clear to me.

src/commands.rs Show resolved Hide resolved
let slots = pws
.get_slot_status()
.context("Failed to read PWS slot status")?;
let slots = pws.get_slots().context("Failed to read PWS slot status")?;
Copy link
Owner

Choose a reason for hiding this comment

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

Consider adjusting the error message slightly to "Failed to read PWS slots".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I’m not sure about that. Internally, we still call the GET_PW_SAFE_SLOT_STATUS command. “Failed to read PWS slots” sounds as if we tried to read the slot values.

@robinkrahl robinkrahl marked this pull request as ready for review March 28, 2021 09:22
@robinkrahl
Copy link
Collaborator Author

Thanks for the review! I’ve released nitrokey-rs v0.9.0 and updated the PR.

@d-e-s-o
Copy link
Owner

d-e-s-o commented Mar 28, 2021

I merged the change into devel. Thanks for fixing up this issue!

@d-e-s-o d-e-s-o closed this Mar 28, 2021
@robinkrahl robinkrahl deleted the pws-slots branch April 9, 2021 18:09
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.

None yet

2 participants