mirror of
https://github.com/apache/nuttx.git
synced 2026-05-13 10:38:40 +08:00
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 <makejian@xiaomi.com>
This commit is contained in:
+6
-10
@@ -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;
|
||||
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
Reference in New Issue
Block a user