Skip to content

(Crypto/Cryptoki)Migrate OpenSSL dependency to centralized score_openssl and score_crates - #317

Open
ShoroukRamzy wants to merge 2 commits into
eclipse-score:mainfrom
Valeo-S-CORE-Organization:openssl-migration
Open

ShoroukRamzy wants to merge 2 commits into
eclipse-score:mainfrom
Valeo-S-CORE-Organization:openssl-migration

Conversation

@ShoroukRamzy

@ShoroukRamzy ShoroukRamzy commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Changes
Migrate C++ and Rust consumers to the centralized score_openssl and score_crates

Next?
Once these PRs eclipse-score/openssl#1, eclipse-score/score-crates#79 and eclipse-score/baselibs#666 are merged, update the git_override commit hashes for openssl, score crates and baselibs (or switch to the official registry release versions).

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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.8.2) and connecting to it...
INFO: Invocation ID: aef43806-65cf-4488-874f-c4c61a1d8d8f
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
WARNING: For repository 'rules_python', the root module requires module version rules_python@1.8.5, but got rules_python@1.9.0 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'score_bazel_platforms', the root module requires module version score_bazel_platforms@0.1.2, but got score_bazel_platforms@1.3.0 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'rules_cc', the root module requires module version rules_cc@0.2.22, but got rules_cc@0.2.26 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 1 packages loaded
Loading: 1 packages loaded
    currently loading: 
Loading: 1 packages loaded
    currently loading: 
Loading: 1 packages loaded
    currently loading: 
Loading: 1 packages loaded
    currently loading: 
Loading: 1 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/crypto/crypto/BUILD
ERROR: no such target '//:license-check': target 'license-check' not declared in package '' defined by /home/runner/work/crypto/crypto/BUILD
INFO: Elapsed time: 17.610s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-317: https://eclipse-score.github.io/inc_security_crypto/pr-317/

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

