crypto: crypto4xx - use sync skcipher for fallback
authorChristian Lamparter <chunkeey@gmail.com>
Mon, 22 Apr 2019 11:26:00 +0000 (13:26 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 May 2019 06:03:29 +0000 (14:03 +0800)
This replaces struct crypto_skcipher and the extra request size
with struct crypto_sync_skcipher and SYNC_SKCIPHER_REQUEST_ON_STACK(),
which uses a fixed stack size.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/amcc/crypto4xx_alg.c
drivers/crypto/amcc/crypto4xx_core.c
drivers/crypto/amcc/crypto4xx_core.h

index 3458c5a085d93166c77b31baa4df90c308c77d46..307f5cfa9ba48cfc8f12549ed4e9379a51a7408c 100644 (file)
@@ -264,10 +264,10 @@ crypto4xx_ctr_crypt(struct skcipher_request *req, bool encrypt)
         * overlow.
         */
        if (counter + nblks < counter) {
-               struct skcipher_request *subreq = skcipher_request_ctx(req);
+               SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, ctx->sw_cipher.cipher);
                int ret;
 
-               skcipher_request_set_tfm(subreq, ctx->sw_cipher.cipher);
+               skcipher_request_set_sync_tfm(subreq, ctx->sw_cipher.cipher);
                skcipher_request_set_callback(subreq, req->base.flags,
                        NULL, NULL);
                skcipher_request_set_crypt(subreq, req->src, req->dst,
@@ -289,14 +289,14 @@ static int crypto4xx_sk_setup_fallback(struct crypto4xx_ctx *ctx,
 {
        int rc;
 
-       crypto_skcipher_clear_flags(ctx->sw_cipher.cipher,
+       crypto_sync_skcipher_clear_flags(ctx->sw_cipher.cipher,
                                    CRYPTO_TFM_REQ_MASK);
-       crypto_skcipher_set_flags(ctx->sw_cipher.cipher,
+       crypto_sync_skcipher_set_flags(ctx->sw_cipher.cipher,
                crypto_skcipher_get_flags(cipher) & CRYPTO_TFM_REQ_MASK);
-       rc = crypto_skcipher_setkey(ctx->sw_cipher.cipher, key, keylen);
+       rc = crypto_sync_skcipher_setkey(ctx->sw_cipher.cipher, key, keylen);
        crypto_skcipher_clear_flags(cipher, CRYPTO_TFM_RES_MASK);
        crypto_skcipher_set_flags(cipher,
-               crypto_skcipher_get_flags(ctx->sw_cipher.cipher) &
+               crypto_sync_skcipher_get_flags(ctx->sw_cipher.cipher) &
                        CRYPTO_TFM_RES_MASK);
 
        return rc;
index 920bd5e720b2dbcd28976d04ca2c35115a9b3141..3e7d24ff3fa6a90b5178501ff1c7d43619458098 100644 (file)
@@ -965,15 +965,10 @@ static int crypto4xx_sk_init(struct crypto_skcipher *sk)
 
        if (alg->base.cra_flags & CRYPTO_ALG_NEED_FALLBACK) {
                ctx->sw_cipher.cipher =
-                       crypto_alloc_skcipher(alg->base.cra_name, 0,
-                                             CRYPTO_ALG_NEED_FALLBACK |
-                                             CRYPTO_ALG_ASYNC);
+                       crypto_alloc_sync_skcipher(alg->base.cra_name, 0,
+                                             CRYPTO_ALG_NEED_FALLBACK);
                if (IS_ERR(ctx->sw_cipher.cipher))
                        return PTR_ERR(ctx->sw_cipher.cipher);
-
-               crypto_skcipher_set_reqsize(sk,
-                       sizeof(struct skcipher_request) + 32 +
-                       crypto_skcipher_reqsize(ctx->sw_cipher.cipher));
        }
 
        amcc_alg = container_of(alg, struct crypto4xx_alg, alg.u.cipher);
@@ -992,7 +987,7 @@ static void crypto4xx_sk_exit(struct crypto_skcipher *sk)
 
        crypto4xx_common_exit(ctx);
        if (ctx->sw_cipher.cipher)
-               crypto_free_skcipher(ctx->sw_cipher.cipher);
+               crypto_free_sync_skcipher(ctx->sw_cipher.cipher);
 }
 
 static int crypto4xx_aead_init(struct crypto_aead *tfm)
index 18df695ca6b10f42a7276ee03ce3107a08e6f092..4ecc34fa8ebd0236b5d8108d58c6cfc473c1c4f4 100644 (file)
@@ -131,7 +131,7 @@ struct crypto4xx_ctx {
        __le32 iv_nonce;
        u32 sa_len;
        union {
-               struct crypto_skcipher *cipher;
+               struct crypto_sync_skcipher *cipher;
                struct crypto_aead *aead;
        } sw_cipher;
 };