Skip to content

Commit 9848e4c

Browse files
chunkeeyherbertx
authored andcommitted
crypto: crypto4xx - use sync skcipher for fallback
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>
1 parent 7e92e17 commit 9848e4c

3 files changed

Lines changed: 10 additions & 15 deletions

File tree

‎drivers/crypto/amcc/crypto4xx_alg.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ crypto4xx_ctr_crypt(struct skcipher_request *req, bool encrypt)
264264
* overlow.
265265
*/
266266
if (counter + nblks < counter) {
267-
struct skcipher_request *subreq = skcipher_request_ctx(req);
267+
SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, ctx->sw_cipher.cipher);
268268
int ret;
269269

270-
skcipher_request_set_tfm(subreq, ctx->sw_cipher.cipher);
270+
skcipher_request_set_sync_tfm(subreq, ctx->sw_cipher.cipher);
271271
skcipher_request_set_callback(subreq, req->base.flags,
272272
NULL, NULL);
273273
skcipher_request_set_crypt(subreq, req->src, req->dst,
@@ -289,14 +289,14 @@ static int crypto4xx_sk_setup_fallback(struct crypto4xx_ctx *ctx,
289289
{
290290
int rc;
291291

292-
crypto_skcipher_clear_flags(ctx->sw_cipher.cipher,
292+
crypto_sync_skcipher_clear_flags(ctx->sw_cipher.cipher,
293293
CRYPTO_TFM_REQ_MASK);
294-
crypto_skcipher_set_flags(ctx->sw_cipher.cipher,
294+
crypto_sync_skcipher_set_flags(ctx->sw_cipher.cipher,
295295
crypto_skcipher_get_flags(cipher) & CRYPTO_TFM_REQ_MASK);
296-
rc = crypto_skcipher_setkey(ctx->sw_cipher.cipher, key, keylen);
296+
rc = crypto_sync_skcipher_setkey(ctx->sw_cipher.cipher, key, keylen);
297297
crypto_skcipher_clear_flags(cipher, CRYPTO_TFM_RES_MASK);
298298
crypto_skcipher_set_flags(cipher,
299-
crypto_skcipher_get_flags(ctx->sw_cipher.cipher) &
299+
crypto_sync_skcipher_get_flags(ctx->sw_cipher.cipher) &
300300
CRYPTO_TFM_RES_MASK);
301301

302302
return rc;

‎drivers/crypto/amcc/crypto4xx_core.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -965,15 +965,10 @@ static int crypto4xx_sk_init(struct crypto_skcipher *sk)
965965

966966
if (alg->base.cra_flags & CRYPTO_ALG_NEED_FALLBACK) {
967967
ctx->sw_cipher.cipher =
968-
crypto_alloc_skcipher(alg->base.cra_name, 0,
969-
CRYPTO_ALG_NEED_FALLBACK |
970-
CRYPTO_ALG_ASYNC);
968+
crypto_alloc_sync_skcipher(alg->base.cra_name, 0,
969+
CRYPTO_ALG_NEED_FALLBACK);
971970
if (IS_ERR(ctx->sw_cipher.cipher))
972971
return PTR_ERR(ctx->sw_cipher.cipher);
973-
974-
crypto_skcipher_set_reqsize(sk,
975-
sizeof(struct skcipher_request) + 32 +
976-
crypto_skcipher_reqsize(ctx->sw_cipher.cipher));
977972
}
978973

979974
amcc_alg = container_of(alg, struct crypto4xx_alg, alg.u.cipher);
@@ -992,7 +987,7 @@ static void crypto4xx_sk_exit(struct crypto_skcipher *sk)
992987

993988
crypto4xx_common_exit(ctx);
994989
if (ctx->sw_cipher.cipher)
995-
crypto_free_skcipher(ctx->sw_cipher.cipher);
990+
crypto_free_sync_skcipher(ctx->sw_cipher.cipher);
996991
}
997992

998993
static int crypto4xx_aead_init(struct crypto_aead *tfm)

‎drivers/crypto/amcc/crypto4xx_core.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct crypto4xx_ctx {
131131
__le32 iv_nonce;
132132
u32 sa_len;
133133
union {
134-
struct crypto_skcipher *cipher;
134+
struct crypto_sync_skcipher *cipher;
135135
struct crypto_aead *aead;
136136
} sw_cipher;
137137
};

0 commit comments

Comments
 (0)