Repository navigation
(Crypto/Cryptoki)Migrate OpenSSL dependency to centralized score_openssl and score_crates - #317
ShoroukRamzy wants to merge 2 commits into
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
|
Documentation preview for this pull request is available at: |
63eff2e to
24b9c91
Compare
24b9c91 to
e5c847e
Compare
OliverHeilwagen
left a comment
There was a problem hiding this comment.
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 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 |
Thanks @OliverHeilwagen for this explanation. then I will update the PRs as following: |
e5c847e to
10513d9
Compare
10513d9 to
283fde7
Compare
ff4995a to
647d6a9
Compare
647d6a9 to
3686cd3
Compare
3686cd3 to
8744a20
Compare
8744a20 to
473c997
Compare
|
@OliverHeilwagen, I opened this fix #359 to solve the CI coverage link issue. |
| ] + select({ | ||
| "@score_openssl//:dynamic_openssl_enabled": [ | ||
| "@score_openssl//:openssl_shared", | ||
| "//third_party/soft_hsm:softhsm_shared", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thanks @kssim and @OliverHeilwagen for your feedbacks. For now I added another flag for the shared pks11 version as Oliver suggested.
There was a problem hiding this comment.
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?
| DEPS = [ | ||
| # --- Company Approved (Score Ecosystem) --- | ||
| "@score_crates//:libc", | ||
| "@score_crates//:openssl", |
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
473c997 to
551fa1b
Compare
|
@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
left a comment
There was a problem hiding this comment.
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": [ |
There was a problem hiding this comment.
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
- If Score provider, openssl is enabled
| @@ -274,9 +281,13 @@ integration_test( | |||
| libraries = [ | |||
| "//score/crypto/src/api/control_plane", | |||
| "//third_party/grpc:libgrpc_shared", | |||
There was a problem hiding this comment.
Please rebase grpc is not longer present
There was a problem hiding this comment.
Thanks@OliverHeilwagen, rebase done, all other points will be addressed in coming PR.
There was a problem hiding this comment.
@OliverHeilwagen, if no more points for this PR, can we merge it please to avoid PRs stack?
There was a problem hiding this comment.
@OliverHeilwagen, the PR created #456 (comment)
| "//third_party/soft_hsm:softhsm_so", | ||
| ], | ||
| ] + select({ | ||
| "@score_openssl//:dynamic_openssl_enabled": [ |
There was a problem hiding this comment.
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": [ |
There was a problem hiding this comment.
adding of dynamic_deps should also be dependent on selected backend.
| filegroup( | ||
| name = "softhsm_so", | ||
| srcs = [":softhsm_so_extract"], | ||
| srcs = [":softhsm_shared"], |
There was a problem hiding this comment.
i would assume the filegroup is technically not longer needed.
Referencing the softhsm_shared target should also work.
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| # Shared SoftHSM backend library for linking into daemon or test runners |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@OliverHeilwagen, you are correct. I removed it and applied this fix https://github.com/etas-contrib/score_crypto/blob/cryptoki_and_fixes_for_ref_int/third_party/soft_hsm/BUILD#L36C1-L38C50
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).