[PATCH v5 00/19] crypto: talitos - Driver cleanup

From: Paul Louvel

Date: Mon Sep 07 2026 - 09:32:24 EST


The Freescale Integrated Security Engine (SEC) aka "Talitos" driver
implementation is a monolithic ~3800-line file that mixes SEC1 and SEC2
hardware variants with hash, skcipher, aead and hwrng algorithm.

This series reorganises the driver to improve readability and
maintainability:

- Split the driver into a dedicated directory with separate files for
hash, skcipher, aead, and hwrng implementations.

- Modernise the crypto API usage: adopt {init,exit}_tfm (deprecated
cra_init/cra_exit), use CRYPTO_AHASH_ALG_BLOCK_ONLY to eliminate
manual partial-block buffering, and use macros to deduplicate
algorithm definitions.

- Introduce a is_sec1() helper to get rid of is_sec1 variables /
parameters.

- Define descriptor/pointer structures for each hardware version,
instead of using a single structure and anonymous union.

No functional changes are intended except for patch 1.

This series depends on the "crypto: talitos - bug fixes" series :
https://patch.msgid.link/20260507-bootlin_test-7-1-rc1_sec_bugfix-v3-0-c98d7589b942@xxxxxxxxxxx

Signed-off-by: Paul Louvel <paul.louvel@xxxxxxxxxxx>
---
Changes in v5:
- Patch 1: compute the SEC1 software padding length in little endian for
MD5. Update message_size only once the hardware has accepted the
request, so a failed submission no longer updates the message length.
A note on Sashiko third comment [1]:

- If the current digest operation errors out because the driver
returned -EAGAIN, it indeed clears the partial block buffer in the
core with CRYPTO_AHASH_ALG_BLOCK_ONLY.

Looking at how the API handles it, it means for me that the entire
digest operation must be restarted, not just the current chunk of
data currently being processed with .update() or .finup(). In this
case, no need to keep the partial block buffer.

If I am mistaken, how should this be handled?

- Patch 4: rename the module target to crypto-talitos to remove the
circular dependency in the Makefile.

- Patch 5: make __map_single_talitos_ptr() static inline to avoid
unused-function warnings.

- Patches 6, 7 and 8: register algorithms from a copy of the templates
instead of modifying the global arrays. Make the algorithm template
arrays const.

- Patch 12: keep the "hmac-<hash>-talitos" driver names in the hash
macros.

- Patches 12/13/14: added a driver_name parameter to the algorithm
macros. The driver name is built from driver_name"-talitos" instead
of name"-talitos", so the old dash separated format survives
("cbc-aes-talitos" rather than "cbc(aes)-talitos"). Sashiko flagged
this in the v4 review as a userspace ABI break.

- Patch 15: move before the macro conversion patches, and set the
properties that do not depend on runtime features in the templates.
This patch is now patch 12 in the series.

- Link to v4:
https://patch.msgid.link/20260722-7-1-rc1_talitos_cleanup-v4-0-81d1ed2ad911@xxxxxxxxxxx

Changes in v4:
- The modification I did in v3 in PATCH 1 was incomplete. message_size
was not initialized in ahash_init(), and not incremented in
ahash_process_req().
- Link to v3: https://patch.msgid.link/20260721-7-1-rc1_talitos_cleanup-v3-0-7c71a2b77c83@xxxxxxxxxxx

Changes in v3:
- Upon Herbert's remark on FINAL_NONZERO flag not working with algorithms
like md5, I removed the flag entirely for all algorithms.
Only the SEC1 revision is buggy when sending 0 byte descriptor
: the hardware yield an error. On the SEC2, this bug is not present
and can accept zero byte descriptor if the hardware auto-pad.
This bug is mitigated for SEC1 with software padding in
talitos_handle_buggy_hash().
It had to be slightly change in PATCH 1 because of the removal of
FINAL_NONZERO : the message length in bits was always zero. Now, a
zero byte request can happen after a handful of non-zero byte
requests.
Keep track of the message length in the request context, and put the
message length in bits as a 64-bit big endian integer at the end of
the padding.
Allocate a buffer per ahash request instead of using a static buffer,
since it is now written to.
- Link to v2: https://patch.msgid.link/20260611-7-1-rc1_talitos_cleanup-v2-0-aa4a813ce69b@xxxxxxxxxxx

