aboutsummaryrefslogtreecommitdiff
path: root/src/otp.rs
Commit message (Collapse)AuthorAge
* Remove unused importsRobin Krahl2020-07-08
|
* Update documentation for Manager refactoringRobin Krahl2019-07-09
| | | | | | This patch updates the documentation to reflect the latest changes to connection handling. It also updates the doc tests to prefer the new methods over the old ones.
* Revert "Refactor User and Admin to use a mutable reference"Robin Krahl2019-02-05
| | | | This reverts commit 0972bbe82623c3d9649b6023d8f50d304aa0cde6.
* Refactor User and Admin to use a mutable referenceRobin Krahl2019-02-02
| | | | | | | | | | | | In the initial nitrokey-rs implementation, the Admin and the User struct take the Device by value to make sure that the user cannot initiate a second authentication while this first is still active (which would invalidate the temporary password). Now we realized that this is not necessary – taking a mutable reference has the same effect, but leads to a much cleaner API. This patch refactors the Admin and User structs – and all dependent code – to use a mutable reference instead of a Device value.
* Require mutable reference if method changes device stateRobin Krahl2019-02-02
| | | | | | | | | | | | Previously, all methods that access a Nitrokey device took a reference to the device as input. This method changes methods that change the device state to require a mutable reference instead. In most case, this is straightforward as the method writes data to the device (for example write_config or change_user_pin). But there are two edge cases: - Authenticating with a PIN changes the device state as it may decrease the PIN retry counter if the authentication fails. - Generating an HOTP code changes the device state as it increases the HOTP counter.
* Prefer eprintln over println for error messagesRobin Krahl2019-01-28
|
* Add license and copyright informationRobin Krahl2019-01-23
| | | | | | | This patch adds license and copyright information to all files to make nitrokey-rs compliant with the REUSE practices [0]. [0] https://reuse.software/practices/2.0/
* Refactor and clean up all codeRobin Krahl2019-01-23
| | | | | | | This includes: - using idiomatic Rust - limiting the scope of unsafe blocks - simplifying code
* Refactor library errors into LibraryError enumRobin Krahl2019-01-20
| | | | | | Previously, library errors were part of the CommandError enum. As command errors and library errors are two different error types, they should be split into two enums.
* Return Error instead of CommandErrorRobin Krahl2019-01-20
| | | | | | | | | | This patch changes all public functions to return the Error enum instead of the CommandError enum. This breaks the tests which will be fixed with the next patch. This patch also adds a placeholder variant Error::CommandError and a placeholder enum CommandError to make the transition to a new nitrokey-test version easier.
* Move util::CommandError to the new error moduleRobin Krahl2019-01-20
| | | | This prepares the refactoring of util::CommandError into multiple enums.
* Fix example for GenerateOtp::get_totp_codeRobin Krahl2019-01-05
|
* Add force argument to ConfigureOtp::set_timeRobin Krahl2019-01-02
| | | | | | | | This patch adds the force argument to the set_time method in the ConfigureOtp trait that allows the user to choose whether jumps to the past are allowed when updating the time. It is implemented by using the NK_totp_set_time_soft function. Previously, jumps where unconditionally allowed.
* Derive Clone and Copy for CommandError, LogLevel, OtpModeRobin Krahl2018-12-30
| | | | | | As these three enums are scalar values, this patch derives the Clone and Copy traits for them. This should avoid unnecessary allocations and reduce the memory footprint.
* Use the crate:: path qualifier for modulesRobin Krahl2018-12-16
| | | | | | This patch changes use declarations for modules within this crate to use the crate:: path qualifier. This will be mandatory in Rust edition 2018.
* Use {} instead of {:?} where possibleRobin Krahl2018-06-07
| | | | | Most notably, for command errors, this will print a human-readable error message instead of just the name of the enum.
* Implement easier CString creationRobin Krahl2018-06-07
| | | | | | The new get_cstring method in util returns a Result<CString, CommandError>, so mast callers can just use the ? operator to unwrap the result instead of cumbersome unwrapping code.
* Use Result<(), CommandError> instead of CommandStatusRobin Krahl2018-06-07
| | | | | | The Result enum is more idiomatic and easier to use than our custom CommandStatus enum with the same structure. This is especially true for the try operator ?.
* Move set_time from Device to GenerateOtpRobin Krahl2018-05-28
| | | | | | The set_time operation is only used with TOTP generation. Therefore it makes more sense to have it in the GenerateOtp trait than in the Device trait.
* Rewrap documentation comments to 100 charactersRobin Krahl2018-05-28
|
* Move the authenticate methods to a new Authenticate traitRobin Krahl2018-05-22
|
* Add an example for setting the current timeRobin Krahl2018-05-22
| | | | | The example uses the chrono crate and can therefore not be executed, but at least it shows how to set the Nitrokey device to the current time.
* Improve OtpSlotData constructor / builderRobin Krahl2018-05-22
| | | | | Firstly, use Into<String> instead of String::from(&str). Secondly, add methods to set the two arguments not set in the constructor.
* Restructure code by functionalityRobin Krahl2018-05-22
In future versions, we want to support not only the Nitrokey Pro, but also the Nitrokey Storage. This requires a better code layout. This patch introduces two main changes: First, the OTP-specific methods are moved from the Device trait and the AdminAuthenticatedDevice struct to the functionality-based traits ConfigureOtp and GenerateOtp. This will hopefully make it easier to integrate the Nitrokey Storage. Secondly, the code is split into separate modules. These modules are currently all private and re-exported in the lib module, but we can consider making them public in the future.