Skip to content

Introduce backend-agnostic provider configuration and provider manager factory - #92

Open
ChansAlive wants to merge 26 commits into
eclipse-score:mainfrom
etas-contrib:backend_integration
Open

Introduce backend-agnostic provider configuration and provider manager factory#92
ChansAlive wants to merge 26 commits into
eclipse-score:mainfrom
etas-contrib:backend_integration

Conversation

@ChansAlive

@ChansAlive ChansAlive commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR decouples the crypto daemon's provider layer from any specific cryptographic backend.

Previously, daemon manually wired OpenSSL and SoftHSM factories step by step, provider names were hardcoded, and a single factory failure aborted the entire startup. There was no stable seam between which backends are compiled in and how providers are registered and routed at runtime.

Key changes:

  • Introduced a backend abstraction layer (score/crypto/src/backend/) that contains all backend-specific knowledge — how to construct an OpenSSL provider, what default SoftHSM token entries look like, which backends are compiled in. The provider framework itself no longer imports any backend headers.
  • Introduced ProviderManagerFactory that replaces the multi-step factory wiring in daemon.cpp with a single Create(config) call, owning the full sequencing: parse config → create factories for enabled backends → register providers → initialize routing tables.
  • Made provider startup resilient: factory results now carry per-provider failure details instead of a single bool, so a single unavailable token no longer blocks all other providers from registering.
  • Added documentation for the backend configuration model and updated the component overview and provider architecture diagrams.

Out of scope:
Test reuse across providers.

Build impact:
Backends selected via compile-time flags; existing OpenSSL and SoftHSM defaults are preserved.

closes #94

@github-actions

github-actions Bot commented Jul 17, 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: 24c8c07f-7b5d-4620-abe3-cb228871cd62
Computing main repo mapping: 
Computing main repo mapping: 
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 '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: 
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: 
Loading: 
Loading: 1 packages loaded
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/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: 18.033s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

@github-actions

Copy link
Copy Markdown

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

@schreibwsag

Copy link
Copy Markdown
Contributor

I just checked whether I could integrate the NXP pkcs11-hse module using the mechanism
you implemented (backend_config.bzl/backend_exports.bzl). All was working as described.

@ShoroukRamzy

Copy link
Copy Markdown
Contributor

Hi @ChansAlive, Thank you for the great PR. I would like to revisit the decision we took today with @sunildevda and @schreibwsag regarding the merge of Cryptoki PR first https://github.com/eclipse-score/inc_security_crypto/pull/49/changes#diff-d1c061eac386f8ea2f48819d2f3a6ba46b3d17d9ac16176816beaf2fbea1c681. Sorry for the confusion, in the meeting I was thinking this is a proposal PR for the architecture improvement not a ready implementation. In this case, I think merging this PR first then adapting cryptoki PR accordingly will be more convenient and will allow me to handle the cryptoki integration the correct way based on this current implementation. So those will be two steps. otherwise, I think this PR will need to handle the cryptoki integration as well to resolve some expected conflicts. What do you think @ChansAlive, @sunildevda and @schreibwsag?
Thanks!

@ChansAlive
ChansAlive deployed to workflow-approval August 4, 2026 07:53 — with GitHub Actions Active
@ChansAlive
ChansAlive temporarily deployed to workflow-approval August 4, 2026 07:53 — with GitHub Actions Inactive
@ChansAlive

ChansAlive commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Integration of AFALG provider completed. As both use chases I checked (new pkcs11 backend and new score_provider) are working, the PR could be merged from my point of view.

@schreibwsag @ShoroukRamzy ,

Based on the review comments, I have modified the way to configure the backend providers.
More details on adding the provider is present in Readme. https://github.com/eclipse-score/inc_security_crypto/pull/92/changes#diff-b9bd4fabe749201c9f08d2150104206de4c59b3a556fb20be84b3855294bbb93

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

Review result.
Following topics are expected to be solved in follow up PRs:

)

bool_flag(
name = "score_crypto_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.

Suggested change
name = "score_crypto_openssl_enabled",
name = "score_crypto_score_openssl_enabled",

Please also updates description and readme accordingly

)

bool_flag(
name = "score_crypto_primula_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.

Suggested change
name = "score_crypto_primula_enabled",
name = "score_crypto_score_primula_enabled",

Please also updates description and readme accordingly


## Score Provider Sub-Backends

Score provider sub-backends live under `score_provider/<backend>/`. Each follows

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.

Suggested change
Score provider sub-backends live under `score_provider/<backend>/`. Each follows
Score provider sub-backends live under `score/crypto/src/daemon/provider/score_provider/<backend>/`. Each follows

@ChansAlive ChansAlive Aug 4, 2026

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.

I understand the confusion here. I will try to rephrase here with absolute paths.
I have created a section to explain the two folder view of the provider families and what each exists for. The folder mentioned here is infact backend package folder


## Adding a New Score Provider Backend

1. Implement the provider under `score_provider/<backend>/`.

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 provide full path to score_provider as above.

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.

Same as the comment for above

Comment thread score/crypto/src/backend/BUILD
+Shutdown() : Result<void>
+Initialize(context : ProviderInitContext) : bool
+Shutdown() : void
+IsInitialized() : bool

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 is expected that this method is not necessary (Initialize -> false -> provider is not initialized -> daemon terminates)


interface provider::IProviderFactory {
+CreateAndRegister(manager) : bool
+CreateAndRegister(manager : ProviderManager&) : ProviderFactoryResult

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 change to Expected<void, error>

+RegisterFactory(factory)
+Initialize() : bool
+RegisterProvider(name, provider, type) : bool
+IsProviderRegistered(name) : bool

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.

Should not be required (RegisterProvider -> false -> Provider could not be registered -> daemon terminates)

title __Architecture overview__

set namespaceSeparator ::
top to bottom direction

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.

plantuml preview in devconatiner does not longer work please check the file for errors.
May also be deffered to eclipse-score/inc_security_crypto#140

└── BuildTypeMappings(ProviderInitConfig.typeToProviderName)
resolve registered names → runtime ProviderId

On a later request, ``ProviderManager::GetProvider(...)`` checks

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.

We should not allow a further defferred initialization. If the provider_manager->Initialize() fails the daemon should terminate and not try a deffered initialization on user application demand.

@schreibwsag

Copy link
Copy Markdown
Contributor

I could integrate my pkcs11_dynload backend and my afalg provider using the new config method.
Only one cosmetic remark (active_backends_list.hpp)

// Include enabled backend adapters (controlled by BUILD file defines)
#ifdef SCORE_BACKEND_OPENSSL_ENABLED
#include "score/crypto/src/backend/score_provider/openssl/openssl_backend_adapter.hpp"
#endif

#ifdef SCORE_BACKEND_PRIMULA_ENABLED
#include "score/crypto/src/backend/primula/primula_backend_adapter.hpp"
#endif

For Primula it should also be:
#include "score/crypto/src/backend/score_provider/primula/primula_backend_adapter.hpp"

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.

Backend concept

6 participants