diff options
| -rw-r--r-- | src/auth.rs | 6 | ||||
| -rw-r--r-- | src/device.rs | 58 | ||||
| -rw-r--r-- | src/lib.rs | 6 | ||||
| -rw-r--r-- | src/otp.rs | 28 | ||||
| -rw-r--r-- | src/pws.rs | 6 | 
5 files changed, 52 insertions, 52 deletions
| diff --git a/src/auth.rs b/src/auth.rs index 18b6572..8978f32 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -49,7 +49,7 @@ pub trait Authenticate {      ///         user.device()      ///     },      ///     Err((device, err)) => { -    ///         println!("Could not authenticate as user: {}", err); +    ///         eprintln!("Could not authenticate as user: {}", err);      ///         device      ///     },      /// }; @@ -95,7 +95,7 @@ pub trait Authenticate {      ///         admin.device()      ///     },      ///     Err((device, err)) => { -    ///         println!("Could not authenticate as admin: {}", err); +    ///         eprintln!("Could not authenticate as admin: {}", err);      ///         device      ///     },      /// }; @@ -282,7 +282,7 @@ impl<T: Device> Admin<T> {      ///         admin.write_config(config);      ///         ()      ///     }, -    ///     Err((_, err)) => println!("Could not authenticate as admin: {}", err), +    ///     Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),      /// };      /// #     Ok(())      /// # } diff --git a/src/device.rs b/src/device.rs index 2fac4f2..d199d9a 100644 --- a/src/device.rs +++ b/src/device.rs @@ -78,7 +78,7 @@ impl fmt::Display for VolumeMode {  ///         user.device()  ///     },  ///     Err((device, err)) => { -///         println!("Could not authenticate as user: {}", err); +///         eprintln!("Could not authenticate as user: {}", err);  ///         device  ///     },  /// }; @@ -142,7 +142,7 @@ pub enum DeviceWrapper {  ///         user.device()  ///     },  ///     Err((device, err)) => { -///         println!("Could not authenticate as user: {}", err); +///         eprintln!("Could not authenticate as user: {}", err);  ///         device  ///     },  /// }; @@ -188,7 +188,7 @@ pub struct Pro {  ///         user.device()  ///     },  ///     Err((device, err)) => { -///         println!("Could not authenticate as user: {}", err); +///         eprintln!("Could not authenticate as user: {}", err);  ///         device  ///     },  /// }; @@ -325,7 +325,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.get_serial_number() {      ///     Ok(number) => println!("serial no: {}", number), -    ///     Err(err) => println!("Could not get serial number: {}", err), +    ///     Err(err) => eprintln!("Could not get serial number: {}", err),      /// };      /// #     Ok(())      /// # } @@ -347,7 +347,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.get_user_retry_count() {      ///     Ok(count) => println!("{} remaining authentication attempts (user)", count), -    ///     Err(err) => println!("Could not get user retry count: {}", err), +    ///     Err(err) => eprintln!("Could not get user retry count: {}", err),      /// }      /// #     Ok(())      /// # } @@ -370,7 +370,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let count = device.get_admin_retry_count();      /// match device.get_admin_retry_count() {      ///     Ok(count) => println!("{} remaining authentication attempts (admin)", count), -    ///     Err(err) => println!("Could not get admin retry count: {}", err), +    ///     Err(err) => eprintln!("Could not get admin retry count: {}", err),      /// }      /// #     Ok(())      /// # } @@ -391,7 +391,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.get_firmware_version() {      ///     Ok(version) => println!("Firmware version: {}", version), -    ///     Err(err) => println!("Could not access firmware version: {}", err), +    ///     Err(err) => eprintln!("Could not access firmware version: {}", err),      /// };      /// #     Ok(())      /// # } @@ -455,7 +455,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.change_admin_pin("12345678", "12345679") {      ///     Ok(()) => println!("Updated admin PIN."), -    ///     Err(err) => println!("Failed to update admin PIN: {}", err), +    ///     Err(err) => eprintln!("Failed to update admin PIN: {}", err),      /// };      /// #     Ok(())      /// # } @@ -488,7 +488,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.change_user_pin("123456", "123457") {      ///     Ok(()) => println!("Updated admin PIN."), -    ///     Err(err) => println!("Failed to update admin PIN: {}", err), +    ///     Err(err) => eprintln!("Failed to update admin PIN: {}", err),      /// };      /// #     Ok(())      /// # } @@ -521,7 +521,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.unlock_user_pin("12345678", "123456") {      ///     Ok(()) => println!("Unlocked user PIN."), -    ///     Err(err) => println!("Failed to unlock user PIN: {}", err), +    ///     Err(err) => eprintln!("Failed to unlock user PIN: {}", err),      /// };      /// #     Ok(())      /// # } @@ -555,7 +555,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.lock() {      ///     Ok(()) => println!("Locked the Nitrokey device."), -    ///     Err(err) => println!("Could not lock the Nitrokey device: {}", err), +    ///     Err(err) => eprintln!("Could not lock the Nitrokey device: {}", err),      /// };      /// #     Ok(())      /// # } @@ -586,7 +586,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.factory_reset("12345678") {      ///     Ok(()) => println!("Performed a factory reset."), -    ///     Err(err) => println!("Could not perform a factory reset: {}", err), +    ///     Err(err) => eprintln!("Could not perform a factory reset: {}", err),      /// };      /// #     Ok(())      /// # } @@ -620,7 +620,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {      /// let device = nitrokey::connect()?;      /// match device.build_aes_key("12345678") {      ///     Ok(()) => println!("New AES keys have been built."), -    ///     Err(err) => println!("Could not build new AES keys: {}", err), +    ///     Err(err) => eprintln!("Could not build new AES keys: {}", err),      /// };      /// #     Ok(())      /// # } @@ -649,7 +649,7 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {  ///  /// match nitrokey::connect() {  ///     Ok(device) => do_something(device), -///     Err(err) => println!("Could not connect to a Nitrokey: {}", err), +///     Err(err) => eprintln!("Could not connect to a Nitrokey: {}", err),  /// }  /// ```  /// @@ -681,7 +681,7 @@ pub fn connect() -> Result<DeviceWrapper, Error> {  ///  /// match nitrokey::connect_model(Model::Pro) {  ///     Ok(device) => do_something(device), -///     Err(err) => println!("Could not connect to a Nitrokey Pro: {}", err), +///     Err(err) => eprintln!("Could not connect to a Nitrokey Pro: {}", err),  /// }  /// ```  /// @@ -785,7 +785,7 @@ impl Pro {      ///      /// match nitrokey::Pro::connect() {      ///     Ok(device) => use_pro(device), -    ///     Err(err) => println!("Could not connect to the Nitrokey Pro: {}", err), +    ///     Err(err) => eprintln!("Could not connect to the Nitrokey Pro: {}", err),      /// }      /// ```      /// @@ -838,7 +838,7 @@ impl Storage {      ///      /// match nitrokey::Storage::connect() {      ///     Ok(device) => use_storage(device), -    ///     Err(err) => println!("Could not connect to the Nitrokey Storage: {}", err), +    ///     Err(err) => eprintln!("Could not connect to the Nitrokey Storage: {}", err),      /// }      /// ```      /// @@ -878,7 +878,7 @@ impl Storage {      /// let device = nitrokey::Storage::connect()?;      /// match device.change_update_pin("12345678", "87654321") {      ///     Ok(()) => println!("Updated update PIN."), -    ///     Err(err) => println!("Failed to update update PIN: {}", err), +    ///     Err(err) => eprintln!("Failed to update update PIN: {}", err),      /// };      /// #     Ok(())      /// # } @@ -915,7 +915,7 @@ impl Storage {      /// let device = nitrokey::Storage::connect()?;      /// match device.enable_firmware_update("12345678") {      ///     Ok(()) => println!("Nitrokey entered update mode."), -    ///     Err(err) => println!("Could not enter update mode: {}", err), +    ///     Err(err) => eprintln!("Could not enter update mode: {}", err),      /// };      /// #     Ok(())      /// # } @@ -949,7 +949,7 @@ impl Storage {      /// let device = nitrokey::Storage::connect()?;      /// match device.enable_encrypted_volume("123456") {      ///     Ok(()) => println!("Enabled the encrypted volume."), -    ///     Err(err) => println!("Could not enable the encrypted volume: {}", err), +    ///     Err(err) => eprintln!("Could not enable the encrypted volume: {}", err),      /// };      /// #     Ok(())      /// # } @@ -983,11 +983,11 @@ impl Storage {      ///         match device.disable_encrypted_volume() {      ///             Ok(()) => println!("Disabled the encrypted volume."),      ///             Err(err) => { -    ///                 println!("Could not disable the encrypted volume: {}", err); +    ///                 eprintln!("Could not disable the encrypted volume: {}", err);      ///             },      ///         };      ///     }, -    ///     Err(err) => println!("Could not enable the encrypted volume: {}", err), +    ///     Err(err) => eprintln!("Could not enable the encrypted volume: {}", err),      /// };      /// #     Ok(())      /// # } @@ -1025,7 +1025,7 @@ impl Storage {      /// device.enable_encrypted_volume("123445")?;      /// match device.enable_hidden_volume("hidden-pw") {      ///     Ok(()) => println!("Enabled a hidden volume."), -    ///     Err(err) => println!("Could not enable the hidden volume: {}", err), +    ///     Err(err) => eprintln!("Could not enable the hidden volume: {}", err),      /// };      /// #     Ok(())      /// # } @@ -1063,11 +1063,11 @@ impl Storage {      ///         match device.disable_hidden_volume() {      ///             Ok(()) => println!("Disabled the hidden volume."),      ///             Err(err) => { -    ///                 println!("Could not disable the hidden volume: {}", err); +    ///                 eprintln!("Could not disable the hidden volume: {}", err);      ///             },      ///         };      ///     }, -    ///     Err(err) => println!("Could not enable the hidden volume: {}", err), +    ///     Err(err) => eprintln!("Could not enable the hidden volume: {}", err),      /// };      /// #     Ok(())      /// # } @@ -1144,7 +1144,7 @@ impl Storage {      /// let device = nitrokey::Storage::connect()?;      /// match device.set_unencrypted_volume_mode("123456", VolumeMode::ReadWrite) {      ///     Ok(()) => println!("Set the unencrypted volume to read-write mode."), -    ///     Err(err) => println!("Could not set the unencrypted volume to read-write mode: {}", err), +    ///     Err(err) => eprintln!("Could not set the unencrypted volume to read-write mode: {}", err),      /// };      /// #     Ok(())      /// # } @@ -1184,7 +1184,7 @@ impl Storage {      ///     Ok(status) => {      ///         println!("SD card ID: {:#x}", status.serial_number_sd_card);      ///     }, -    ///     Err(err) => println!("Could not get Storage status: {}", err), +    ///     Err(err) => eprintln!("Could not get Storage status: {}", err),      /// };      /// #     Ok(())      /// # } @@ -1228,7 +1228,7 @@ impl Storage {      ///         println!("SD card ID:   {:#x}", data.sd_card.serial_number);      ///         println!("SD card size: {} GB", data.sd_card.size);      ///     }, -    ///     Err(err) => println!("Could not get Storage production info: {}", err), +    ///     Err(err) => eprintln!("Could not get Storage production info: {}", err),      /// };      /// #     Ok(())      /// # } @@ -1273,7 +1273,7 @@ impl Storage {      /// let device = nitrokey::Storage::connect()?;      /// match device.clear_new_sd_card_warning("12345678") {      ///     Ok(()) => println!("Cleared the new SD card warning."), -    ///     Err(err) => println!("Could not set the clear the new SD card warning: {}", err), +    ///     Err(err) => eprintln!("Could not set the clear the new SD card warning: {}", err),      /// };      /// #     Ok(())      /// # } @@ -50,10 +50,10 @@  //!     Ok(admin) => {  //!         match admin.write_hotp_slot(slot_data, 0) {  //!             Ok(()) => println!("Successfully wrote slot."), -//!             Err(err) => println!("Could not write slot: {}", err), +//!             Err(err) => eprintln!("Could not write slot: {}", err),  //!         }  //!     }, -//!     Err((_, err)) => println!("Could not authenticate as admin: {}", err), +//!     Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),  //! }  //! #     Ok(())  //! # } @@ -69,7 +69,7 @@  //! let device = nitrokey::connect()?;  //! match device.get_hotp_code(1) {  //!     Ok(code) => println!("Generated HOTP code: {}", code), -//!     Err(err) => println!("Could not generate HOTP code: {}", err), +//!     Err(err) => eprintln!("Could not generate HOTP code: {}", err),  //! }  //! #     Ok(())  //! # } @@ -41,10 +41,10 @@ pub trait ConfigureOtp {      ///     Ok(admin) => {      ///         match admin.write_hotp_slot(slot_data, 0) {      ///             Ok(()) => println!("Successfully wrote slot."), -    ///             Err(err) => println!("Could not write slot: {}", err), +    ///             Err(err) => eprintln!("Could not write slot: {}", err),      ///         }      ///     }, -    ///     Err((_, err)) => println!("Could not authenticate as admin: {}", err), +    ///     Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),      /// }      /// #     Ok(())      /// # } @@ -77,10 +77,10 @@ pub trait ConfigureOtp {      ///     Ok(admin) => {      ///         match admin.write_totp_slot(slot_data, 30) {      ///             Ok(()) => println!("Successfully wrote slot."), -    ///             Err(err) => println!("Could not write slot: {}", err), +    ///             Err(err) => eprintln!("Could not write slot: {}", err),      ///         }      ///     }, -    ///     Err((_, err)) => println!("Could not authenticate as admin: {}", err), +    ///     Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),      /// }      /// #     Ok(())      /// # } @@ -109,10 +109,10 @@ pub trait ConfigureOtp {      ///     Ok(admin) => {      ///         match admin.erase_hotp_slot(1) {      ///             Ok(()) => println!("Successfully erased slot."), -    ///             Err(err) => println!("Could not erase slot: {}", err), +    ///             Err(err) => eprintln!("Could not erase slot: {}", err),      ///         }      ///     }, -    ///     Err((_, err)) => println!("Could not authenticate as admin: {}", err), +    ///     Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),      /// }      /// #     Ok(())      /// # } @@ -139,10 +139,10 @@ pub trait ConfigureOtp {      ///     Ok(admin) => {      ///         match admin.erase_totp_slot(1) {      ///             Ok(()) => println!("Successfully erased slot."), -    ///             Err(err) => println!("Could not erase slot: {}", err), +    ///             Err(err) => eprintln!("Could not erase slot: {}", err),      ///         }      ///     }, -    ///     Err((_, err)) => println!("Could not authenticate as admin: {}", err), +    ///     Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),      /// }      /// #     Ok(())      /// # } @@ -175,7 +175,7 @@ pub trait GenerateOtp {      /// let time = time::SystemTime::now().duration_since(time::UNIX_EPOCH);      /// match time {      ///     Ok(time) => device.set_time(time.as_secs(), false)?, -    ///     Err(_) => println!("The system time is before the Unix epoch!"), +    ///     Err(_) => eprintln!("The system time is before the Unix epoch!"),      /// }      /// #     Ok(())      /// # } @@ -212,8 +212,8 @@ pub trait GenerateOtp {      /// let device = nitrokey::connect()?;      /// match device.get_hotp_slot_name(1) {      ///     Ok(name) => println!("HOTP slot 1: {}", name), -    ///     Err(Error::CommandError(CommandError::SlotNotProgrammed)) => println!("HOTP slot 1 not programmed"), -    ///     Err(err) => println!("Could not get slot name: {}", err), +    ///     Err(Error::CommandError(CommandError::SlotNotProgrammed)) => eprintln!("HOTP slot 1 not programmed"), +    ///     Err(err) => eprintln!("Could not get slot name: {}", err),      /// };      /// #     Ok(())      /// # } @@ -241,8 +241,8 @@ pub trait GenerateOtp {      /// let device = nitrokey::connect()?;      /// match device.get_totp_slot_name(1) {      ///     Ok(name) => println!("TOTP slot 1: {}", name), -    ///     Err(Error::CommandError(CommandError::SlotNotProgrammed)) => println!("TOTP slot 1 not programmed"), -    ///     Err(err) => println!("Could not get slot name: {}", err), +    ///     Err(Error::CommandError(CommandError::SlotNotProgrammed)) => eprintln!("TOTP slot 1 not programmed"), +    ///     Err(err) => eprintln!("Could not get slot name: {}", err),      /// };      /// #     Ok(())      /// # } @@ -313,7 +313,7 @@ pub trait GenerateOtp {      ///         let code = device.get_totp_code(1)?;      ///         println!("Generated TOTP code on slot 1: {}", code);      ///     }, -    ///     Err(_) => println!("Timestamps before 1970-01-01 are not supported!"), +    ///     Err(_) => eprintln!("Timestamps before 1970-01-01 are not supported!"),      /// }      /// #     Ok(())      /// # } @@ -103,7 +103,7 @@ pub trait GetPasswordSafe {      ///         use_password_safe(&pws);      ///         device.lock()?;      ///     }, -    ///     Err(err) => println!("Could not open the password safe: {}", err), +    ///     Err(err) => eprintln!("Could not open the password safe: {}", err),      /// };      /// #     Ok(())      /// # } @@ -201,7 +201,7 @@ impl<'a> PasswordSafe<'a> {      ///         let password = pws.get_slot_login(0)?;      ///         println!("Credentials for {}: login {}, password {}", name, login, password);      ///     }, -    ///     Err(err) => println!("Could not open the password safe: {}", err), +    ///     Err(err) => eprintln!("Could not open the password safe: {}", err),      /// };      /// #     Ok(())      /// # } @@ -344,7 +344,7 @@ impl<'a> PasswordSafe<'a> {      /// let pws = device.get_password_safe("123456")?;      /// match pws.erase_slot(0) {      ///     Ok(()) => println!("Erased slot 0."), -    ///     Err(err) => println!("Could not erase slot 0: {}", err), +    ///     Err(err) => eprintln!("Could not erase slot 0: {}", err),      /// };      /// #     Ok(())      /// # } | 
