Skip to content

Commit aec48ad

Browse files
horiagherbertx
authored andcommitted
crypto: caam/qi - remove ablkcipher IV generation
IV generation is done only at AEAD level. Support in ablkcipher is not needed, thus remove the dead code. Link: https://www.mail-archive.com/search?l=mid&q=20160901101257.GA3362@gondor.apana.org.a Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent cf5448b commit aec48ad

File tree

4 files changed

+20
-327
lines changed

4 files changed

+20
-327
lines changed

drivers/crypto/caam/caamalg_desc.c

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,87 +1358,6 @@ void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata,
13581358
}
13591359
EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_decap);
13601360

1361-
/**
1362-
* cnstr_shdsc_ablkcipher_givencap - ablkcipher encapsulation shared descriptor
1363-
* with HW-generated initialization vector.
1364-
* @desc: pointer to buffer used for descriptor construction
1365-
* @cdata: pointer to block cipher transform definitions
1366-
* Valid algorithm values - one of OP_ALG_ALGSEL_{AES, DES, 3DES} ANDed
1367-
* with OP_ALG_AAI_CBC.
1368-
* @ivsize: initialization vector size
1369-
* @is_rfc3686: true when ctr(aes) is wrapped by rfc3686 template
1370-
* @ctx1_iv_off: IV offset in CONTEXT1 register
1371-
*/
1372-
void cnstr_shdsc_ablkcipher_givencap(u32 * const desc, struct alginfo *cdata,
1373-
unsigned int ivsize, const bool is_rfc3686,
1374-
const u32 ctx1_iv_off)
1375-
{
1376-
u32 *key_jump_cmd, geniv;
1377-
1378-
init_sh_desc(desc, HDR_SHARE_SERIAL | HDR_SAVECTX);
1379-
/* Skip if already shared */
1380-
key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
1381-
JUMP_COND_SHRD);
1382-
1383-
/* Load class1 key only */
1384-
append_key_as_imm(desc, cdata->key_virt, cdata->keylen,
1385-
cdata->keylen, CLASS_1 | KEY_DEST_CLASS_REG);
1386-
1387-
/* Load Nonce into CONTEXT1 reg */
1388-
if (is_rfc3686) {
1389-
const u8 *nonce = cdata->key_virt + cdata->keylen;
1390-
1391-
append_load_as_imm(desc, nonce, CTR_RFC3686_NONCE_SIZE,
1392-
LDST_CLASS_IND_CCB |
1393-
LDST_SRCDST_BYTE_OUTFIFO | LDST_IMM);
1394-
append_move(desc, MOVE_WAITCOMP | MOVE_SRC_OUTFIFO |
1395-
MOVE_DEST_CLASS1CTX | (16 << MOVE_OFFSET_SHIFT) |
1396-
(CTR_RFC3686_NONCE_SIZE << MOVE_LEN_SHIFT));
1397-
}
1398-
set_jump_tgt_here(desc, key_jump_cmd);
1399-
1400-
/* Generate IV */
1401-
geniv = NFIFOENTRY_STYPE_PAD | NFIFOENTRY_DEST_DECO |
1402-
NFIFOENTRY_DTYPE_MSG | NFIFOENTRY_LC1 | NFIFOENTRY_PTYPE_RND |
1403-
(ivsize << NFIFOENTRY_DLEN_SHIFT);
1404-
append_load_imm_u32(desc, geniv, LDST_CLASS_IND_CCB |
1405-
LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM);
1406-
append_cmd(desc, CMD_LOAD | DISABLE_AUTO_INFO_FIFO);
1407-
append_move(desc, MOVE_WAITCOMP | MOVE_SRC_INFIFO |
1408-
MOVE_DEST_CLASS1CTX | (ivsize << MOVE_LEN_SHIFT) |
1409-
(ctx1_iv_off << MOVE_OFFSET_SHIFT));
1410-
append_cmd(desc, CMD_LOAD | ENABLE_AUTO_INFO_FIFO);
1411-
1412-
/* Copy generated IV to memory */
1413-
append_seq_store(desc, ivsize, LDST_SRCDST_BYTE_CONTEXT |
1414-
LDST_CLASS_1_CCB | (ctx1_iv_off << LDST_OFFSET_SHIFT));
1415-
1416-
/* Load Counter into CONTEXT1 reg */
1417-
if (is_rfc3686)
1418-
append_load_imm_be32(desc, 1, LDST_IMM | LDST_CLASS_1_CCB |
1419-
LDST_SRCDST_BYTE_CONTEXT |
1420-
((ctx1_iv_off + CTR_RFC3686_IV_SIZE) <<
1421-
LDST_OFFSET_SHIFT));
1422-
1423-
if (ctx1_iv_off)
1424-
append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | JUMP_COND_NCP |
1425-
(1 << JUMP_OFFSET_SHIFT));
1426-
1427-
/* Load operation */
1428-
append_operation(desc, cdata->algtype | OP_ALG_AS_INITFINAL |
1429-
OP_ALG_ENCRYPT);
1430-
1431-
/* Perform operation */
1432-
ablkcipher_append_src_dst(desc);
1433-
1434-
#ifdef DEBUG
1435-
print_hex_dump(KERN_ERR,
1436-
"ablkcipher givenc shdesc@" __stringify(__LINE__) ": ",
1437-
DUMP_PREFIX_ADDRESS, 16, 4, desc, desc_bytes(desc), 1);
1438-
#endif
1439-
}
1440-
EXPORT_SYMBOL(cnstr_shdsc_ablkcipher_givencap);
1441-
14421361
/**
14431362
* cnstr_shdsc_xts_ablkcipher_encap - xts ablkcipher encapsulation shared
14441363
* descriptor

drivers/crypto/caam/caamalg_desc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ void cnstr_shdsc_ablkcipher_decap(u32 * const desc, struct alginfo *cdata,
104104
unsigned int ivsize, const bool is_rfc3686,
105105
const u32 ctx1_iv_off);
106106

107-
void cnstr_shdsc_ablkcipher_givencap(u32 * const desc, struct alginfo *cdata,
108-
unsigned int ivsize, const bool is_rfc3686,
109-
const u32 ctx1_iv_off);
110-
111107
void cnstr_shdsc_xts_ablkcipher_encap(u32 * const desc, struct alginfo *cdata);
112108

113109
void cnstr_shdsc_xts_ablkcipher_decap(u32 * const desc, struct alginfo *cdata);

0 commit comments

Comments
 (0)