From: T Pratham <t-pratham@ti.com>
To: T Pratham <t-pratham@ti.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Manorit Chawdhry <m-chawdhry@ti.com>,
Shiva Tripathi <s-tripathi1@ti.com>,
Sebin Francis <sebin.francis@ti.com>,
Vishal Mahaveer <vishalm@ti.com>,
Praneeth Bajjuri <praneeth@ti.com>,
<linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v5 2/3] crypto: ti - Add support for MD5 in DTHEv2 Hashing Engine driver
Date: Fri, 7 Aug 2026 16:34:58 +0530 [thread overview]
Message-ID: <20260807110501.975130-3-t-pratham@ti.com> (raw)
In-Reply-To: <20260807110501.975130-1-t-pratham@ti.com>
Add support for MD5 algorithm in the hashing engine of DTHEv2 hardware
cryptographic engine.
Signed-off-by: T Pratham <t-pratham@ti.com>
---
drivers/crypto/ti/Kconfig | 1 +
drivers/crypto/ti/dthev2-common.h | 1 +
drivers/crypto/ti/dthev2-hash.c | 47 +++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/drivers/crypto/ti/Kconfig b/drivers/crypto/ti/Kconfig
index 90af2c7cb1c55..9c2aa50cfbfbe 100644
--- a/drivers/crypto/ti/Kconfig
+++ b/drivers/crypto/ti/Kconfig
@@ -12,6 +12,7 @@ config CRYPTO_DEV_TI_DTHEV2
select CRYPTO_CCM
select CRYPTO_SHA256
select CRYPTO_SHA512
+ select CRYPTO_MD5
select SG_SPLIT
help
This enables support for the TI DTHE V2 hw cryptography engine
diff --git a/drivers/crypto/ti/dthev2-common.h b/drivers/crypto/ti/dthev2-common.h
index d3fb7c5ff3052..2c6e06df16d35 100644
--- a/drivers/crypto/ti/dthev2-common.h
+++ b/drivers/crypto/ti/dthev2-common.h
@@ -17,6 +17,7 @@
#include <crypto/internal/aead.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/skcipher.h>
+#include <crypto/md5.h>
#include <crypto/sha2.h>
#include <linux/delay.h>
diff --git a/drivers/crypto/ti/dthev2-hash.c b/drivers/crypto/ti/dthev2-hash.c
index dc7a397a9e58c..1606b982e4581 100644
--- a/drivers/crypto/ti/dthev2-hash.c
+++ b/drivers/crypto/ti/dthev2-hash.c
@@ -9,6 +9,7 @@
#include <crypto/algapi.h>
#include <crypto/hash.h>
#include <crypto/internal/hash.h>
+#include <crypto/md5.h>
#include <crypto/scatterwalk.h>
#include <crypto/sha2.h>
@@ -97,6 +98,9 @@ static void dthe_hash_write_zero_message(enum dthe_hash_alg_sel mode, void *dst)
case DTHE_HASH_SHA224:
memcpy(dst, sha224_zero_message_hash, SHA224_DIGEST_SIZE);
break;
+ case DTHE_HASH_MD5:
+ memcpy(dst, md5_zero_message_hash, MD5_DIGEST_SIZE);
+ break;
default:
break;
}
@@ -125,6 +129,9 @@ static enum dthe_hash_alg_sel dthe_hash_get_hash_mode(struct crypto_ahash *tfm)
case SHA224_DIGEST_SIZE:
hash_mode = DTHE_HASH_SHA224;
break;
+ case MD5_DIGEST_SIZE:
+ hash_mode = DTHE_HASH_MD5;
+ break;
default:
hash_mode = DTHE_HASH_ERR;
break;
@@ -146,6 +153,9 @@ static unsigned int dthe_hash_get_phash_size(struct dthe_tfm_ctx *ctx)
case DTHE_HASH_SHA224:
phash_size = SHA256_DIGEST_SIZE;
break;
+ case DTHE_HASH_MD5:
+ phash_size = MD5_DIGEST_SIZE;
+ break;
default:
break;
}
@@ -489,6 +499,10 @@ static const u64 sha512_init_state[SHA512_DIGEST_SIZE / sizeof(u64)] = {
SHA512_H4, SHA512_H5, SHA512_H6, SHA512_H7
};
+static const u32 md5_init_state[MD5_DIGEST_SIZE / sizeof(u32)] = {
+ MD5_H0, MD5_H1, MD5_H2, MD5_H3
+};
+
static const void *dthe_hash_get_init_state(struct dthe_tfm_ctx *ctx)
{
switch (ctx->hash_mode) {
@@ -500,6 +514,8 @@ static const void *dthe_hash_get_init_state(struct dthe_tfm_ctx *ctx)
return sha384_init_state;
case DTHE_HASH_SHA512:
return sha512_init_state;
+ case DTHE_HASH_MD5:
+ return md5_init_state;
default:
return NULL;
}
@@ -682,6 +698,37 @@ static struct ahash_engine_alg hash_algs[] = {
},
.op.do_one_request = dthe_hash_run,
},
+ {
+ .base.init_tfm = dthe_hash_init_tfm,
+ .base.init = dthe_hash_init,
+ .base.update = dthe_hash_update,
+ .base.final = dthe_hash_final,
+ .base.finup = dthe_hash_finup,
+ .base.digest = dthe_hash_digest,
+ .base.export = dthe_hash_export,
+ .base.import = dthe_hash_import,
+ .base.halg = {
+ .digestsize = MD5_DIGEST_SIZE,
+ .statesize = sizeof(struct dthe_hash_req_ctx),
+ .base = {
+ .cra_name = "md5",
+ .cra_driver_name = "md5-dthev2",
+ .cra_priority = 299,
+ .cra_flags = CRYPTO_ALG_TYPE_AHASH |
+ CRYPTO_ALG_ASYNC |
+ CRYPTO_ALG_OPTIONAL_KEY |
+ CRYPTO_ALG_KERN_DRIVER_ONLY |
+ CRYPTO_ALG_ALLOCATES_MEMORY |
+ CRYPTO_AHASH_ALG_BLOCK_ONLY |
+ CRYPTO_AHASH_ALG_NO_EXPORT_CORE,
+ .cra_blocksize = MD5_BLOCK_SIZE,
+ .cra_ctxsize = sizeof(struct dthe_tfm_ctx),
+ .cra_reqsize = sizeof(struct dthe_hash_req_ctx),
+ .cra_module = THIS_MODULE,
+ }
+ },
+ .op.do_one_request = dthe_hash_run,
+ },
};
int dthe_register_hash_algs(void)
--
2.34.1
next prev parent reply other threads:[~2026-08-07 11:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 11:04 [PATCH v5 0/3] Add support for hashing algorithms in TI DTHE V2 T Pratham
2026-08-07 11:04 ` [PATCH v5 1/3] crypto: ti - Add support for SHA224/256/384/512 in DTHEv2 driver T Pratham
2026-08-07 11:04 ` T Pratham [this message]
2026-08-07 11:04 ` [PATCH v5 3/3] crypto: ti - Add support for HMAC in DTHEv2 Hashing Engine driver T Pratham
2026-08-15 1:09 ` [PATCH v5 0/3] Add support for hashing algorithms in TI DTHE V2 Herbert Xu
2026-08-19 7:39 ` T Pratham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260807110501.975130-3-t-pratham@ti.com \
--to=t-pratham@ti.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-chawdhry@ti.com \
--cc=praneeth@ti.com \
--cc=s-tripathi1@ti.com \
--cc=sebin.francis@ti.com \
--cc=vishalm@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.