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 <peter.barada@gmail.com>
This commit is contained in:
Peter Barada 2026-07-03 17:45:04 -04:00 committed by Xiang Xiao
parent 70fd28f73b
commit fb428899dc
6 changed files with 22 additions and 1 deletions

View file

@ -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:

View file

@ -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;

View file

@ -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",