Repository navigation
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: |
00b284e to
940e5fc
Compare
940e5fc to
0869885
Compare
0869885 to
63da2e0
Compare
63da2e0 to
6aceb37
Compare
6aceb37 to
21a4fed
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Active correctness issues remain: the documentation uses the wrong ownership-transfer API, missing PKCS#11 configuration drops defaults, the provider retains an unintended PIN copy, and invalid referenced files do not enforce fail-closed startup.
4 open issues
What changed in this PR
This pull request adds startup-time runtime configuration for backend-specific settings, currently implemented for PKCS#11. The common Crypto configuration references versioned backend-owned FlatBuffers, which are resolved relative to the main configuration file and securely parsed before provider creation.
Changes:
- Adds provider-neutral backend configuration references and relative-path resolution.
- Adds versioned PKCS#11 schema, validation, parsing, secure file loading, and PIN handling.
- Updates provider-factory wiring, integration fixtures, tests, build targets, and architecture documentation.
| File | Description |
|---|---|
| score/tests/test_vectors/config/integration_test_config.json | References the runtime PKCS#11 configuration and updates provider names. |
| score/tests/test_vectors/config/integration_pkcs11_config.json | Defines the PKCS#11 integration token configuration. |
| score/tests/test_vectors/config/BUILD | Builds and packages the versioned PKCS#11 configuration vector. |
| score/tests/bazel/integration.bzl | Packages integration configuration files with owner-only permissions. |
| score/crypto/src/daemon/provider/tests/provider_test/test_pkcs11_provider.cpp | Tests secure PIN transfer during provider construction. |
| score/crypto/src/daemon/provider/tests/provider_test/test_pkcs11_multi_token.cpp | Updates multi-token provider construction for consumed configuration objects. |
| score/crypto/src/daemon/provider/src/provider_manager_factory.cpp | Resolves backend references and passes parsed PKCS#11 configuration to the provider factory. |
| score/crypto/src/daemon/provider/pkcs11/src/pkcs11_token_config.cpp | Implements PKCS#11 configuration ownership transfer and PIN cleanup. |
| score/crypto/src/daemon/provider/pkcs11/src/pkcs11_provider.cpp | Updates provider construction to consume configuration and handle PIN cleanup. |
| score/crypto/src/daemon/provider/pkcs11/src/pkcs11_provider_factory.cpp | Converts parsed token entries into providers and registers them with configured provider types. |
| score/crypto/src/daemon/provider/pkcs11/src/pkcs11_module.cpp | Adds secure PIN ownership and cleanup to token authentication guards. |
| score/crypto/src/daemon/provider/pkcs11/pkcs11_token_config.hpp | Defines the PKCS#11 backend identifier and transferable configuration API. |
| score/crypto/src/daemon/provider/pkcs11/pkcs11_provider.hpp | Updates provider constructors to consume configuration objects. |
| score/crypto/src/daemon/provider/pkcs11/pkcs11_provider_factory.hpp | Updates factory ownership and registration result documentation. |
| score/crypto/src/daemon/provider/pkcs11/pkcs11_module.hpp | Documents token authentication guard PIN ownership and lifetime. |
| score/crypto/src/daemon/provider/pkcs11/BUILD | Adds secure-memory dependencies for PKCS#11 targets. |
| score/crypto/src/daemon/config/src/flatbuffer_config_parser.hpp | Declares parsing for provider-neutral backend configuration references. |
| score/crypto/src/daemon/config/src/flatbuffer_config_parser.cpp | Parses and validates common backend configuration references. |
| score/crypto/src/daemon/config/src/config.cpp | Resolves backend paths relative to the main configuration file and integrates backend parsing. |
| score/crypto/src/daemon/config/src/backend_config_test.cpp | Tests backend-reference parsing, validation, and path normalization. |
| score/crypto/src/daemon/config/inc/config.hpp | Adds the provider-neutral backend configuration catalog. |
| score/crypto/src/daemon/config/crypto_config.fbs | Extends the common configuration schema with backend references. |
| score/crypto/src/daemon/config/BUILD | Adds generated schema and backend configuration test targets. |
| score/crypto/src/daemon/common/storage/owner_only_file_io_test.cpp | Tests secure owner-only configuration file loading. |
| score/crypto/src/daemon/common/storage/file_io.hpp | Declares secure owner-only file reading. |
| score/crypto/src/daemon/common/storage/file_io.cpp | Implements descriptor-based secure file validation and reading. |
| score/crypto/src/daemon/common/storage/BUILD | Adds the owner-only file I/O test target. |
| score/crypto/src/daemon/common/secure_memory.hpp | Adds secure string and scoped byte-buffer zeroization helpers. |
| score/crypto/src/common/flatbuffer_config_utils.hpp | Provides shared FlatBuffers text validation utilities. |
| score/crypto/src/common/BUILD | Builds the shared FlatBuffers configuration utility library. |
| score/crypto/src/backend/README.md | Documents runtime backend configuration and PKCS#11 security requirements. |
| score/crypto/src/backend/pkcs11/pkcs11_token_config_parser.cpp | Reads, versions, validates, and securely parses PKCS#11 configuration files. |
| score/crypto/src/backend/pkcs11/pkcs11_token_config_parser_test.cpp | Tests PKCS#11 schema handling, semantic validation, permissions, and failure behavior. |
| score/crypto/src/backend/pkcs11/pkcs11_config.fbs | Defines the versioned backend-owned PKCS#11 schema. |
| score/crypto/src/backend/pkcs11/BUILD | Generates PKCS#11 schema artifacts and builds parser tests. |
| score/crypto/docs/architecture/provider_architecture.rst | Documents backend-owned runtime configuration flow and PKCS#11 parsing. |
| score/crypto/docs/architecture/provider_architecture.puml | Updates the provider architecture diagram with backend configuration components. |
| score/crypto/docs/architecture/key_management_class_diagram.puml | Updates PKCS#11 configuration and factory interfaces in the class diagram. |
| score/crypto/docs/architecture/index.rst | Documents configured provider types and factory registration behavior. |
| score/crypto/docs/architecture/component_overview.puml | Updates the component overview for runtime PKCS#11 configuration and factory interfaces. |
Review effort: Lite
There was a problem hiding this comment.
Need an issue to bring improvements in this fbs.
- To perform json schema validation before flatbuffer bin file generation.
- To generate checks in json schema using comments in fbs, refer, Crypto configuration concept , extend crypto configuration schema and add JSON validation before serialization #483
- We may add a TODO and may create an issue.
| /// @return Byte vector on success; kResourceNotAllocated if the path is absent, | ||
| /// kAccessDenied for an insecure or inaccessible file, kInvalidArgument | ||
| /// if path/size is invalid, or kInternalError for another I/O failure. | ||
| [[nodiscard]] score::crypto::Expected<std::vector<std::uint8_t>, DaemonErrorCode> ReadOwnerOnlyFile( |
There was a problem hiding this comment.
Do we read any file via this class / in general in score::crypto daemon side ? if not we don't need ReadFile, only ReadOwnerOnlyFile
There was a problem hiding this comment.
ReadFile() is still used by certificate management, key management, and the KV deployment loader. ReadOwnerOnlyFile() is the stricter variant intended for files containing sensitive backend configuration, so both functions are required.
There was a problem hiding this comment.
Do we have an issue to take care of exhaustive test cases for the implementation done in this scope?
Not sure how is exhaustive testing planned.
There was a problem hiding this comment.
The required coverage has been added or confirmed:
- Added a test verifying that an explicitly configured invalid PKCS#11 file causes daemon startup to fail.
- Changed
Pkcs11Providerto move its configuration instead of copying it, avoiding an unnecessary PIN copy. Existing constructor tests verify that the source PIN is cleared. - Existing tests verify that no PKCS#11 provider is configured when no runtime configuration is referenced.
The parser tests already cover versions, malformed input, permissions, transactional failures, and PIN transfer. Broader cross-provider and real-HSM tests can be tracked separately.
| // Forward declarations for FlatBuffers-generated types (key slot config) | ||
| class CryptoConfig; | ||
| class KeySlotConfig; | ||
| struct CryptoConfig; |
There was a problem hiding this comment.
FlatBuffers generated code declares the corresponding table type as a struct, so the forward declaration has been updated to match. This does not change any behaviour. It simply prevents mismatched declaration warnings.
# Conflicts: # score/crypto/src/backend/pkcs11/pkcs11_token_config_parser.cpp # score/crypto/src/daemon/provider/pkcs11/BUILD # score/crypto/src/daemon/provider/tests/provider_test/test_pkcs11_multi_token.cpp



Summary
Backend configuration is loaded once at startup. Existing defaults are retained when no PKCS#11 configuration is referenced, while explicitly configured invalid files cause startup parsing to fail.
Closes #149