Commit 528f776d authored by Giovanni Cabiddu's avatar Giovanni Cabiddu Committed by Herbert Xu

crypto: qat - allow xts requests not multiple of block

Allow AES-XTS requests that are not multiple of the block size.
If a request is smaller than the block size, return -EINVAL.

This fixes the following issue reported by the crypto testmgr self-test:

  alg: skcipher: qat_aes_xts encryption failed on test vector "random: len=116 klen=64"; expected_error=0, actual_error=-22, cfg="random: inplace may_sleep use_finup src_divs=[<reimport>45.85%@+4077, <flush>54.15%@alignmask+18]"

Fixes: 96ee111a ("crypto: qat - return error for block...")
Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 74da4058
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <crypto/hmac.h> #include <crypto/hmac.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/authenc.h> #include <crypto/authenc.h>
#include <crypto/xts.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include "adf_accel_devices.h" #include "adf_accel_devices.h"
#include "adf_transport.h" #include "adf_transport.h"
...@@ -1058,6 +1059,14 @@ static int qat_alg_skcipher_blk_encrypt(struct skcipher_request *req) ...@@ -1058,6 +1059,14 @@ static int qat_alg_skcipher_blk_encrypt(struct skcipher_request *req)
return qat_alg_skcipher_encrypt(req); return qat_alg_skcipher_encrypt(req);
} }
static int qat_alg_skcipher_xts_encrypt(struct skcipher_request *req)
{
if (req->cryptlen < XTS_BLOCK_SIZE)
return -EINVAL;
return qat_alg_skcipher_encrypt(req);
}
static int qat_alg_skcipher_decrypt(struct skcipher_request *req) static int qat_alg_skcipher_decrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *stfm = crypto_skcipher_reqtfm(req); struct crypto_skcipher *stfm = crypto_skcipher_reqtfm(req);
...@@ -1117,6 +1126,15 @@ static int qat_alg_skcipher_blk_decrypt(struct skcipher_request *req) ...@@ -1117,6 +1126,15 @@ static int qat_alg_skcipher_blk_decrypt(struct skcipher_request *req)
return qat_alg_skcipher_decrypt(req); return qat_alg_skcipher_decrypt(req);
} }
static int qat_alg_skcipher_xts_decrypt(struct skcipher_request *req)
{
if (req->cryptlen < XTS_BLOCK_SIZE)
return -EINVAL;
return qat_alg_skcipher_decrypt(req);
}
static int qat_alg_aead_init(struct crypto_aead *tfm, static int qat_alg_aead_init(struct crypto_aead *tfm,
enum icp_qat_hw_auth_algo hash, enum icp_qat_hw_auth_algo hash,
const char *hash_name) const char *hash_name)
...@@ -1310,8 +1328,8 @@ static struct skcipher_alg qat_skciphers[] = { { ...@@ -1310,8 +1328,8 @@ static struct skcipher_alg qat_skciphers[] = { {
.init = qat_alg_skcipher_init_tfm, .init = qat_alg_skcipher_init_tfm,
.exit = qat_alg_skcipher_exit_tfm, .exit = qat_alg_skcipher_exit_tfm,
.setkey = qat_alg_skcipher_xts_setkey, .setkey = qat_alg_skcipher_xts_setkey,
.decrypt = qat_alg_skcipher_blk_decrypt, .decrypt = qat_alg_skcipher_xts_decrypt,
.encrypt = qat_alg_skcipher_blk_encrypt, .encrypt = qat_alg_skcipher_xts_encrypt,
.min_keysize = 2 * AES_MIN_KEY_SIZE, .min_keysize = 2 * AES_MIN_KEY_SIZE,
.max_keysize = 2 * AES_MAX_KEY_SIZE, .max_keysize = 2 * AES_MAX_KEY_SIZE,
.ivsize = AES_BLOCK_SIZE, .ivsize = AES_BLOCK_SIZE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment