What is asymmetric encryption and why should I want it for my backups?

Asymmetric encryption or public key cryptography is a class of encryption where you have a public key that is derived from a private key. To be a good asymmetric crypto it should be very hard to derive the private key from the public key. Examples of this kind of encryption is used in a lot of places such as PGP (Encrypted messages), TLS (In transit internet connections). The first popular asymmetric algorithm is RSA which is still in wide use even though it is starting to show its age. More modern algorithms include a variety of elliptic curve cryptography algorithms.

Underscore Backup uses the X25519 elliptic curve crypto to encrypt all its data. The way this works is that the private key for this crypto is derived from the password used to encrypt the backup. Only the public key is ever stored on disk or in the backup destinations. A neat feature of public key cryptography is that you need the public key to encrypt data, but you need the private key to decrypt the data. The upside of this is that when Underscore Backup is running in the background on your computer it does not even have the private key required to read your backup, it can only write backups.

What this means is that if your computer gets compromised that means that the contents of your backups are not compromised along with your computer. Only when you enter your password into your application to do a restore will the application have the private key in memory (It is never committed to disk) and it will make sure to forget it as soon as your restore operation is complete.

I know all about encryption, tell me the details please

The private key for encryption is derived from your password using the Argon2 algorithm. Once this is created during setup the public key and the password salt is stored in both your manifest directory and uploaded to your manifest backup destination. For every backup block (A backup block is around 8mb of backup data) that is stored in the backup destination a new X25519 private and public key pair is created. The block public key is stored in a header in the block, the block private key is combined with the backup public key using a Diffie-Hellman key exchange. The resulting 256 bit key is then used to encrypt the rest of the backup block using the symmetric AES 256 encryption scheme.

A Diffie-Hellman key exchange has the property that given two public/private key pairs if you combine the public key of one key and the private key of the other you end up with the same result as when you do it with the other public/private key pair. In the previous operation the private key for the block is discarded after the block has been written (And as noted the public key is written with the block itself). That means that after the block has been written only the backup private key can be used with the block public key to get the symmetric encryption key to read the block.

0 comments: