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