This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 955ba956433c9c34e32105f39990cf0a069325ba Author: makejian <[email protected]> AuthorDate: Wed Nov 25 12:48:12 2026 +0800 crypto/mbedtls: add CIOCKEY wrapper to dev_alt The asymmetric alt modules (ECDSA/ECDH) talk to /dev/crypto through cryptodev_context_t, but the context only carries the symmetric crypt_op. Add a crypt_kop and a cryptodev_cryptk() helper so those modules can submit CIOCKEY requests the same way they submit CIOCCRYPT. The kernel reports key-op hardware results through the ioctl return value, so map failures to -errno exactly like cryptodev_crypt(). A signature verification failure thus comes back as -EBADMSG. Signed-off-by: makejian <[email protected]> --- crypto/mbedtls/include/dev_alt.h | 2 ++ crypto/mbedtls/source/dev_alt.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/crypto/mbedtls/include/dev_alt.h b/crypto/mbedtls/include/dev_alt.h index caed8b9eb..6059d8862 100644 --- a/crypto/mbedtls/include/dev_alt.h +++ b/crypto/mbedtls/include/dev_alt.h @@ -33,6 +33,7 @@ typedef struct cryptodev_context_s int fd; struct session_op session; struct crypt_op crypt; + struct crypt_kop cryptk; } cryptodev_context_t; @@ -43,5 +44,6 @@ void cryptodev_free(FAR cryptodev_context_t *ctx); int cryptodev_get_session(FAR cryptodev_context_t *ctx); void cryptodev_free_session(FAR cryptodev_context_t *ctx); int cryptodev_crypt(FAR cryptodev_context_t *ctx); +int cryptodev_cryptk(FAR cryptodev_context_t *ctx); #endif /* __APPS_CRYPTO_MBEDTLS_INCLUDE_DEV_ALT_H */ diff --git a/crypto/mbedtls/source/dev_alt.c b/crypto/mbedtls/source/dev_alt.c index adb2bc928..0fec4d71a 100644 --- a/crypto/mbedtls/source/dev_alt.c +++ b/crypto/mbedtls/source/dev_alt.c @@ -91,6 +91,14 @@ int cryptodev_crypt(FAR cryptodev_context_t *ctx) return ret < 0 ? -errno : ret; } +int cryptodev_cryptk(FAR cryptodev_context_t *ctx) +{ + int ret; + + ret = ioctl(ctx->fd, CIOCKEY, &ctx->cryptk); + return ret < 0 ? -errno : ret; +} + int cryptodev_clone(FAR cryptodev_context_t *dst, FAR const cryptodev_context_t *src) {
