md5-compat-test.m4 1.3 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "md5-compat.h"

BEGIN_TEST

MD5_CTX ctx;
unsigned char digest[MD5_DIGEST_SIZE];

MD5Init(&ctx);
MD5Final(digest, &ctx);
if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("D41D8CD98F00B204 E9800998ECF8427E")))
  FAIL;

MD5Init(&ctx);
MD5Update(&ctx, "a", 1);
MD5Final(digest, &ctx);

if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("0CC175B9C0F1B6A8 31C399E269772661")))
  FAIL;

MD5Init(&ctx);
MD5Update(&ctx, "abc", 3);
MD5Final(digest, &ctx);

if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("900150983cd24fb0 D6963F7D28E17F72")))
  FAIL;

MD5Init(&ctx);
MD5Update(&ctx, "message digest", 14);
MD5Final(digest, &ctx);

if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("F96B697D7CB7938D 525A2F31AAF161D0")))
  FAIL;

MD5Init(&ctx);
MD5Update(&ctx, "abcdefghijklmnopqrstuvwxyz", 26);
MD5Final(digest, &ctx);

if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("C3FCD3D76192E400 7DFB496CCA67E13B")))
  FAIL;

MD5Init(&ctx);
MD5Update(&ctx, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62);
MD5Final(digest, &ctx);

if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("D174AB98D277D9F5 A5611C2C9F419D9F")))
  FAIL;

MD5Init(&ctx);
MD5Update(&ctx, "1234567890123456789012345678901234567890"
                "1234567890123456789012345678901234567890",
          80);
MD5Final(digest, &ctx);

if (!MEMEQ(MD5_DIGEST_SIZE, digest, H("57EDF4A22BE3C955 AC49DA2E2107B67A")))
  FAIL;