Changes in v2:
- Fixed compilation warnings and errors.
- Instead of using ops to dispatch SEC1/SEC2 variants, keep the small
helpers, and introduce is_sec1() inline function that can use static
key branching in case both hardware version are compiled.
- Dropped the SEC1/SEC2 function variants inside the core driver file.
- Reworded the cover letter for clarity.
- Link to v1: https://patch.msgid.link/20260528-7-1-rc1_talitos_cleanup-v1-0-cb1ad6cdea49@xxxxxxxxxxx

References:

[1]: https://sashiko.dev/#/patchset/20260722-7-1-rc1_talitos_cleanup-v4-0-81d1ed2ad911%40bootlin.com?part=1

---
Paul Louvel (19):
crypto: talitos/hash - Use CRYPTO_AHASH_BLOCK_ONLY API
crypto: talitos - Move driver into dedicated directory
crypto: talitos - Add missing includes to driver header file
crypto: talitos/hwrng - Move into separate file
crypto: talitos - Prepare crypto implementation file splitting
crypto: talitos/hash - Move into separate file
crypto: talitos/skcipher - Move into separate file
crypto: talitos/aead - Move into separate file
crypto: talitos/hash - Convert to {init,exit}_tfm type-specific API
crypto: talitos/skcipher - Convert to {init,exit}_tfm type-specific API
crypto: talitos/aead - Convert to {init,exit}_tfm type-specific API
crypto: talitos - Remove alg settings in talitos_register_common()
crypto: talitos/hash - Use macro for algorithm definitions
crypto: talitos/skcipher - Use macro for algorithm definitions
crypto: talitos/aead - Use macro for algorithm definitions
crypto: talitos - Introduce is_sec1() helper with static key support
crypto: talitos - Replace has_ftr_sec1() with is_sec1() static key helper
crypto: talitos - Introduce per-SEC-version descriptor and pointer structures
crypto: talitos - Remove TALITOS_DESC_SIZE macro

drivers/crypto/Kconfig | 38 +-
drivers/crypto/Makefile | 2 +-
drivers/crypto/talitos.c | 3640 -----------------------------
drivers/crypto/talitos/Kconfig | 36 +
drivers/crypto/talitos/Makefile | 3 +
drivers/crypto/talitos/talitos-aead.c | 680 ++++++
drivers/crypto/talitos/talitos-hash.c | 705 ++++++
drivers/crypto/talitos/talitos-rng.c | 93 +
drivers/crypto/talitos/talitos-skcipher.c | 359 +++
drivers/crypto/talitos/talitos.c | 1337 +++++++++++
drivers/crypto/{ => talitos}/talitos.h | 316 ++-
11 files changed, 3503 insertions(+), 3706 deletions(-)
---
base-commit: db8b9f227833e729faf44a512aa1e88a625b5ad8
change-id: 20260518-7-1-rc1_talitos_cleanup-9231a64e29fa
prerequisite-change-id: 20260504-bootlin_test-7-1-rc1_sec_bugfix-13169ed07ddc:v3
prerequisite-patch-id: 7b364911e4b8d1c1033eb14e67ed24dac6a4bc13
prerequisite-patch-id: 2c1cd7fdd003d9a116a697efa25d1716d548389f
prerequisite-patch-id: b12bdbf565747609e0cfe0609a42cf69b5d816a1
prerequisite-patch-id: 72cb2bc0fc2a48a5a029b049c199f4c86085cf04
prerequisite-patch-id: 5f1f5ad6add760161bd48875df48c0893aa12613
prerequisite-patch-id: 934931086968229434d15a2f2358aeb7e6975a1d
prerequisite-patch-id: 8a0b4828fc0690e0c841bc9adcc6568bb522e0e8
prerequisite-patch-id: 1d870f32e7dbf9a8bd3b8979558544107693e0f4
prerequisite-patch-id: 758c18d7c9fabb14bd90df62e5e8a62a6f880db4
prerequisite-patch-id: ce6e9e585f8edc1861ae6bb8fbdd836c20cbd290
prerequisite-patch-id: 9446dc03e442ea81c5f5b39e802e01b37da29971

Best regards,
--
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com