Adapt all Espressif SoC and driver code to the updated
hal_espressif module synced with IDF master branch.
Main changes:
- clock control: delegate peripheral clock gating to HAL
layer using new clock/reset APIs
- SPI/GDMA: adapt to restructured DMA HAL with new channel
allocation and configuration interfaces
- ethernet: add RMII clock configuration and PHY management
- GPIO: simplify using direct HAL function calls
- flash: adapt to updated SPI flash HAL interfaces
- linker scripts: update IRAM/DRAM mappings for new HAL
object files
- DTS: fix ESP32-S2 PSRAM dcache1 address to match actual
MMU mapping region (0x3f800000 DRAM1 instead of 0x3f500000
DPORT which lacks 8-bit access capability)
- west.yml: update hal_espressif revision
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Add hardware crypto drivers for the Bouffalo Lab SEC Engine:
- AES: ECB, CBC, CTR modes with 128/192/256-bit keys
- SHA: SHA-224 and SHA-256 (SHA-384/512 not supported in HW)
- GMAC: Galois MAC (GF(2^128) multiply)
Each sub-block is a separate driver with its own Kconfig and
DT compatible. All drivers recover SEC_ENG_BASE from the DT
sub-block address to work with HAL register offsets.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Remove inclusions that date back to the original addition of this driver
and that are no more required when PSA API is used.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
In ataes132a_aes_ecb_block(), error paths could return after
k_sem_take() without releasing device_sem, leading to a potential
deadlock on subsequent calls.
Ensure k_sem_give() is called on all early-return paths after the
semaphore is taken.
This fixes a potential deadlock when invalid buffer sizes are
detected after acquiring the device semaphore.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
Use int return type for command results to avoid truncating negative
errno values and ensure proper error propagation.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Addressed stability and security issues identified by Coverity in
the ATaes132a crypto driver:
- CID 434625: Added range validation for 'count' to prevent tainted
scalar usage and buffer underflow in response processing.
- CID 487700 & 487763: Implemented overflow guards for 'buf_len' to
prevent integer overflow and type truncation when calling
ataes132a_send_command.
- CID 487746: Applied explicit type casting to CRC calculations to
satisfy static analysis regarding integer promotion.
Signed-off-by: Shreya Kulkarni <kulkarnishreya2421@gmail.com>
As per Zephyr coding guideline #59, "operands shall not be of an
inappropriate essential type". This makes sure boolean variables are
assigned true/false values, not 1/0.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
ataes132a_state is an array of CRYPTO_MAX_SESSION length.
This constant must be used when iterating over its elements
and not ATAES132A_AES_KEY_SIZE (even they having the same
value).
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- **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>
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>
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>
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>
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>
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>
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(¶m_buffer[19], 0x0, 0) is called. But this
is an undefined behaviour in C even if size is 0, as ¶m_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>
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>