質問

I’m storing a transaction log of application events to allow replay of application state at a later time. This data needs to be encrypted on the fly (ie before it hits disk). I’d like to implement this using the .Net AES stream writer.

How ‘safe’ this is with regards to file recovery in the case of file corruption (app crash during write, bit rot, etc)?

If the stream is terminated during a write (ie in the app crash scenario), can I just truncate the file to the largest multiple of the block size and decrypt the remaining data without problems?

What will happen if I try to decrypt a filestream with bit-rot errors mid-stream? Is this a recoverable state?

役に立ちましたか?

解決

It depends on which mode of operation you use with the AES cipher. For instance in CBC mode, if a bit is flipped in a block of ciphertext, the whole block becomes garbage when decrypted, and in the next block the corresponding bit of decrypted plaintext is inverted (which may or may not be a problem depending on what the plaintext is). The rest of the stream afterwards is unaffected.

The wiki article on the subject is a good primer. See: Block cipher mode of operation

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top