1/* BEGIN_HEADER */ 2#include "mbedtls/md2.h" 3#include "mbedtls/md4.h" 4#include "mbedtls/md5.h" 5#include "mbedtls/ripemd160.h" 6/* END_HEADER */ 7 8/* BEGIN_CASE depends_on:MBEDTLS_MD2_C */ 9void md2_text(char *text_src_string, data_t *hash) 10{ 11 int ret; 12 unsigned char src_str[100]; 13 unsigned char output[16]; 14 15 memset(src_str, 0x00, sizeof(src_str)); 16 memset(output, 0x00, sizeof(output)); 17 18 strncpy((char *) src_str, text_src_string, sizeof(src_str) - 1); 19 20 ret = mbedtls_md2_ret(src_str, strlen((char *) src_str), output); 21 TEST_ASSERT(ret == 0); 22 23 TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, 24 sizeof(output), hash->len) == 0); 25} 26/* END_CASE */ 27 28/* BEGIN_CASE depends_on:MBEDTLS_MD4_C */ 29void md4_text(char *text_src_string, data_t *hash) 30{ 31 int ret; 32 unsigned char src_str[100]; 33 unsigned char output[16]; 34 35 memset(src_str, 0x00, sizeof(src_str)); 36 memset(output, 0x00, sizeof(output)); 37 38 strncpy((char *) src_str, text_src_string, sizeof(src_str) - 1); 39 40 ret = mbedtls_md4_ret(src_str, strlen((char *) src_str), output); 41 TEST_ASSERT(ret == 0); 42 43 TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, 44 sizeof(output), hash->len) == 0); 45} 46/* END_CASE */ 47 48/* BEGIN_CASE depends_on:MBEDTLS_MD5_C */ 49void md5_text(char *text_src_string, data_t *hash) 50{ 51 int ret; 52 unsigned char src_str[100]; 53 unsigned char output[16]; 54 55 memset(src_str, 0x00, sizeof(src_str)); 56 memset(output, 0x00, sizeof(output)); 57 58 strncpy((char *) src_str, text_src_string, sizeof(src_str) - 1); 59 60 ret = mbedtls_md5_ret(src_str, strlen((char *) src_str), output); 61 TEST_ASSERT(ret == 0); 62 63 TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, 64 sizeof(output), hash->len) == 0); 65} 66/* END_CASE */ 67 68/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */ 69void ripemd160_text(char *text_src_string, data_t *hash) 70{ 71 int ret; 72 unsigned char src_str[100]; 73 unsigned char output[20]; 74 75 memset(src_str, 0x00, sizeof(src_str)); 76 memset(output, 0x00, sizeof(output)); 77 78 strncpy((char *) src_str, text_src_string, sizeof(src_str) - 1); 79 80 ret = mbedtls_ripemd160_ret(src_str, strlen((char *) src_str), output); 81 TEST_ASSERT(ret == 0); 82 83 TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, 84 sizeof(output), hash->len) == 0); 85} 86/* END_CASE */ 87 88/* BEGIN_CASE depends_on:MBEDTLS_MD2_C:MBEDTLS_SELF_TEST */ 89void md2_selftest() 90{ 91 TEST_ASSERT(mbedtls_md2_self_test(1) == 0); 92} 93/* END_CASE */ 94 95/* BEGIN_CASE depends_on:MBEDTLS_MD4_C:MBEDTLS_SELF_TEST */ 96void md4_selftest() 97{ 98 TEST_ASSERT(mbedtls_md4_self_test(1) == 0); 99} 100/* END_CASE */ 101 102/* BEGIN_CASE depends_on:MBEDTLS_MD5_C:MBEDTLS_SELF_TEST */ 103void md5_selftest() 104{ 105 TEST_ASSERT(mbedtls_md5_self_test(1) == 0); 106} 107/* END_CASE */ 108 109/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C:MBEDTLS_SELF_TEST */ 110void ripemd160_selftest() 111{ 112 TEST_ASSERT(mbedtls_ripemd160_self_test(1) == 0); 113} 114/* END_CASE */ 115