using System.Collections.Generic; namespace StellaOps.Cryptography; /// /// High-level cryptographic capabilities supported by StellaOps providers. /// public enum CryptoCapability { PasswordHashing, Signing, Verification, SymmetricEncryption, KeyDerivation } /// /// Identifies a stored key or certificate handle. /// public sealed record CryptoKeyReference(string KeyId, string? ProviderHint = null); /// /// Contract implemented by crypto providers (BCL, CryptoPro, OpenSSL, etc.). /// public interface ICryptoProvider { string Name { get; } bool Supports(CryptoCapability capability, string algorithmId); IPasswordHasher GetPasswordHasher(string algorithmId); /// /// Retrieves a signer for the supplied algorithm and key reference. /// /// Signing algorithm identifier (e.g., ES256). /// Key reference. /// Signer instance. ICryptoSigner GetSigner(string algorithmId, CryptoKeyReference keyReference); /// /// Adds or replaces signing key material managed by this provider. /// /// Key material descriptor. void UpsertSigningKey(CryptoSigningKey signingKey); /// /// Removes signing key material by key identifier. /// /// Identifier to remove. /// true if the key was removed. bool RemoveSigningKey(string keyId); /// /// Lists signing key descriptors managed by this provider. /// IReadOnlyCollection GetSigningKeys(); } /// /// Registry managing provider discovery and policy selection. /// public interface ICryptoProviderRegistry { IReadOnlyCollection Providers { get; } bool TryResolve(string preferredProvider, out ICryptoProvider provider); ICryptoProvider ResolveOrThrow(CryptoCapability capability, string algorithmId); /// /// Resolves a signer for the supplied algorithm and key reference using registry policy. /// /// Capability required (typically ). /// Algorithm identifier. /// Key reference. /// Optional provider hint. /// Resolved signer. CryptoSignerResolution ResolveSigner( CryptoCapability capability, string algorithmId, CryptoKeyReference keyReference, string? preferredProvider = null); } public sealed record CryptoSignerResolution(ICryptoSigner Signer, string ProviderName);