Skip to content

Commit 4427112

Browse files
committed
Prepare for release
1 parent e475782 commit 4427112

File tree

14 files changed

+88
-85
lines changed

14 files changed

+88
-85
lines changed

70-solo2.rules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# NXP LPC55 ROM bootloader (unmodified)
2+
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="0021", TAG+="uaccess"
3+
# NXP LPC55 ROM bootloader (with Solo 2 VID:PID)
4+
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="beee", TAG+="uaccess"
5+
# Solo 2
6+
SUBSYSTEM=="tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="beee", TAG+="uaccess"
7+
# Solo 2
8+
SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="beee", TAG+="uaccess"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.6] - 2021-11-06
9+
10+
### Changed
11+
12+
- No more async - we're not a high throughput webserver
13+
- Nicer user dialogs (dialoguer/indicatif)
14+
- Model devices modes (bootloader/card)
15+
- Add udev rules
16+
817
## [0.0.5] - 2021-11-06
918

1019
### Added

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "solo2"
3-
version = "0.0.5"
3+
version = "0.0.6"
44
authors = ["SoloKeys Developers"]
55
edition = "2021"
66
rust-version = "1.56"

src/apps.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use hex_literal::hex;
22

3+
use crate::device::{prompt_user_to_select_device, Device};
34
use crate::{Card, Result, Uuid};
4-
use crate::device::{Device, prompt_user_to_select_device};
55

