I have used GnuPG to encrypt some long-term backups, but I am concerned whether over time data corruption might make it impossible to recover the archives.
Can you decrypt partially corrupted OpenPGP files?
I have used GnuPG to encrypt some long-term backups, but I am concerned whether over time data corruption might make it impossible to recover the archives.
Can you decrypt partially corrupted OpenPGP files?
Whether a crypto system is resilient to partial corruption (this is called self-synchronising cipher) or not depends on the mode of operation.
OpenPGP (the standard GnuPG implements) relies on the cipher feedback mode CFB with a shift register making the cipher mode self-synchronizing. A corrupted block in the crypto text will result in two blocks being affected in the plain text: the corrupted bits in the block directly affected by the corruption, and the next block being completely garbled. After this, the cipher synchronized again and returns the correct plain text.
To have GnuPG ignore detected corruption, apply the --ignore-mdc-error
option. But be aware, such a corruption could also be by intend of an attacker, and disabling this check prevents detection of such issues (from man gpg
):
This option changes a MDC integrity protection failure into a warning. This can be useful if a message is partially corrupt, but it is necessary to get as much data as possible out of the corrupt message. However, be aware that a MDC protection failure may also mean that the message was tampered with intentionally by an attacker.
But be aware that usually compression is applied before encryption (as compression is much cheaper/faster than encryption, and also can prevent a rather esoteric attack on OpenPGP): depending on the compression algorithm used (internal to OpenPGP or external like JPEG-compressed images), additional corruptions might occur.
To generally prevent random corruptions over time, have a backup periodically "scrub" both the original and backup copy. Modern file systems like ZFS, BTRFS and Microsoft's ReFS implement such a scrub-feature on file system level, and all proper Backup software also does.