parallaxsecond / rust-cryptoki

Rust wrapper for the PKCS #11 API, Cryptoki
https://docs.rs/cryptoki/
Apache License 2.0
77 stars 61 forks source link

Missing constants for x86_64-unknown-linux-gnu #134

Closed j-chmielewski closed 1 week ago

j-chmielewski commented 1 year ago

Latest version of cryptoki-sys does not include CKF_EC_F_2M constant and so compilation of cryptoki v0.4.1 as dependency fails.

My system:

Linux blade 6.2.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 03 Mar 2023 15:58:31 +0000 x86_64 GNU/Linux

Steps to reproduce

cargo new cryptoki-repro
cd cryptoki-repro
cargo add cryptoki@0.4.1
cargo build

Fails with message:

error[E0425]: cannot find value `CKF_EC_F_2M` in this scope
   --> /home/jck/.cargo/registry/src/github.com-1ecc6299db9ec823/cryptoki-0.4.1/src/mechanism/mechanism_info.rs:26:25
    |
26  |         const EC_F_2M = CKF_EC_F_2M;
    |                         ^^^^^^^^^^^ help: a constant with a similar name exists: `CKF_EC_F_P`
    |
   ::: /home/jck/.cargo/registry/src/github.com-1ecc6299db9ec823/cryptoki-sys-0.1.5/src/bindings/x86_64-unknown-linux-gnu.rs:581:1
    |
581 | pub const CKF_EC_F_P: CK_FLAGS = 1048576;
    | ------------------------------ similarly named constant `CKF_EC_F_P` defined here

error[E0425]: cannot find value `CKF_EC_ECPARAMETERS` in this scope
  --> /home/jck/.cargo/registry/src/github.com-1ecc6299db9ec823/cryptoki-0.4.1/src/mechanism/mechanism_info.rs:27:33
   |
27 |         const EC_ECPARAMETERS = CKF_EC_ECPARAMETERS;
   |                                 ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `CKF_ERROR_STATE` in this scope
  --> /home/jck/.cargo/registry/src/github.com-1ecc6299db9ec823/cryptoki-0.4.1/src/slot/token_info.rs:35:29
   |
35 |         const ERROR_STATE = CKF_ERROR_STATE;
   |                             ^^^^^^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
error: could not compile `cryptoki` due to 3 previous errors

I can see that latest main branch code contains those constants so perhaps all that is to be done is tagging a new version?

wiktor-k commented 1 year ago

I can reproduce this problem. Adding generate-bindings feature does not help.

I did succeed when I used crate directly via git: cryptoki = { version = "0.4.1", git = "https://github.com/parallaxsecond/rust-cryptoki" }. Maybe recent changes in #130 helped?

augjoh commented 1 year ago

I'm having the same problems. These constants disappeared in packaged pkcs11.h of cryptoki-sys@0.1.5:

296d295
< #define CKF_ERROR_STATE       (1UL << 24)
1048,1049d1046
< #define CKF_EC_F_2M       (1UL << 21)
< #define CKF_EC_ECPARAMETERS   (1UL << 22)
cfrantz commented 1 year ago

I'm having the same problem.

It seems as though there may have been error releasing or tagging.

cryptoki-0.4.1 was created on 2022-09-29. cryptoki-0.4.0 was created on 2022-09-07. cryptoki-0.3.0 was created on 2022-01-14.

Then, on 2023-03-15, cryptoki-0.3.1 and cryptoki-sys-0.1.5 were created on the cryptoki-0.3.0 branch. Crates.io shows the cryptoki-sys dep for cryptoki as "^0.1.4", so cargo selects 0.1.5.

If I manually say cryptoki-sys = "=0.1.4" in my Cargo.toml, I can build. Of course, this means you're depending on a cryptoki-sys that is 9 months older than cryptoki...

ionut-arm commented 1 year ago

Ok, sorry for the huge delay.

So, it seems when we branched out cryptoki-0.3.x to release Parsec back in March, we branched from the latest v0.3 of cryptoki. We made some changes to cryptoki-sys and upstreamed that as 0.1.5 - however the problem here is that we had added other stuff to cryptoki-sys since that v0.3 of cryptoki. Which means this newest version of cryptoki-sys is actually missing some stuff that is present in main.

My suggestions here are:

Apologies everyone for this mistake, it is yet another lesson in juggling the versions of two interdependent crates in the same repo :[

cc @gowthamsk-arm - I don't think this would affect Parsec in any way.

ionut-arm commented 1 year ago

Update: I have released v0.1.6 of cryptoki-sys. I'll be yanking 0.1.5 tomorrow.

nbdd0121 commented 1 year ago

cryptoki-sys 0.1.5 doesn't seem to be yanked.

hug-dev commented 1 week ago

Closing as new release of cryptoki-sys were made. Re-open if not!