aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-02-03 10:22:37 +0100
committerRobin Krahl <robin.krahl@ireas.org>2020-02-03 10:22:37 +0100
commitce4479b6f7a353f388aecda03cddc35389940252 (patch)
tree9824d4552faf18a09eabb214deb87b4db950ab41 /src/config.rs
parent395ace0131ef6cd655a222734f2cc8d037395a3b (diff)
parentc1f48ce6c614586042db8891d2eebf19d2212ce4 (diff)
downloadnitrokey-rs-ce4479b6f7a353f388aecda03cddc35389940252.tar.gz
nitrokey-rs-ce4479b6f7a353f388aecda03cddc35389940252.tar.bz2
Merge branch 'get_config' into next
This patch series changes the Device::get_config implementation to use libnitrokey’s NK_get_status instead of NK_read_config. This does results in the same command being sent to the Nitrokey device, but avoids a new[]/free mismatch and makes the parsing more robust.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/config.rs b/src/config.rs
index cb678d7..120a51b 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -83,13 +83,13 @@ impl convert::TryFrom<Config> for RawConfig {
}
}
-impl From<[u8; 5]> for RawConfig {
- fn from(data: [u8; 5]) -> Self {
- RawConfig {
- numlock: data[0],
- capslock: data[1],
- scrollock: data[2],
- user_password: data[3] != 0,
+impl From<&nitrokey_sys::NK_status> for RawConfig {
+ fn from(status: &nitrokey_sys::NK_status) -> Self {
+ Self {
+ numlock: status.config_numlock,
+ capslock: status.config_capslock,
+ scrollock: status.config_scrolllock,
+ user_password: status.otp_user_password,
}
}
}