]> git.ipfire.org Git - thirdparty/qemu.git/commit
crypto: ensure XTS is only used with ciphers with 16 byte blocks
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 24 Aug 2016 15:28:15 +0000 (16:28 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 20 Sep 2016 16:08:52 +0000 (11:08 -0500)
commitd90481343f93581ab6f3415ee35663cc8f2da1f5
tree3840fdf17f761ebacc17292bd9d91ea475c72898
parent0751a606c2be849cb9763f7c88578210d75884f3
crypto: ensure XTS is only used with ciphers with 16 byte blocks

The XTS cipher mode needs to be used with a cipher which has
a block size of 16 bytes. If a mis-matching block size is used,
the code will either corrupt memory beyond the IV array, or
not fully encrypt/decrypt the IV.

This fixes a memory corruption crash when attempting to use
cast5-128 with xts, since the former has an 8 byte block size.

A test case is added to ensure the cipher creation fails with
such an invalid combination.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit a5d2f44d0d3e7523670e103a8c37faed29ff2b76)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
crypto/cipher-gcrypt.c
crypto/cipher-nettle.c
tests/test-crypto-cipher.c