Skip to content

Cryptoki etas integration - #49

Open
oeweda wants to merge 38 commits into
eclipse-score:mainfrom
Valeo-S-CORE-Organization:cryptoki_etas_integration
Open

Cryptoki etas integration#49
oeweda wants to merge 38 commits into
eclipse-score:mainfrom
Valeo-S-CORE-Organization:cryptoki_etas_integration

Conversation

@oeweda

@oeweda oeweda commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Key Changes:

Your Reviews will be appreciated @ChansAlive @PandaeDo @masc2023 @schreibwsag @OliverHeilwagen

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
2026/08/24 07:08:16 Downloading https://releases.bazel.build/8.6.0/release/bazel-8.6.0-linux-x86_64...
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 3a5b854d-131b-49dc-b2f6-f47a85d46fb6
Computing main repo mapping: 
Computing main repo mapping: 
DEBUG: Rule 'score_baselibs_rust+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-4kzcXcvGi9xBEEnrPOiSEvteITZMPKmK3MNgJXQIGtY="
DEBUG: Repository score_baselibs_rust+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:431:31: in <toplevel>
DEBUG: Rule 'score_logging+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-/Q5+YfLkbMpz5PfvOkNS7qA3ehzth4emFhTcsk4q3zQ="
DEBUG: Repository score_logging+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:431:31: in <toplevel>
DEBUG: Rule 'abseil-cpp+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-m3oGQwXp/ZTRJP+mzDWFkutCtdpYj7TgfQklSqQAhts="
DEBUG: Repository abseil-cpp+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:431:31: in <toplevel>
Computing main repo mapping: 
DEBUG: Rule 'grpc+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-CvN7gAlTEwtHwHW1ZoPuYL3D7aPDf8YAQZP1tWl1ggQ="
DEBUG: Repository grpc+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:431:31: in <toplevel>
Computing main repo mapping: 
DEBUG: Rule 'protobuf+' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-w6Cp7OiTLjHDtzbi2xixxC5wcM2biBOIsm0BqnHiTKI="
DEBUG: Repository protobuf+ instantiated at:
  <builtin>: in <toplevel>
Repository rule http_archive defined at:
  /home/runner/.bazel/external/bazel_tools/tools/build_defs/repo/http.bzl:431:31: in <toplevel>
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Loading: 2 packages loaded
    currently loading: 
WARNING: Target pattern parsing failed.
ERROR: Skipping '//:license-check': no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/inc_security_crypto/inc_security_crypto/BUILD
ERROR: no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/inc_security_crypto/inc_security_crypto/BUILD
INFO: Elapsed time: 11.976s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

Comment thread docs/crypto/architecture/index.rst
Comment thread docs/crypto/architecture/index.rst Outdated
Comment thread docs/crypto/architecture/dynamic_architecture.rst Outdated
Comment thread docs/crypto/architecture/dynamic_architecture.rst Outdated
@PandaeDo

Copy link
Copy Markdown
Contributor

80k lines. Sorry, but I'm not able to review that. Is it possible to create smaller, readable PR's?

@ChansAlive

Copy link
Copy Markdown
Contributor

Kindly check the PR again and resolve the merge conflicts.
It may then reflect the actual changes that is being brought in.
It currently shows the source code that is already present in the main as incoming changes.
Thanks

@oeweda
oeweda force-pushed the cryptoki_etas_integration branch 4 times, most recently from 4d92606 to cc51b96 Compare June 17, 2026 04:36
@schreibwsag

Copy link
Copy Markdown
Contributor

test_pkcs11_provider fails when compiled with USE_RUST_PKCS11 ("C_InitToken failed: 160").
test_pkcs11_provider tries to initialize the token which is apparently necessary for the SoftHSM2
case, but not for libcryptoki. Proposal: to get test_pkcs11_provider running, do the initialization
parts only if USE_RUST_PKCS11 is not defined. Then test_pkcs11_provider will run:

