Cryptoki etas integration - #49
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
80k lines. Sorry, but I'm not able to review that. Is it possible to create smaller, readable PR's? |
|
Kindly check the PR again and resolve the merge conflicts. |
4d92606 to
cc51b96
Compare
|
test_pkcs11_provider fails when compiled with USE_RUST_PKCS11 ("C_InitToken failed: 160"). ./bazel-bin/tests/provider_test/test_pkcs11_provider [----------] Global test environment tear-down |
4e95a25 to
0f08964
Compare
|
The created documentation from the pull request is available at: docu-html |
ab068a8 to
09800f7
Compare
ChansAlive
left a comment
There was a problem hiding this comment.
Review done on the daemon changes as part of integrating the rust pkcs11 provider
| } | ||
| auto& km = km_result.value(); | ||
|
|
||
| auto slot_result = ctx->ResolveResource("HMAC_SHA256_IntegrationTestKey_SoftHSM", ResourceType::kKeySlot); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Are these patch files really required to be merged?
There was a problem hiding this comment.
Hi @ChansAlive, Yes, these patches are required to compile successfully:
- 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.
- Other patches: Fix outdated Rust syntax and Cargo workspace README paths so S-CORE compiles cleanly on modern stable toolchains
There was a problem hiding this comment.
Hi @ShoroukRamzy ,
Thanks for the response.
- 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?
- 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
There was a problem hiding this comment.
Hi @ChansAlive,
Thank you for your feedback. Regarding the first point, Let me clarify some points:
-
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.
-
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.
-
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).
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@ChansAlive,
I removed all other patches, I tested without them and they are not needed
There was a problem hiding this comment.
@ChansAlive, Regarding the openssl point, I fully agree with it and I updated the patch to maintain this consistency. Thanks!
There was a problem hiding this comment.
@ChansAlive, Regarding the openssl point, I fully agree with it and I updated the patch to maintain this consistency. Thanks!
@ChansAlive, Done
09800f7 to
2811e99
Compare
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.
Key Changes:
Integrated the cryptoki module natively into the score_crypto.
Moved the cryptoki provider to score/crypto/daemon/provider/pkcs11/cryptoki.
Updated all Bazel build configurations, Cargo dependencies, and lockfiles to correctly map to the new path.
Verified that the daemon, integration tests, and multi-provider demos build and pass successfully with the new provider location.
Use a single source for openssl (ETAS provided version) found under third_party/openssl
Integrate SCORE Logger into Cryptoki code
closes Integrate PKCS11 (Cryptoki) to SCORE #29 (children tasks PKCS11 (Cryptoki) Integration with SCORE #31 and Integration of PKCS11 (Cryptoki) With ETAS Architecture #32)
closes Have only one version of OpenSSL on target #30 (child task Selecting One OpenSSL Version for the Security Code #33)
Your Reviews will be appreciated @ChansAlive @PandaeDo @masc2023 @schreibwsag @OliverHeilwagen