Skip to content

Commit 8628cc9

Browse files
ThePassionatexiaoxiang781216
authored andcommitted
crypto/ripemd160: export ripemd160 algorithm via /dev/crypto
Signed-off-by: makejian <[email protected]>
1 parent 419a8ab commit 8628cc9

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

crypto/cryptodev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ static int cryptof_ioctl(FAR struct file *filep,
248248
case CRYPTO_SHA2_512_HMAC:
249249
case CRYPTO_AES_128_GMAC:
250250
case CRYPTO_MD5:
251+
case CRYPTO_RIPEMD160:
251252
case CRYPTO_SHA1:
252253
case CRYPTO_SHA2_224:
253254
case CRYPTO_SHA2_256:

crypto/cryptosoft.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,9 @@ int swcr_newsession(FAR uint32_t *sid, FAR struct cryptoini *cri)
776776
case CRYPTO_MD5:
777777
axf = &auth_hash_md5;
778778
goto auth3common;
779+
case CRYPTO_RIPEMD160:
780+
axf = &auth_hash_ripemd_160;
781+
goto auth3common;
779782
case CRYPTO_SHA1:
780783
axf = &auth_hash_sha1;
781784
goto auth3common;
@@ -941,6 +944,7 @@ int swcr_freesession(uint64_t tid)
941944
case CRYPTO_AES_256_GMAC:
942945
case CRYPTO_CHACHA20_POLY1305_MAC:
943946
case CRYPTO_MD5:
947+
case CRYPTO_RIPEMD160:
944948
case CRYPTO_SHA1:
945949
case CRYPTO_SHA2_224:
946950
case CRYPTO_SHA2_256:
@@ -1073,6 +1077,7 @@ int swcr_process(struct cryptop *crp)
10731077
break;
10741078

10751079
case CRYPTO_MD5:
1080+
case CRYPTO_RIPEMD160:
10761081
case CRYPTO_SHA1:
10771082
case CRYPTO_SHA2_224:
10781083
case CRYPTO_SHA2_256:
@@ -1211,6 +1216,7 @@ void swcr_init(void)
12111216
algs[CRYPTO_CHACHA20_POLY1305] = CRYPTO_ALG_FLAG_SUPPORTED;
12121217
algs[CRYPTO_CHACHA20_POLY1305_MAC] = CRYPTO_ALG_FLAG_SUPPORTED;
12131218
algs[CRYPTO_MD5] = CRYPTO_ALG_FLAG_SUPPORTED;
1219+
algs[CRYPTO_RIPEMD160] = CRYPTO_ALG_FLAG_SUPPORTED;
12141220
algs[CRYPTO_SHA1] = CRYPTO_ALG_FLAG_SUPPORTED;
12151221
algs[CRYPTO_SHA2_224] = CRYPTO_ALG_FLAG_SUPPORTED;
12161222
algs[CRYPTO_SHA2_256] = CRYPTO_ALG_FLAG_SUPPORTED;

crypto/xform.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,15 @@ const struct auth_hash auth_hash_md5 =
389389
(void (*) (FAR uint8_t *, FAR void *)) md5final
390390
};
391391

392+
const struct auth_hash auth_hash_ripemd_160 =
393+
{
394+
CRYPTO_RIPEMD160, "RIPEMD160",
395+
0, 20, 20, sizeof(RMD160_CTX), HMAC_RIPEMD160_BLOCK_LEN,
396+
(void (*) (FAR void *)) rmd160init, NULL, NULL,
397+
rmd160update_int,
398+
(void (*) (FAR uint8_t *, FAR void *)) rmd160final
399+
};
400+
392401
const struct auth_hash auth_hash_sha1 =
393402
{
394403
CRYPTO_SHA1, "SHA1",

include/crypto/cryptodev.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@
117117
#define CRYPTO_CHACHA20_POLY1305 24
118118
#define CRYPTO_CHACHA20_POLY1305_MAC 25
119119
#define CRYPTO_MD5 26
120-
#define CRYPTO_SHA1 27
121-
#define CRYPTO_SHA2_224 28
122-
#define CRYPTO_SHA2_256 29
123-
#define CRYPTO_SHA2_384 30
124-
#define CRYPTO_SHA2_512 31
125-
#define CRYPTO_ESN 32 /* Support for Extended Sequence Numbers */
126-
#define CRYPTO_ALGORITHM_MAX 32 /* Keep updated */
120+
#define CRYPTO_RIPEMD160 27
121+
#define CRYPTO_SHA1 28
122+
#define CRYPTO_SHA2_224 29
123+
#define CRYPTO_SHA2_256 30
124+
#define CRYPTO_SHA2_384 31
125+
#define CRYPTO_SHA2_512 32
126+
#define CRYPTO_ESN 33 /* Support for Extended Sequence Numbers */
127+
#define CRYPTO_ALGORITHM_MAX 33 /* Keep updated */
127128

128129
/* Algorithm flags */
129130

include/crypto/xform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ extern const struct auth_hash auth_hash_gmac_aes_192;
121121
extern const struct auth_hash auth_hash_gmac_aes_256;
122122
extern const struct auth_hash auth_hash_chacha20_poly1305;
123123
extern const struct auth_hash auth_hash_md5;
124+
extern const struct auth_hash auth_hash_ripemd_160;
124125
extern const struct auth_hash auth_hash_sha1;
125126
extern const struct auth_hash auth_hash_sha2_224;
126127
extern const struct auth_hash auth_hash_sha2_256;

0 commit comments

Comments
 (0)