Skip to content

Fix Pkcs11::new bug preventing PKCS#11 library loading and bump rust-version and update deps #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mematthias
Copy link
Contributor

@mematthias mematthias commented Jun 19, 2025

Update crates: cargo update and fix Clippy warnings

This pull request was originally intended to cover multiple changes, but it has now been split into several smaller parts for clarity and easier review.

This PR is focused solely on crate updates and cleanup:

  • Re-ran cargo update to ensure dependencies are up to date
  • Fixed all warnings reported by cargo clippy

Further related changes will follow in separate pull requests.

Old description

// # Summary
//
// This PR fixes a critical issue in `Pkcs11::new` that prevented my PKCS#11 library from being loaded correctly. The root cause was the use of `MaybeUninit::uninit()` in a context where zero-initialized or `null`-assigned variables were required. This has been resolved by using explicitly `null`-assigned variables instead.
//
// # Changes
//
// - Fixed bug in `Pkcs11::new` related to improper initialization, resolving library loading failure
// - Made the `basic.rs` test module compile again
// - Ran `cargo update` to bring dependencies up to date
// - Raised `rust-version` to `1.77` in `Cargo.toml`, as `mem::offset_of` is used and only available from that version onward

@Jakuje
Copy link
Collaborator

Jakuje commented Jun 23, 2025

Thank you for the fix for this issue!

It would be good if you could provide the changes at least in separate commits (or ideally as separate PRs) . Now there is everything mixed up in one commit (that is missing the sing-off) and then there is a fixup commit reverting one of the changes. We are certainly interested in the fix, but I am not sure if we want to pull all the changes of dependencies.

Do you know why the CI still works on the rust 1.66 when the offset_of is used? Or is it only on some configurations?

@mematthias
Copy link
Contributor Author

mematthias commented Jun 23, 2025

I've opened a new #291 PR that includes only the small change related to Pkcs11::new.
Unfortunately, I don't immediately know why offset_of works within the CI.
I've only tested this on Windows without performing any manual configuration.

@Jakuje
Copy link
Collaborator

Jakuje commented Jun 23, 2025

Interesting, The CI runs only on Linux now. From what I see, it looks the the offset_of was there before 1.77, but was stabilized with 1.77. Is there some way to run (at least build of rust crate) in GH Actions CI on Windows? It might help to catch some differences.

@wiktor-k
Copy link
Collaborator

Is there some way to run (at least build of rust crate) in GH Actions CI on Windows? It might help to catch some differences.

I've worked on it at #276. Maybe it'd be good to merge it early to have at least a check if everything looks sane? 🤔

Copy link
Member

@hug-dev hug-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!! Looks good to me but we need to:

  • decide if it's ok to bump the MRSV version. This mostly depends on where cryptoki is used: Ubuntu, Fedora, Microsoft, MacOS. We should have a look at what's the rustc version in the most common distribution
  • investigate why the MRSV CI check does not work 😅

You might also need to rebase to latest main since I have now added the Windows build as required!

@@ -1,6 +1,6 @@
[package]
name = "cryptoki-sys"
version = "0.4.0"
version = "0.4.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to change that one now, we usually bump that manually when we release a new version :)

@@ -10,13 +10,13 @@ categories = ["api-bindings", "external-ffi-bindings", "cryptography", "hardware
license = "Apache-2.0"
repository = "https://github.com/parallaxsecond/rust-cryptoki"
documentation = "https://docs.rs/crate/cryptoki-sys"
rust-version = "1.66.0"
rust-version = "1.77.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently have a MSRV of 1.66.0 so I guess we would need to decide to bump it before moving on... I am also surprised that the "MSRV - Execute CI script" CI step passed successfully with this change... Looking at its logs it does not seem to use the good Rust version 😢

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! I guess some lazy developer didn't check that!

/me checks out who touched CI lately

... 😽

I've read the docs of the action and filed #294 on mobile. Sadly there seem to be quite a few problems (I've enabled web sign off in repo settings but I guess I won't be able to fix everything like this :()

(if you want to feel free to adjust, if not I'll look at it on Monday the earliest).

…ith `null`-assigned variables; this resolves an issue that prevented my PKCS#11 library from loading

- Ran `cargo update` to refresh crate versions
- Raised `rust-version` to 1.77 in `Cargo.toml`, since `mem::offset_of` is stabilized only in this version
- Made `basic.rs` tests compile successfully again

Signed-off-by: mematthias <[email protected]>
…version, and resolved all `cargo clippy` warnings

Signed-off-by: mematthias <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants