Skip to content

Commit 9dbe307

Browse files
horiagherbertx
authored andcommitted
crypto: caam/qi - ablkcipher -> skcipher conversion
Convert driver from deprecated ablkcipher API to skcipher. Link: https://www.mail-archive.com/search?l=mid&q=20170728085622.GC19664@gondor.apana.org.au Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 5ca7bad commit 9dbe307

File tree

4 files changed

+217
-253
lines changed

4 files changed

+217
-253
lines changed

drivers/crypto/caam/caamalg.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,15 +693,15 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
693693

694694
/* skcipher_encrypt shared descriptor */
695695
desc = ctx->sh_desc_enc;
696-
cnstr_shdsc_ablkcipher_encap(desc, &ctx->cdata, ivsize, is_rfc3686,
697-
ctx1_iv_off);
696+
cnstr_shdsc_skcipher_encap(desc, &ctx->cdata, ivsize, is_rfc3686,
697+
ctx1_iv_off);
698698
dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
699699
desc_bytes(desc), ctx->dir);
700700

701701
/* skcipher_decrypt shared descriptor */
702702
desc = ctx->sh_desc_dec;
703-
cnstr_shdsc_ablkcipher_decap(desc, &ctx->cdata, ivsize, is_rfc3686,
704-
ctx1_iv_off);
703+
cnstr_shdsc_skcipher_decap(desc, &ctx->cdata, ivsize, is_rfc3686,
704+
ctx1_iv_off);
705705
dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
706706
desc_bytes(desc), ctx->dir);
707707

@@ -727,13 +727,13 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
727727

728728
/* xts_skcipher_encrypt shared descriptor */
729729
desc = ctx->sh_desc_enc;
730-
cnstr_shdsc_xts_ablkcipher_encap(desc, &ctx->cdata);
730+
cnstr_shdsc_xts_skcipher_encap(desc, &ctx->cdata);
731731
dma_sync_single_for_device(jrdev, ctx->sh_desc_enc_dma,
732732
desc_bytes(desc), ctx->dir);
733733

734734
/* xts_skcipher_decrypt shared descriptor */
735735
desc = ctx->sh_desc_dec;
736-
cnstr_shdsc_xts_ablkcipher_decap(desc, &ctx->cdata);
736+
cnstr_shdsc_xts_skcipher_decap(desc, &ctx->cdata);
737737
dma_sync_single_for_device(jrdev, ctx->sh_desc_dec_dma,
738738
desc_bytes(desc), ctx->dir);
739739

drivers/crypto/caam/caamalg_desc.c

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* Shared descriptors for aead, ablkcipher algorithms
2+
* Shared descriptors for aead, skcipher algorithms
33
*
4-
* Copyright 2016 NXP
4+
* Copyright 2016-2018 NXP
55
*/
66

77
#include "compat.h"
@@ -1212,11 +1212,8 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata,
12121212
}
12131213
EXPORT_SYMBOL(cnstr_shdsc_rfc4543_decap);
12141214

1215-
/*
1216-
* For ablkcipher encrypt and decrypt, read from req->src and
1217-
* write to req->dst
1218-
*/
1219-
static inline void ablkcipher_append_src_dst(u32 *desc)
1215+
/* For skcipher encrypt and decrypt, read from req->src and write to req->dst */
1216+
static inline void skcipher_append_src_dst(u32 *desc)
12201217
{
12211218
append_math_add(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
12221219
append_math_add(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
@@ -1226,7 +1223,7 @@ static inline void ablkcipher_append_src_dst(u32 *desc)
12261223
}
12271224

12281225
/**
1229-
* cnstr_shdsc_ablkcipher_encap - ablkcipher encapsulation shared descriptor
1226+
* cnstr_shdsc_skcipher_encap - skcipher encapsulation shared descriptor
12301227
* @desc: pointer to buffer used for descriptor construction
12311228
* @cdata: pointer to block cipher transform definitions
12321229
* Valid algorithm values - one of OP_ALG_ALGSEL_{AES, DES, 3DES} ANDed
@@ -1235,9 +1232,9 @@ static inline void ablkcipher_append_src_dst(u32 *desc)
12351232
* @is_rfc3686: true when ctr(aes) is wrapped by rfc3686 template
12361233
* @ctx1_iv_off: IV offset in CONTEXT1 register
12371234
*/
1238-
void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata,
1239-
unsigned int ivsize, const bool is_rfc3686,
1240-
const u32 ctx1_iv_off)
1235+
void cnstr_shdsc_skcipher_encap(u32 * const desc, struct alginfo *cdata,
1236+
unsigned int ivsize, const bool is_rfc3686,
1237+
const u32 ctx1_iv_off)
12411238
{
12421239
u32 *key_jump_cmd;
12431240

@@ -1280,18 +1277,18 @@ void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata,
12801277
OP_ALG_ENCRYPT);
12811278

12821279
/* Perform operation */
1283-
ablkcipher_append_src_dst(desc);
1280+
skcipher_append_src_dst(desc);
12841281

12851282
#ifdef DEBUG
12861283
print_hex_dump(KERN_ERR,
1287-
"ablkcipher enc shdesc@" __stringify(__LINE__)": ",
1284+
"skcipher enc shdesc@" __stringify(__LINE__)": ",
12881285
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
12891286
#endif
12901287
}
1291-
EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_encap);
1288+
EXPORT_SYMBOL(cnstr_shdsc_skcipher_encap);
12921289

12931290
/**
1294-
* cnstr_shdsc_ablkcipher_decap - ablkcipher decapsulation shared descriptor
1291+
* cnstr_shdsc_skcipher_decap - skcipher decapsulation shared descriptor
12951292
* @desc: pointer to buffer used for descriptor construction
12961293
* @cdata: pointer to block cipher transform definitions
12971294
* Valid algorithm values - one of OP_ALG_ALGSEL_{AES, DES, 3DES} ANDed
@@ -1300,9 +1297,9 @@ EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_encap);
13001297
* @is_rfc3686: true when ctr(aes) is wrapped by rfc3686 template
13011298
* @ctx1_iv_off: IV offset in CONTEXT1 register
13021299
*/
1303-
void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata,
1304-
unsigned int ivsize, const bool is_rfc3686,
1305-
const u32 ctx1_iv_off)
1300+
void cnstr_shdsc_skcipher_decap(u32 * const desc, struct alginfo *cdata,
1301+
unsigned int ivsize, const bool is_rfc3686,
1302+
const u32 ctx1_iv_off)
13061303
{
13071304
u32 *key_jump_cmd;
13081305

@@ -1348,24 +1345,23 @@ void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata,
13481345
append_dec_op1(desc, cdata->algtype);
13491346

13501347
/* Perform operation */
1351-
ablkcipher_append_src_dst(desc);
1348+
skcipher_append_src_dst(desc);
13521349

13531350
#ifdef DEBUG
13541351
print_hex_dump(KERN_ERR,
1355-
"ablkcipher dec shdesc@" __stringify(__LINE__)": ",
1352+
"skcipher dec shdesc@" __stringify(__LINE__)": ",
13561353
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
13571354
#endif
13581355
}
1359-
EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_decap);
1356+
EXPORT_SYMBOL(cnstr_shdsc_skcipher_decap);
13601357

13611358
/**
1362-
* cnstr_shdsc_xts_ablkcipher_encap - xts ablkcipher encapsulation shared
1363-
* descriptor
1359+
* cnstr_shdsc_xts_skcipher_encap - xts skcipher encapsulation shared descriptor
13641360
* @desc: pointer to buffer used for descriptor construction
13651361
* @cdata: pointer to block cipher transform definitions
13661362
* Valid algorithm values - OP_ALG_ALGSEL_AES ANDed with OP_ALG_AAI_XTS.
13671363
*/
1368-
void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata)
1364+
void cnstr_shdsc_xts_skcipher_encap(u32 * const desc, struct alginfo *cdata)
13691365
{
13701366
__be64 sector_size = cpu_to_be64(512);
13711367
u32 *key_jump_cmd;
@@ -1400,24 +1396,23 @@ void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata)
14001396
OP_ALG_ENCRYPT);
14011397

14021398
/* Perform operation */
1403-
ablkcipher_append_src_dst(desc);
1399+
skcipher_append_src_dst(desc);
14041400

14051401
#ifdef DEBUG
14061402
print_hex_dump(KERN_ERR,
1407-
"xts ablkcipher enc shdesc@" __stringify(__LINE__) ": ",
1403+
"xts skcipher enc shdesc@" __stringify(__LINE__) ": ",
14081404
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
14091405
#endif
14101406
}
1411-
EXPORT_SYMBOL(cnstr_shdsc_xts_ablkcipher_encap);
1407+
EXPORT_SYMBOL(cnstr_shdsc_xts_skcipher_encap);
14121408