Please link statically for now (@score_openssl//:openssl see comment)
Please remove usage of crate_universe.

Comment thread score/tests/integration_tests/BUILD Resolved
Comment thread MODULE.bazel Resolved
@ShoroukRamzy

Copy link
Copy Markdown
Contributor Author

Please link statically for now (@score_openssl//:openssl see comment) Please remove usage of crate_universe.

@OliverHeilwagen, since openssl_link also links statically by default. so can i keep openssl_link here and in other PRs as well?

@OliverHeilwagen

OliverHeilwagen commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Please link statically for now (@score_openssl//:openssl see comment) Please remove usage of crate_universe.

@OliverHeilwagen, since openssl_link also links statically by default. so can i keep openssl_link here and in other PRs as well?

@ShoroukRamzy Unfortunately not, the behaviour between cc_* rules and rust_* rules is different.
For C++ we need to create dedicated parallel cc_shared_library targets and use respective dynamic_deps (cc_binary and cc_library). These two target chains should be kept separate.

There will be a relation of cc_library components <-> cc_shared_library allocation, but this is the only coupling. The switches between shared library and static is always on the consumer side in C++ (cc_binary activate dynamic_deps, cc_shared_library use targets otherwise ignored).

For rust_* rules deps carry all relevant information there is no split between static and shared present.

@ShoroukRamzy

Copy link
Copy Markdown
Contributor Author

Please link statically for now (@score_openssl//:openssl see comment) Please remove usage of crate_universe.

@OliverHeilwagen, since openssl_link also links statically by default. so can i keep openssl_link here and in other PRs as well?

@ShoroukRamzy Unfortunately not, the behaviour between cc_* rules and rust_* rules is different. For C++ we need to create dedicated parallel cc_shared_library targets and use respective dynamic_deps (cc_binary and cc_library). These two target chains should be kept separate.

There will be a relation of cc_library components <-> cc_shared_library allocation, but this is the only coupling. The switches between shared library and static is always on the consumer side in C++ (cc_binary activate dynamic_deps, cc_shared_library use targets otherwise ignored).

For rust_* rules deps carry all relevant information there is no split between static and shared present.

Thanks @OliverHeilwagen for this explanation. then I will update the PRs as following:
static linking for C++ consumers at the moment and using the switch openssl_link for Rust consumers.

@ShoroukRamzy

Copy link
Copy Markdown
Contributor Author

@OliverHeilwagen, I opened this fix #359 to solve the CI coverage link issue.

Comment thread score/crypto/src/daemon/BUILD Outdated
] + select({
"@score_openssl//:dynamic_openssl_enabled": [
"@score_openssl//:openssl_shared",
"//third_party/soft_hsm:softhsm_shared",

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.

If I understand correctly, softhsm_shared is selected solely from use_dynamic_openssl, independently of the active pkcs11_backend. With the documented Cryptoki override and dynamic OpenSSL enabled, the configured graph contains both cryptoki_cdylib_wrapped and softhsm_shared. Both libraries export the PKCS#11 entry points, so C_GetFunctionList may resolve to SoftHSM even though Cryptoki was selected.

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.

Good catch, yes we need to reference here a label flag for the shared version.

For static swap of a pkcs11 library the existing label flag is sufficient, for activating it with enabled shared library linking we need a second label flag for the shared library target.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @kssim and @OliverHeilwagen for your feedbacks. For now I added another flag for the shared pks11 version as Oliver suggested.

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.

If I understand correctly, I do not think this fully addresses the original issue yet, because pkcs11_backend and pkcs11_shared_backend are selected independently. With the documented Cryptoki override and use_dynamic_openssl=true, deps still brings in cryptoki_cdylib_wrapped while dynamic_deps uses the default softhsm_shared, so both PKCS#11 implementations remain in the graph. Could the shared dependency be derived from the selected backend and gated by pkcs11_backend_enabled, or could inconsistent combinations be rejected?

Comment thread score/cryptoki/BUILD
DEPS = [
# --- Company Approved (Score Ecosystem) ---
"@score_crates//:libc",
"@score_crates//:openssl",

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.

@score_crates//:openssl reaches @score_openssl//:openssl_link, which resolves to the static OpenSSL target by default, while cryptoki_cdylib_wrapped is always a shared library. Selecting the documented Cryptoki backend without the dynamic flag therefore embeds one static OpenSSL instance in libcryptoki.so while the daemon’s Score provider links another one. This is exactly the invalid configuration described in the new backend README. Am I understanding correctly?

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.

Yes if libcryptoki.so is always produced and not following DR-002 it would mean that for activation of cryptoki as a backend we also are forced to enable shared library linking for openssl.

However if we wan to stay compliant with DR-002 we should also allow for static linking of cryptoki.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, in a follow-up pr, dynamic linking of pks11 should be decoupled from dynamic openssl linking.
also support for cryptoki statick linking should be supported

@ShoroukRamzy

Copy link
Copy Markdown
Contributor Author

@OliverHeilwagen, as we discussed in the meeting. we use old baselibs for now to unblock the first release. I will handle other universe crates migration in a following pr.

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

Correct handling for shared library switches may also be deferred to a follow up user story.

"//third_party/grpc:libgrpc_shared",
],
] + select({
"@score_openssl//:dynamic_openssl_enabled": [

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.

As stated in follow up PR we should require a compination of select switchs:

  • If shared lib is enabled
    • If Score provider, openssl is enabled
      • Add openssl_shared
    • If PKCS11 provider is enabled
      • Add pkcs11_shared_backend

Comment thread score/tests/integration_tests/BUILD Outdated
@@ -274,9 +281,13 @@ integration_test(
libraries = [
"//score/crypto/src/api/control_plane",
"//third_party/grpc:libgrpc_shared",

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 rebase grpc is not longer present

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks@OliverHeilwagen, rebase done, all other points will be addressed in coming PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@OliverHeilwagen, if no more points for this PR, can we merge it please to avoid PRs stack?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"//third_party/soft_hsm:softhsm_so",
],
] + select({
"@score_openssl//:dynamic_openssl_enabled": [

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.

Same as for crypto daemon we need to consider both options.
Is shared library activated + is the respective backend activated.

Here shared library + PKCS11 via softhsm would required both softhsm and openssl shared library.

name = "init_pkcs11_token",
srcs = ["init_pkcs11_token.cpp"],
dynamic_deps = select({
"@score_openssl//:dynamic_openssl_enabled": [

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.

adding of dynamic_deps should also be dependent on selected backend.

Comment thread third_party/soft_hsm/BUILD Outdated
filegroup(
name = "softhsm_so",
srcs = [":softhsm_so_extract"],
srcs = [":softhsm_shared"],

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.

i would assume the filegroup is technically not longer needed.
Referencing the softhsm_shared target should also work.

Comment thread third_party/soft_hsm/BUILD Outdated
visibility = ["//visibility:public"],
)

# Shared SoftHSM backend library for linking into daemon or test runners

@OliverHeilwagen OliverHeilwagen Nov 19, 2026 •

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 additiona library necessary with ECC=1?
In the following branch i don't have this and reference_integration is working:
https://github.com/etas-contrib/score_crypto/blob/cryptoki_and_fixes_for_ref_int/third_party/soft_hsm/BUILD#L36C1-L38C50

Maybe this was created for the problem mentioned in the comment? If the setting is not enabled the host system openssl info can leak into the build.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This branch is waiting to be deployed

1 waiting deployment
workflow-approval — 30c1ccc7 Waiting Nov 19, 2026 by ShoroukRamzy via Build and Test x86_64-qnx-itf / approval #1147
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants