174 Commits

Author SHA1 Message Date
Gaetan Perrot
bca0b43be9 drivers: crypto: intel_sha: make set_resume_length_dw1 void
intel_sha_set_resume_length_dw1() never reports errors
and always returns 0.
The error check at the call site is therefore dead code.

Make the function void and drop the unused error handling.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-01-12 12:36:48 -06:00
Gaetan Perrot
f017f4cb91 drivers: crypto: intel_sha: make set_ctl_enable void
intel_sha_set_ctl_enable() never reports errors
and always returns 0.
The error check at the call site is therefore dead code.

Make the function void and drop the unused error handling.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-01-12 12:36:48 -06:00
TOKITA Hiroshi
41a86eb1fe drivers: crypto: Add initial support for rpi_pico sha256 accelerator
Add basic support for RaspberryPi Pico's SHA256 hardware accelerator.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2025-12-31 11:00:21 +00:00
Jeremy Bettis
f14ccdf462 drivers: Add const to rts5912_sha256_process() input
rts5913_sha256_update was changed in #94218, but this function passes
it's input into rts5912_sha256_process also.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-12-16 10:06:45 -06:00
Valerio Setti
d76477f9eb drivers: crypto: mbedtls_shim: fix crash in AES-ECB for RISCV 64 bits
Using "pkt->out_len" as the output length of "psa_cipher_[en|de]crypt"
caused a crash in RISCV 64 bits platforms due to misaligned address
access.
The solution is to add a temporary value on the stack to store this lenght
and only after the [en|de]cryption copy it to "pkt->out_len".

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-15 07:29:29 -05:00
Johan Hedberg
69946a1253 drivers: crypto_mbedtls_shim: Fix build with Clang/LLVM
drivers/crypto/crypto_mbedtls_shim.c:310:3: error: label followed by a
declaration is a C23 extension [-Werror,-Wc23-extensions]
                 uint16_t tag_len = ctx->mode_params.ccm_info.tag_len;
                 ^

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-12-05 13:38:37 +02:00
Valerio Setti
4cf7cd5748 drivers: crypto: mbedtls_shim: allow tag len to be specified in CCM
Retrieve the desired tag length from the "struct cipher_ctx" being passed
to "cipher_begin_session()" when using CCM.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-04 14:01:02 -05:00
Tony Han
6d52c87443 drivers: crypto: hash: add driver for Microchip SHA
Add driver for Microchip Secure Hash Algorithm (SHA), update Kconfig
and make files.

Signed-off-by: Tony Han <tony.han@microchip.com>
2025-12-03 09:11:40 -05:00
Tony Han
ac31be0d98 drivers: crypto: Kconfig: rename Kconfig.xec to Kconfig.mchp
Rename to Kconfig.mchp for Microchip crypto drivers support.

Signed-off-by: Tony Han <tony.han@microchip.com>
2025-12-03 09:11:40 -05:00
Ha Duong Quang
aab99a548b driver: crypto: add NXP S32 CRYPTO HSE driver
Add device tree node for MU instances that will be used by HSE and RTU
for s32z270.

Add support hash crypto for NXP S32 with Algo 2:
SHA224, SHA256, SHA384 and SHA512.

Add support cipher crypto with ECB, CBC and CTR mode by using ram key
catalog.

Add support 128/256 bits ram key length.

Signed-off-by: Ha Duong Quang <ha.duongquang@nxp.com>
2025-12-02 11:20:29 +01:00
Valerio Setti
711f13fff6 drivers: crypto: mbedtls_shim: improve session handling
Add a new function to free an mbedtls_shim session:
'mbedtls_free_session()'. Together with 'mbedtls_get_unused_session()',
these will be the only entry points to acquire/release sessions.
In this way it's easier to ensure that the mutex is properly held while
setting the 'in_use' parameter.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-01 08:26:29 +01:00
Valerio Setti
cc65c9543b drivers: crypto: mbedtls_shim: replace legacy cipher API with PSA API
Replace legacy crypto API for cipher (ECB, CBC) and AEAD (CCM, GCM) with
PSA API.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-01 08:26:29 +01:00
Valerio Setti
678542d899 drivers: crypto: mbedtls_shim: replace legacy hash API with PSA API
Replace usage of legacy crypto hash functions from Mbed TLS with PSA API.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-01 08:26:29 +01:00
Valerio Setti
91dbaf5c45 drivers: crypto: mbedtls_shim: move mbedtls_get_unused_session_index()
Move mbedtls_get_unused_session_index() at the top of the file and leave
cipher and hash functions below.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-01 08:26:29 +01:00
Valerio Setti
0cee013a3f drivers: crypto: mbedtls_shim: add _cipher_ to cipher ops
Another small renaming for cipher ops that just adds "_cipher_" in the
function's name.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-01 08:26:29 +01:00
Valerio Setti
37197f869a drivers: crypto: mbedtls_shim: general renaming
This commit just implements some renaming:
* mbedTLS -> Mbed TLS
* MbedTLS -> Mbed TLS
* MTLS_ -> MBEDTLS_
* mtls_ -> mbedtls_
* mtls_ccm -> ccm_ctx
* mtls_gcm -> gcm_ctx
* mtls_aes -> aes_ctx
* mtls_sha256 -> sha256_ctx
* mtls_sha512 -> sha512_ctx

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-01 08:26:29 +01:00
Valerio Setti
5eb2f46e0d drivers: crypto: mbedtls_shim: rename module
Use full name for the module so "mtls" -> "mbedtls"

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-12-01 08:26:29 +01:00
Josuah Demangeon
30950b888d style: drivers: sort Kconfig and CMake includes
Use the "zephyr-keep-sorted-start/stop" comment to have CI check
the alphabetical order of includes, to help reducing the chance
of conflicts while contributing drivers.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-11-17 13:48:03 -05:00
Etienne Carriere
b0ccb2295f drivers: stm32: use STM32_CLOCK_INFO_BY_NAME() and friends
Use STM32_CLOCK_INFO(), STM32_DT_INST_CLOCK_INFO(),
STM32_CLOCK_INFO_BY_NAME() and STM32_DT_INST_CLOCK_INFO_BY_NAME()
helper macros in STM32 drivers.

Using these macros ensure the clock division factor is properly
populated according to DT information. Prior these changes some
drivers only got the bus and bits position information and missed
the clock division information which is fine only when this division
factor information is 0.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-11-14 15:26:17 +02:00
Badr Bacem KAABIA
0719c9eca2 crypto: mbedtls_shim: Fix concurrency and deadlock issues
- **Fix session mutex handling:** Ensure the `mtls_sessions_lock` is
    always released in `mtls_get_unused_session_index` on failure
    to prevent deadlocks.
- **Protect `in_use` flag:** Added mutex protection when setting
    `in_use = false` in free functions.
- **Cleanup on setup failure:** Added calls to `mbedtls_*_free()`
    in `mtls_session_setup()` when key initialization fails.
- **Free logic fix:** Corrected `if/else` structure in
    `mtls_session_free()` to ensure the correct context is freed.

Signed-off-by: Badr Bacem KAABIA <badrbacemkaabia@gmail.com>
2025-11-13 12:01:44 +02:00
Badr Bacem KAABIA
577f60dcd7 crypto: mbedtls_shim: Remove incorrect out_len calculation in AEAD decrypt
Remove erroneous calculation of `apkt->pkt->out_len` in
`mtls_ccm_decrypt_auth` and `mtls_gcm_decrypt_auth`.
The output length should be handled by the caller or the
AEAD decryption process itself.

Signed-off-by: Badr Bacem KAABIA <badrbacemkaabia@gmail.com>
2025-11-13 12:01:44 +02:00
Badr Bacem KAABIA
01b0280bad crypto: mbedtls_shim: Fix typos
Corrected "encrypt" log messages to "decrypt."

Signed-off-by: Badr Bacem KAABIA <badrbacemkaabia@gmail.com>
2025-11-13 12:01:44 +02:00
Loic Domaigne
1b0950035e drivers: crypto: crypto_ataes132a fix missing count check
Coverity reported an untrusted loop bound caused by a missing check on
the count value in ataes132a_send_command() for the response received
from the device.  As per datasheet section 6.1, count should be at least
3 bytes (1 byte for count, and 2 bytes for the 16 bits CRC).

While I'm expecting this condition to be very rare, it doesn't hurt to
implement a proper checking and report an error if count<3.

Coverity CID: 434625

Signed-off-by: Loic Domaigne <tech@domaigne.com>
2025-11-06 14:02:39 -05:00
Sylvio Alves
998d9ab04f drivers: crypto: expand mbedTLS shim driver capabilities
Select SHA24, SHA256 and SHA384 as part of the shim driver.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-10-28 11:51:04 +02:00
Sylvio Alves
4b4332ac18 drivers: crypto: return -ENOTSUP when needed
Make sure all crypto driver returns proper error
when feature is not supported.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-10-28 11:51:04 +02:00
Sylvio Alves
9b3bb86855 drivers: crypto: add Espressif HW AES support
Add hardware-accelerated AES driver for Espressif SoCs supporting
ECB, CBC, and CTR cipher modes with AES-128, AES-192, and AES-256
key lengths.

Supported modes:
- ECB (Electronic Codebook)
- CBC (Cipher Block Chaining)
- CTR (Counter)

Supported SoCs:
- ESP32: All modes, all key sizes
- ESP32-S2/S3: All modes, AES-128/256 only
- ESP32-C2/C3/C6/H2: All modes, all key sizes

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-10-24 13:21:24 -04:00
Sylvio Alves
391ffabd66 drivers: crypto: add Espressif HW SHA support
Add hardware-accelerated SHA driver for Espressif SoCs supporting
SHA-224, SHA-256, SHA-384, and SHA-512 algorithms.

Supported SoCs:
- ESP32: SHA-224/256/384/512 (single-shot operations)
- ESP32-S2/S3: SHA-224/256/384/512 (with multi-part support)
- ESP32-C2/C3/C6/H2: SHA-224/256 (with multi-part support)

Tested with Zephyr crypto subsystem hash_compute() API.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-10-24 13:21:24 -04:00
Titouan Christophe
b677e828d0 drivers: crypto: hash_pkt.in_buf is now constant
Previous commit made the input buffer of the hash packet constant.
Let's therefore adapt typing where used, and remove inappropriate
casts of constant buffers to non-constant ones.

All the "backend" hashing functions already take a constant input,
these changes only affect the "plumbing" between the Zephyr crypto
API and the actual implementation where applicable.

Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
2025-10-21 22:55:24 +03:00
Elmo Lan
79d7ce61d2 driver: crypto: fix timing discrepancies
Use a temporary variable to store and compare the reference time
instead of calling the time function multiple times,
which may lead to slight mismatches in comparison due to timing drift.

Signed-off-by: Elmo Lan <elmo_lan@realtek.com>
2025-09-02 07:56:56 +02:00
Julien Panis
22d04f7f93 drivers: crypto: cc23x0: Add power management
Add PM support to cc23x0 AES module.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
2025-08-29 22:55:37 -04:00
Alain Volmat
14525b99d5 drivers: crypto: stm32: ensure RESET is selected
stm32 crypto driver requires a reset control hence ensure that
CONFIG_RESET is properly selected to allow proper build.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
2025-08-18 17:49:28 +02:00
Bayrem Gharsellaoui
95934d2abd drivers: crypto: Add STM32 HASH hardware driver
Add STM32 HASH driver with SHA-224/256 support for STM32U5

Signed-off-by: Bayrem Gharsellaoui <bayrem.gharsellaoui@protonmail.com>
2025-08-15 10:10:24 +03:00
Loic Domaigne
28f37e522a drivers: crypto: crypto_ataes132a fix memset undefined behavior
Coverity reported a memory - illegal accesses when using memset in
ataes132a_aes_ecb_block(). This can happen when the input block is
exactly 16 bytes: memset(&param_buffer[19], 0x0, 0) is called. But this
is an undefined behaviour in C even if size is 0, as &param_buffer[19]
is an invalid pointer.

The fix consists of simply skipping memset() in this case, since there's
nothing to zero out.

Coverity CID: 434642

Signed-off-by: Loic Domaigne <tech@domaigne.com>
2025-07-10 10:13:17 -05:00
Pisit Sawangvonganan
b8a8173c1f drivers: kconfig: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in `Kconfig` files within the `drivers` directory.
Additionally, incorporates a fix recommended by the reviewer.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-07-01 10:58:54 -10:00
Julien Panis
e0f02d93a6 drivers: crypto: cc23x0: Add support for DMA mode
Two DMA channels are assigned to AES channels A and B respectively.
Each channel A/B has an interface to control the conditions that will
generate requests on the related DMA channel: trigger condition,
R/W address, and DMA done action.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
2025-06-11 16:06:55 -07:00
Lin Yu-Cheng
b2e13bd6c3 driver: crypto: add crypto driver for rts5912
Add crypto driver for Realtek rts5912

Signed-off-by: Lin Yu-Cheng <lin_yu_cheng@realtek.com>
2025-06-07 13:29:07 +01:00
Flavio Ceolin
dfde32144a drivers; crypto: Remove TinyCrypt shim
TC crypto driver was depecrated in 4.0 release. Time to
remove it \o/

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2025-05-23 17:41:06 -04:00
Yunshao Chiang
8f8b223ff2 drivers: crypto: add it51xxx sha256 driver
Implement a crypto sha256 driver for it51xxx series.

Signed-off-by: Yunshao Chiang <Yunshao.Chiang@ite.com.tw>
2025-05-16 19:07:37 +02:00
Julien Panis
fa8d5177c1 drivers: crypto: Add support for cc23x0 AES
Add support for AES module to cc23x0 SoC. The driver supports the
following modes:
- ECB encryption only (since decryption is not supported by the HW)
- CTR
- CCM

Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
Signed-off-by: Julien Panis <jpanis@baylibre.com>
2025-03-07 19:47:11 +01:00
Benjamin Cabé
6c735705cd drivers: crypto: fix spelling of "below"
s/bellow/below/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-19 18:51:13 +01:00
Jilay Pandya
0ab69fb19e drivers: crypto: crypto_ataes132a fix buffer overrun issue
fix buffer overrun issue by assigning more bytes to the param buf

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2024-12-29 05:51:51 +01:00
Pieter De Gendt
45be45d7e0 drivers: crypto: Place API into iterable section
Add wrapper DEVICE_API macro to all crypto_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-06 12:13:37 +01:00
Johan Hedberg
8b02141ca7 Bluetooth: Controller: Replace BT_CTLR with HAS_BT_CTLR
Deprecate BT_CTLR, and add a new HAS_BT_CTLR as a virtual option which
specific users (like BT_LL_SW_SPLIT) select. This also means that we can
remove all places that were forcefully enabling the BT_CTLR option, and
instead we now depend on devicetree to get some local LL HCI driver
enabled which in turn also enables the HAS_BT_CTLR option.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-12-03 10:16:44 +01:00
Valerio Setti
dbda4642cd drivers: crypto: deprecated TinyCrypt shim driver
As part of the deprecation process of TinyCrypt started in #79566,
this commit set the TinyCrypt based crypto shim driver as
deprecated.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-11-05 13:44:20 -06:00
Reto Schneider
1790eda851 drivers: crypto: Add initial SiM3U1xx support
This driver makes use of the hardware AES acceleration, using DMA
transfers.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-10-24 17:52:05 +02:00
Lucas Dietrich
11abb5e4fc drivers: crypto: Fix pointer type warnings in STM32 AES driver
This patch resolves compiler warnings related to mismatched pointer types
between the STM32L4 and generic STM32 AES HAL by introducing CAST_VEC
macro.

Fix github CI warning

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2024-10-11 09:28:12 +02:00
Lucas Dietrich
ad431dcc23 drivers: crypto: Add support for STM32L4 AES accelerator
This patch completes the addition of support for the STM32L4 AES
accelerator by introducing conditional handling for different STM32 AES
HAL variants. Key changes include:

- Created device tree bindings `st,stm32l4-aes` for STM32L4 AES
- Replaced `copy_reverse_words` with `copy_words_adjust_endianness`
to handle endianness conversion for different variants.

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2024-10-11 09:28:12 +02:00
Lucas Dietrich
8f0de8455d drivers: crypto: Refactor encryption and decryption functions for STM32 AES
This patch introduces a unified function pointer approach to handle
encryption and decryption operations for the STM32 AES accelerator.

- Replace separate `do_encrypt` and `do_decrypt` functions with a generic
`do_aes` function, using function pointers to AES HAL functions.

Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
2024-10-11 09:28:12 +02:00
Saravanan Sekar
c143cbaa7c drivers: crypto: use reset api for crypto peripheral reset
Replace direct HAL api by zephyr reset api framework for crypto
peripheral block reset.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2024-07-28 07:31:25 +03:00
Ioannis Damigos
0a0bccabd8 drivers/smartbond: Fix PM device runtime support
Removed PM device runtime support from drivers in PD_SYS domain.

Update the rest device drivers to call pm_device_runtime_get/put()
functions when CONFIG_PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-18 14:36:38 -04:00