Skip to content

feat(crypto): pin keys to one permitted algorithm - #352

Draft
abdullahelmarghany wants to merge 2 commits into
eclipse-score:mainfrom
abdullahelmarghany:feat/wp1-5-permitted-algorithm
Draft

abdullahelmarghany wants to merge 2 commits into
eclipse-score:mainfrom
abdullahelmarghany:feat/wp1-5-permitted-algorithm

Conversation

@abdullahelmarghany

@abdullahelmarghany abdullahelmarghany commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

depends on: #346. Only the last commit belongs to this PR.

A key labelled with a key row fits every operation of its family: an
"AES-256" key serves AES-256-CBC, AES-256-GCM and AES-256-CMAC, and an
"ECDSA-P256" key serves every ECDSA-P256 digest. Using one key in two
modes can leak what one mode relies on: key material also used for
AES-256-GCM outside the daemon (no provider serves AES-GCM today) could
be bound to an AES-256-CBC context, where one zero block under a zero
IV returns the GCM hash subkey.

Add an optional permitted algorithm to a key:

  • GenerateKeyParams::permitted_algorithm / SetPermittedAlgorithm(),
    by name, sent as an optional trailing string on KEY_GENERATE.
  • "permitted_algorithm" on a key slot in the daemon configuration
    (FlatBuffers schema, parser, KeyConfig, KeySlotConfig).

The pin stays a name on the wire and in the configuration; the daemon
resolves it to its catalog row once and refuses an unknown name with
kUnsupportedAlgorithm.

The pin is daemon policy. It is stored on the KeyEntry (generated or
slot-loaded keys) or the slot configuration, and PeekKeyHandle()
returns it in ProviderKeyHandle::permitted_algorithm, so providers need
no change. MediatorImpl::BindAndAuthorizeKey refuses any context whose
resolved row is not the pinned row with kIncompatibleKeyType. No pin
keeps today's behaviour.

A pin the key could never serve, or one that names a key, digest or
random generator, is refused at generation with kIncompatibleKeyType,
and such a slot is skipped at load. A key labelled with an operation
row, such as "HMAC-SHA256" or "AES-256-CBC", already serves only that
row (#345), so the only pin it accepts is that row.

@github-actions

github-actions Bot commented Oct 30, 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.6.0) and connecting to it...
INFO: Invocation ID: b9de5ad4-ac36-4e4d-bdff-e0d6bbe751fb
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>
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>
WARNING: For repository 'score_bazel_platforms', the root module requires module version score_bazel_platforms@0.1.2, but got score_bazel_platforms@1.1.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.25 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'flatbuffers', the root module requires module version flatbuffers@25.12.19, but got flatbuffers@25.12.19.bcr.1 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
WARNING: For repository 'score_process_description', the root module requires module version score_process_description@2.2.2, but got score_process_description@2.2.3 in the resolved dependency graph. Please update the version in your MODULE.bazel or set --check_direct_dependencies=off
Computing main repo mapping: 
Loading: 
Loading: 1 packages loaded
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/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: 12.621s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

@abdullahelmarghany
abdullahelmarghany force-pushed the feat/wp1-5-permitted-algorithm branch from 7c11511 to cf7de3d Compare November 1, 2026 00:13
@abdullahelmarghany
abdullahelmarghany force-pushed the feat/wp1-5-permitted-algorithm branch from cf7de3d to 4d3abb2 Compare November 1, 2026 00:57
@abdullahelmarghany
abdullahelmarghany force-pushed the feat/wp1-5-permitted-algorithm branch from 4d3abb2 to 80cda41 Compare November 2, 2026 10:28
@PandaeDo
PandaeDo requested a balanced review from Copilot November 3, 2026 11:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The integration suite fails in PKCS#11-only builds because capability tests unconditionally require RANDOM and asymmetric operations that the backend does not support.

3 open issues
What changed in this PR

Adds optional, daemon-enforced algorithm pins to generated and slot-loaded keys, preventing cross-algorithm reuse while preserving existing behavior for unpinned keys. The PR also introduces typed algorithm handling and provider capability discovery.

Changes:

  • Carries permitted-algorithm policy through generation requests, slot configuration, validation, and key metadata.
  • Migrates provider interfaces to algorithm descriptors and adds enumerator-based API selection.
  • Expands tests, integration wiring, build dependencies, and architecture documentation.

This pull request requires changes.

