diff options
Diffstat (limited to 'test/testmd5.c')
-rw-r--r-- | test/testmd5.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/testmd5.c b/test/testmd5.c index 5189993b410c..4e13da2371a8 100644 --- a/test/testmd5.c +++ b/test/testmd5.c @@ -66,6 +66,30 @@ static void test_md5sum(abts_case *tc, void *data) (memcmp(digest, sum, APR_MD5_DIGESTSIZE) == 0)); } +static void test_md5sum_unaligned(abts_case *tc, void *data) +{ + apr_md5_ctx_t context; + const char *string = "abcdefghijklmnopqrstuvwxyz01234" + "abcdefghijklmnopqrstuvwxyz01234" + "abcdefghijklmnopqrstuvwxyz01234" + "abcdefghijklmnopqrstuvwxyz01234_"; + const char *sum = + "\x93\x17\x22\x78\xee\x30\x82\xb3\xeb\x95\x33\xec\xea\x78\xb7\x89"; + unsigned char digest[APR_MD5_DIGESTSIZE]; + unsigned int i; + + ABTS_ASSERT(tc, "apr_md5_init", (apr_md5_init(&context) == 0)); + for (i = 0; i < 10; i++) { + ABTS_ASSERT(tc, "apr_md5_update", + (apr_md5_update(&context, string, strlen(string)) == 0)); + string++; + } + ABTS_ASSERT(tc, "apr_md5_final", (apr_md5_final(digest, &context) + == 0)); + ABTS_ASSERT(tc, "check for correct md5 digest of unaligned data", + (memcmp(digest, sum, APR_MD5_DIGESTSIZE) == 0)); +} + abts_suite *testmd5(abts_suite *suite) { suite = ADD_SUITE(suite); @@ -73,6 +97,7 @@ abts_suite *testmd5(abts_suite *suite) for (count=0; count < num_sums; count++) { abts_run_test(suite, test_md5sum, NULL); } + abts_run_test(suite, test_md5sum_unaligned, NULL); return suite; } |