crypto/ripemd160: export ripemd160 algorithm via /dev/crypto

Signed-off-by: makejian <makejian@xiaomi.com>
This commit is contained in:
makejian 2023-10-25 16:00:13 +08:00 committed by Xiang Xiao
parent 419a8ab050
commit 8628cc9c0e
5 changed files with 25 additions and 7 deletions

View File

@ -248,6 +248,7 @@ static int cryptof_ioctl(FAR struct file *filep,
case CRYPTO_SHA2_512_HMAC:
case CRYPTO_AES_128_GMAC:
case CRYPTO_MD5:
case CRYPTO_RIPEMD160:
case CRYPTO_SHA1:
case CRYPTO_SHA2_224:
case CRYPTO_SHA2_256:

View File

@ -776,6 +776,9 @@ int swcr_newsession(FAR uint32_t *sid, FAR struct cryptoini *cri)
case CRYPTO_MD5:
axf = &auth_hash_md5;
goto auth3common;
case CRYPTO_RIPEMD160:
axf = &auth_hash_ripemd_160;
goto auth3common;
case CRYPTO_SHA1:
axf = &auth_hash_sha1;
goto auth3common;
@ -941,6 +944,7 @@ int swcr_freesession(uint64_t tid)
case CRYPTO_AES_256_GMAC:
case CRYPTO_CHACHA20_POLY1305_MAC:
case CRYPTO_MD5:
case CRYPTO_RIPEMD160:
case CRYPTO_SHA1:
case CRYPTO_SHA2_224:
case CRYPTO_SHA2_256:
@ -1073,6 +1077,7 @@ int swcr_process(struct cryptop *crp)
break;
case CRYPTO_MD5:
case CRYPTO_RIPEMD160:
case CRYPTO_SHA1:
case CRYPTO_SHA2_224:
case CRYPTO_SHA2_256:
@ -1211,6 +1216,7 @@ void swcr_init(void)
algs[CRYPTO_CHACHA20_POLY1305] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_CHACHA20_POLY1305_MAC] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_MD5] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_RIPEMD160] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_SHA1] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_SHA2_224] = CRYPTO_ALG_FLAG_SUPPORTED;
algs[CRYPTO_SHA2_256] = CRYPTO_ALG_FLAG_SUPPORTED;

View File

@ -389,6 +389,15 @@ const struct auth_hash auth_hash_md5 =
(void (*) (FAR uint8_t *, FAR void *)) md5final
};
const struct auth_hash auth_hash_ripemd_160 =
{
CRYPTO_RIPEMD160, "RIPEMD160",
0, 20, 20, sizeof(RMD160_CTX), HMAC_RIPEMD160_BLOCK_LEN,
(void (*) (FAR void *)) rmd160init, NULL, NULL,
rmd160update_int,
(void (*) (FAR uint8_t *, FAR void *)) rmd160final
};
const struct auth_hash auth_hash_sha1 =
{
CRYPTO_SHA1, "SHA1",

View File

@ -117,13 +117,14 @@
#define CRYPTO_CHACHA20_POLY1305 24
#define CRYPTO_CHACHA20_POLY1305_MAC 25
#define CRYPTO_MD5 26
#define CRYPTO_SHA1 27
#define CRYPTO_SHA2_224 28
#define CRYPTO_SHA2_256 29
#define CRYPTO_SHA2_384 30
#define CRYPTO_SHA2_512 31
#define CRYPTO_ESN 32 /* Support for Extended Sequence Numbers */
#define CRYPTO_ALGORITHM_MAX 32 /* Keep updated */
#define CRYPTO_RIPEMD160 27
#define CRYPTO_SHA1 28
#define CRYPTO_SHA2_224 29
#define CRYPTO_SHA2_256 30
#define CRYPTO_SHA2_384 31
#define CRYPTO_SHA2_512 32
#define CRYPTO_ESN 33 /* Support for Extended Sequence Numbers */
#define CRYPTO_ALGORITHM_MAX 33 /* Keep updated */
/* Algorithm flags */

View File

@ -121,6 +121,7 @@ extern const struct auth_hash auth_hash_gmac_aes_192;
extern const struct auth_hash auth_hash_gmac_aes_256;
extern const struct auth_hash auth_hash_chacha20_poly1305;
extern const struct auth_hash auth_hash_md5;
extern const struct auth_hash auth_hash_ripemd_160;
extern const struct auth_hash auth_hash_sha1;
extern const struct auth_hash auth_hash_sha2_224;
extern const struct auth_hash auth_hash_sha2_256;