Skip to content

Commit 17e78b6

Browse files
authored
Merge pull request #3972 from Bravo555/deps/cryptoki-bump
deps: bump cryptoki crate
2 parents d4b06b6 + 7727321 commit 17e78b6

5 files changed

Lines changed: 39 additions & 56 deletions

File tree

‎Cargo.lock‎

Lines changed: 31 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ clap = { version = "4.5", features = [
108108
"unstable-styles",
109109
] }
110110
clap_complete = { version = "4.5", features = ["unstable-dynamic"] }
111-
cryptoki = "0.10.0"
111+
cryptoki = "0.12.0"
112112
csv = "1.1"
113113
darling = "0.21"
114114
doku = "0.21"
@@ -241,7 +241,7 @@ zeroize = "1.5"
241241
# dlopen is directly under libc, so we need to modify the extern block to not link libdl
242242
# TODO: remove once fix is upstreamed to libloading
243243
[patch.crates-io]
244-
libloading = { git = "https://github.com/Bravo555/rust_libloading.git", branch = "0.8.8" }
244+
libloading = { git = "https://github.com/Bravo555/rust_libloading.git", branch = "0.8.9" }
245245

246246
[profile.release]
247247
codegen-units = 1

‎crates/extensions/tedge-p11-server/src/pkcs11/mod.rs‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use asn1_rs::ToDer;
6868
use camino::Utf8Path;
6969
use camino::Utf8PathBuf;
7070
use cryptoki::context::CInitializeArgs;
71+
use cryptoki::context::CInitializeFlags;
7172
use cryptoki::context::Pkcs11;
7273
use cryptoki::error::Error;
7374
use cryptoki::mechanism::Mechanism;
@@ -226,7 +227,7 @@ impl TedgeP11Service for Cryptoki {
226227
impl Cryptoki {
227228
pub fn new(config: CryptokiConfigDirect) -> anyhow::Result<Self> {
228229
let pkcs11client = Self::load(&config.module_path)?;
229-
pkcs11client.initialize(CInitializeArgs::OsThreads)?;
230+
pkcs11client.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))?;
230231

231232
Ok(Self {
232233
context: Arc::new(Mutex::new(pkcs11client)),
@@ -252,10 +253,11 @@ impl Cryptoki {
252253
// the spec says "(C_Finalize) should be the last Cryptoki call made by an application", so call it on the old
253254
// client before initializing new client
254255
// https://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/errata01/os/pkcs11-base-v2.40-errata01-os-complete.html#_Toc441755803
255-
old_client.finalize();
256+
let _ = old_client.finalize();
256257

257258
// can return Error::AlreadyInitialized, but it shouldn't, only warn if it does anyway
258-
if let Err(err) = context.initialize(CInitializeArgs::OsThreads) {
259+
if let Err(err) = context.initialize(CInitializeArgs::new(CInitializeFlags::OS_LOCKING_OK))
260+
{
259261
warn!(?err, "Initializing cryptoki library failed");
260262
}
261263

@@ -513,17 +515,6 @@ impl CryptokiSession<'_> {
513515
// ideally we'd simply get a cryptoki mechanism that corresponds to this sigscheme but it's not possible;
514516
// instead we have to manually parse additional attributes to select a proper sigscheme; currently don't do it
515517
// and just select the most common sigscheme for both types of keys
516-
517-
// NOTE: cryptoki has AttributeType::AllowedMechanisms, but when i use it in get_attributes() with opensc-pkcs11
518-
// module it gets ignored (not present or supported) and with softhsm2 module it panics(seems to be an issue
519-
// with cryptoki, but regardless):
520-
521-
// thread 'main' panicked at library/core/src/panicking.rs:218:5:
522-
// unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
523-
// note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
524-
// thread caused non-unwinding panic. aborting.
525-
// Aborted (core dumped)
526-
527518
let key = match keytype {
528519
KeyType::EC => {
529520
let sigscheme =

‎crates/extensions/tedge-p11-server/src/service.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl SecretString {
7878

7979
impl From<SecretString> for AuthPin {
8080
fn from(value: SecretString) -> Self {
81-
AuthPin::new(value.0)
81+
AuthPin::new(value.0.into())
8282
}
8383
}
8484

‎deny.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ feature-depth = 1
7272
ignore = [
7373
{ id = "RUSTSEC-2024-0384", reason = "crate: instant. Used by backoff and requires refactoring to remove this dependency" },
7474
{ id = "RUSTSEC-2025-0012", reason = "crate: backoff. Needs refactoring to remove dependency" },
75-
{ id = "RUSTSEC-2024-0436", reason = "crate: paste. Used by cryptoki dependency" },
7675
{ id = "RUSTSEC-2023-0071", reason = "crate: rsa. No patch available, not using affected API, added rules to clippy to forbid using these APIs" },
7776
{ id = "RUSTSEC-2026-0009", reason = "crate: time. Patching requires updating MSRV, applied workaround in one usage, added rules to clippy to forbid using these APIs elsewhere" },
7877

0 commit comments

Comments
 (0)