blob: df94d16e144548924e6bd65525785c23a67baaa8 [file] [log] [blame]
Tom Rini0344c602024-10-08 13:56:50 -06001/* BEGIN_HEADER */
2#include "mbedtls/md5.h"
3#include "mbedtls/ripemd160.h"
4/* END_HEADER */
5
6/* BEGIN_CASE depends_on:MBEDTLS_MD5_C */
7void md5_text(char *text_src_string, data_t *hash)
8{
9 int ret;
10 unsigned char src_str[100];
11 unsigned char output[16];
12
13 memset(src_str, 0x00, sizeof(src_str));
14 memset(output, 0x00, sizeof(output));
15
16 strncpy((char *) src_str, text_src_string, sizeof(src_str) - 1);
17
18 ret = mbedtls_md5(src_str, strlen((char *) src_str), output);
19 TEST_ASSERT(ret == 0);
20
21 TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
22 sizeof(output), hash->len) == 0);
23}
24/* END_CASE */
25
26/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */
27void ripemd160_text(char *text_src_string, data_t *hash)
28{
29 int ret;
30 unsigned char src_str[100];
31 unsigned char output[20];
32
33 memset(src_str, 0x00, sizeof(src_str));
34 memset(output, 0x00, sizeof(output));
35
36 strncpy((char *) src_str, text_src_string, sizeof(src_str) - 1);
37
38 ret = mbedtls_ripemd160(src_str, strlen((char *) src_str), output);
39 TEST_ASSERT(ret == 0);
40
41 TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x,
42 sizeof(output), hash->len) == 0);
43}
44/* END_CASE */
45
46/* BEGIN_CASE depends_on:MBEDTLS_MD5_C:MBEDTLS_SELF_TEST */
47void md5_selftest()
48{
49 TEST_ASSERT(mbedtls_md5_self_test(1) == 0);
50}
51/* END_CASE */
52
53/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C:MBEDTLS_SELF_TEST */
54void ripemd160_selftest()
55{
56 TEST_ASSERT(mbedtls_ripemd160_self_test(1) == 0);
57}
58/* END_CASE */