Skip to main content
Table of Contents

Class DummyKeyStore

Namespace
Stratara.Security
Assembly
Stratara.Security.dll

Development-only IKeyStore that returns a single deterministic key derived from a fixed pass-phrase. Used as the fallback when no production key store (e.g. AddStrataraFileKeyStore) has been registered.

public sealed class DummyKeyStore : IKeyStore
Inheritance
DummyKeyStore
Implements
Inherited Members
Extension Methods

Remarks

Never use in production, staging, QA, or any environment that handles real or production-derived data. The constructor enforces a whitelist guard — it throws InvalidOperationException in any environment whose name is not exactly Development, so a host can never silently encrypt with the world-known test pass-phrase baked into the shipping NuGet.

Register a real IKeyStore (the file-backed envelope store, an HSM, Key Vault, KMS, etc.) before calling the security composition so the TryAdd default never resolves.

Constructors

DummyKeyStore(IHostEnvironment)

Creates a DummyKeyStore with the default test key-phrase.

public DummyKeyStore(IHostEnvironment environment)

Parameters

environment IHostEnvironment

The host environment — used to enforce the Development-only whitelist guard.

Exceptions

InvalidOperationException

Thrown when the host environment is anything other than Development.

DummyKeyStore(IHostEnvironment, string)

Creates a DummyKeyStore with a custom key-phrase (test scenarios).

public DummyKeyStore(IHostEnvironment environment, string keyPhrase)

Parameters

environment IHostEnvironment

The host environment — used to enforce the Development-only whitelist guard.

keyPhrase string

Pass-phrase to derive the deterministic key from.

Exceptions

InvalidOperationException

Thrown when the host environment is anything other than Development.

Methods

EraseScopeAsync(KeyScope, CancellationToken)

Not supported. The development store derives its key from a fixed pass-phrase and holds no key material it could destroy, so an erasure here would shred nothing.

public ValueTask EraseScopeAsync(KeyScope scope, CancellationToken cancellationToken = default)

Parameters

scope KeyScope

The scope to erase.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

ValueTask

Exceptions

NotSupportedException

Always.

GetDataEncryptionKeyAsync(string, CancellationToken)

Return the raw key bytes for the id, or null if revoked / erased / unknown.

public ValueTask<byte[]?> GetDataEncryptionKeyAsync(string keyId, CancellationToken cancellationToken = default)

Parameters

keyId string

The key id previously obtained from GetOrCreateCurrentKeyAsync(KeyScope, CancellationToken).

cancellationToken CancellationToken

Propagated to the underlying store.

Returns

ValueTask<byte[]>

GetOrCreateCurrentKeyAsync(KeyScope, CancellationToken)

Return the current (highest non-revoked version) key for the scope, creating a first version if none exists yet.

public ValueTask<KeyMaterial> GetOrCreateCurrentKeyAsync(KeyScope scope, CancellationToken cancellationToken = default)

Parameters

scope KeyScope

The key scope to resolve.

cancellationToken CancellationToken

Propagated to the underlying store.

Returns

ValueTask<KeyMaterial>

The resolved KeyMaterial (key id + raw bytes).

RevokeAsync(string, CancellationToken)

Not supported. The development store derives its key from a fixed pass-phrase and holds no key material it could destroy, so a revocation here would shred nothing.

public ValueTask RevokeAsync(string keyId, CancellationToken cancellationToken = default)

Parameters

keyId string

The key to revoke.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

ValueTask

Exceptions

NotSupportedException

Always.

RotateAsync(KeyScope, CancellationToken)

Create a new key version for the scope and make it the current one. Older versions remain resolvable via GetDataEncryptionKeyAsync(string, CancellationToken) so existing ciphertext stays readable.

public ValueTask<string> RotateAsync(KeyScope scope, CancellationToken cancellationToken = default)

Parameters

scope KeyScope

The key scope to rotate.

cancellationToken CancellationToken

Propagated to the underlying store.

Returns

ValueTask<string>

The id of the newly created current key.