Table of Contents

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

options ReEncryptionOptions

Options specifying the scope of re-encryption.

cancellationToken CancellationToken

A 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

entity T

The entity to re-encrypt.

context ReEncryptionContext

The re-encryption context.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<ReEncryptionResult>

The re-encryption result.

Type Parameters

T

The 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

entities IAsyncEnumerable<T>

The entities to re-encrypt.

options ReEncryptionOptions

Options controlling re-encryption behavior.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

IAsyncEnumerable<ReEncryptionResult<T>>

An async enumerable of re-encryption results.

Type Parameters

T

The entity type containing encrypted fields.

Remarks

Batch processing uses streaming for memory efficiency.

When ContinueOnError is true, failed items are yielded with Success = false.