14131409
/**
1414-
* cnstr_shdsc_xts_ablkcipher_decap - xts ablkcipher decapsulation shared
1415-
* descriptor
1410+
* cnstr_shdsc_xts_skcipher_decap - xts skcipher decapsulation shared descriptor
14161411
* @desc: pointer to buffer used for descriptor construction
14171412
* @cdata: pointer to block cipher transform definitions
14181413
* Valid algorithm values - OP_ALG_ALGSEL_AES ANDed with OP_ALG_AAI_XTS.
14191414
*/
1420-
void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata)
1415+
void cnstr_shdsc_xts_skcipher_decap(u32 * const desc, struct alginfo *cdata)
14211416
{
14221417
__be64 sector_size = cpu_to_be64(512);
14231418
u32 *key_jump_cmd;
@@ -1451,15 +1446,15 @@ void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata)
14511446
append_dec_op1(desc, cdata->algtype);
14521447

14531448
/* Perform operation */
1454-
ablkcipher_append_src_dst(desc);
1449+
skcipher_append_src_dst(desc);
14551450

14561451
#ifdef DEBUG
14571452
print_hex_dump(KERN_ERR,
1458-
"xts ablkcipher dec shdesc@" __stringify(__LINE__) ": ",
1453+
"xts skcipher dec shdesc@" __stringify(__LINE__) ": ",
14591454
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
14601455
#endif
14611456
}
1462-
EXPORT_SYMBOL(cnstr_shdsc_xts_ablkcipher_decap);
1457+
EXPORT_SYMBOL(cnstr_shdsc_xts_skcipher_decap);
14631458

14641459
MODULE_LICENSE("GPL");
14651460
MODULE_DESCRIPTION("FSL CAAM descriptor support");

drivers/crypto/caam/caamalg_desc.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* Shared descriptors for aead, ablkcipher algorithms
3+
* Shared descriptors for aead, skcipher algorithms
44
*
55
* Copyright 2016 NXP
66
*/
@@ -42,10 +42,10 @@
4242
#define DESC_QI_RFC4543_ENC_LEN (DESC_RFC4543_ENC_LEN + 4 * CAAM_CMD_SZ)
4343
#define DESC_QI_RFC4543_DEC_LEN (DESC_RFC4543_DEC_LEN + 4 * CAAM_CMD_SZ)
4444

45-
#define DESC_ABLKCIPHER_BASE (3 * CAAM_CMD_SZ)
46-
#define DESC_ABLKCIPHER_ENC_LEN (DESC_ABLKCIPHER_BASE + \
45+
#define DESC_SKCIPHER_BASE (3 * CAAM_CMD_SZ)
46+
#define DESC_SKCIPHER_ENC_LEN (DESC_SKCIPHER_BASE + \
4747
20 * CAAM_CMD_SZ)
48-
#define DESC_ABLKCIPHER_DEC_LEN (DESC_ABLKCIPHER_BASE + \
48+
#define DESC_SKCIPHER_DEC_LEN (DESC_SKCIPHER_BASE + \
4949
15 * CAAM_CMD_SZ)
5050

5151
void cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata,
@@ -96,16 +96,16 @@ void cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata,
9696
unsigned int ivsize, unsigned int icvsize,
9797
const bool is_qi);
9898

99-
void cnstr_shdsc_ablkcipher_encap(u32 * const desc, struct alginfo *cdata,
100-
unsigned int ivsize, const bool is_rfc3686,
101-
const u32 ctx1_iv_off);
99+
void cnstr_shdsc_skcipher_encap(u32 * const desc, struct alginfo *cdata,
100+
unsigned int ivsize, const bool is_rfc3686,
101+
const u32 ctx1_iv_off);
102102

103-
void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata,
104-
unsigned int ivsize, const bool is_rfc3686,
105-
const u32 ctx1_iv_off);
103+
void cnstr_shdsc_skcipher_decap(u32 * const desc, struct alginfo *cdata,
104+
unsigned int ivsize, const bool is_rfc3686,
105+
const u32 ctx1_iv_off);
106106

107-
void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata);
107+
void cnstr_shdsc_xts_skcipher_encap(u32 * const desc, struct alginfo *cdata);
108108

109-
void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata);
109+
void cnstr_shdsc_xts_skcipher_decap(u32 * const desc, struct alginfo *cdata);
110110

111111
#endif /* _CAAMALG_DESC_H_ */

0 commit comments

Comments
 (0)