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.git
The following commit(s) were added to refs/heads/master by this push:
new fb428899dc9 crypto: Support SHA2_224_HMAC
fb428899dc9 is described below
commit fb428899dc944e577acb4b44232fe6f312ebf5ed
Author: Peter Barada <[email protected]>
AuthorDate: Fri Jul 3 17:45:04 2026 -0400
crypto: Support SHA2_224_HMAC
Since already have support for SHA2-224, extend cryptodev/cryptosoft
to support HMAC version of SHA2-224.
Signed-off-by: Peter Barada <[email protected]>
---
Documentation/components/crypto.rst | 1 +
crypto/cryptodev.c | 1 +
crypto/cryptosoft.c | 7 +++++++
crypto/xform.c | 9 +++++++++
include/crypto/cryptodev.h | 4 +++-
include/crypto/xform.h | 1 +
6 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/Documentation/components/crypto.rst
b/Documentation/components/crypto.rst
index fcc4bb9b1ca..aac0fe42fc6 100644
--- a/Documentation/components/crypto.rst
+++ b/Documentation/components/crypto.rst
@@ -62,6 +62,7 @@ Authentication and Hashing Algorithms
- CRYPTO_SHA1_HMAC
- SHA-2 HMAC:
+ - CRYPTO_SHA2_224_HMAC (224-bit)
- CRYPTO_SHA2_256_HMAC (256-bit)
- CRYPTO_SHA2_384_HMAC (384-bit)
- CRYPTO_SHA2_512_HMAC (512-bit)
diff --git a/crypto/cryptodev.c b/crypto/cryptodev.c
index b4d4ec5f5dd..fa165165f4c 100644
--- a/crypto/cryptodev.c
+++ b/crypto/cryptodev.c
@@ -250,6 +250,7 @@ static int cryptof_ioctl(FAR struct file *filep,
case CRYPTO_MD5_HMAC:
case CRYPTO_SHA1_HMAC:
case CRYPTO_RIPEMD160_HMAC:
+ case CRYPTO_SHA2_224_HMAC:
case CRYPTO_SHA2_256_HMAC:
case CRYPTO_SHA2_384_HMAC:
case CRYPTO_SHA2_512_HMAC:
diff --git a/crypto/cryptosoft.c b/crypto/cryptosoft.c
index 7a22b6ce80f..9dcbce8b503 100644
--- a/crypto/cryptosoft.c
+++ b/crypto/cryptosoft.c
@@ -1153,6 +1153,7 @@ int swcr_authcompute(FAR struct cryptop *crp,
case CRYPTO_MD5_HMAC:
case CRYPTO_SHA1_HMAC:
case CRYPTO_RIPEMD160_HMAC:
+ case CRYPTO_SHA2_224_HMAC:
case CRYPTO_SHA2_256_HMAC:
case CRYPTO_SHA2_384_HMAC:
case CRYPTO_SHA2_512_HMAC:
@@ -1665,6 +1666,9 @@ int swcr_newsession(FAR uint32_t *sid, FAR struct
cryptoini *cri)
case CRYPTO_RIPEMD160_HMAC:
axf = &auth_hash_hmac_ripemd_160_96;
goto authcommon;
+ case CRYPTO_SHA2_224_HMAC:
+ axf = &auth_hash_hmac_sha2_224_114;
+ goto authcommon;
case CRYPTO_SHA2_256_HMAC:
case CRYPTO_PBKDF2_HMAC_SHA256:
axf = &auth_hash_hmac_sha2_256_128;
@@ -1894,6 +1898,7 @@ int swcr_freesession(uint64_t tid)
case CRYPTO_MD5_HMAC:
case CRYPTO_SHA1_HMAC:
case CRYPTO_RIPEMD160_HMAC:
+ case CRYPTO_SHA2_224_HMAC:
case CRYPTO_SHA2_256_HMAC:
case CRYPTO_SHA2_384_HMAC:
case CRYPTO_SHA2_512_HMAC:
@@ -2044,6 +2049,7 @@ int swcr_process(struct cryptop *crp)
case CRYPTO_MD5_HMAC:
case CRYPTO_SHA1_HMAC:
case CRYPTO_RIPEMD160_HMAC:
+ case CRYPTO_SHA2_224_HMAC:
case CRYPTO_SHA2_256_HMAC:
case CRYPTO_SHA2_384_HMAC:
case CRYPTO_SHA2_512_HMAC:
@@ -2409,6 +2415,7 @@ void swcr_init(void)
algs[CRYPTO_AES_GCM_16] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_AES_GMAC] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_NULL] = CRYPTO_ALG_FLAG_SUPPORTED;
+ algs[CRYPTO_SHA2_224_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_SHA2_256_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_SHA2_384_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_SHA2_512_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED;
diff --git a/crypto/xform.c b/crypto/xform.c
index b18982d4f4c..cc63cd0562b 100644
--- a/crypto/xform.c
+++ b/crypto/xform.c
@@ -357,6 +357,15 @@ const struct auth_hash auth_hash_hmac_ripemd_160_96 =
(void (*)(FAR uint8_t *, FAR void *)) rmd160final
};
+const struct auth_hash auth_hash_hmac_sha2_224_114 =
+{
+ CRYPTO_SHA2_256_HMAC, "HMAC-SHA2-224",
+ HMAC_SHA2_224_BLOCK_LEN, 28, 14, sizeof(SHA2_CTX), HMAC_SHA2_224_BLOCK_LEN,
+ (void (*)(FAR void *)) sha224init, NULL, NULL,
+ sha224update_int,
+ (void (*)(FAR uint8_t *, FAR void *)) sha224final
+};
+
const struct auth_hash auth_hash_hmac_sha2_256_128 =
{
CRYPTO_SHA2_256_HMAC, "HMAC-SHA2-256",
diff --git a/include/crypto/cryptodev.h b/include/crypto/cryptodev.h
index f58f1b38e43..ad5f62afb53 100644
--- a/include/crypto/cryptodev.h
+++ b/include/crypto/cryptodev.h
@@ -73,6 +73,7 @@
#define HMAC_MD5_BLOCK_LEN 64
#define HMAC_SHA1_BLOCK_LEN 64
#define HMAC_RIPEMD160_BLOCK_LEN 64
+#define HMAC_SHA2_224_BLOCK_LEN 64
#define HMAC_SHA2_256_BLOCK_LEN 64
#define HMAC_SHA2_384_BLOCK_LEN 128
#define HMAC_SHA2_512_BLOCK_LEN 128
@@ -138,7 +139,8 @@
#define CRYPTO_PBKDF2_HMAC_SHA1 38
#define CRYPTO_PBKDF2_HMAC_SHA256 39
#define CRYPTO_ESN 40 /* Support for Extended Sequence Numbers */
-#define CRYPTO_ALGORITHM_MAX 40 /* Keep updated */
+#define CRYPTO_SHA2_224_HMAC 41
+#define CRYPTO_ALGORITHM_MAX 41 /* Keep updated */
/* Algorithm flags */
diff --git a/include/crypto/xform.h b/include/crypto/xform.h
index f168aa281de..6f3bc42ec64 100644
--- a/include/crypto/xform.h
+++ b/include/crypto/xform.h
@@ -118,6 +118,7 @@ extern const struct enc_xform enc_xform_null;
extern const struct auth_hash auth_hash_hmac_md5_96;
extern const struct auth_hash auth_hash_hmac_sha1_96;
extern const struct auth_hash auth_hash_hmac_ripemd_160_96;
+extern const struct auth_hash auth_hash_hmac_sha2_224_114;
extern const struct auth_hash auth_hash_hmac_sha2_256_128;
extern const struct auth_hash auth_hash_hmac_sha2_384_192;
extern const struct auth_hash auth_hash_hmac_sha2_512_256;