The following issues must be addressed before approval:

  • Critical · 1 vote — score/tests/integration_tests/integration_test.py:245: Capability tests unconditionally expect RANDOM and RSA/Ed25519 support, causing failures in PKCS#11-only builds. Make expectations conditional on the software backend or restrict execution to OpenSSL configurations.
  • Moderate · 3 votes — score/crypto/src/daemon/provider/pkcs11/detail/pkcs11_algorithm_info_test.cpp:26: Row() returns a reference into a temporary optional, leaving a dangling reference and undefined behavior. Return AlgorithmDescriptor by value.
  • Moderate · 3 votes — score/crypto/src/daemon/provider/pkcs11/operations/factory/pkcs11_handler_factory.cpp:46: HASH discovery checks only static mappings, whereas handler creation also requires token mechanism support with CKF_DIGEST. Apply the same token support gate to discovery.
File Description
score/​tests/​test_vectors/​config/​integration_test_config.json Adds pinned HMAC slots and resource mappings.
score/​tests/​integration_tests/​score_api_mac_test.cpp Tests typed MAC selection and unknown algorithms.
score/​tests/​integration_tests/​score_api_hash_test.cpp Tests typed hash selection and invalid enumerators.
score/​tests/​integration_tests/​score_api_ecdsa_test.cpp Tests curve mismatches and additional digest pairings.
score/​tests/​integration_tests/​integration_test.py Runs capability-discovery integration tests.
score/​tests/​integration_tests/​BUILD Builds and deploys capability-discovery tests.
score/​tests/​demo/​mac_multi_provider_demo.cpp Updates demo calls to algorithm descriptors.
score/​crypto/​src/​daemon/​provider/​tests/​provider_test/​test_provider.cpp Migrates hash tests to catalog descriptors.
score/​crypto/​src/​daemon/​provider/​tests/​provider_test/​test_provider_signature.cpp Migrates signature tests to catalog descriptors.
score/​crypto/​src/​daemon/​provider/​tests/​provider_test/​test_pkcs11_provider.cpp Migrates PKCS#11 hash tests to descriptors.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​verify/​src/​score_verify_handler.cpp Derives signature size from descriptor metadata.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​verify/​score_verify_handler.hpp Stores typed verification algorithms.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​sign/​src/​score_sign_handler.cpp Derives signature size from descriptor metadata.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​sign/​score_sign_handler.hpp Stores typed signing algorithms.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​random/​src/​score_random_handler.cpp Accepts random-algorithm descriptors.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​random/​score_random_handler.hpp Stores typed random algorithms.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​mac/​src/​score_mac_handler.cpp Accepts MAC-algorithm descriptors.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​mac/​score_mac_handler.hpp Stores typed MAC algorithms.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​hash/​src/​score_hash_handler.cpp Reads digest size from catalog metadata.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​hash/​score_hash_handler.hpp Stores typed hash algorithms.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​factory/​src/​score_handler_factory.cpp Routes descriptor-based handler creation.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​factory/​score_handler_factory.hpp Separates key-management creation from algorithm hooks.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​cipher/​src/​score_cipher_handler.cpp Reads block and IV sizes from descriptors.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​cipher/​score_cipher_handler.hpp Stores typed cipher algorithms.
score/​crypto/​src/​daemon/​provider/​score_provider/​operations/​cipher/​score_cipher_handler_test.cpp Updates descriptor-based output-size tests.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​verify/​openssl_rsa_pss_verify_handler.hpp Updates RSA-PSS verification interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​verify/​openssl_rsa_pss_verify_handler.cpp Uses typed RSA-PSS digest and size metadata.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​verify/​openssl_ed25519_verify_handler.hpp Updates Ed25519 verification interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​verify/​openssl_ed25519_verify_handler.cpp Uses typed Ed25519 support checks.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​verify/​openssl_ecdsa_verify_handler.hpp Updates ECDSA verification interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​verify/​openssl_ecdsa_verify_handler.cpp Uses typed digest and curve metadata.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​sign/​openssl_rsa_pss_sign_handler.hpp Updates RSA-PSS signing interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​sign/​openssl_ed25519_sign_handler.hpp Updates Ed25519 signing interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​sign/​openssl_ed25519_sign_handler.cpp Uses typed Ed25519 support checks.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​sign/​openssl_ecdsa_sign_handler.hpp Updates ECDSA signing interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​sign/​openssl_ecdsa_sign_handler.cpp Uses typed digest and signature-buffer metadata.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​random/​openssl_random_handler.hpp Updates RNG descriptor interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​random/​openssl_random_handler.cpp Delegates typed RNG support checks.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​mac/​openssl_hmac_handler.hpp Updates HMAC descriptor interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​mac/​openssl_hmac_handler.cpp Replaces string lists with typed HMAC checks.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​hash/​openssl_hash_handler.hpp Updates hash validation interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​hash/​openssl_hash_handler.cpp Uses typed hash validation and EVP mapping.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​factory/​openssl_handler_factory.hpp Declares capability queries and descriptor hooks.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​factory/​openssl_handler_factory.cpp Implements typed creation and capability reporting.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​cipher/​openssl_cipher_handler.hpp Updates cipher descriptor interfaces.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​operations/​cipher/​openssl_cipher_handler.cpp Uses typed cipher selection and key sizing.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​key_management/​openssl_key_handler_test.cpp Migrates key tests to catalog descriptors.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​key_management/​openssl_key_factory.hpp Declares typed sizing and generation support.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​detail/​signature_common.hpp Updates signature helpers to descriptors.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​detail/​signature_common.cpp Uses typed key-family, curve, and digest checks.
score/​crypto/​src/​daemon/​provider/​score_provider/​openssl/​BUILD Adds algorithm-catalog dependencies.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​mac/​pkcs11_mac_handler.hpp Updates MAC descriptor interfaces.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​mac/​pkcs11_mac_handler.cpp Uses typed mechanism and MAC-size mapping.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​key_management/​pkcs11_key_management_handler.hpp Updates key-algorithm support interfaces.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​key_management/​pkcs11_key_management_handler.cpp Uses typed key-management support checks.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​key_management/​pkcs11_key_management_handler_test.cpp Uses separate key-management factory entry point.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​hash/​pkcs11_hash_handler.hpp Updates hash descriptor interfaces.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​hash/​pkcs11_hash_handler.cpp Uses typed mechanisms and digest sizes.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​factory/​pkcs11_handler_factory.hpp Declares capability queries and key-management creation.
score/​crypto/​src/​daemon/​provider/​pkcs11/​operations/​factory/​pkcs11_handler_factory.cpp Implements descriptor-based creation and support reporting.
score/​crypto/​src/​daemon/​provider/​pkcs11/​key_management/​pkcs11_key_store.hpp Updates key-registration descriptor interfaces.
score/​crypto/​src/​daemon/​provider/​pkcs11/​key_management/​pkcs11_key_store.cpp Registers typed key metadata.
score/​crypto/​src/​daemon/​provider/​pkcs11/​key_management/​pkcs11_key_slot_handler.cpp Resolves slot algorithms before registration.
score/​crypto/​src/​daemon/​provider/​pkcs11/​key_management/​pkcs11_key_factory.hpp Declares key-generation capability reporting.
score/​crypto/​src/​daemon/​provider/​pkcs11/​key_management/​pkcs11_key_factory.cpp Reports descriptor-based generation support.
score/​crypto/​src/​daemon/​provider/​pkcs11/​detail/​pkcs11_algorithm_info_test.cpp Tests typed mechanism and key mappings.
score/​crypto/​src/​daemon/​provider/​pkcs11/​BUILD Adds catalog dependencies and mapping tests.
score/​crypto/​src/​daemon/​provider/​handler/​i_crypto_handler_factory.hpp Defines typed creation and capability contracts.
score/​crypto/​src/​daemon/​provider/​handler/​BUILD Adds algorithm-descriptor dependencies.
score/​crypto/​src/​daemon/​provider/​executors/​src/​key_mgmt_executor.cpp Validates generation pins and registers policy.
score/​crypto/​src/​daemon/​provider/​executors/​key_mgmt_request_parser.hpp Resolves key algorithms and optional wire pins.
score/​crypto/​src/​daemon/​provider/​executors/​BUILD Adds key-compatibility dependencies.
score/​crypto/​src/​daemon/​mediator/​src/​mediator_impl.hpp Updates binding interfaces and discovery declarations.
score/​crypto/​src/​daemon/​mediator/​mediator_operations.hpp Defines algorithm resolution and discovery operations.
score/​crypto/​src/​daemon/​mediator/​context_algorithm_test.cpp Tests context algorithm-resolution rules.
score/​crypto/​src/​daemon/​mediator/​BUILD Adds catalog dependencies and resolution tests.
score/​crypto/​src/​daemon/​key_management/​slot/​slot_registry.hpp Adds permitted algorithms to registration parameters.
score/​crypto/​src/​daemon/​key_management/​slot/​file_backed_slot_handler.cpp Resolves algorithms before importing slot material.
score/​crypto/​src/​daemon/​key_management/​slot/​config_driven_slot_catalog.cpp Skips unknown or incompatible slot pins.
score/​crypto/​src/​daemon/​key_management/​interfaces/​key_types.hpp Adds typed key metadata and pin fields.
score/​crypto/​src/​daemon/​key_management/​interfaces/​key_slot_config.hpp Adds slot-level permitted-algorithm policy.
score/​crypto/​src/​daemon/​key_management/​interfaces/​i_key_factory.hpp Defines key-generation capability queries.
score/​crypto/​src/​daemon/​key_management/​core/​key_management_service.cpp Preserves pins during loading and metadata lookup.
score/​crypto/​src/​daemon/​key_management/​core/​key_entry.hpp Stores daemon-owned permitted-algorithm policy.
score/​crypto/​src/​daemon/​key_management/​BUILD Adds compatibility-validation dependencies.
score/​crypto/​src/​daemon/​config/​src/​flatbuffer_config_parser.cpp Parses optional slot algorithm pins.
score/​crypto/​src/​daemon/​config/​inc/​config.hpp Adds configured slot pins.
score/​crypto/​src/​daemon/​config/​crypto_config.fbs Extends slot schema with optional pins.
score/​crypto/​src/​daemon/​common/​key_compatibility.hpp Defines key-fit and exact-pin checks.
score/​crypto/​src/​daemon/​common/​BUILD Adds compatibility utilities and test targets.
score/​crypto/​src/​daemon/​common/​algorithm_info_test.cpp Tests descriptor-derived algorithm properties.
score/​crypto/​src/​api/​types/​BUILD Exposes algorithm catalog and tests.
score/​crypto/​src/​api/​i_crypto_context.hpp Clarifies names and default-RNG query behavior.
score/​crypto/​src/​api/​future/​config/​csr_generation_context_config.hpp Adds enumerator-based algorithm selection.
score/​crypto/​src/​api/​future/​config/​aead_context_config.hpp Adds enumerator-based algorithm selection.
score/​crypto/​src/​api/​contexts/​src/​key_management_context_impl.cpp Validates names and serializes generation pins.
score/​crypto/​src/​api/​contexts/​BUILD Adds client-side algorithm-check dependencies.
score/​crypto/​src/​api/​config/​verify_signature_context_config.hpp Adds typed selection and updates examples.
score/​crypto/​src/​api/​config/​sign_context_config.hpp Adds typed selection and updates examples.
score/​crypto/​src/​api/​config/​random_context_config.hpp Adds typed RNG selection.
score/​crypto/​src/​api/​config/​mac_context_config.hpp Adds typed MAC selection and corrects examples.
score/​crypto/​src/​api/​config/​key_operation_params.hpp Adds generation pins and typed key selection.
score/​crypto/​src/​api/​config/​hash_context_config.hpp Adds typed hash selection.
score/​crypto/​src/​api/​config/​cipher_context_config.hpp Adds typed cipher selection.
score/​crypto/​src/​api/​config/​BUILD Adds selection helpers and test targets.
score/​crypto/​src/​api/​config/​base_context_config.hpp Implements shared enumerator selection.
score/​crypto/​src/​api/​config/​algorithm_selection.hpp Converts enumerators to wire names.
score/​crypto/​src/​api/​config/​algorithm_selection_test.cpp Tests overloads, names, and unknown values.
score/​crypto/​src/​api/​common/​src/​algorithm_check.hpp Adds pre-IPC catalog validation.
score/​crypto/​src/​api/​common/​BUILD Exposes internal algorithm-check helpers.
score/​crypto/​src/​api/​BUILD Wires validation and implementation dependencies.
score/​crypto/​docs/​architecture/​provider_architecture.puml Updates factory interface diagrams.
score/​crypto/​docs/​architecture/​key_management_sequence_diagrams.puml Shows descriptor-based handler creation.
score/​crypto/​docs/​architecture/​key_management_class_diagram.puml Updates MAC algorithm types.
score/​crypto/​docs/​architecture/​key_management_architecture.rst Documents descriptor handling and slot pins.
score/​crypto/​docs/​architecture/​interfaces.rst Documents compile-time output-size helpers.
score/​crypto/​docs/​architecture/​design_decisions.rst Records structured algorithm-catalog design.
score/​crypto/​docs/​architecture/​api_description.rst Documents discovery, algorithm selection, and pin policy.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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

