Skip to content

Commit

Permalink
Bump cryptoki to 0.7.0 (#3)
Browse files Browse the repository at this point in the history
 Also:
- fix new Clippy warning
- bump version for release

---------

Co-authored-by: Simon Bihel <[email protected]>
  • Loading branch information
jippeholwerda and sbihel authored Jun 20, 2024
1 parent 4f6d229 commit a7e3eeb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "r2d2-cryptoki"
version = "0.2.1"
version = "0.3.0"
edition = "2021"
authors = ["Spruce Systems, Inc."]
license = "MIT OR Apache-2.0"
Expand All @@ -12,7 +12,7 @@ documentation = "https://docs.rs/r2d2-cryptoki/"
serde = ["cryptoki/serde"]

[dependencies]
cryptoki = "0.6.0"
cryptoki = "0.7.0"
r2d2 = "0.8.10"

[dev-dependencies]
Expand Down
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub use cryptoki;
pub use r2d2;

use cryptoki::{
context::Pkcs11,
context::{Function, Pkcs11},
error::RvError,
session::{Session, SessionState, UserType},
slot::{Limit, Slot},
Expand Down Expand Up @@ -101,9 +101,9 @@ impl SessionManager {
}
};
let res = match limit {
Limit::Max(m) => Some(m.try_into().unwrap_or(u32::max_value())),
Limit::Max(m) => Some(m.try_into().unwrap_or(u32::MAX)),
Limit::Unavailable => None,
Limit::Infinite => Some(u32::max_value()),
Limit::Infinite => Some(u32::MAX),
};
Ok(if let Some(true) = res.map(|r| r > maximum) {
Some(maximum)
Expand Down Expand Up @@ -136,7 +136,7 @@ impl ManageConnection for SessionManager {
};
if let Some(user_type) = maybe_user_info {
match session.login(user_type.0, Some(user_type.1)) {
Err(Self::Error::Pkcs11(RvError::UserAlreadyLoggedIn)) => {}
Err(Self::Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
res => res?,
};
}
Expand All @@ -147,7 +147,10 @@ impl ManageConnection for SessionManager {
let actual_state = session.get_session_info()?.session_state();
let expected_state = &self.session_type;
if actual_state != expected_state.as_state() {
Err(Self::Error::Pkcs11(RvError::UserNotLoggedIn))
Err(Self::Error::Pkcs11(
RvError::UserNotLoggedIn,
Function::GetSessionInfo,
))
} else {
Ok(())
}
Expand Down

0 comments on commit a7e3eeb

Please sign in to comment.