aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-06-29 06:04:04 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2016-07-01 11:45:09 -0400
commit2d20ce070d3b78f0974408ef648223967d0efb0a (patch)
tree13a056c6fc214875399f438a9bd54a5521c2155f
parent1eb60ff82d822299b8b4fd685d1f85de87706c00 (diff)
crypto: qce - Use skcipher for fallback
This patch replaces use of the obsolete ablkcipher with skcipher. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/qce/ablkcipher.c27
-rw-r--r--drivers/crypto/qce/cipher.h2
2 files changed, 17 insertions, 12 deletions
diff --git a/drivers/crypto/qce/ablkcipher.c b/drivers/crypto/qce/ablkcipher.c
index dbcbbe242bd6..b04b42f48366 100644
--- a/drivers/crypto/qce/ablkcipher.c
+++ b/drivers/crypto/qce/ablkcipher.c
@@ -15,8 +15,8 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <crypto/aes.h> 17#include <crypto/aes.h>
18#include <crypto/algapi.h>
19#include <crypto/des.h> 18#include <crypto/des.h>
19#include <crypto/internal/skcipher.h>
20 20
21#include "cipher.h" 21#include "cipher.h"
22 22
@@ -189,7 +189,7 @@ static int qce_ablkcipher_setkey(struct crypto_ablkcipher *ablk, const u8 *key,
189 memcpy(ctx->enc_key, key, keylen); 189 memcpy(ctx->enc_key, key, keylen);
190 return 0; 190 return 0;
191fallback: 191fallback:
192 ret = crypto_ablkcipher_setkey(ctx->fallback, key, keylen); 192 ret = crypto_skcipher_setkey(ctx->fallback, key, keylen);
193 if (!ret) 193 if (!ret)
194 ctx->enc_keylen = keylen; 194 ctx->enc_keylen = keylen;
195 return ret; 195 return ret;
@@ -212,10 +212,16 @@ static int qce_ablkcipher_crypt(struct ablkcipher_request *req, int encrypt)
212 212
213 if (IS_AES(rctx->flags) && ctx->enc_keylen != AES_KEYSIZE_128 && 213 if (IS_AES(rctx->flags) && ctx->enc_keylen != AES_KEYSIZE_128 &&
214 ctx->enc_keylen != AES_KEYSIZE_256) { 214 ctx->enc_keylen != AES_KEYSIZE_256) {
215 ablkcipher_request_set_tfm(req, ctx->fallback); 215 SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback);
216 ret = encrypt ? crypto_ablkcipher_encrypt(req) : 216
217 crypto_ablkcipher_decrypt(req); 217 skcipher_request_set_tfm(subreq, ctx->fallback);
218 ablkcipher_request_set_tfm(req, __crypto_ablkcipher_cast(tfm)); 218 skcipher_request_set_callback(subreq, req->base.flags,
219 NULL, NULL);
220 skcipher_request_set_crypt(subreq, req->src, req->dst,
221 req->nbytes, req->info);
222 ret = encrypt ? crypto_skcipher_encrypt(subreq) :
223 crypto_skcipher_decrypt(subreq);
224 skcipher_request_zero(subreq);
219 return ret; 225 return ret;
220 } 226 }
221 227
@@ -239,10 +245,9 @@ static int qce_ablkcipher_init(struct crypto_tfm *tfm)
239 memset(ctx, 0, sizeof(*ctx)); 245 memset(ctx, 0, sizeof(*ctx));
240 tfm->crt_ablkcipher.reqsize = sizeof(struct qce_cipher_reqctx); 246 tfm->crt_ablkcipher.reqsize = sizeof(struct qce_cipher_reqctx);
241 247
242 ctx->fallback = crypto_alloc_ablkcipher(crypto_tfm_alg_name(tfm), 248 ctx->fallback = crypto_alloc_skcipher(crypto_tfm_alg_name(tfm), 0,
243 CRYPTO_ALG_TYPE_ABLKCIPHER, 249 CRYPTO_ALG_ASYNC |
244 CRYPTO_ALG_ASYNC | 250 CRYPTO_ALG_NEED_FALLBACK);
245 CRYPTO_ALG_NEED_FALLBACK);
246 if (IS_ERR(ctx->fallback)) 251 if (IS_ERR(ctx->fallback))
247 return PTR_ERR(ctx->fallback); 252 return PTR_ERR(ctx->fallback);
248 253
@@ -253,7 +258,7 @@ static void qce_ablkcipher_exit(struct crypto_tfm *tfm)
253{ 258{
254 struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm); 259 struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
255 260
256 crypto_free_ablkcipher(ctx->fallback); 261 crypto_free_skcipher(ctx->fallback);
257} 262}
258 263
259struct qce_ablkcipher_def { 264struct qce_ablkcipher_def {
diff --git a/drivers/crypto/qce/cipher.h b/drivers/crypto/qce/cipher.h
index 5c6a5f8633e5..2b0278bb6e92 100644
--- a/drivers/crypto/qce/cipher.h
+++ b/drivers/crypto/qce/cipher.h
@@ -22,7 +22,7 @@
22struct qce_cipher_ctx { 22struct qce_cipher_ctx {
23 u8 enc_key[QCE_MAX_KEY_SIZE]; 23 u8 enc_key[QCE_MAX_KEY_SIZE];
24 unsigned int enc_keylen; 24 unsigned int enc_keylen;
25 struct crypto_ablkcipher *fallback; 25 struct crypto_skcipher *fallback;
26}; 26};
27 27
28/** 28/**