Commit 2645deb4 authored by Davide Galassi's avatar Davide Galassi

MD5 RFC 1321 tests fix

parent b8d71398
Pipeline #55466454 passed with stages
in 1 minute and 25 seconds
......@@ -16,15 +16,6 @@ static void param_init(struct md5_param *par, int argc, char *argv[])
raw_init(par->hash, CRY_MD5_DIGEST_SIZE, argv[1]);
}
static void cry_md5(unsigned char *out, unsigned char *data, size_t len)
{
struct cry_md5_ctx ctx;
cry_md5_init(&ctx);
cry_md5_update(&ctx, data, len);
cry_md5_digest(&ctx, out);
}
static void md5_digest(int argc, char *argv[])
{
struct md5_param par;
......@@ -50,37 +41,8 @@ static void dispatch(int argc, char *argv[])
printf("Test '%s' not defined\n", test);
}
static char *input[] = {
"This file is part of CRY software.",
"CRY is free software",
};
static const char md5_hash[] = {
0x48,0x6a,0xc6,0x00,0x0e,0xf1,0x6f,0x00,
0x12,0x0d,0x02,0x46,0xeb,0x4d,0xa6,0x69
};
static void test_old(void)
{
struct cry_md5_ctx md5;
size_t len, i;
unsigned char buf[16];
cry_md5_init(&md5);
for (i = 0; i < ARLEN(input); i++) {
len = strlen(input[i]);
PRINT_ASC("input", input[i], len);
cry_md5_update(&md5, (unsigned char *)input[i], len);
}
cry_md5_digest(&md5, buf);
PRINT_HEX("md5", buf, 16);
ASSERT_EQ_BUF(buf, md5_hash, 16);
}
void md5_test(void)
{
test_old();
printf("* MD5 RFC 1321 Vectors\n");
func_test("md5_test.data", dispatch);
printf("\n");
......
......@@ -17,30 +17,30 @@ d41d8cd98f00b204e9800998ecf8427e
mbedtls_md5 Test vector RFC1321 #2
md5_digest
a
61
0cc175b9c0f1b6a831c399e269772661
mbedtls_md5 Test vector RFC1321 #3
md5_digest
abc
616263
900150983cd24fb0d6963f7d28e17f72
mbedtls_md5 Test vector RFC1321 #4
md5_digest
message digest
6d65737361676520646967657374
f96b697d7cb7938d525a2f31aaf161d0
mbedtls_md5 Test vector RFC1321 #5
md5_digest
abcdefghijklmnopqrstuvwxyz
6162636465666768696a6b6c6d6e6f707172737475767778797a
c3fcd3d76192e4007dfb496cca67e13b
mbedtls_md5 Test vector RFC1321 #6
md5_digest
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839
d174ab98d277d9f5a5611c2c9f419d9f
mbedtls_md5 Test vector RFC1321 #7
md5_digest
12345678901234567890123456789012345678901234567890123456789012345678901234567890
3132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930
57edf4a22be3c955ac49da2e2107b67a
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment