aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/auth.rs9
-rw-r--r--src/config.rs52
-rw-r--r--src/device/mod.rs6
-rw-r--r--src/otp.rs8
4 files changed, 38 insertions, 37 deletions
diff --git a/src/auth.rs b/src/auth.rs
index 9cf0722..5ca59da 100644
--- a/src/auth.rs
+++ b/src/auth.rs
@@ -278,7 +278,8 @@ impl<'a, T: Device<'a>> Admin<'a, T> {
///
/// # Errors
///
- /// - [`InvalidSlot`][] if the provided numlock, capslock or scrolllock slot is larger than two
+ /// - [`InvalidSlot`][] if the provided Num Lock, Caps Lock or Scroll Lock slot is larger than
+ /// two
///
/// # Example
///
@@ -306,9 +307,9 @@ impl<'a, T: Device<'a>> Admin<'a, T> {
let raw_config = RawConfig::try_from(config)?;
get_command_result(unsafe {
nitrokey_sys::NK_write_config(
- raw_config.numlock,
- raw_config.capslock,
- raw_config.scrollock,
+ raw_config.num_lock,
+ raw_config.caps_lock,
+ raw_config.scroll_lock,
raw_config.user_password,
false,
self.temp_password.as_ptr(),
diff --git a/src/config.rs b/src/config.rs
index 120a51b..bc935d7 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -8,15 +8,15 @@ use crate::error::{Error, LibraryError};
/// The configuration for a Nitrokey.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Config {
- /// If set, the stick will generate a code from the HOTP slot with the given number if numlock
+ /// If set, the stick will generate a code from the HOTP slot with the given number if Num Lock
/// is pressed. The slot number must be 0, 1 or 2.
- pub numlock: Option<u8>,
- /// If set, the stick will generate a code from the HOTP slot with the given number if capslock
- /// is pressed. The slot number must be 0, 1 or 2.
- pub capslock: Option<u8>,
- /// If set, the stick will generate a code from the HOTP slot with the given number if
- /// scrollock is pressed. The slot number must be 0, 1 or 2.
- pub scrollock: Option<u8>,
+ pub num_lock: Option<u8>,
+ /// If set, the stick will generate a code from the HOTP slot with the given number if Caps
+ /// Lock is pressed. The slot number must be 0, 1 or 2.
+ pub caps_lock: Option<u8>,
+ /// If set, the stick will generate a code from the HOTP slot with the given number if Scroll
+ /// Lock is pressed. The slot number must be 0, 1 or 2.
+ pub scroll_lock: Option<u8>,
/// If set, OTP generation using [`get_hotp_code`][] or [`get_totp_code`][] requires user
/// authentication. Otherwise, OTPs can be generated without authentication.
///
@@ -27,9 +27,9 @@ pub struct Config {
#[derive(Debug)]
pub struct RawConfig {
- pub numlock: u8,
- pub capslock: u8,
- pub scrollock: u8,
+ pub num_lock: u8,
+ pub caps_lock: u8,
+ pub scroll_lock: u8,
pub user_password: bool,
}
@@ -56,15 +56,15 @@ fn option_to_config_otp_slot(value: Option<u8>) -> Result<u8, Error> {
impl Config {
/// Constructs a new instance of this struct.
pub fn new(
- numlock: Option<u8>,
- capslock: Option<u8>,
- scrollock: Option<u8>,
+ num_lock: Option<u8>,
+ caps_lock: Option<u8>,
+ scroll_lock: Option<u8>,
user_password: bool,
) -> Config {
Config {
- numlock,
- capslock,
- scrollock,
+ num_lock,
+ caps_lock,
+ scroll_lock,
user_password,
}
}
@@ -75,9 +75,9 @@ impl convert::TryFrom<Config> for RawConfig {
fn try_from(config: Config) -> Result<RawConfig, Error> {
Ok(RawConfig {
- numlock: option_to_config_otp_slot(config.numlock)?,
- capslock: option_to_config_otp_slot(config.capslock)?,
- scrollock: option_to_config_otp_slot(config.scrollock)?,
+ num_lock: option_to_config_otp_slot(config.num_lock)?,
+ caps_lock: option_to_config_otp_slot(config.caps_lock)?,
+ scroll_lock: option_to_config_otp_slot(config.scroll_lock)?,
user_password: config.user_password,
})
}
@@ -86,9 +86,9 @@ impl convert::TryFrom<Config> for RawConfig {
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,
+ num_lock: status.config_numlock,
+ caps_lock: status.config_capslock,
+ scroll_lock: status.config_scrolllock,
user_password: status.otp_user_password,
}
}
@@ -97,9 +97,9 @@ impl From<&nitrokey_sys::NK_status> for RawConfig {
impl Into<Config> for RawConfig {
fn into(self) -> Config {
Config {
- numlock: config_otp_slot_to_option(self.numlock),
- capslock: config_otp_slot_to_option(self.capslock),
- scrollock: config_otp_slot_to_option(self.scrollock),
+ num_lock: config_otp_slot_to_option(self.num_lock),
+ caps_lock: config_otp_slot_to_option(self.caps_lock),
+ scroll_lock: config_otp_slot_to_option(self.scroll_lock),
user_password: self.user_password,
}
}
diff --git a/src/device/mod.rs b/src/device/mod.rs
index fbf336d..7fec18b 100644
--- a/src/device/mod.rs
+++ b/src/device/mod.rs
@@ -464,9 +464,9 @@ pub trait Device<'a>: Authenticate<'a> + GetPasswordSafe<'a> + GenerateOtp + fmt
/// let mut manager = nitrokey::take()?;
/// let device = manager.connect()?;
/// let config = device.get_config()?;
- /// println!("numlock binding: {:?}", config.numlock);
- /// println!("capslock binding: {:?}", config.capslock);
- /// println!("scrollock binding: {:?}", config.scrollock);
+ /// println!("Num Lock binding: {:?}", config.num_lock);
+ /// println!("Caps Lock binding: {:?}", config.caps_lock);
+ /// println!("Scroll Lock binding: {:?}", config.scroll_lock);
/// println!("require password for OTP: {:?}", config.user_password);
/// # Ok(())
/// # }
diff --git a/src/otp.rs b/src/otp.rs
index 1d5f507..7b47a3b 100644
--- a/src/otp.rs
+++ b/src/otp.rs
@@ -347,8 +347,8 @@ pub struct OtpSlotData {
pub secret: String,
/// The OTP generation mode.
pub mode: OtpMode,
- /// If true, press the enter key after sending an OTP code using double-pressed
- /// numlock, capslock or scrolllock.
+ /// If true, press the enter key after sending an OTP code using double-pressed Num Lock, Caps
+ /// Lock or Scroll Lock.
pub use_enter: bool,
/// Set the token ID, see [OATH Token Identifier Specification][tokspec], section “Class A”.
///
@@ -385,8 +385,8 @@ impl OtpSlotData {
}
}
- /// Enables pressing the enter key after sending an OTP code using double-pressed numlock,
- /// capslock or scrollock.
+ /// Enables pressing the enter key after sending an OTP code using double-pressed Num Lock,
+ /// Caps Lock or Scroll Lock.
pub fn use_enter(mut self) -> OtpSlotData {
self.use_enter = true;
self