@abdullahelmarghany
abdullahelmarghany force-pushed the feat/wp1-5-permitted-algorithm branch from 69c5389 to ccd817b Compare November 4, 2026 08:13
@abdullahelmarghany
abdullahelmarghany force-pushed the feat/wp1-5-permitted-algorithm branch from ccd817b to 3653daa Compare November 4, 2026 10:00
@abdullahelmarghany
abdullahelmarghany force-pushed the feat/wp1-5-permitted-algorithm branch from 3653daa to 68d1e29 Compare November 4, 2026 12:29
@abdullahelmarghany
abdullahelmarghany force-pushed the feat/wp1-5-permitted-algorithm branch from 68d1e29 to d1b5aee Compare November 9, 2026 15:29
GetProviderInfo() and both QueryCapabilities() overloads of
ICryptoContext returned kUnsupportedOperation ("not yet implemented"),
and ResolveResource(name, kProvider) failed with kUnsupportedOperation
because the daemon registered a resolver only for kKeySlot. Implement
all of them.

The mediator gains PROVIDER_INFO, QUERY_CAPABILITIES and
SYSTEM_CAPABILITIES. Capabilities come from new IsAlgorithmSupported()
and IsKeyGenerationSupported() hooks on the handler and key factories.
Both take the resolved AlgorithmDescriptor and reuse the decisions
context creation and key generation already apply: the handler
factories forward to the handlers' static IsAlgorithmSupported(), and
the OpenSSL key factory runs the same key-type switch as GenerateKey().
The PKCS#11 factories also ask the selected token for the mechanism
(CKF_DIGEST for hash, CKF_SIGN|CKF_VERIFY for HMAC, CKF_GENERATE for
key generation), so a row is not reported when the token lacks it.
QUERY_CAPABILITIES resolves the name to its catalog row first; a name
the catalog does not know is reported with no operations. An empty
name reports CTR-DRBG, the generator a RANDOM context gets when it is
created without an algorithm.
SYSTEM_CAPABILITIES walks kAlgorithmCatalog and passes each row, so
every ECDSA curve/hash pairing is listed as its own algorithm. Each
algorithm goes on the wire by its catalog name, so the client needs no
copy of the catalog to read the answer.

