Skip to content

Cryptoki etas integration - #49

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

Cryptoki etas integration#49
oeweda wants to merge 29 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]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: ffa909e8-418a-4ba9-9876-994a1252787a
Computing main repo mapping: 
ERROR: Error computing the main repository mapping: Missing checksum for registry file https://raw.githubusercontent.com/eclipse-score/bazel_registry/main/modules/score_baselibs/0.2.9/MODULE.bazel not permitted with --lockfile_mode=error. Please run `bazel mod deps --lockfile_mode=update` to update your lockfile.

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
}
auto& km = km_result.value();

auto slot_result = ctx->ResolveResource("HMAC_SHA256_IntegrationTestKey_SoftHSM", ResourceType::kKeySlot);

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.

Since we want to choose either softHSM or cryptoki, it may be better to rename the keyslot resourceId to have a generic name. Else it is bit confusing. The change requires updating the config json.

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?

oeweda and others added 29 commits August 10, 2026 13:00
Co-authored-by: Copilot <copilot@github.com>
Fix the static library link order for OpenSSL (libssl before libcrypto)
to resolve undefined symbols during linking. Additionally, apply missing
Eclipse Foundation copyright headers to newly added Cryptoki source
files to pass the copyright checker.
Refactor the openssl_sys_build_rs.patch build script to dynamically parse the compiled OpenSSL version number from S-CORE's opensslv.h header inside the sandboxed build environment.
Update openssl_sys_build_rs.patch to emit the ossl350 configuration flags and version number 30500000. This provides the correct backward-compatible fallback configuration for S-CORE's compiled OpenSSL 3.6.1.
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