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).
Looking at Windows 10 (v1511) encrypted partitions with AES-XTS, both
128 and 256, shows that the new cipher numbers are 0x8004 and 0x8005
respectively.
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).
Homebrew seems to have changed the polarssl/ folder into mbedtls/, so we
adapt the cmake/FindPolarSSL.cmake file to reflect this change. This
file now exports POLARSSL_INC_FOLDER, which take "polarssl" or "mbedtls"
for value according to the folder name in use on the system.
This is then used to include the correct files in dislocker.
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.
The io_data structure, as stated in the previous commit, shouldn't be
known to the encryption unit. This structure is mainly used by
dislocker.c and sectors.c, so it make sense to put it in the sectors.h
file.
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.