Add support for hashing algorithms in TI DTHE V2
T Pratham
maintainerv8 cover Add support for hashing algorithms in TI DTHE V2
DTHEv2 is a new cryptography engine introduced in TI AM62L SoC. The features of DTHEv2 were detailed in [1]. Additional hardware details available in SoC TRM [2]. DTHEv2 includes, among its various sub-components, a hashing engine which is compliant with various IETF and NIST standards, including FIPS 180-3 and FIPS PUB 198.
This patch series adds support for the hashing algorithms SHA224/256/384/512 as well as their HMAC counnterparts for the hashing engine of Texas Instruments DTHE V2 crypto driver.
The driver is tested using full kernel crypto selftests (CRYPTO_SELFTESTS_FULL) which all pass successfully [3].
Some of the pre-existing errors caught by Sashiko are fixed in a separate series [4]. This patch series depends on [4].
---
[1]: [PATCH v7 0/2] Add support for Texas Instruments DTHEv2 Crypto Engine
[2]: Section 14.6.3 (DMA Control Registers -> DMASS_DTHE)
[3]: DTHEv2 kernel self-tests logs
[4]: [PATCH v3 0/12] Fix several issues in DTHEv2 driver
Changelog:
v8:
- Minor fixes based on Sashiko comments on [4] and changes in [4]
v7:
- Minor fixes based on Sashiko comments on [4]
v6:
- Dropped MD5 and HMAC(MD5)
- Fixed errors pointed by Sashiko
v5:
- Removed CRYPTO_AHASH_ALG_FINAL_NON_ZERO and FINUP_MAX. Implemented the same mechanism in the driver itself by witholding one block in the req ctx.
v4:
- Export initial state when phash_available = 0
v3:
- Check for error in registration individualy for hash and aes driver algos.
- Fixed comment style in dthev2-common.c
v2:
- Completely revamped the driver to use the new CRYPTO_AHASH_BLOCK_ONLY framework for handling partial blocks and crypto_engine for queueing.
- Added HMAC as well.
Link to previous versions:
v7: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
---
T Pratham (2):
crypto: ti - Add support for SHA224/256/384/512 in DTHEv2 driver
crypto: ti - Add support for HMAC in DTHEv2 driver
drivers/crypto/ti/Kconfig | 3 + drivers/crypto/ti/Makefile | 2 +- drivers/crypto/ti/dthev2-aes.c | 10 +- drivers/crypto/ti/dthev2-common.c | 43 +- drivers/crypto/ti/dthev2-common.h | 68 +- drivers/crypto/ti/dthev2-hash.c | 1047 +++++++++++++++++++++++++++++ 6 files changed, 1152 insertions(+), 21 deletions(-) create mode 100644 drivers/crypto/ti/dthev2-hash.c
Signature · 1 line
2.34.1
T Pratham
maintainerPATCH v8 1/2 crypto: ti - Add support for SHA224/256/384/512 in DTHEv2 driver
Add support for SHA224, SHA256, SHA384, SHA512 algorithms in the Hashing Engine of the DTHEv2 hardware cryptographic engine.
--- drivers/crypto/ti/Kconfig | 2 + drivers/crypto/ti/Makefile | 2 +- drivers/crypto/ti/dthev2-aes.c | 10 +- drivers/crypto/ti/dthev2-common.c | 43 +- drivers/crypto/ti/dthev2-common.h | 58 ++- drivers/crypto/ti/dthev2-hash.c | 741 ++++++++++++++++++++++++++++++ 6 files changed, 839 insertions(+), 17 deletions(-) create mode 100644 drivers/crypto/ti/dthev2-hash.c
drivers/crypto/ti/Kconfig +2 -0
@@ -10,6 +10,8 @@ config CRYPTO_DEV_TI_DTHEV2 select CRYPTO_XTS select CRYPTO_GCM select CRYPTO_CCM + select CRYPTO_SHA256 + select CRYPTO_SHA512 select SG_SPLIT help This enables support for the TI DTHE V2 hw cryptography engine
drivers/crypto/ti/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_CRYPTO_DEV_TI_DTHEV2) += dthev2.o -dthev2-objs := dthev2-common.o dthev2-aes.o +dthev2-objs := dthev2-common.o dthev2-aes.o dthev2-hash.o
drivers/crypto/ti/dthev2-aes.c +4 -6
@@ -21,7 +21,6 @@#include <linux/dmaengine.h> #include <linux/dma-mapping.h> #include <linux/io.h> -#include <linux/iopoll.h> #include <linux/scatterlist.h> /* Registers */
@@ -105,7 +104,6 @@ enum aes_ctrl_mode_masks {#define DTHE_AES_GCM_AAD_MAXLEN (BIT_ULL(32) - 1)#define DTHE_AES_CCM_AAD_MAXLEN (BIT(16) - BIT(8))#define DTHE_AES_CCM_CRYPT_MAXLEN (BIT_ULL(61) - 1) -#define POLL_TIMEOUT_INTERVAL HZstatic int dthe_cipher_init_tfm (struct crypto_skcipher *tfm) {
@@ -519,7 +517,7 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq) aes_inval_nent_err:local_bh_disable (); -crypto_finalize_skcipher_request (dev_data->engine, req, ret); +crypto_finalize_skcipher_request (engine, req, ret);local_bh_enable ();dthe_put_drvdata (dev_data);return 0 ;
@@ -563,7 +561,7 @@ static int dthe_aes_crypt(struct skcipher_request *req) rctx->dev_data = dev_data; - engine = dev_data->engine; + engine = dev_data->aes_engine; ret =crypto_transfer_skcipher_request_to_engine (engine, req);if (ret != -EINPROGRESS && ret != -EBUSY )dthe_put_drvdata (dev_data);
@@ -740,7 +738,7 @@ static int dthe_aead_read_tag(struct dthe_aes_req_ctx *rctx, u32 *tag) ret =readl_relaxed_poll_timeout (aes_base_reg +DTHE_P_AES_CTRL , val, (val &DTHE_AES_CTRL_SAVED_CTX_READY ), -0 ,POLL_TIMEOUT_INTERVAL ); +0 ,DTHE_POLL_TIMEOUT_INTERVAL );if (ret)return ret;
@@ -1248,7 +1246,7 @@ static int dthe_aead_crypt(struct aead_request *req) rctx->dev_data = dev_data; - engine = dev_data->engine; + engine = dev_data->aes_engine; ret =crypto_transfer_aead_request_to_engine (engine, req);if (ret != -EINPROGRESS && ret != -EBUSY )dthe_put_drvdata (dev_data);
drivers/crypto/ti/dthev2-common.c +36 -7
82 lines not on this page · raw message
drivers/crypto/ti/dthev2-common.h +55 -3
115 lines not on this page · raw message
drivers/crypto/ti/dthev2-hash.c new file +741 -0
741 lines not on this page · raw message
Signature · 1 line
2.34.1
T Pratham
maintainerPATCH v8 2/2 crypto: ti - Add support for HMAC in DTHEv2 driver
In reply to T PrathamAdd support for HMAC-SHA512/384/256/224 algorithms in the hashing engine driver of the DTHEv2 hardware cryptographic engine.
--- drivers/crypto/ti/Kconfig | 1 + drivers/crypto/ti/dthev2-common.h | 10 +- drivers/crypto/ti/dthev2-hash.c | 310 +++++++++++++++++++++++++++++- 3 files changed, 315 insertions(+), 6 deletions(-)
drivers/crypto/ti/Kconfig +1 -0
@@ -12,6 +12,7 @@ config CRYPTO_DEV_TI_DTHEV2 select CRYPTO_CCM select CRYPTO_SHA256 select CRYPTO_SHA512 + select CRYPTO_HMAC select SG_SPLIT help This enables support for the TI DTHE V2 hw cryptography engine
drivers/crypto/ti/dthev2-common.h +6 -4
@@ -34,9 +34,9 @@#define DTHE_POLL_TIMEOUT_INTERVAL HZ/* * Size of largest possible key (of all algorithms) to be stored in dthe_tfm_ctx -* This is currently the keysize of XTS-AES-256 which is 512 bits (64 bytes) +* This is currently the keysize of HMAC-SHA512 which is 1024 bits (128 bytes) */ -#define DTHE_MAX_KEYSIZE (AES_MAX_KEY_SIZE * 2) +#define DTHE_MAX_KEYSIZE (SHA512_BLOCK_SIZE)enum dthe_hash_alg_sel {DTHE_HASH_MD5 =0 ,
@@ -101,9 +101,9 @@ struct dthe_list {/** * struct dthe_tfm_ctx - Transform ctx struct containing ctx for all sub-components of DTHE V2 * @dev: Device this transform is bound to. -* @keylen: AES key length +* @keylen: Key length for algorithms that use a key * @authsize: Authentication size for modes with authentication -* @key: AES key +* @key: Buffer storing the key * @aes_mode: AES mode * @hash_mode: Hashing Engine mode * @phash_size: partial hash size of the hash algorithm selected
@@ -147,6 +147,7 @@ struct dthe_aes_req_ctx {* @phash: buffer to store a partial hash from a previous operation * @digestcnt: stores the digest count from a previous operation; currently hardware only provides * a single 32-bit value even for SHA384/512 +* @odigest: buffer to store the outer digest from a previous operation * @padding: padding buffer for handling unaligned data * @data: buffer to store one block of data to defer operations for non-zero final. * @flags: bitfield of flags for internal use.
@@ -159,6 +160,7 @@ struct dthe_aes_req_ctx {struct dthe_hash_req_ctx {u32 phash[SHA512_DIGEST_SIZE /sizeof (u32)];u64 digestcnt[2 ]; +u32 odigest[SHA512_DIGEST_SIZE /sizeof (u32)]; __dma_from_device_group_begin();u8 padding[SHA512_BLOCK_SIZE ];
drivers/crypto/ti/dthev2-hash.c +308 -2
423 lines not on this page · raw message
Signature · 1 line
2.34.1