feat(filestore): wire AeadEncryptor into MsgBlock for at-rest encryption
Add FileStoreEncryptionTests covering ChaCha20-Poly1305 and AES-GCM round-trips and wrong-key rejection for the FSV2 AEAD path. Fix RestorePayload to wrap CryptographicException from AEAD decryption as InvalidDataException so RecoverBlocks correctly propagates key-mismatch failures instead of silently swallowing them.
This commit is contained in:
@@ -1183,7 +1183,17 @@ public sealed class FileStore : IStreamStore, IAsyncDisposable, IDisposable
|
||||
if ((flags & EncryptionFlag) != 0)
|
||||
{
|
||||
var key = NormalizeKey(_options.EncryptionKey);
|
||||
data = AeadEncryptor.Decrypt(data, key, _options.Cipher);
|
||||
try
|
||||
{
|
||||
data = AeadEncryptor.Decrypt(data, key, _options.Cipher);
|
||||
}
|
||||
catch (CryptographicException ex)
|
||||
{
|
||||
// AEAD tag verification failed — wrong key or corrupted data.
|
||||
// Wrap as InvalidDataException so RecoverBlocks propagates it
|
||||
// as a fatal key-mismatch error (same behaviour as FSV1 key-hash check).
|
||||
throw new InvalidDataException("AEAD decryption failed: wrong key or corrupted block.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & CompressionFlag) != 0)
|
||||
|
||||
Reference in New Issue
Block a user