aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/commands.rs
Commit message (Collapse)AuthorAge
...
* Refactor the pinentry call into new helper functionsDaniel Mueller2018-12-24
| | | | | | | | | | | | | | | | | Currently, `open` directly calls the `pinentry` module and loops until the user entered a correct passphrase or the retry limit is reached. This patch moves the pinentry call and the loop into the `try_with_passphrase_and_data` function. This function queries a passphrase of a given type and executes a function with that passphrase. This function has a data argument and may return data that is passed to the next call of the function (if it failed). This data-passing mechanism is required for the `nitrokey` authentication functions: These functions take ownership of the device and either return an authenticated device after successful authentication, or an error including the unauthenticated device if the authentication failed. This patch enables the usage of these functions in future patches.
* Return UTF-8 error when handling the passphraseRobin Krahl2018-12-23
| | | | | | | Currently, invalid UTF-8 code points in the passphrase returned by pinentry are replaced with replacement characters by `String::from_utf8_lossy`. This patch changes the code to use `String::from_utf8` and returns an UTF-8 error if encountered.
* Factor out new commands.rs fileDaniel Mueller2018-12-20
In order to prepare for the new argument parsing support based on the argparse crate, this change factors out the existing code used for responding to commands in a new file, commands.rs. No semantic change is introduced.