Commit 2d20ce07 authored by Herbert Xu's avatar Herbert Xu

crypto: qce - Use skcipher for fallback

This patch replaces use of the obsolete ablkcipher with skcipher.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 1eb60ff8
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/types.h> #include <linux/types.h>
#include <crypto/aes.h> #include <crypto/aes.h>
#include <crypto/algapi.h>
#include <crypto/des.h> #include <crypto/des.h>
#include <crypto/internal/skcipher.h>
#include "cipher.h" #include "cipher.h"
...@@ -189,7 +189,7 @@ static int qce_ablkcipher_setkey(struct crypto_ablkcipher *ablk, const u8 *key, ...@@ -189,7 +189,7 @@ static int qce_ablkcipher_setkey(struct crypto_ablkcipher *ablk, const u8 *key,
memcpy(ctx->enc_key, key, keylen); memcpy(ctx->enc_key, key, keylen);
return 0; return 0;
fallback: fallback:
ret = crypto_ablkcipher_setkey(ctx->fallback, key, keylen); ret = crypto_skcipher_setkey(ctx->fallback, key, keylen);
if (!ret) if (!ret)
ctx->enc_keylen = keylen; ctx->enc_keylen = keylen;
return ret; return ret;
...@@ -212,10 +212,16 @@ static int qce_ablkcipher_crypt(struct ablkcipher_request *req, int encrypt) ...@@ -212,10 +212,16 @@ static int qce_ablkcipher_crypt(struct ablkcipher_request *req, int encrypt)
if (IS_AES(rctx->flags) && ctx->enc_keylen != AES_KEYSIZE_128 && if (IS_AES(rctx->flags) && ctx->enc_keylen != AES_KEYSIZE_128 &&
ctx->enc_keylen != AES_KEYSIZE_256) { ctx->enc_keylen != AES_KEYSIZE_256) {
ablkcipher_request_set_tfm(req, ctx->fallback); SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback);
ret = encrypt ? crypto_ablkcipher_encrypt(req) :
crypto_ablkcipher_decrypt(req); skcipher_request_set_tfm(subreq, ctx->fallback);
ablkcipher_request_set_tfm(req, __crypto_ablkcipher_cast(tfm)); skcipher_request_set_callback(subreq, req->base.flags,
NULL, NULL);
skcipher_request_set_crypt(subreq, req->src, req->dst,
req->nbytes, req->info);
ret = encrypt ? crypto_skcipher_encrypt(subreq) :
crypto_skcipher_decrypt(subreq);
skcipher_request_zero(subreq);
return ret; return ret;
} }
...@@ -239,10 +245,9 @@ static int qce_ablkcipher_init(struct crypto_tfm *tfm) ...@@ -239,10 +245,9 @@ static int qce_ablkcipher_init(struct crypto_tfm *tfm)
memset(ctx, 0, sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx));
tfm->crt_ablkcipher.reqsize = sizeof(struct qce_cipher_reqctx); tfm->crt_ablkcipher.reqsize = sizeof(struct qce_cipher_reqctx);
ctx->fallback = crypto_alloc_ablkcipher(crypto_tfm_alg_name(tfm), ctx->fallback = crypto_alloc_skcipher(crypto_tfm_alg_name(tfm), 0,
CRYPTO_ALG_TYPE_ABLKCIPHER, CRYPTO_ALG_ASYNC |
CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
CRYPTO_ALG_NEED_FALLBACK);
if (IS_ERR(ctx->fallback)) if (IS_ERR(ctx->fallback))
return PTR_ERR(ctx->fallback); return PTR_ERR(ctx->fallback);
...@@ -253,7 +258,7 @@ static void qce_ablkcipher_exit(struct crypto_tfm *tfm) ...@@ -253,7 +258,7 @@ static void qce_ablkcipher_exit(struct crypto_tfm *tfm)
{ {
struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm); struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
crypto_free_ablkcipher(ctx->fallback); crypto_free_skcipher(ctx->fallback);
} }
struct qce_ablkcipher_def { struct qce_ablkcipher_def {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
struct qce_cipher_ctx { struct qce_cipher_ctx {
u8 enc_key[QCE_MAX_KEY_SIZE]; u8 enc_key[QCE_MAX_KEY_SIZE];
unsigned int enc_keylen; unsigned int enc_keylen;
struct crypto_ablkcipher *fallback; struct crypto_skcipher *fallback;
}; };
/** /**
......
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