Interface IReEncryptionService
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Provides re-encryption services for key rotation and algorithm migration.
public interface IReEncryptionService
Remarks
This service uses IEncryptionProviderRegistry for provider lookup, decrypting with the source provider and encrypting with the target provider.
Use cases include:
- Key rotation (migrating to a new encryption key)
- Algorithm migration (upgrading encryption algorithm)
- Provider migration (switching encryption providers)
Methods
EstimateAsync(ReEncryptionOptions, CancellationToken)
Estimates the work required for a re-encryption operation.
Task<ReEncryptionEstimate> EstimateAsync(ReEncryptionOptions options, CancellationToken cancellationToken)
Parameters
optionsReEncryptionOptionsOptions specifying the scope of re-encryption.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<ReEncryptionEstimate>
An estimate of the re-encryption work.
Remarks
Use this method for planning and progress tracking before executing ReEncryptBatchAsync<T>(IAsyncEnumerable<T>, ReEncryptionOptions, CancellationToken).
ReEncryptAsync<T>(T, ReEncryptionContext, CancellationToken)
Re-encrypts a single entity with a new provider.
Task<ReEncryptionResult> ReEncryptAsync<T>(T entity, ReEncryptionContext context, CancellationToken cancellationToken) where T : class
Parameters
entityTThe entity to re-encrypt.
contextReEncryptionContextThe re-encryption context.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<ReEncryptionResult>
The re-encryption result.
Type Parameters
TThe entity type containing encrypted fields.
Remarks
Fields marked with EncryptedFieldAttribute are decrypted with the source provider and re-encrypted with the target provider.
ReEncryptBatchAsync<T>(IAsyncEnumerable<T>, ReEncryptionOptions, CancellationToken)
Re-encrypts a batch of entities with a new provider using streaming.
IAsyncEnumerable<ReEncryptionResult<T>> ReEncryptBatchAsync<T>(IAsyncEnumerable<T> entities, ReEncryptionOptions options, CancellationToken cancellationToken) where T : class
Parameters
entitiesIAsyncEnumerable<T>The entities to re-encrypt.
optionsReEncryptionOptionsOptions controlling re-encryption behavior.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- IAsyncEnumerable<ReEncryptionResult<T>>
An async enumerable of re-encryption results.
Type Parameters
TThe entity type containing encrypted fields.
Remarks
Batch processing uses streaming for memory efficiency.
When ContinueOnError is true,
failed items are yielded with Success = false.