Debian Codegraph @

test/cryptounittest/test-calc-pmk.c

raw
1 /*
2 *
3 * test-calc-pmk.c
4 *
5 * Copyright (C) 2012 Carlos Alberto Lopez Perez <[email protected]>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 *
23 */
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include <stdio.h>
30 #include <string.h>
31 #include <stdlib.h>
32
33 #include "aircrack-ng/crypto/crypto.h"
34 #include "tests.h"
35
36 #define PLEN 32 //40
37 #define KLEN 14
38
39 int main(int argc, char ** argv)
40 {
41 if (argc < 1) return 1;
42
43 int error = 0;
44
45 static unsigned char input[PLEN]
46 = "\x72\xea\x7c\xf3\x62\xd0\x63\xb6\xf6\x3b\xd6\xfc\x1c\x6c\xc0\x18"
47 "\xd0\x10\x23\xd6\x86\x4e\x04\xf0\x0e\xc7\x34\xca\x66\x34\x01\xac"
48 /* "\x46\xd4\x7d\x15\x24\xa7\xaa\xb0" */;
49 static unsigned char expected[PLEN]
50 = "\x1d\x4d\xf5\x5d\xd8\xd9\x13\xf5\x54\x0d\x05\x3c\xdb\x57\x83\x53"
51 "\xd0\x6c\x0f\xb3\x50\x71\x10\xee\x48\xda\xce\x2b\x60\xf6\xd0\xd4"
52 /* "\xc2\x24\x39\x9f\xe8\x1d\x1e\x80" */;
53 static uint8_t key[KLEN]
54 = "\x6E\x9C\x7A\x91\x9F\xB8\xAE\x93\xC1\xAB\x80\x3C\x09\x00";
55 static uint8_t essid[8] = "T3st1ng";
56
57 unsigned char pmk[PLEN];
58 memcpy(&pmk, &input, PLEN);
59
60 calc_pmk(key, essid, pmk);
61 error += test(pmk, expected, PLEN, argv[0]);
62
63 calc_pmk(key, essid, pmk);
64 error += test(pmk, expected, PLEN, argv[0]);
65
66 return error;
67 }