diff options
-rw-r--r-- | nitrocli/CHANGELOG.md | 2 | ||||
-rw-r--r-- | nitrocli/Cargo.lock | 4 | ||||
-rw-r--r-- | nitrokey/CHANGELOG.md | 3 | ||||
-rw-r--r-- | nitrokey/Cargo.toml | 2 | ||||
-rw-r--r-- | nitrokey/src/auth.rs | 19 |
5 files changed, 17 insertions, 13 deletions
diff --git a/nitrocli/CHANGELOG.md b/nitrocli/CHANGELOG.md index 416c1e5..6ed910d 100644 --- a/nitrocli/CHANGELOG.md +++ b/nitrocli/CHANGELOG.md @@ -4,7 +4,7 @@ Unreleased - Store cached PINs on a per-device basis to better support multi-device scenarios - Further decreased binary size by using system allocator -- Bumped `nitrokey` dependency to `0.3.3` +- Bumped `nitrokey` dependency to `0.3.4` - Bumped `rand` dependency to `0.6.4` - Removed `rustc_version`, `semver`, and `semver-parser` dependencies - Bumped `nitrokey-sys` dependency to `3.4.3` diff --git a/nitrocli/Cargo.lock b/nitrocli/Cargo.lock index 2f01846..4d793d7 100644 --- a/nitrocli/Cargo.lock +++ b/nitrocli/Cargo.lock @@ -76,14 +76,14 @@ dependencies = [ "argparse 0.2.2", "base32 0.4.0", "libc 0.2.46", - "nitrokey 0.3.3", + "nitrokey 0.3.4", "nitrokey-test 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "nitrokey" -version = "0.3.3" +version = "0.3.4" dependencies = [ "libc 0.2.46", "nitrokey-sys 3.4.3", diff --git a/nitrokey/CHANGELOG.md b/nitrokey/CHANGELOG.md index 3845aaf..edc33f6 100644 --- a/nitrokey/CHANGELOG.md +++ b/nitrokey/CHANGELOG.md @@ -1,3 +1,6 @@ +# v0.3.4 (2019-01-20) +- Fix authentication methods that assumed that `char` is signed. + # v0.3.3 (2019-01-16) - Add the `get_production_info` and `clear_new_sd_card_warning` methods to the `Storage` struct. diff --git a/nitrokey/Cargo.toml b/nitrokey/Cargo.toml index 802d022..838ab45 100644 --- a/nitrokey/Cargo.toml +++ b/nitrokey/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nitrokey" -version = "0.3.3" +version = "0.3.4" authors = ["Robin Krahl <robin.krahl@ireas.org>"] edition = "2018" homepage = "https://code.ireas.org/nitrokey-rs/" diff --git a/nitrokey/src/auth.rs b/nitrokey/src/auth.rs index 3280924..2d61d4b 100644 --- a/nitrokey/src/auth.rs +++ b/nitrokey/src/auth.rs @@ -1,4 +1,5 @@ use std::ops::Deref; +use std::os::raw::c_char; use std::os::raw::c_int; use nitrokey_sys; @@ -147,7 +148,7 @@ fn authenticate<D, A, T>(device: D, password: &str, callback: T) -> Result<A, (D where D: Device, A: AuthenticatedDevice<D>, - T: Fn(*const i8, *const i8) -> c_int, + T: Fn(*const c_char, *const c_char) -> c_int, { let temp_password = match generate_password(TEMPORARY_PASSWORD_LENGTH) { Ok(temp_password) => temp_password, @@ -158,7 +159,7 @@ where Err(err) => return Err((device, err)), }; let password_ptr = password.as_ptr(); - let temp_password_ptr = temp_password.as_ptr() as *const i8; + let temp_password_ptr = temp_password.as_ptr() as *const c_char; return match callback(password_ptr, temp_password_ptr) { 0 => Ok(A::new(device, temp_password)), rv => Err((device, CommandError::from(rv))), @@ -217,14 +218,14 @@ impl<T: Device> Deref for User<T> { impl<T: Device> GenerateOtp for User<T> { fn get_hotp_code(&self, slot: u8) -> Result<String, CommandError> { unsafe { - let temp_password_ptr = self.temp_password.as_ptr() as *const i8; + let temp_password_ptr = self.temp_password.as_ptr() as *const c_char; return result_from_string(nitrokey_sys::NK_get_hotp_code_PIN(slot, temp_password_ptr)); } } fn get_totp_code(&self, slot: u8) -> Result<String, CommandError> { unsafe { - let temp_password_ptr = self.temp_password.as_ptr() as *const i8; + let temp_password_ptr = self.temp_password.as_ptr() as *const c_char; return result_from_string(nitrokey_sys::NK_get_totp_code_PIN( slot, 0, @@ -297,17 +298,17 @@ impl<T: Device> Admin<T> { raw_config.scrollock, raw_config.user_password, false, - self.temp_password.as_ptr() as *const i8, + self.temp_password.as_ptr() as *const c_char, )) } } fn write_otp_slot<C>(&self, data: OtpSlotData, callback: C) -> Result<(), CommandError> where - C: Fn(RawOtpSlotData, *const i8) -> c_int, + C: Fn(RawOtpSlotData, *const c_char) -> c_int, { let raw_data = RawOtpSlotData::new(data)?; - let temp_password_ptr = self.temp_password.as_ptr() as *const i8; + let temp_password_ptr = self.temp_password.as_ptr() as *const c_char; get_command_result(callback(raw_data, temp_password_ptr)) } } @@ -346,12 +347,12 @@ impl<T: Device> ConfigureOtp for Admin<T> { } fn erase_hotp_slot(&self, slot: u8) -> Result<(), CommandError> { - let temp_password_ptr = self.temp_password.as_ptr() as *const i8; + let temp_password_ptr = self.temp_password.as_ptr() as *const c_char; unsafe { get_command_result(nitrokey_sys::NK_erase_hotp_slot(slot, temp_password_ptr)) } } fn erase_totp_slot(&self, slot: u8) -> Result<(), CommandError> { - let temp_password_ptr = self.temp_password.as_ptr() as *const i8; + let temp_password_ptr = self.temp_password.as_ptr() as *const c_char; unsafe { get_command_result(nitrokey_sys::NK_erase_totp_slot(slot, temp_password_ptr)) } } } |