Skip to content

Commit 5839f55

Browse files
pfsmorigoherbertx
authored andcommitted
crypto: vmx - Use skcipher for xts fallback
Cc: stable@vger.kernel.org #4.10 Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent c96d0a1 commit 5839f55

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

drivers/crypto/vmx/aes_xts.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
#include <crypto/aes.h>
2929
#include <crypto/scatterwalk.h>
3030
#include <crypto/xts.h>
31+
#include <crypto/skcipher.h>
3132

3233
#include "aesp8-ppc.h"
3334

3435
struct p8_aes_xts_ctx {
35-
struct crypto_blkcipher *fallback;
36+
struct crypto_skcipher *fallback;
3637
struct aes_key enc_key;
3738
struct aes_key dec_key;
3839
struct aes_key tweak_key;
@@ -41,28 +42,28 @@ struct p8_aes_xts_ctx {
4142
static int p8_aes_xts_init(struct crypto_tfm *tfm)
4243
{
4344
const char *alg;
44-
struct crypto_blkcipher *fallback;
45+
struct crypto_skcipher *fallback;
4546
struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm);
4647

4748
if (!(alg = crypto_tfm_alg_name(tfm))) {
4849
printk(KERN_ERR "Failed to get algorithm name.\n");
4950
return -ENOENT;
5051
}
5152

52-
fallback =
53-
crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
53+
fallback = crypto_alloc_skcipher(alg, 0,
54+
CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
5455
if (IS_ERR(fallback)) {
5556
printk(KERN_ERR
5657
"Failed to allocate transformation for '%s': %ld\n",
5758
alg, PTR_ERR(fallback));
5859
return PTR_ERR(fallback);
5960
}
6061
printk(KERN_INFO "Using '%s' as fallback implementation.\n",
61-
crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback));
62+
crypto_skcipher_driver_name(fallback));
6263

63-
crypto_blkcipher_set_flags(
64+
crypto_skcipher_set_flags(
6465
fallback,
65-
crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm));
66+
crypto_skcipher_get_flags((struct crypto_skcipher *)tfm));
6667
ctx->fallback = fallback;
6768

6869
return 0;
@@ -73,7 +74,7 @@ static void p8_aes_xts_exit(struct crypto_tfm *tfm)
7374
struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm);
7475

7576
if (ctx->fallback) {
76-
crypto_free_blkcipher(ctx->fallback);
77+
crypto_free_skcipher(ctx->fallback);
7778
ctx->fallback = NULL;
7879
}
7980
}
@@ -98,7 +99,7 @@ static int p8_aes_xts_setkey(struct crypto_tfm *tfm, const u8 *key,
9899
pagefault_enable();
99100
preempt_enable();
100101

101-
ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen);
102+
ret += crypto_skcipher_setkey(ctx->fallback, key, keylen);
102103
return ret;
103104
}
104105

@@ -113,15 +114,14 @@ static int p8_aes_xts_crypt(struct blkcipher_desc *desc,
113114
struct blkcipher_walk walk;
114115
struct p8_aes_xts_ctx *ctx =
115116
crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
116-
struct blkcipher_desc fallback_desc = {
117-
.tfm = ctx->fallback,
118-
.info = desc->info,
119-
.flags = desc->flags
120-
};
121117

122118
if (in_interrupt()) {
123-
ret = enc ? crypto_blkcipher_encrypt(&fallback_desc, dst, src, nbytes) :
124-
crypto_blkcipher_decrypt(&fallback_desc, dst, src, nbytes);
119+
SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
120+
skcipher_request_set_tfm(req, ctx->fallback);
121+
skcipher_request_set_callback(req, desc->flags, NULL, NULL);
122+
skcipher_request_set_crypt(req, src, dst, nbytes, desc->info);
123+
ret = enc? crypto_skcipher_encrypt(req) : crypto_skcipher_decrypt(req);
124+
skcipher_request_zero(req);
125125
} else {
126126
preempt_disable();
127127
pagefault_disable();

0 commit comments

Comments
 (0)