The answer is the union over the initialized providers; each supported
operation is reported as a mode string (HASH, MAC, CIPHER, SIGN,
VERIFY, RANDOM, GENERATE_KEY).

A new score_api_capabilities_test covers both backends, including the
ECDSA cross pairings. Rows only the software provider serves are
checked under SCORE_CRYPTO_SOFTWARE_BACKEND_ENABLED; a PKCS#11-only
build expects them to be reported unsupported.

Signed-off-by: Abdullah Elmarghany <abdullah.elmarghany@bmw.de>
A key labelled with a key row fits every operation of its family: an
"AES-256" key serves AES-256-CBC, AES-256-GCM and AES-256-CMAC, and an
"ECDSA-P256" key serves every ECDSA-P256 digest. Using one key in two
modes can leak what one mode relies on: key material also used for
AES-256-GCM outside the daemon (no provider serves AES-GCM today) could
be bound to an AES-256-CBC context, where one zero block under a zero
IV returns the GCM hash subkey.

Add an optional permitted algorithm to a key:
  - GenerateKeyParams::permitted_algorithm / SetPermittedAlgorithm(),
    by name, sent as an optional trailing string on KEY_GENERATE.
  - "permitted_algorithm" on a key slot in the daemon configuration
    (FlatBuffers schema, parser, KeyConfig, KeySlotConfig).

On the wire and in the configuration the pin stays a name. The daemon
resolves it to its catalog row once: the KEY_GENERATE parser refuses a
name without a row with kUnsupportedAlgorithm, and a slot's pin is
resolved when its key is used. KeyGenerationRequest, KeyEntry,
KeyRegistrationParams and ProviderKeyHandle carry it as
std::optional<AlgorithmDescriptor>; std::nullopt means no pin.

The pin is daemon policy. It is stored on the KeyEntry (generated or
slot-loaded keys) or the slot configuration, and PeekKeyHandle()
returns it in ProviderKeyHandle::permitted_algorithm, so providers need
no change. MediatorImpl::BindAndAuthorizeKey refuses any context whose
resolved row is not the pinned row with kIncompatibleKeyType. No pin
keeps today's behaviour.

A pin the key could never serve, or one that names a key, digest or
random generator, is refused at generation with kIncompatibleKeyType;
IsValidPermittedAlgorithm() is IsKeyCompatible() on the two rows. A key
labelled with an operation row, such as "HMAC-SHA256" or "AES-256-CBC",
already serves only that row, so the only pin it accepts is that row.
ConfigDrivenSlotCatalog::Load() skips, with an error log, a slot whose
pin is unknown or does not fit its key. The earlier rule that accepted
an unknown pin and left it to an exact name match is gone: every
context algorithm is a catalog row now, so such a pin could never
match.

Signed-off-by: Abdullah Elmarghany <abdullah.elmarghany@bmw.de>

This branch is waiting to be deployed

1 waiting deployment
workflow-approval — 0316b711 Waiting Nov 10, 2026 by abdullahelmarghany via Build and Test x86_64-qnx / approval #916
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.

2 participants