Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #28 from csssuf/fixes
Browse files Browse the repository at this point in the history
Miscellaneous small fixes
  • Loading branch information
csssuf authored Apr 25, 2018
2 parents 338994a + b3d0519 commit 36f26b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
17 changes: 10 additions & 7 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,19 @@ impl Session {
}
}

/// Reset the device to factory settings and reboot.
///
/// Note that since the device reboots when this function is called, this function is far more
/// likely to return a `ReturnCode::NetError` upon success, since it will vanish out from
/// underneath the connector. However, it is left to library consumers to decide whether or not
/// this is an acceptable result.
pub fn reset(self) -> Result<(), Error> {
let rc = ReturnCode::from(unsafe {
match ReturnCode::from(unsafe {
yubihsm_sys::yh_util_reset(self.this.load(Ordering::Relaxed))
});

if rc != ReturnCode::Success {
bail!("util_reset failed: {}", rc);
}) {
ReturnCode::Success => Ok(()),
rc => Err(rc.into()),
}

Ok(())
}

pub fn list_objects(&self) -> ListObjectsQuery {
Expand Down
10 changes: 5 additions & 5 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl From<DomainParam> for Vec<Domain> {
}
}

#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Fail)]
pub enum ReturnCode {
Success,
Memory,
Expand Down Expand Up @@ -549,8 +549,8 @@ impl<'a> From<&'a Capability> for String {
Capability::DeleteOpaque => String::from("delete_opaque"),
Capability::DeleteAuthkey => String::from("delete_authkey"),
Capability::DeleteAsymmetric => String::from("delete_asymmetric"),
Capability::DeleteWrapKey => String::from("delete_wrap_key"),
Capability::DeleteHmacKey => String::from("delete_hmac_key"),
Capability::DeleteWrapKey => String::from("delete_wrapkey"),
Capability::DeleteHmacKey => String::from("delete_hmackey"),
Capability::DeleteTemplate => String::from("delete_template"),
Capability::DeleteOtpAeadKey => String::from("delete_otp_aead_key"),
Capability::Unknown => String::from("unknown"),
Expand Down Expand Up @@ -606,8 +606,8 @@ where
"delete_opaque" => Capability::DeleteOpaque,
"delete_authkey" => Capability::DeleteAuthkey,
"delete_asymmetric" => Capability::DeleteAsymmetric,
"delete_wrap_key" => Capability::DeleteWrapKey,
"delete_hmac_key" => Capability::DeleteHmacKey,
"delete_wrapkey" => Capability::DeleteWrapKey,
"delete_hmackey" => Capability::DeleteHmacKey,
"delete_template" => Capability::DeleteTemplate,
"delete_otp_aead_key" => Capability::DeleteOtpAeadKey,
_ => Capability::Unknown,
Expand Down

0 comments on commit 36f26b3

Please sign in to comment.