~ireas/nitrokey-rs

ref: db48656015d958594b4818582439f7515359cd60 nitrokey-rs/CHANGELOG.md -rw-r--r-- 9.2 KiB
Refactor PWS slot access

Previously, the PasswordSafe::get_slot_{name,login,password} methods
would return a SlotNotProgrammed error if the libnitrokey functions
return an empty string.  This was because libnitrokey does not return an
error code when accessing an unprogrammed slot.  But this was ambigous
as the slot values might actually be empty.

With this patch, we deprecate the existing methods for accessing the
slot data.  Instead, we introduce the PasswordSlot struct that can be
used to access the (empty or non-empty) values of programmed slots.
Instances of this struct can be obtained using the get_slots (all
programmed slots), get_slot (one slot that is checked to be programmed)
and get_slot_unchecked (one slot without checking whether it is
programmed) methods.

See this discussion for more information:
	https://github.com/d-e-s-o/nitrocli/issues/133
Merge branch 'release-v0.8.0' into next
Release v0.8.0

This minor release updates the nitrokey-sys-rs/libnitrokey dependency to
v3.6.0 and adds support for the Librem model.
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.
Add get_struct utility function

This patch adds the internal get_struct utility function that can be
used for querying a struct with a libnitrokey function that uses an
output parameter.  Instead of this:

    let mut out = R::default();
    get_command_result(op(&mut out))?;
    Ok(out.into())

We can now write this:

    get_struct(|out| op(out))
Use Default::default for nitrokey-sys structs

Since version 3.6.0, nitrokey-sys derives the Default trait for all
structs.  This allows us to simplify code snippets where we have to
construct an empty struct that is then filled by nitrokey-sys.
Use NK_config struct for configuration handling

Previously, the Nitrokey configuration was represented as an array in
libnitrokey.  libnitrokey 3.6 added the NK_config struct and the
NK_{read,write}_config_struct for type-safe configuration handling.
This patch replaces the old functions with the new versions using the
NK_config struct.  This makes the RawConfig struct obsolete as it is
identical to NK_config.
Correctly free pointer to PWS status

The NK_get_password_safe_slot_status function returns a pointer to an
array that has been allocated using new[].  As we only have access to
libc’s free function, we could not free this pointer properly (using
delete[]).  libnitrokey 3.6 added the NK_free_password_safe_slot_status
function which we now use to properly free the pointer.
Use NK_device_serial_number_as_u32

Previously, we called the NK_device_serial_number function in
Device::get_serial which returned a string that we had to parse into an
unsigned integer to use with the SerialNumber struct.  libnitrokey 3.6
introduced the NK_device_serial_number_as_u32 function that returns the
serial number as an unsigned integer.  This patch replaces the call to
NK_device_serial_number with this new function.
Update nitrokey-sys to v3.6.0

This patch updates the nitrokey-sys dependency to version 3.6.0, which
links to libnitrokey 3.6.
Rename *lock fields of the Config struct

libnitrokey calls the configuration fields that set bindings for the Num
Lock, Caps Lock and Scroll Lock keys numlock, capslock, scrolllock.  Due
to a typo, scrolllock with three l was renamed to scrollock with two l
in nitrokey-rs.

To make the field names easier to read (and type) and consistent with
the typical names for these keys, this patch changes them to num_lock,
caps_lock and scroll_lock.  In the doc comments, we now use the spelling
“Num Lock”, “Caps Lock” and “Scroll Lock”.
Bump the MSRV to 1.40.0

In a previous commit, we used the non_exhaustive attribute to mark some
enums as non-exhaustive.  This attribute was stabilized in Rust version
1.40.0, so we have to increase our minimum supported Rust version.
Make *Error, Model, DeviceWrapper non-exhaustive

Previously, all enums defined by the nitrokey crate were exhaustive.
This means that adding new variants to these enums is a breaking change.
To make it possible to add new features to nitrokey-rs without breaking
compatibility, this patch marks the Error, CommandError,
CommunicationError, LibraryError, Model and DeviceWrapper enums as
non-exhaustive.
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 'release-v0.7.1' into next
Release v0.7.1

This patch release contains a minor change to the Error enum so that
error handling frameworks like anyhow don’t produce redundant error
messages.
Remove custom source implementation for Error

This patch removes the custom implementation of the source method of the
std::error::Error trait for the error::Error type.  This means that the
default implementation is used that always returns None.  The reason for
this change is that we already print the error message of the source
error in the Display implementation.  This leads to a duplicated error
message if both Display and source are checked, for example with
anyhow’s error formatting.

See this thread for more information:
	https://lists.sr.ht/~ireas/nitrokey-rs-dev/%3C6e0b4dc8-9059-a113-e98e-b49e52818c75%40posteo.net%3E
Merge branch 'release-0.7.0' into next
Release v0.7.0

This release changes the Error enum to implement Send, Sync and 'static
for compatibility with error handling crates like anyhow.
Next