Skip to content

Commit

Permalink
Support Librem Key
Browse files Browse the repository at this point in the history
This patch adds the librem device model for the Librem Key.
  • Loading branch information
robinkrahl authored and d-e-s-o committed Jan 11, 2021
1 parent f18fdc6 commit 3d83b07
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Unreleased
----------
- Added support for the Librem Key
- Added the `fill` command that fills the SD card of a Nitrokey Storage device
with random data
- Added the `termion` dependency in version `1.5.5`
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ nitrocli
- [Changelog](CHANGELOG.md)

**nitrocli** is a program that provides a command line interface for
interaction with [Nitrokey Pro][nitrokey-pro] and [Nitrokey
Storage][nitrokey-storage] devices.
interaction with [Nitrokey Pro][nitrokey-pro], [Nitrokey
Storage][nitrokey-storage], and [Librem Key][librem-key] devices.


The following commands are currently supported:
Expand Down Expand Up @@ -181,6 +181,7 @@ the full text of the license.
[nitrokey-gmbh]: https://www.nitrokey.com
[nitrokey-pro]: https://shop.nitrokey.com/shop/product/nitrokey-pro-2-3
[nitrokey-storage]: https://shop.nitrokey.com/shop/product/nitrokey-storage-2-56
[librem-key]: https://puri.sm/products/librem-key/
[nitrocli-arch]: https://aur.archlinux.org/packages/nitrocli
[nitrocli-cratesio]: https://crates.io/crates/nitrocli
[nitrocli-debian]: https://packages.debian.org/stable/nitrocli
Expand Down
14 changes: 7 additions & 7 deletions doc/nitrocli.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nitrocli \- access Nitrokey devices
[\fIarguments\fR]
.SH DESCRIPTION
\fBnitrocli\fR provides access to Nitrokey devices.
It supports the Nitrokey Pro and the Nitrokey Storage.
It supports the Nitrokey Pro, the Nitrokey Storage, and the Librem Key.
It can be used to access the encrypted volume, the one-time password generator,
and the password safe.
.SS Device selection
Expand All @@ -21,7 +21,7 @@ Use the \fBlist\fR command to list all attached devices with their USB path,
model, and serial number (if available).
.SH OPTIONS
.TP
\fB\-m\fR, \fB\-\-model pro\fR|\fBstorage\fR
\fB\-m\fR, \fB\-\-model librem\fR|\fBpro\fR|\fBstorage\fR
Restrict connections to the given device model, see the Device selection
section.
.TP
Expand Down Expand Up @@ -153,9 +153,9 @@ Instead it checks whether a fill operation is currently running on the device
and shows its progress.

.SS One-time passwords
The Nitrokey Pro and the Nitrokey Storage support the generation of one-time
passwords using the HOTP algorithm according to RFC 4226 or the TOTP algorithm
according to RFC 6238.
The Nitrokey Pro, the Nitrokey Storage, and the Librem Key support the
generation of one-time passwords using the HOTP algorithm according to RFC 4226
or the TOTP algorithm according to RFC 6238.
The required data \(en a name and the secret \(en is stored in slots.
Currently, the Nitrokey devices provide three HOTP slots and 15 TOTP slots.
The slots are numbered per algorithm starting at zero.
Expand Down Expand Up @@ -245,8 +245,8 @@ If \fB\-\-no\-otp\-pin\fR is set, OTP generation can be performed without PIN.
These two options are mutually exclusive.

.SS Password safe
The Nitrokey Pro and the Nitrokey Storage provide a password safe (PWS) with 16
slots.
The Nitrokey Pro, the Nitrokey Storage, and the Librem Key provide a password
safe (PWS) with 16 slots.
In each of these slots you can store a name, a login, and a password.
The PWS is not encrypted, but it is protected with the user PIN by the firmware.
Once the PWS is unlocked by one of the commands listed below, it can be
Expand Down
Binary file modified doc/nitrocli.1.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Args {
Enum! {
/// The available Nitrokey models.
DeviceModel, [
Librem => "librem",
Pro => "pro",
Storage => "storage",
]
Expand All @@ -46,6 +47,7 @@ Enum! {
impl DeviceModel {
pub fn as_user_facing_str(&self) -> &str {
match self {
DeviceModel::Librem => "Librem",
DeviceModel::Pro => "Pro",
DeviceModel::Storage => "Storage",
}
Expand All @@ -55,6 +57,7 @@ impl DeviceModel {
impl From<DeviceModel> for nitrokey::Model {
fn from(model: DeviceModel) -> nitrokey::Model {
match model {
DeviceModel::Librem => nitrokey::Model::Librem,
DeviceModel::Pro => nitrokey::Model::Pro,
DeviceModel::Storage => nitrokey::Model::Storage,
}
Expand All @@ -66,6 +69,7 @@ impl convert::TryFrom<nitrokey::Model> for DeviceModel {

fn try_from(model: nitrokey::Model) -> Result<DeviceModel, anyhow::Error> {
match model {
nitrokey::Model::Librem => Ok(DeviceModel::Librem),
nitrokey::Model::Pro => Ok(DeviceModel::Pro),
nitrokey::Model::Storage => Ok(DeviceModel::Storage),
_ => Err(anyhow::anyhow!("Unsupported device model: {}", model)),
Expand Down
1 change: 1 addition & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl Nitrocli {

fn model_to_arg(model: nitrokey::Model) -> &'static str {
match model {
nitrokey::Model::Librem => "--model=librem",
nitrokey::Model::Pro => "--model=pro",
nitrokey::Model::Storage => "--model=storage",
_ => panic!("Unexpected model in test suite: {}", model),
Expand Down

0 comments on commit 3d83b07

Please sign in to comment.