66
pub mod admin;
77
pub mod ndef;
@@ -53,7 +53,6 @@ pub trait App: Sized {
5353
fn card(&mut self) -> &mut Card;
5454

5555
fn connect(uuid: Option<Uuid>) -> Result<Card> {
56-
5756
let mut cards = Card::list(Default::default());
5857

5958
if cards.is_empty() {
@@ -73,10 +72,11 @@ pub trait App: Sized {
7372
}
7473
}
7574

76-
return Err(anyhow::anyhow!("Could not find any Solo 2 device with uuid {}.", uuid.hex()));
77-
75+
return Err(anyhow::anyhow!(
76+
"Could not find any Solo 2 device with uuid {}.",
77+
uuid.hex()
78+
));
7879
} else {
79-
8080
let devices = cards.into_iter().map(Device::from).collect();
8181

8282
let selected = prompt_user_to_select_device(devices)?;

src/apps/oath.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use core::{
2-
convert::{TryFrom, TryInto},
3-
fmt,
4-
};
1+
use core::fmt;
52

63
use anyhow::anyhow;
74
use flexiber::{Encodable, TaggedSlice};

src/apps/provisioner.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use core::convert::TryInto;
2-
31
use anyhow::anyhow;
42
use iso7816::Instruction;
53

src/bin/solo2/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ fn main() {
1919
}
2020

2121
fn try_main(args: clap::ArgMatches<'_>) -> anyhow::Result<()> {
22-
23-
let uuid = args.value_of("uuid")
22+
let uuid = args
23+
.value_of("uuid")
2424
// if uuid is Some, parse and fail on invalidity (no silent failure)
25-
.map(|uuid| solo2::Uuid::from_hex(&uuid))
25+
.map(|uuid| solo2::Uuid::from_hex(uuid))
2626
.transpose()?;
2727

2828
if let Some(args) = args.subcommand_matches("app") {
@@ -229,7 +229,6 @@ fn try_main(args: clap::ArgMatches<'_>) -> anyhow::Result<()> {
229229
}
230230

231231
if let Some(_args) = args.subcommand_matches("list") {
232-
233232
let devices = solo2::Device::list();
234233
for device in devices {
235234
println!("{}", &device);

src/dev_pki.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! In particular, there is no root CA, no use of hardware keys / PKCS #11,
44
//! no revocation, etc. etc.
55
6-
use core::convert::TryInto;
7-
86
use pkcs8::FromPrivateKey as _;
97
use rand_core::{OsRng, RngCore};
108

src/device.rs

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33
use anyhow::anyhow;
44
use lpc55::bootloader::Bootloader;
55

6-
use core::fmt;
76
use crate::{Card, Result, Uuid};
7+
use core::fmt;
88

99
// #[derive(Debug, Eq, PartialEq)]
1010
pub enum Device {
1111
Bootloader(Bootloader),
1212
Card(Card),
1313
}
1414

15-
1615
impl fmt::Display for Device {
1716
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1817
match self {
19-
Device::Bootloader(bootloader) =>
20-
f.write_fmt(format_args!("Bootloader UUID: {}", Uuid::from(bootloader.uuid).hex())),
18+
Device::Bootloader(bootloader) => f.write_fmt(format_args!(
19+
"Bootloader UUID: {}",
20+
Uuid::from(bootloader.uuid).hex()
21+
)),
2122
Device::Card(card) => card.fmt(f),
2223
}
2324
}
@@ -26,18 +27,21 @@ impl fmt::Display for Device {
2627
impl Device {
2728
pub fn list() -> Vec<Self> {
2829
let bootloaders = Bootloader::list().into_iter().map(Device::from);
29-
let cards = Card::list(crate::smartcard::Filter::SoloCards).into_iter().map(Device::from);
30+
let cards = Card::list(crate::smartcard::Filter::SoloCards)
31+
.into_iter()
32+
.map(Device::from);
3033

31-
let devices = bootloaders.chain(cards).collect();
32-
devices
34+
bootloaders.chain(cards).collect()
3335
}
3436

3537
/// If this is a Solo device, this will successfully report the UUID.
3638
/// Not guaranteed to work with other devices.
3739
pub fn uuid(&self) -> Result<Uuid> {
3840
match self {
3941
Device::Bootloader(bootloader) => Ok(bootloader.uuid.into()),
40-
Device::Card(card) => card.uuid.ok_or(anyhow!("Device does not have a UUID")),
42+
Device::Card(card) => card
43+
.uuid
44+
.ok_or_else(|| anyhow!("Device does not have a UUID")),
4145
}
4246
}
4347

@@ -79,7 +83,10 @@ pub fn find_bootloader(uuid: Option<Uuid>) -> Result<Bootloader> {
7983
return Ok(bootloader);
8084
}
8185
}
82-
return Err(anyhow!("Could not find any Solo 2 device with uuid {}.", uuid.hex()));
86+
return Err(anyhow!(
87+
"Could not find any Solo 2 device with uuid {}.",
88+
uuid.hex()
89+
));
8390
} else {
8491
let mut devices: Vec<Device> = Default::default();
8592
for bootloader in bootloaders {
@@ -97,35 +104,36 @@ pub fn prompt_user_to_select_device(mut devices: Vec<Device>) -> Result<Device>
97104
return Err(anyhow!("No Solo 2 devices connected"));
98105
}
99106

100-
let items: Vec<String> = devices.iter().map(|device| {
101-
match device {
102-
Device::Bootloader(bootloader) => {
103-
format!(
104-
"Bootloader UUID: {}",
105-
hex::encode(bootloader.uuid.to_be_bytes())
106-
)
107-
108-
},
109-
Device::Card(card) => {
110-
if let Some(uuid) = card.uuid {
111-
// format!("\"{}\" UUID: {}", card.reader_name, hex::encode(uuid.to_be_bytes()))
112-
format!("Solo 2 {}", uuid.hex())
113-
} else {
114-
format!(" \"{}\"", card.reader_name)
107+
let items: Vec<String> = devices
108+
.iter()
109+
.map(|device| {
110+
match device {
111+
Device::Bootloader(bootloader) => {
112+
format!(
113+
"Bootloader UUID: {}",
114+
hex::encode(bootloader.uuid.to_be_bytes())
115+
)
116+
}
117+
Device::Card(card) => {
118+
if let Some(uuid) = card.uuid {
119+
// format!("\"{}\" UUID: {}", card.reader_name, hex::encode(uuid.to_be_bytes()))
120+
format!("Solo 2 {}", uuid.hex())
121+
} else {
122+
format!(" \"{}\"", card.reader_name)
123+
}
115124
}
116125
}
117-
}
118-
}).collect();
126+
})
127+
.collect();
119128

120-
use dialoguer::{Select, theme};
129+
use dialoguer::{theme, Select};
121130
// let selection = Select::with_theme(&theme::SimpleTheme)
122131
let selection = Select::with_theme(&theme::ColorfulTheme::default())
123132
.with_prompt("Multiple Solo 2 devices connected, select one or hit Escape key")
124133
.items(&items)
125134
.default(0)
126135
.interact_opt()?
127-
.ok_or(anyhow!("No device selected"))?;
136+
.ok_or_else(|| anyhow!("No device selected"))?;
128137

129138
Ok(devices.remove(selection))
130-
131139
}

0 commit comments

Comments
 (0)