ref: b181dd0b64b99cadf2ea8c2dbd099e1297b93f8f nitrokey-rs/src/lib.rs -rw-r--r-- 21.6 KiB
Merge branch 'nitrokey-sys-v3.6.0' into next

This patch series updates the nitrokey-sys dependency to version 3.6.0
and makes use of the new features.
Support the Librem Key model

This patch adds support for the Librem Key model, a clone of the
Nitrokey Pro.  Functionally, it is identical to the Nitrokey Pro, but it
has a different USB vendor and product ID.

With this patch, we also change the Display implementation for Model to
return the complete name of the model, i. e. Nitrokey Pro, Nitrokey
Storage or Librem Key.
Export the FirmwareVersion struct

This patch adds the FirmwareVersion struct to the re-exports in lib.rs.
Previosuly, nitrokey users where able to access FirmwareVersion values
as part of the Status struct and the Device::get_firmware_version method
but could not see its definition.
Merge branch 'poison-error' into next

This patch series refactors the Error enum and ensures that it is Send,
Sync and 'static.  This makes sure that it is compatible with the anyhow
crate.  To achieve this, we drop the RandError variant and remove the
sync::PoisonError value from the PoisonError variant.
Remove sync::PoisonError from Error::PoisonError

Previously, the Error::PoisonError contained the sync::PoisonError that
caused the error.  This is problematic as sync::PoisonError does not
implement Send, making it impossible to use the Error enum with the
anyhow crate.  At the same time, storing the sync::PoisonError is not
very useful.  If a user wants to access the poisoned lock, they can call
the force_take function.

Therefore we remove the sync::PoisonError value from the Error::
PoisonError variant.  This also allows us to simplify the
From<sync::PoisonError<…>> and From<sync::TryLockError<…>>
implementations as we no longer need to know the type of the mutex that
caused the error.

For more information, see this thread:
Remove unused imports
Represent serial numbers using SerialNumber struct

In a previous commit, we changed the serial number representation from a
string to an integer.  This made it easier to compare serial numbers,
but also introduced new problems:
- Serial numbers should be formatted consistently, for example as
  "{:#010x}".  It is hard to ensure this for an integer value.
- The format of the serial number may be subject to change.  Users
  should not rely too much on the u32 representation.

Therefore we introduce a new SerialNumber struct that represents a
serial number.  Currently it only stores a u32 value.  The following
traits and functions can be used to access its value:
- FromStr for string parsing
- ToString/Display for string formatting
- as_u32 to access the underlying integer value
Merge branch 'release-0.5.0'
Document background operations

This patch adds a new section about background operations to the crate
Add the get_operation_status function to the Storage struct

This patch adds support for the NK_get_progress_bar_value function:  It
adds the OperationStatus enum that stores the return value of this
command and adds the get_operation_status function to the Storage struct
that executes the command.
Add support for the GET_STATUS command

This patch adds support for the GET_STATUS command that returns the
status information common to all Nitrokey devices.  It can be accessed
using the Device::get_status function and is stored in a Status struct.

Due to a bug in the Storage firmware [0], the GET_STATUS command returns
wrong firmware versions and serial numbers.  Until this is fixed in
libnitrokey [1], we have to manually execute the GET_DEVICE_STATUS
command to fix these values for the Nitrokey Storage.

Also, this leads to a name clash with the existing Storage::get_status
function, which will be renamed in an upcoming patch.

[0] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/96
[1] https://github.com/Nitrokey/libnitrokey/issues/166
Merge branch 'connect_path' into next

This patch series adds the list_devices function that returns a list of
available Nitrokey devices and the Manager::connect_path function that
connects to one of the available devices.
Add the connect_path function to the Manager struct

This patch adds the connect_path function to the Manager struct that
uses NK_connect_with_path to connect to a Nitrokey device at a given USB
Add list_devices function

This patch adds support for libnitrokey’s NK_list_devices function by
introducing the top-level list_devices function.  It returns a vector of
DeviceInfo structs with information about all connected Nitrokey
Add the DeviceInfo struct

In the next patch, we will add support for the NK_list_devices functions
that returns a list of NK_device_info structs with information about the
connected devices.  This patch introduces the DeviceInfo struct that
holds the information returned by NK_list_devices and that can be
created from a NK_device_info struct.
Implement conversion traits for Model and NK_device_model

A nitrokey_sys::NK_device_model (= u32) value may correspond to a
nitrokey::Model, and vice versa.  This patch adds the appropriate From
and TryFrom implementations.
Merge branch 'release-0.4.0'
Simplify doc tests with results

Since Rust 1.34.0, we no longer need a `fn main` comment in doc tests
that return results.  It is sufficient to have an `Ok` return value with
type annotations.
Add force_take function to ignore poisoned cache

The take and take_blocking functions return a PoisonError if the cache
is poisoned, i. e. if a thread panicked while holding the manager.  This
is a sensible default behaviour, but for example during testing, one
might want to ignore the poisoned cache.  This patch adds the force_take
function that unwraps the PoisonError and returns the cached Manager
even if the cache was poisoned.
Remove allow(deprecated) attribute for in lib.rs

During the connection manager refactoring, we temporarily used
deprecated methods.  This is no longer the case, so we can remove the
allow(deprecated) attribute.