This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5b52a32f5a024ff91fad33cf65f8c4e8a9708eba Author: makejian <[email protected]> AuthorDate: Fri May 30 15:07:32 2025 +0800 crypto/crypto.c: Determine the order of obtained crypto drivers After adding the cross-core crypto driver, there are now three encryption modes: 1. Hardware driver in local core 2. Crypto driver in remote core 3. Software encryption in local core This prioritizes local hardware driver first, then remote driver (typically hardware), and finally local software encryption as a fallback. Signed-off-by: makejian <[email protected]> --- crypto/crypto.c | 16 ++++++---------- include/crypto/cryptodev.h | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crypto/crypto.c b/crypto/crypto.c index 8766581b931..e463f3204cb 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -106,22 +106,18 @@ int crypto_newsession(FAR uint64_t *sid, if (cpc->cc_flags & CRYPTOCAP_F_SOFTWARE) { - /* First round of search, ignore - * software drivers. - */ + /* Thread round of search only for software */ - if (turn == 0) + if (turn != 2) { continue; } } - else + else if (cpc->cc_flags & CRYPTOCAP_F_REMOTE) { - /* !CRYPTOCAP_F_SOFTWARE - * Second round of search, only software. - */ + /* Second round of search only for remote */ - if (turn == 1) + if (turn != 1) { continue; } @@ -189,7 +185,7 @@ int crypto_newsession(FAR uint64_t *sid, /* If we only want hardware drivers, don't do second pass. */ } - while (turn <= 2 && hard == 0); + while (turn < 2 || (turn == 2 && !hard)); hid = hid2; diff --git a/include/crypto/cryptodev.h b/include/crypto/cryptodev.h index aaec0790dbd..c26810f3d6a 100644 --- a/include/crypto/cryptodev.h +++ b/include/crypto/cryptodev.h @@ -352,6 +352,7 @@ struct cryptocap #define CRYPTOCAP_F_SOFTWARE 0x02 #define CRYPTOCAP_F_ENCRYPT_MAC 0x04 /* Can do encrypt-then-MAC (IPsec) */ #define CRYPTOCAP_F_MAC_ENCRYPT 0x08 /* Can do MAC-then-encrypt (TLS) */ +#define CRYPTOCAP_F_REMOTE 0x10 /* Remote core driver */ CODE int (*cc_newsession)(FAR uint32_t *, FAR struct cryptoini *); CODE int (*cc_process)(FAR struct cryptop *);
