~ubuntu-branches/ubuntu/vivid/wpasupplicant/vivid

« back to all changes in this revision

Viewing changes to wpa_supplicant/tests/test_md5.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2008-03-12 20:03:04 UTC
  • mfrom: (1.1.10 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080312200304-4331y9wj46pdd34z
Tags: 0.6.3-1
* New upstream release.
* Drop patches applied upstream:
  - debian/patches/30_wpa_gui_qt4_eventhistoryui_rework.patch
  - debian/patches/31_wpa_gui_qt4_eventhistory_always_scrollbar.patch
  - debian/patches/32_wpa_gui_qt4_eventhistory_scroll_with_events.patch
  - debian/patches/40_dbus_ssid_data.patch
* Tidy up the clean target of debian/rules. Now that the madwifi headers are
  handled differently we no longer need to do any cleanup.
* Fix formatting error in debian/ifupdown/wpa_action.8 to make lintian
  quieter.
* Add patch to fix formatting errors in manpages build from sgml source. Use
  <emphasis> tags to hightlight keywords instead of surrounding them in
  strong quotes.
  - debian/patches/41_manpage_format_fixes.patch
* wpasupplicant binary package no longer suggests pcscd, guessnet, iproute
  or wireless-tools, nor does it recommend dhcp3-client. These are not
  needed.
* Add debian/patches/10_silence_siocsiwauth_icotl_failure.patch to disable
  ioctl failure messages that occur under normal conditions.
* Cherry pick two upstream git commits concerning the dbus interface:
  - debian/patches/11_avoid_dbus_version_namespace.patch
  - debian/patches/12_fix_potential_use_after_free.patch
* Add debian/patches/42_manpage_explain_available_drivers.patch to explain
  that not all of the driver backends are available in the provided
  wpa_supplicant binary, and that the canonical list of supported driver
  backends can be retrieved from the wpa_supplicant -h (help) output.
  (Closes: #466910)
* Add debian/patches/20_wpa_gui_qt4_disable_link_prl.patch to remove
  link_prl CONFIG compile flag added by qmake-qt4 >= 4.3.4-2 to avoid excess
  linking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Test program for MD5 (test vectors from RFC 1321)
 
3
 * Copyright (c) 2006, Jouni Malinen <j@w1.fi>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License version 2 as
 
7
 * published by the Free Software Foundation.
 
8
 *
 
9
 * Alternatively, this software may be distributed under the terms of BSD
 
10
 * license.
 
11
 *
 
12
 * See README and COPYING for more details.
 
13
 */
 
14
 
 
15
#include "includes.h"
 
16
 
 
17
#include "common.h"
 
18
#include "crypto.h"
 
19
 
 
20
int main(int argc, char *argv[])
 
21
{
 
22
        struct {
 
23
                char *data;
 
24
                u8 *hash;
 
25
        } tests[] = {
 
26
                {
 
27
                        "",
 
28
                        "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04"
 
29
                        "\xe9\x80\x09\x98\xec\xf8\x42\x7e"
 
30
                },
 
31
                {
 
32
                        "a",
 
33
                        "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8"
 
34
                        "\x31\xc3\x99\xe2\x69\x77\x26\x61"
 
35
                },
 
36
                {
 
37
                        "abc",
 
38
                        "\x90\x01\x50\x98\x3c\xd2\x4f\xb0"
 
39
                        "\xd6\x96\x3f\x7d\x28\xe1\x7f\x72"
 
40
                },
 
41
                {
 
42
                        "message digest",
 
43
                        "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d"
 
44
                        "\x52\x5a\x2f\x31\xaa\xf1\x61\xd0"
 
45
                },
 
46
                {
 
47
                        "abcdefghijklmnopqrstuvwxyz",
 
48
                        "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00"
 
49
                        "\x7d\xfb\x49\x6c\xca\x67\xe1\x3b"
 
50
                },
 
51
                {
 
52
                        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
 
53
                        "0123456789",
 
54
                        "\xd1\x74\xab\x98\xd2\x77\xd9\xf5"
 
55
                        "\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f"
 
56
                },
 
57
                {
 
58
                        "12345678901234567890123456789012345678901234567890"
 
59
                        "123456789012345678901234567890",
 
60
                        "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55"
 
61
                        "\xac\x49\xda\x2e\x21\x07\xb6\x7a"
 
62
                }
 
63
        };
 
64
        unsigned int i;
 
65
        u8 hash[16];
 
66
        const u8 *addr[2];
 
67
        size_t len[2];
 
68
        int errors = 0;
 
69
 
 
70
        for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
 
71
                printf("MD5 test case %d:", i);
 
72
 
 
73
                addr[0] = tests[i].data;
 
74
                len[0] = strlen(tests[i].data);
 
75
                md5_vector(1, addr, len, hash);
 
76
                if (memcmp(hash, tests[i].hash, 16) != 0) {
 
77
                        printf(" FAIL");
 
78
                        errors++;
 
79
                } else
 
80
                        printf(" OK");
 
81
 
 
82
                if (len[0]) {
 
83
                        addr[0] = tests[i].data;
 
84
                        len[0] = strlen(tests[i].data);
 
85
                        addr[1] = tests[i].data + 1;
 
86
                        len[1] = strlen(tests[i].data) - 1;
 
87
                        md5_vector(1, addr, len, hash);
 
88
                        if (memcmp(hash, tests[i].hash, 16) != 0) {
 
89
                                printf(" FAIL");
 
90
                                errors++;
 
91
                        } else
 
92
                                printf(" OK");
 
93
                }
 
94
 
 
95
                printf("\n");
 
96
        }
 
97
 
 
98
        return errors;
 
99
}