| Commit message (Collapse) | Author | Age |
|
|
|
|
|
| |
Newer Rust versions support integration tests in a top-level tests
directory. This patch refactors the existing unit tests into
integration tests.
|
|
|
|
|
|
|
| |
With Rust edition 2018, it is no longer necessary to declare
dependencies in the code using `extern crate`. Therefore, this patch
removes these declarations and replaces them with `use` declarations if
necessary.
|
|
|
|
|
|
| |
This patch changes use declarations for modules within this crate to use
the crate:: path qualifier. This will be mandatory in Rust edition
2018.
|
|
|
|
|
| |
This patch changes the type of trait objects from `Trait` to `dyn
Trait`. This fixes bare-trait-object compiler warnings.
|
|
|
|
|
| |
This patch makes hidden life time parameters explicit to fix
elided-lifetime-in-path compiler warnings.
|
| |
|
|
|
|
|
|
|
|
| |
This patch enables the following compiler warnings:
- missing_docs for public symbols without documentation
- rust_2018_compatibility for Rust edition 2018 support
- rust_2018_idioms for Rust edition 2018 support
- unused for different types of unused code
|
| |
|
| |
|
|
|
|
|
|
| |
This patch adds a `get_status` method to the `Storage` structure. The
returned structure `StorageStatus` is based on the structure provided by
libnitrokey.
|
|
|
|
|
|
|
| |
As connect() now returns DeviceWrappers of the correct type, this patch
adds an example to the DeviceWrapper documentation that shows how to use
type conditions, i. e. how to execute a command only for Nitrokey
Storage devices.
|
|
|
|
|
|
| |
This patch fixes the generic connect() method to return a DeviceWrapper
of the correct type. This is enabled by the NK_get_device_model()
method introduced in libnitrokey v3.4.
|
|
|
|
|
|
|
|
| |
Old libnitrokey versions could return pointers to both statically and
dynamically allocated strings for functions that return strings. This
has been fixed in libnitrokey commit 7a8550d (included in v3.4). This
patch removes the old workaround and always frees the return value of
functions returning a string pointer.
|
|
|
|
|
| |
Most notably, for command errors, this will print a human-readable error
message instead of just the name of the enum.
|
|
|
|
|
|
| |
The std::fmt::Display implementation provides a human-readable error
message for a CommandError. It is intended to be used in error
messages displayed to the user.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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 ?.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When enabled, the password safe can be used without authentication. The
lock device can be used to lock the password safe. Currently,
PasswordSafe::drop calls this command to make sure that other
applications cannot access the password safe without authentication.
On the Nitrokey Storage, locking the device may also disable the
encrypted or hidden volume. As using the password safe should not have
side effects on the storage volumes, this patch removes the call to the
lock device command from the Drop implementation. Instead, the user
should call this method after making sure that it does not have side
effects.
A feature request for a command that only locks the password safe
without side effects is submitted to the Nitrokey Storage firmware
repository:
https://github.com/Nitrokey/nitrokey-storage-firmware/issues/65
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds support for the commands to enable or disable the
encrypted volume on the Nitrokey Storage. To test these commands, the
output of lsblk is parsed for the device model “Nitrokey Storage”. This
is not perfect but seems to be the best solution for automated testing.
As the effect of enabling and disabling volumes is not immediate, a
delay of two seconds is added to the tests before checking lsblk. This
is sufficient on my machine, yet it would be better to have a portable
version of this check.
This patch also adds a lock method to Device that executes the
lock_device command. This command was previously only used to close the
password safe. On the Nitrokey Storage, it also disables the encrypted
and hidden volume.
|
|
|
|
|
|
|
|
| |
The current Nitrokey Storage firmware does not support timestamps that
do not fit into an unsigned integer. Therefore, the tests totp_pin and
totp_no_pin are restricted to 32-bit timestamps. New tests totp_pin_64
and totp_no_pin_64 are introduced for 64-bit timestamps. These are
expected to panic for the Nitrokey Storage.
|
|
|
|
|
|
| |
The firmware version is too volatile to restrict it to certain values.
Therefore, we only check that there is a non-zero version number instead
of expecting specific values.
|
| |
|
|
|
|
|
|
| |
By calling NK_lock_device when dropping a PasswordSafe instance, we can
make sure that the password safe cannot be reused without
authentication.
|
|
|
|
|
|
|
|
|
| |
Instead of wrapping an owned Device instance, PasswordSafe now only
requires a reference to a Device. The lifetime parameter makes sure
that the device lives at least as long as the password safe. Using a
reference instead of an owned device allows us to implement Drop on
PasswordSafe to make sure that the password safe is disabled once it is
destructed.
|
|
|
|
|
|
|
|
| |
While 30 seconds is the default time step for TOTP, arbitrary values are
possible. Yet the RFC does only provide test cases for the default time
window. This patch adds tests where these test cases are applied for a
time window of 60 seconds (if both the current time and the time window
double, the resulting TOTP code is the same).
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Previously, the Authenticate implementation for DeviceWrapper paniced if
the wrapped device is a Nitrokey Storage. This patch implements
authentication for wrapped Storage devices.
|
|
|
|
|
| |
Authenticate is supported by both the Nitrokey Pro and the Nitrokey
Storage. Therefore Device should extend it.
|
| |
|
|
|
|
|
|
|
|
|
| |
A password safe (PWS) stores names, logins and passwords in slots. PWS
are supported both by the Nitrokey Pro and the Nitrokey Storage. They
are implemented as a struct wrapping a device as the device may not be
disconnected while the password safe is alive. The creation of a
password safe is handled by the GetPasswordSafe trait, implemented by
DeviceWrapper, Pro and Storage.
|
|
|
|
|
| |
This patch adds the Storage struct and the test-storage feature. It
also enables all currently supported Pro commands for the Storage.
|
| |
|
| |
|
|
|
|
|
|
|
| |
For DeviceWrapper, the traits GenerateOtp and Device are now directly
implemented instead of complicated template implementations. For User
and Admin, the wrapper implementations are replaced with an
implementation of the Deref trait for easier access.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
The defnition of the ConfigureOtp trait already contains documentation
comments, therefore the comments in the implementation for User<T> can
be removed.
|
| |
|
|
|
|
|
|
|
| |
DeviceWrapper abstracts over the supported devices. It implements the
traits that are implemented by all supported devices. The previous
UnauthenticatedDevice is renamed to Pro to prepare Storage support.
connect_model is moved to Pro::connect.
|
| |
|
|
|
|
|
|
| |
Now, the documentation clearly states the purpose of each log level.
Also, the documentation for set_log_level is corrected: libnitrokey
always prints to stderr.
|
|
|
|
|
|
|
| |
Since libnitrokey v3.3, libnitrokey no long has debugging output enabled
per default. Therefore, a corresponding note can be removed from the
crate documentation and the set_debug calls can be removed from the
tests.
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Firstly, use Into<String> instead of String::from(&str). Secondly, add
methods to set the two arguments not set in the constructor.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
| |
As Drop is only implemented for UnauthenticatedDevice, it is relevant to
test whether it also works if we work on authenticated devices.
|