test_eap_sim_common.c revision 189251
1189251Ssam/*
2189251Ssam * Test program for EAP-SIM PRF
3189251Ssam * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
4189251Ssam *
5189251Ssam * This program is free software; you can redistribute it and/or modify
6189251Ssam * it under the terms of the GNU General Public License version 2 as
7189251Ssam * published by the Free Software Foundation.
8189251Ssam *
9189251Ssam * Alternatively, this software may be distributed under the terms of BSD
10189251Ssam * license.
11189251Ssam *
12189251Ssam * See README and COPYING for more details.
13189251Ssam */
14189251Ssam
15189251Ssam#include "eap_sim_common.c"
16189251Ssam
17189251Ssam
18189251Ssamstatic int test_eap_sim_prf(void)
19189251Ssam{
20189251Ssam	/* http://csrc.nist.gov/encryption/dss/Examples-1024bit.pdf */
21189251Ssam	u8 xkey[] = {
22189251Ssam		0xbd, 0x02, 0x9b, 0xbe, 0x7f, 0x51, 0x96, 0x0b,
23189251Ssam		0xcf, 0x9e, 0xdb, 0x2b, 0x61, 0xf0, 0x6f, 0x0f,
24189251Ssam		0xeb, 0x5a, 0x38, 0xb6
25189251Ssam	};
26189251Ssam	u8 w[] = {
27189251Ssam		0x20, 0x70, 0xb3, 0x22, 0x3d, 0xba, 0x37, 0x2f,
28189251Ssam		0xde, 0x1c, 0x0f, 0xfc, 0x7b, 0x2e, 0x3b, 0x49,
29189251Ssam		0x8b, 0x26, 0x06, 0x14, 0x3c, 0x6c, 0x18, 0xba,
30189251Ssam		0xcb, 0x0f, 0x6c, 0x55, 0xba, 0xbb, 0x13, 0x78,
31189251Ssam		0x8e, 0x20, 0xd7, 0x37, 0xa3, 0x27, 0x51, 0x16
32189251Ssam	};
33189251Ssam	u8 buf[40];
34189251Ssam
35189251Ssam	printf("Testing EAP-SIM PRF (FIPS 186-2 + change notice 1)\n");
36189251Ssam	eap_sim_prf(xkey, buf, sizeof(buf));
37189251Ssam	if (memcmp(w, buf, sizeof(w) != 0)) {
38189251Ssam		printf("eap_sim_prf failed\n");
39189251Ssam		return 1;
40189251Ssam	}
41189251Ssam
42189251Ssam	return 0;
43189251Ssam}
44189251Ssam
45189251Ssam
46189251Ssamint main(int argc, char *argv[])
47189251Ssam{
48189251Ssam	int errors = 0;
49189251Ssam
50189251Ssam	errors += test_eap_sim_prf();
51189251Ssam
52189251Ssam	return errors;
53189251Ssam}
54