rust-cryptoki icon indicating copy to clipboard operation
rust-cryptoki copied to clipboard

Missing constants for x86_64-unknown-linux-gnu

Open j-chmielewski opened this issue 1 year ago • 6 comments

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 [email protected]
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?

j-chmielewski avatar Mar 16 '23 10:03 j-chmielewski

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?

wiktor-k avatar Mar 16 '23 11:03 wiktor-k

I'm having the same problems. These constants disappeared in packaged pkcs11.h of [email protected]:

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

augjoh avatar Mar 19 '23 09:03 augjoh

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...

cfrantz avatar Apr 20 '23 15:04 cfrantz

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:

  • we bump the main version of cryptoki-sys to 0.1.6 and release that ASAP (see #138 )
  • we yank 0.1.5 of cryptoki

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 avatar Apr 23 '23 20:04 ionut-arm

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

ionut-arm avatar Apr 25 '23 22:04 ionut-arm

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

nbdd0121 avatar Jul 14 '23 12:07 nbdd0121