./bazel-bin/tests/provider_test/test_pkcs11_provider
[==========] Running 4 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 4 tests from Pkcs11ProviderHashTest
[ RUN ] Pkcs11ProviderHashTest.SHA256SingleShotHash
mw::log initialization error: Error No logging configuration files could be found. occurred with context information: Failed to load configuration files. Fallback to console logging.
mw::log initialization error: Error No logging configuration files could be found. occurred with context information: Failed to load configuration files. Fallback to console logging.
2026/06/18 05:17:33.9853564 2801418324 000 ECU1 NONE DFLT log warn verbose 4 [PKCS#11] Warning: token label autodetect failed for ' SoftHSM '. Falling back to first present slot id= 0
[ OK ] Pkcs11ProviderHashTest.SHA256SingleShotHash (126 ms)
[ RUN ] Pkcs11ProviderHashTest.SHA256StreamingHash
2026/06/18 05:17:33.9853692 2801419597 000 ECU1 NONE DFLT log warn verbose 4 [PKCS#11] Warning: token label autodetect failed for ' SoftHSM '. Falling back to first present slot id= 0
[ OK ] Pkcs11ProviderHashTest.SHA256StreamingHash (122 ms)
[ RUN ] Pkcs11ProviderHashTest.StreamStateViolation
2026/06/18 05:17:33.9853802 2801420698 000 ECU1 NONE DFLT log warn verbose 4 [PKCS#11] Warning: token label autodetect failed for ' SoftHSM '. Falling back to first present slot id= 0
[ OK ] Pkcs11ProviderHashTest.StreamStateViolation (110 ms)
[ RUN ] Pkcs11ProviderHashTest.TrueConcurrentStreamingOnSeparateSessions
2026/06/18 05:17:33.9853925 2801421927 000 ECU1 NONE DFLT log warn verbose 4 [PKCS#11] Warning: token label autodetect failed for ' SoftHSM '. Falling back to first present slot id= 0
[ OK ] Pkcs11ProviderHashTest.TrueConcurrentStreamingOnSeparateSessions (123 ms)
[----------] 4 tests from Pkcs11ProviderHashTest (482 ms total)

[----------] Global test environment tear-down
[==========] 4 tests from 1 test suite ran. (482 ms total)
[ PASSED ] 4 tests.

@oeweda
oeweda force-pushed the cryptoki_etas_integration branch 4 times, most recently from 4e95a25 to 0f08964 Compare June 22, 2026 09:41
@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

@ShoroukRamzy
ShoroukRamzy force-pushed the cryptoki_etas_integration branch 7 times, most recently from ab068a8 to 09800f7 Compare July 7, 2026 14:31
@sunildevda
sunildevda requested a review from ChansAlive July 8, 2026 08:30

@ChansAlive ChansAlive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review done on the daemon changes as part of integrating the rust pkcs11 provider

Comment thread score/crypto/daemon/provider/pkcs11/BUILD Outdated
Comment thread score/crypto/daemon/provider/pkcs11/detail/pkcs11_algorithm_info.hpp Outdated
Comment thread score/crypto/daemon/provider/pkcs11/pkcs11_provider.cpp Outdated
Comment thread score/crypto/daemon/src/daemon.cpp Outdated
Comment thread tests/integration_tests/cryptoki_demo_client.cpp Outdated
Comment thread third_party/patches/BUILD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these patch files really required to be merged?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @ChansAlive, Yes, these patches are required to compile successfully:

  1. openssl_sys patch: Bypasses host filesystem scanning (which is blocked by Bazel's secure sandbox) to link directly to our built-in //third_party/openssl library.
  2. Other patches: Fix outdated Rust syntax and Cargo workspace README paths so S-CORE compiles cleanly on modern stable toolchains

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @ShoroukRamzy ,
Thanks for the response.

  1. Currently, if I understand correctly, the patch hardcodes the version to 3.4 and we already are using 3.6.1, shouldn't we check which version of openssl we are using and adapt the patch to maintain consistency?
  2. Regarding the score_logging.patch, if this is some change that should ideally be present in the respective module, we should not be patching it here right? Probably if we are using a third_party exclusively used sources, it may be fine. But from the middleware perspective, considering the modules could be shared by multiple modules, how do we expect this patching to work?

Ideally we should try to reduce patches as this might cause issues in the reference integration.
cc: @OliverHeilwagen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @ChansAlive,

Thank you for your feedback. Regarding the first point, Let me clarify some points:

  1. OpenSSL (C++) vs openssl-sys (Rust): S-CORE compiles OpenSSL 3.6.1 (the actual C++ binary), but our Rust bindings crate openssl-sys has no 3.6.x or ossl360 flags in its source code; its highest defined 3.x flag is ossl350.

  2. Why we patch (Bazel Sandbox): The unpatched crate’s script scans host paths (like /usr/include), which is blocked inside Bazel's secure sandbox. Our patch simply bypasses this scan to prevent a compile-time crash.

  3. Backward Compatibility: If the unpatched script could scan our 3.6.1 dynamically, it would automatically fall back to ossl350. OpenSSL strictly guarantees ABI backward compatibility, making this 3.5.0 compiled subset 100% compatible and safe to run against S-CORE's compiled 3.6.1 binary at runtime.

To maintain perfect consistency, we have updated the patch to output ossl350 and version number 30500000 (3.5.0 fallback).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ShoroukRamzy,
I agree with the reason for patching the openssl-sys crate. Please check if all other patches are necessary.

The open point I have is on how to maintain consistency with openssl-sys crate patch and the openssl what we are building automatically. Else we might change (upgrade or downgrade) the openssl version without upgrading the patch.

It would be great if we have a possibility to patch with the maximum supported version of openssl (either of what is supported by crate or what we build) and throw necessary error in case of incompatibility.
Thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ChansAlive,
I removed all other patches, I tested without them and they are not needed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ChansAlive, Regarding the openssl point, I fully agree with it and I updated the patch to maintain this consistency. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ChansAlive, Regarding the openssl point, I fully agree with it and I updated the patch to maintain this consistency. Thanks!

@ChansAlive, Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@oeweda any update on the PR?

@ChansAlive ChansAlive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non rust code review

Comment thread score/tests/integration_tests/cryptoki_demo_client.cpp Outdated
Comment thread score/tests/integration_tests/init_pkcs11_token.cpp
Comment thread score/tests/integration_tests/integration_test.py
Comment thread score/tests/integration_tests/BUILD Outdated
Comment thread README.md Outdated
@masc2023

Copy link
Copy Markdown
Contributor

@ChansAlive , is this to be merged now?

@ShoroukRamzy

Copy link
Copy Markdown
Contributor

Hi @ChansAlive and @OliverHeilwagen, I addressed all the review comments. next step, I will create the sub-issues that will need to be handled in other dedicated PRs. Thanks for all the review comments and your efforts!
cc: @sunildevda @masc2023

Comment thread score/crypto/src/daemon/provider/pkcs11/src/pkcs11_module.cpp Outdated
@ChansAlive

Copy link
Copy Markdown
Contributor

@ChansAlive , is this to be merged now?

Yes. We can target to merge this next.
cc: @sunildevda @OliverHeilwagen

Comment thread README.md Outdated
Comment thread score/crypto/src/backend/BUILD

@OliverHeilwagen OliverHeilwagen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved with suggestions.

Comment thread .github/workflows/docs.yml Outdated
with:
# the bazel-target depends on your repo specific docs_targets configuration (e.g. "suffix")
bazel-target: "--lockfile_mode=error //:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"
bazel-target: "--lockfile_mode=update //:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please revert to error.
Update should hide a wrong MODULE.bazel.lock which should not be done.

This also applies to license_check.yml

We can make the lockfile update part of the pre-commit so it is less annoying when doing dependency updates.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fixed please resolve comment.

Comment thread .bazelrc
build:x86_64-linux --config=shared
build:x86_64-linux --platforms=@score_bazel_platforms//:x86_64-linux-gcc_12.2.0-posix
build:x86_64-linux --extra_toolchains=@score_gcc_x86_64_toolchain//:x86_64-linux-gcc_12.2.0
build:x86_64-linux --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this not longer required?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@OliverHeilwagen, yes not needed because this Rust toolchain registration is automatically handled by the Bzlmod module system through our dependency on@score_toolchains_rust in MODULE.bazel, making manual registeration in bazel.rc redundant

Comment thread .bazelrc
build --output_groups=+rules_lint_human
build:lint --@aspect_rules_lint//lint:fail_on_violation=true
build:lint --config=per-x86_64-linux
test --test_output=errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick, please separate it from the Clippy linting settings as it is a generic setting affecting all bazel test invocations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fixed please resolve comment.

@OliverHeilwagen OliverHeilwagen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blockers from testing and bazel point of view.
Remove of patches and crate_universe are planned as follow-up topics.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It should not be necessary to upload this file to the repository.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file got removed in earlier PRs no need to bring it back

@OliverHeilwagen OliverHeilwagen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blockers from testing and bazel point of view.
Remove of patches and crate_universe are planned as follow-up topics.

@ShoroukRamzy

ShoroukRamzy commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Hi @ChansAlive and @OliverHeilwagen, Thank you for all your feedbacks. I addressed all the review comments and I created the sub-issues that to be handled in dedicated follow-up PRs. Any other feedbacks?
cc: @sunildevda, @masc2023

@ShoroukRamzy

Copy link
Copy Markdown
Contributor

No blockers from testing and bazel point of view. Remove of patches and crate_universe are planned as follow-up topics.

Hi @OliverHeilwagen , I created these issues #185 #184 #183 to be implemented in dedicated PRs in next step

@ShoroukRamzy ShoroukRamzy mentioned this pull request Aug 24, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

PKCS11 (Cryptoki) Integration with SCORE Have only one version of OpenSSL on target Integrate PKCS11 (Cryptoki) to SCORE

8 participants