Skip to content

Commit 8bf0871

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: qce - switch to skcipher API
Commit 7a7ffe6 ("crypto: skcipher - Add top-level skcipher interface") dated 20 august 2015 introduced the new skcipher API which is supposed to replace both blkcipher and ablkcipher. While all consumers of the API have been converted long ago, some producers of the ablkcipher remain, forcing us to keep the ablkcipher support routines alive, along with the matching code to expose [a]blkciphers via the skcipher API. So switch this driver to the skcipher API, allowing us to finally drop the ablkcipher code in the near future. Reviewed-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent b3cde6b commit 8bf0871

6 files changed

Lines changed: 100 additions & 99 deletions

File tree

‎drivers/crypto/qce/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ qcrypto-objs := core.o \
44
common.o \
55
dma.o \
66
sha.o \
7-
ablkcipher.o
7+
skcipher.o

‎drivers/crypto/qce/cipher.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ struct qce_cipher_reqctx {
4545
unsigned int cryptlen;
4646
};
4747

48-
static inline struct qce_alg_template *to_cipher_tmpl(struct crypto_tfm *tfm)
48+
static inline struct qce_alg_template *to_cipher_tmpl(struct crypto_skcipher *tfm)
4949
{
50-
struct crypto_alg *alg = tfm->__crt_alg;
51-
return container_of(alg, struct qce_alg_template, alg.crypto);
50+
struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
51+
return container_of(alg, struct qce_alg_template, alg.skcipher);
5252
}
5353

54-
extern const struct qce_algo_ops ablkcipher_ops;
54+
extern const struct qce_algo_ops skcipher_ops;
5555

5656
#endif /* _CIPHER_H_ */

‎drivers/crypto/qce/common.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ static int qce_setup_regs_ahash(struct crypto_async_request *async_req,
304304
return 0;
305305
}
306306

307-
static int qce_setup_regs_ablkcipher(struct crypto_async_request *async_req,
307+
static int qce_setup_regs_skcipher(struct crypto_async_request *async_req,
308308
u32 totallen, u32 offset)
309309
{
310-
struct ablkcipher_request *req = ablkcipher_request_cast(async_req);
311-
struct qce_cipher_reqctx *rctx = ablkcipher_request_ctx(req);
310+
struct skcipher_request *req = skcipher_request_cast(async_req);
311+
struct qce_cipher_reqctx *rctx = skcipher_request_ctx(req);
312312
struct qce_cipher_ctx *ctx = crypto_tfm_ctx(async_req->tfm);
313-
struct qce_alg_template *tmpl = to_cipher_tmpl(async_req->tfm);
313+
struct qce_alg_template *tmpl = to_cipher_tmpl(crypto_skcipher_reqtfm(req));
314314
struct qce_device *qce = tmpl->qce;
315315
__be32 enckey[QCE_MAX_CIPHER_KEY_SIZE / sizeof(__be32)] = {0};
316316
__be32 enciv[QCE_MAX_IV_SIZE / sizeof(__be32)] = {0};
@@ -389,8 +389,8 @@ int qce_start(struct crypto_async_request *async_req, u32 type, u32 totallen,
389389
u32 offset)
390390
{
391391
switch (type) {
392-
case CRYPTO_ALG_TYPE_ABLKCIPHER:
393-
return qce_setup_regs_ablkcipher(async_req, totallen, offset);
392+
case CRYPTO_ALG_TYPE_SKCIPHER:
393+
return qce_setup_regs_skcipher(async_req, totallen, offset);
394394
case CRYPTO_ALG_TYPE_AHASH:
395395
return qce_setup_regs_ahash(async_req, totallen, offset);
396396
default:

‎drivers/crypto/qce/common.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/types.h>
1111
#include <crypto/aes.h>
1212
#include <crypto/hash.h>
13+
#include <crypto/internal/skcipher.h>
1314

1415
/* key size in bytes */
1516
#define QCE_SHA_HMAC_KEY_SIZE 64
@@ -79,7 +80,7 @@ struct qce_alg_template {
7980
unsigned long alg_flags;
8081
const u32 *std_iv;
8182
union {
82-
struct crypto_alg crypto;
83+
struct skcipher_alg skcipher;
8384
struct ahash_alg ahash;
8485
} alg;
8586
struct qce_device *qce;

‎drivers/crypto/qce/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define QCE_QUEUE_LENGTH 1
2323

2424
static const struct qce_algo_ops *qce_ops[] = {
25-
&ablkcipher_ops,
25+
&skcipher_ops,
2626
&ahash_ops,
2727
};
2828

0 commit comments

Comments
 (0)