Skip to content

Commit a7e3eeb

Browse files
Bump cryptoki to 0.7.0 (#3)
Also: - fix new Clippy warning - bump version for release --------- Co-authored-by: Simon Bihel <simon.bihel@spruceid.com>
1 parent 4f6d229 commit a7e3eeb

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "r2d2-cryptoki"
3-
version = "0.2.1"
3+
version = "0.3.0"
44
edition = "2021"
55
authors = ["Spruce Systems, Inc."]
66
license = "MIT OR Apache-2.0"
@@ -12,7 +12,7 @@ documentation = "https://docs.rs/r2d2-cryptoki/"
1212
serde = ["cryptoki/serde"]
1313

1414
[dependencies]
15-
cryptoki = "0.6.0"
15+
cryptoki = "0.7.0"
1616
r2d2 = "0.8.10"
1717

1818
[dev-dependencies]

src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub use cryptoki;
55
pub use r2d2;
66

77
use cryptoki::{
8-
context::Pkcs11,
8+
context::{Function, Pkcs11},
99
error::RvError,
1010
session::{Session, SessionState, UserType},
1111
slot::{Limit, Slot},
@@ -101,9 +101,9 @@ impl SessionManager {
101101
}
102102
};
103103
let res = match limit {
104-
Limit::Max(m) => Some(m.try_into().unwrap_or(u32::max_value())),
104+
Limit::Max(m) => Some(m.try_into().unwrap_or(u32::MAX)),
105105
Limit::Unavailable => None,
106-
Limit::Infinite => Some(u32::max_value()),
106+
Limit::Infinite => Some(u32::MAX),
107107
};
108108
Ok(if let Some(true) = res.map(|r| r > maximum) {
109109
Some(maximum)
@@ -136,7 +136,7 @@ impl ManageConnection for SessionManager {
136136
};
137137
if let Some(user_type) = maybe_user_info {
138138
match session.login(user_type.0, Some(user_type.1)) {
139-
Err(Self::Error::Pkcs11(RvError::UserAlreadyLoggedIn)) => {}
139+
Err(Self::Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
140140
res => res?,
141141
};
142142
}
@@ -147,7 +147,10 @@ impl ManageConnection for SessionManager {
147147
let actual_state = session.get_session_info()?.session_state();
148148
let expected_state = &self.session_type;
149149
if actual_state != expected_state.as_state() {
150-
Err(Self::Error::Pkcs11(RvError::UserNotLoggedIn))
150+
Err(Self::Error::Pkcs11(
151+
RvError::UserNotLoggedIn,
152+
Function::GetSessionInfo,
153+
))
151154
} else {
152155
Ok(())
153156
}

0 commit comments

Comments
 (0)