Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: caam/qi2 - add support for XTS with 16B IV

Newer CAAM versions (Era 9+) support 16B IVs. Since for these devices
the HW limitation is no longer present newer version should process the
requests containing 16B IVs directly in hardware without using a fallback.

Signed-off-by: Andrei Botila <andrei.botila@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Andrei Botila and committed by
Herbert Xu
4fc98326 3a15679b

+10 -5
+10 -5
drivers/crypto/caam/caamalg_qi2.c
··· 1058 1058 { 1059 1059 struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher); 1060 1060 struct device *dev = ctx->dev; 1061 + struct dpaa2_caam_priv *priv = dev_get_drvdata(dev); 1061 1062 struct caam_flc *flc; 1062 1063 u32 *desc; 1063 1064 int err; ··· 1072 1071 if (keylen != 2 * AES_KEYSIZE_128 && keylen != 2 * AES_KEYSIZE_256) 1073 1072 ctx->xts_key_fallback = true; 1074 1073 1075 - err = crypto_skcipher_setkey(ctx->fallback, key, keylen); 1076 - if (err) 1077 - return err; 1074 + if (priv->sec_attr.era <= 8 || ctx->xts_key_fallback) { 1075 + err = crypto_skcipher_setkey(ctx->fallback, key, keylen); 1076 + if (err) 1077 + return err; 1078 + } 1078 1079 1079 1080 ctx->cdata.keylen = keylen; 1080 1081 ctx->cdata.key_virt = key; ··· 1473 1470 struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req); 1474 1471 struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher); 1475 1472 struct caam_request *caam_req = skcipher_request_ctx(req); 1473 + struct dpaa2_caam_priv *priv = dev_get_drvdata(ctx->dev); 1476 1474 int ret; 1477 1475 1478 1476 /* ··· 1484 1480 if (!req->cryptlen && !ctx->fallback) 1485 1481 return 0; 1486 1482 1487 - if (ctx->fallback && (xts_skcipher_ivsize(req) || 1483 + if (ctx->fallback && ((priv->sec_attr.era <= 8 && xts_skcipher_ivsize(req)) || 1488 1484 ctx->xts_key_fallback)) { 1489 1485 skcipher_request_set_tfm(&caam_req->fallback_req, ctx->fallback); 1490 1486 skcipher_request_set_callback(&caam_req->fallback_req, ··· 1523 1519 struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req); 1524 1520 struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher); 1525 1521 struct caam_request *caam_req = skcipher_request_ctx(req); 1522 + struct dpaa2_caam_priv *priv = dev_get_drvdata(ctx->dev); 1526 1523 int ret; 1527 1524 1528 1525 /* ··· 1534 1529 if (!req->cryptlen && !ctx->fallback) 1535 1530 return 0; 1536 1531 1537 - if (ctx->fallback && (xts_skcipher_ivsize(req) || 1532 + if (ctx->fallback && ((priv->sec_attr.era <= 8 && xts_skcipher_ivsize(req)) || 1538 1533 ctx->xts_key_fallback)) { 1539 1534 skcipher_request_set_tfm(&caam_req->fallback_req, ctx->fallback); 1540 1535 skcipher_request_set_callback(&caam_req->fallback_req,