summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md1
-rw-r--r--src/lib.rs13
2 files changed, 4 insertions, 10 deletions
diff --git a/TODO.md b/TODO.md
index 4a9f276..57ccf10 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,6 +1,5 @@
- Add support and tests for the Nitrokey Storage.
- Add support for the currently unsupported commands:
- - `NK_login_enum`
- `NK_set_unencrypted_volume_rorw_pin_type_user`
- `NK_lock_device`
- `NK_factory_reset`
diff --git a/src/lib.rs b/src/lib.rs
index 259ff89..471d481 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -679,17 +679,12 @@ pub fn connect() -> Result<UnauthenticatedDevice, CommandError> {
/// }
/// ```
pub fn connect_model(model: Model) -> Result<UnauthenticatedDevice, CommandError> {
- let model_string = match model {
- Model::Storage => "S",
- Model::Pro => "P",
+ let model = match model {
+ Model::Storage => nitrokey_sys::NK_device_model_NK_STORAGE,
+ Model::Pro => nitrokey_sys::NK_device_model_NK_PRO,
};
- let model_cstring = CString::new(model_string);
- if model_cstring.is_err() {
- return Err(CommandError::InvalidString);
- }
- let model = model_cstring.unwrap();
unsafe {
- return match nitrokey_sys::NK_login(model.as_ptr()) {
+ return match nitrokey_sys::NK_login_enum(model) {
1 => Ok(UnauthenticatedDevice {}),
rv => Err(CommandError::from(rv)),
};