From: Herbert Xu <herbert@gondor.apana.org.au>
To: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: [PATCH 16/28] crypto: mxs-dcp - Use skcipher for fallback
Date: Wed, 29 Jun 2016 18:04:02 +0800 [thread overview]
Message-ID: <E1bICLi-0006v3-Kz@gondolin.me.apana.org.au> (raw)
In-Reply-To: 20160629100223.GA26260@gondor.apana.org.au
This patch replaces use of the obsolete ablkcipher with skcipher.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
drivers/crypto/mxs-dcp.c | 47 +++++++++++++++++++++--------------------------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index 59ed54e..625ee50 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -11,7 +11,6 @@
* http://www.gnu.org/copyleft/gpl.html
*/
-#include <linux/crypto.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/io.h>
@@ -25,6 +24,7 @@
#include <crypto/aes.h>
#include <crypto/sha.h>
#include <crypto/internal/hash.h>
+#include <crypto/internal/skcipher.h>
#define DCP_MAX_CHANS 4
#define DCP_BUF_SZ PAGE_SIZE
@@ -84,7 +84,7 @@ struct dcp_async_ctx {
unsigned int hot:1;
/* Crypto-specific context */
- struct crypto_ablkcipher *fallback;
+ struct crypto_skcipher *fallback;
unsigned int key_len;
uint8_t key[AES_KEYSIZE_128];
};
@@ -374,20 +374,22 @@ static int dcp_chan_thread_aes(void *data)
static int mxs_dcp_block_fallback(struct ablkcipher_request *req, int enc)
{
- struct crypto_tfm *tfm =
- crypto_ablkcipher_tfm(crypto_ablkcipher_reqtfm(req));
- struct dcp_async_ctx *ctx = crypto_ablkcipher_ctx(
- crypto_ablkcipher_reqtfm(req));
+ struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
+ struct dcp_async_ctx *ctx = crypto_ablkcipher_ctx(tfm);
+ SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback);
int ret;
- ablkcipher_request_set_tfm(req, ctx->fallback);
+ skcipher_request_set_tfm(subreq, ctx->fallback);
+ skcipher_request_set_callback(subreq, req->base.flags, NULL, NULL);
+ skcipher_request_set_crypt(subreq, req->src, req->dst,
+ req->nbytes, req->info);
if (enc)
- ret = crypto_ablkcipher_encrypt(req);
+ ret = crypto_skcipher_encrypt(subreq);
else
- ret = crypto_ablkcipher_decrypt(req);
+ ret = crypto_skcipher_decrypt(subreq);
- ablkcipher_request_set_tfm(req, __crypto_ablkcipher_cast(tfm));
+ skcipher_request_zero(subreq);
return ret;
}
@@ -453,28 +455,22 @@ static int mxs_dcp_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
return 0;
}
- /* Check if the key size is supported by kernel at all. */
- if (len != AES_KEYSIZE_192 && len != AES_KEYSIZE_256) {
- tfm->base.crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
- return -EINVAL;
- }
-
/*
* If the requested AES key size is not supported by the hardware,
* but is supported by in-kernel software implementation, we use
* software fallback.
*/
- actx->fallback->base.crt_flags &= ~CRYPTO_TFM_REQ_MASK;
- actx->fallback->base.crt_flags |=
- tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK;
+ crypto_skcipher_clear_flags(actx->fallback, CRYPTO_TFM_REQ_MASK);
+ crypto_skcipher_set_flags(actx->fallback,
+ tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK);
- ret = crypto_ablkcipher_setkey(actx->fallback, key, len);
+ ret = crypto_skcipher_setkey(actx->fallback, key, len);
if (!ret)
return 0;
tfm->base.crt_flags &= ~CRYPTO_TFM_RES_MASK;
- tfm->base.crt_flags |=
- actx->fallback->base.crt_flags & CRYPTO_TFM_RES_MASK;
+ tfm->base.crt_flags |= crypto_skcipher_get_flags(actx->fallback) &
+ CRYPTO_TFM_RES_MASK;
return ret;
}
@@ -484,9 +480,9 @@ static int mxs_dcp_aes_fallback_init(struct crypto_tfm *tfm)
const char *name = crypto_tfm_alg_name(tfm);
const uint32_t flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK;
struct dcp_async_ctx *actx = crypto_tfm_ctx(tfm);
- struct crypto_ablkcipher *blk;
+ struct crypto_skcipher *blk;
- blk = crypto_alloc_ablkcipher(name, 0, flags);
+ blk = crypto_alloc_skcipher(name, 0, flags);
if (IS_ERR(blk))
return PTR_ERR(blk);
@@ -499,8 +495,7 @@ static void mxs_dcp_aes_fallback_exit(struct crypto_tfm *tfm)
{
struct dcp_async_ctx *actx = crypto_tfm_ctx(tfm);
- crypto_free_ablkcipher(actx->fallback);
- actx->fallback = NULL;
+ crypto_free_skcipher(actx->fallback);
}
/*
next prev parent reply other threads:[~2016-06-29 10:04 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-29 10:02 [PATCH 0/28] crypto: skcipher - skcipher algorithm conversion part 1 Herbert Xu
2016-06-29 10:03 ` [PATCH 1/28] crypto: authenc - Consider ahash ASYNC bit Herbert Xu
2016-06-29 10:03 ` [PATCH 2/28] crypto: ahash - Add padding in crypto_ahash_extsize Herbert Xu
2016-06-29 10:03 ` [PATCH 3/28] crypto: skcipher - Add low-level skcipher interface Herbert Xu
2016-06-29 10:03 ` [PATCH 4/28] crypto: null - Add new default null skcipher Herbert Xu
2016-06-29 10:03 ` [PATCH 5/28] crypto: tcrypt - Use skcipher Herbert Xu
2016-06-29 10:03 ` [PATCH 6/28] crypto: authenc " Herbert Xu
2016-06-29 10:03 ` [PATCH 7/28] crypto: authencesn " Herbert Xu
2016-06-29 10:03 ` [PATCH 8/28] crypto: ctr - Use skcipher in rfc3686 Herbert Xu
2016-06-29 10:03 ` [PATCH 9/28] crypto: ccm - Use skcipher Herbert Xu
2016-06-29 10:03 ` [PATCH 10/28] crypto: gcm " Herbert Xu
2016-06-29 10:03 ` [PATCH 11/28] crypto: chacha20poly1305 " Herbert Xu
2016-06-29 10:03 ` [PATCH 12/28] crypto: cryptd - Add support for skcipher Herbert Xu
2016-06-29 10:03 ` [PATCH 13/28] crypto: aesni - Use crypto_cipher to derive rfc4106 subkey Herbert Xu
2016-06-29 10:04 ` [PATCH 14/28] KEYS: Use skcipher for big keys Herbert Xu
2016-06-29 10:04 ` [PATCH 15/28] crypto: ccp - Use skcipher for fallback Herbert Xu
2016-06-29 10:04 ` Herbert Xu [this message]
2016-06-29 10:04 ` [PATCH 17/28] crypto: picoxcell " Herbert Xu
2016-06-29 10:04 ` [PATCH 18/28] crypto: qce " Herbert Xu
2016-06-29 10:04 ` [PATCH 19/28] crypto: sahara " Herbert Xu
2016-06-29 10:04 ` [PATCH 20/28] crypto: s390/aes " Herbert Xu
2016-06-29 10:04 ` [PATCH 21/28] crypto: aead - Add skcipher null for IV generators Herbert Xu
2016-06-29 10:04 ` [PATCH 22/28] crypto: echainiv - Use skcipher Herbert Xu
2016-06-29 10:04 ` [PATCH 23/28] crypto: seqiv " Herbert Xu
2016-06-29 10:04 ` [PATCH 24/28] crypto: aead - Remove blkcipher null for IV generators Herbert Xu
2016-06-29 10:04 ` [PATCH 25/28] crypto: null - Remove default null blkcipher Herbert Xu
2016-06-29 10:04 ` [PATCH 26/28] crypto: api - Add crypto_inst_setname Herbert Xu
2016-06-29 10:04 ` [PATCH 27/28] crypto: tcrypt - Add speed test for cts Herbert Xu
2016-06-29 10:04 ` [PATCH 28/28] crypto: cts - Convert to skcipher Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1bICLi-0006v3-Kz@gondolin.me.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox