core-admin/qubes
Marek Marczykowski-Górecki 418d749680
backup: use 'scrypt' tool for backup encryption and integrity protection
`openssl dgst` and `openssl enc` used previously poorly handle key
stretching - in case of `openssl enc` encryption key is derived using
single MD5 iteration, without even any salt. This hardly prevent
brute force or even rainbow tables attacks. To make things worse, the
same key is used for encryption and integrity protection which ease
brute force even further.
All this is still about brute force attacks, so when using long, high
entropy passphrase, it should be still relatively safe. But lets do
better.
According to discussion in QubesOS/qubes-issues#971, scrypt algorithm is
a good choice for key stretching (it isn't the best of all existing, but
a good one and widely adopted). At the same time, lets switch away from
`openssl` tool, as it is very limited and apparently not designed for
production use. Use `scrypt` tool, which is very simple and does exactly
what we need - encrypt the data and integrity protect it. Its archive
format have own (simple) header with data required by the `scrypt`
algorithm, including salt. Internally data is encrypted with AES256-CTR
and integrity protected with HMAC-SHA256. For details see:
https://github.com/tarsnap/scrypt/blob/master/FORMAT

This means change of backup format. Mainly:

1. HMAC is stored in scrypt header, so don't use separate file for it.
Instead have data in files with `.enc` extension.
2. For compatibility leave `backup-header` and `backup-header.hmac`. But
`backup-header.hmac` is really scrypt-encrypted version of `backup-header`.
3. For each file, prepend its identifier to the passphrase, to
authenticate filename itself too. Having this we can guard against
reordering archive files within a single backup and across backups. This
identifier is built as:

        backup ID (from backup-header)!filename!

For backup-header itself, there is no backup ID (just 'backup-header!').

Fixes QubesOS/qubes-issues#971
2016-10-28 11:53:32 +02:00
..
ext qubes/ext/r3compat: update firewall handling for new API 2016-09-19 20:36:31 +02:00
qmemman qmemman: fix meminfo handling 2016-09-13 02:15:25 +02:00
storage storage: improve handling volume export 2016-09-29 01:59:54 +02:00
tests tests/backup: verify migration into LVM thin pool 2016-10-28 11:53:31 +02:00
tools Make pylint happy ♥ 2016-09-21 16:39:06 +02:00
vm storage: set only 'default' pool when creating VM on custom one 2016-09-29 01:59:54 +02:00
__init__.py qubes: fix resetting already default property 2016-09-08 04:17:58 +02:00
app.py qubes/vm: move misc XML tags loading to separate method 2016-08-18 11:57:11 +02:00
backup.py backup: use 'scrypt' tool for backup encryption and integrity protection 2016-10-28 11:53:32 +02:00
config.py pylint fixes 2016-06-10 21:27:29 +02:00
core2migration.py qubes/backup: misc fixes 2016-10-05 01:58:11 +02:00
devices.py qubes/ext/pci: move PCI devices handling to an extension 2016-09-03 20:41:03 +02:00
dochelpers.py pylint fixes 2016-06-10 21:27:29 +02:00
events.py qubes: new devices API 2016-09-03 20:40:39 +02:00
exc.py core3: add different exceptions 2015-10-17 00:17:12 +02:00
firewall.py Make pylint happy 2016-09-19 20:36:32 +02:00
log.py core/log: do not attach multiple handlers to the same logger 2016-03-03 01:18:15 +01:00
rngdoc.py qubes: pylint fixes (small mistakes and wrong names) 2015-06-29 17:39:27 +02:00
tarwriter.py qubes/tarwriter: add simple sparse-tar writer module 2016-10-05 01:54:41 +02:00
utils.py Add qubes.utils.random_string() 2016-08-03 02:57:40 +02:00