drivers: crypto: bee: add PSA hardware accelerator driver - #15
Open
ZhiyuanTang17 wants to merge 2 commits into
Open
ZhiyuanTang17 wants to merge 2 commits into
ZhiyuanTang17 wants to merge 2 commits into
Conversation
Add a PSA crypto driver for the Realtek Bee hardware crypto engine. The driver is built when CONFIG_CRYPTO_BEE_PSA_ACCELERATOR is set and provides PSA-compatible implementations for: - SHA-256 (compute, streaming) - AES-ECB/CBC/CFB/OFB/CTR (one-shot and multipart) - AES-CCM AEAD (one-shot and multipart) - P-256 ECDSA sign/verify (RTL87X2G only) - P-256 ECDH key agreement (RTL87X2G only) The driver is structured as a portable core (crypto_bee_psa.c) plus a thin platform adapter (crypto_bee_psa_adapter.c) that calls the hardware engine APIs from the HAL. Expose the AES block-cipher and PKE/ECC ROM function declarations in the rtl8752h and rtl87x2g HAL headers, and add the corresponding ROM entry-point addresses to the RTL87X2G linker script. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Zhiyuan Tang <zhiyuan_tang@realsil.com.cn>
ZhiyuanTang17
force-pushed
the
tzy/bee-psa-driver
branch
from
August 18, 2026 09:12
479434d to
f9f2bad
Compare
RTL87x2J exposes AES (ECB/CBC) and SHA (SHA-224, SHA-256) through a
different ROM API than other Bee SoC series. Extend the PSA hardware
accelerator driver to support RTL87x2J across all layers:
bee/drivers/crypto/inc/rtl87x2j/
Add vendor header files for the RTL87x2J AES and SHA2 ROM driver:
aes_interface.h, sha2_interface.h, aes_dma_types.h.
CMakeLists.txt
Include the above directory when building for SOC_SERIES_RTL87X2J.
crypto_bee_psa_adapter.h / .c
- Introduce bee_aes_mode_t to abstract AES_WORK_MODE (RTL87x2J) vs
T_HW_AES_MODE (other series) and matching BEE_AES_MODE_CBC/ECB
aliases so call sites are SoC-family-agnostic.
- Add a dedicated RTL87x2J path in bee_aes_hw_crypt_block() that
drives the aes_encrypt()/aes_decrypt() ROM functions and clears the
hardware busy flag via AES_BASE after each operation.
- Rename the one-shot hash entry point to bee_sha2_hw_compute() and
add a hash_length parameter to support both SHA-224 (28 B) and
SHA-256 (32 B).
- Add bee_sha2_hw_start/update/finish() multipart API for RTL87x2J,
backed by sha2_iv_init(), sha2_cpu_update(), and sha2_finish(); a
restore helper re-seeds the hardware IV register from the saved
SHA2_CTX on each call so context switching is safe.
crypto_bee_psa_types.h
Use SHA2_CTX as the internal context type for RTL87x2J (selected via
CONFIG_SOC_SERIES_RTL87X2J); retain HW_SHA256_CTX for other series.
crypto_bee_psa.c
- Extend bee_psa_hash_compute/setup/update/finish/clone to accept
PSA_ALG_SHA_224 on RTL87x2J in addition to PSA_ALG_SHA_256.
- Derive required_size from PSA_HASH_LENGTH(alg) instead of
hard-coding the SHA-256 length, so SHA-224 output is sized
correctly.
- Use BEE_AES_MODE_ECB/CBC aliases in cipher paths to remain
portable across SoC families.
bee/ld/rtl87x2j/bootloader.ld
Add PROVIDE() entries for all AES ROM symbols (aes_cmac,
aes_cpu_operate, aes_decrypt, aes_dma_*, aes_encrypt, aes_init) and
SHA2 ROM symbols (sha2, sha2_cpu_finish, sha2_cpu_update,
sha2_dma_*, sha2_get_digest*, sha2_init, sha2_iv_init, sha2_start)
required by the crypto driver at link time.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a PSA crypto driver for the Realtek Bee hardware crypto
engine. The driver is built when
CONFIG_CRYPTO_BEE_PSA_ACCELERATORis set and provides PSA-compatible implementations for:
The driver is structured as a portable core (
crypto_bee_psa.c)plus a thin platform adapter (
crypto_bee_psa_adapter.c) thatcalls the hardware engine APIs from the HAL.
Expose the AES block-cipher and PKE/ECC ROM function declarations
in the
rtl8752handrtl87x2gHAL headers, and add thecorresponding ROM entry-point addresses to the RTL87X2G linker
script.
🤖 Generated with Claude Code