2 * test program for uuid library
4 * written by nathan wagner and placed in the public domain
15 static int strbytes(char *s, unsigned char *d) {
20 if (*s == 0) return 0;
23 if (*s == '-' || *s == ':') s++;
25 if (sscanf(s, "%02x", &byte) != 1) {
34 void ufmt(pd_uuid_t *uuid, char *s) {
37 s += sprintf(s, "%02x", uuid->data[i]);
41 s += sprintf(s, "%02x", uuid->data[i]);
45 s += sprintf(s, "%02x", uuid->data[i]);
49 s += sprintf(s, "%02x", uuid->data[i]);
53 s += sprintf(s, "%02x", uuid->data[i]);
57 int str_ok(pd_uuid_t *uuid, char *s, char *name) {
60 is_string(s, fmt, name);
64 int main(int ac, char *av[]) {
65 unsigned char tmp[16];
71 unsigned char hash[16];
74 { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04,
75 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } },
77 {0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8,
78 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } },
80 { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0,
81 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } },
83 { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d,
84 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } },
85 { "abcdefghijklmnopqrstuvwxyz",
86 { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00,
87 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } },
88 { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
89 { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5,
90 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } },
91 { "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
92 { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55,
93 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } },
99 for (i = 0; tests[i].msg != NULL; i++) {
101 md5_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
103 ok(memcmp(tmp, tests[i].hash, 16) == 0, "md5 %s", tests[i].msg);