The previous implementation was only an AES-XEX one, without support for
not-divisible-by-16 sectors. We now support this through a real - if not
entirely complete in the test vectors point of vue - implementation.
Note that we don't support sectors not aligned on the byte limit, as
should be the case in a real AES-XTS implementation. But so far, I
didn't see it implemented anywhere, so I think we're good.
This adds functions which call the mbedtls_aes_crypt_xex function. This
function isn't available yet in mbedTLS, so this is of no use for common
users.
The bright side is, when it's available, it will be supported in
dislocker. A future commit will test for the maybe-existing function and
use our own implementation if it's not existing.
When decrypting keys (VMK or FVEK mainly), we gave 256 as of the key
size. This worked until now but I suspect that was mainly by the chance
that the current keys always are 256 bits long.
With the XTS mode, it seems the keys sizes have to be doubled, so that
would also prepare for the AES-XTS-256 mode, where keys could be 512
(I'm not sure yet).
AES-XTS is the new encryption scheme available on Windows 10 (from the
1511 version).
Moreover, this commit remove a branching case which often happens, which
should give beter performances (not tested though).
Now that git issues warnings when trailing whitespaces are commited, the
commit-output is not really nice. So just remove trailing whitespaces on
the overall sources and be done with it.
The crypt structure, representing an encryption object is now private.
We use the .priv.h convention for a private header. This private header
is thus named encommon.priv.h and can be used only by the encryption/
directory units.
This adds an include/ directory from which includes files will be. Each
header is now moved to this directory, in the same sub-directory it was
in.
Each #include has been changed accordingly in order not to break
compilation.
Things were getting a little bit out of control in the various names of
structure's members, function names and in comments.
Now, metadata refer to the entire metadata of the BitLocker volume,
information is the header of these metadata.
While trying to harden the binaries according to [1] gcc aborted compilation
with error 'dereferencing type-punned pointer will break strict-aliasing rules'
at several code fragments. To make the code strict aliasing compliant several
casts like
uint8_t iv[16] = {0,};
*(off_t*)iv = sector_address;
have been changed to
union {
uint8_t multi[16];
off_t single;
} iv;
memset(iv.multi, 0, 16);
iv.single = sector_address;
following the advises from [2] and [3].
[1] https://wiki.debian.org/Hardening
[2] http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
[3] http://stackoverflow.com/a/3246340
Remove disk_op_data global variable in the library
Extract file & fuse outputs in two standalone binaries
Provide global stub functions for dislocker library
Add FIXMEs & TODOs everywhere...