@@ -4,6 +4,7 @@
#include <crypto/b128ops.h>
#include <crypto/internal/skcipher.h>
+#include <crypto/aes.h>
#include <linux/fips.h>
#define XTS_BLOCK_SIZE 16
@@ -12,10 +13,10 @@ static inline int xts_check_key(struct crypto_tfm *tfm,
const u8 *key, unsigned int keylen)
{
/*
- * key consists of keys of equal size concatenated, therefore
- * the length must be even.
+ * key consists of keys of equal size concatenated, possible
+ * values are 32 or 64 bytes.
*/
- if (keylen % 2)
+ if (keylen != 2 * AES_MIN_KEY_SIZE && keylen != 2 * AES_MAX_KEY_SIZE)
return -EINVAL;
/* ensure that the AES and tweak key are not identical */
@@ -29,10 +30,10 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm,
const u8 *key, unsigned int keylen)
{
/*
- * key consists of keys of equal size concatenated, therefore
- * the length must be even.
+ * key consists of keys of equal size concatenated, possible
+ * values are 32 or 64 bytes.
*/
- if (keylen % 2)
+ if (keylen != 2 * AES_MIN_KEY_SIZE && keylen != 2 * AES_MAX_KEY_SIZE)
return -EINVAL;
/* ensure that the AES and tweak key are not identical */