1 /* 2 * Test program for EAP-SIM PRF 3 * Copyright (c) 2004-2006, Jouni Malinen <j (at) 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 "eap_sim_common.c" 16 17 18 static int test_eap_sim_prf(void) 19 { 20 /* http://csrc.nist.gov/encryption/dss/Examples-1024bit.pdf */ 21 u8 xkey[] = { 22 0xbd, 0x02, 0x9b, 0xbe, 0x7f, 0x51, 0x96, 0x0b, 23 0xcf, 0x9e, 0xdb, 0x2b, 0x61, 0xf0, 0x6f, 0x0f, 24 0xeb, 0x5a, 0x38, 0xb6 25 }; 26 u8 w[] = { 27 0x20, 0x70, 0xb3, 0x22, 0x3d, 0xba, 0x37, 0x2f, 28 0xde, 0x1c, 0x0f, 0xfc, 0x7b, 0x2e, 0x3b, 0x49, 29 0x8b, 0x26, 0x06, 0x14, 0x3c, 0x6c, 0x18, 0xba, 30 0xcb, 0x0f, 0x6c, 0x55, 0xba, 0xbb, 0x13, 0x78, 31 0x8e, 0x20, 0xd7, 0x37, 0xa3, 0x27, 0x51, 0x16 32 }; 33 u8 buf[40]; 34 35 printf("Testing EAP-SIM PRF (FIPS 186-2 + change notice 1)\n"); 36 eap_sim_prf(xkey, buf, sizeof(buf)); 37 if (memcmp(w, buf, sizeof(w) != 0)) { 38 printf("eap_sim_prf failed\n"); 39 return 1; 40 } 41 42 return 0; 43 } 44 45 46 int main(int argc, char *argv[]) 47 { 48 int errors = 0; 49 50 errors += test_eap_sim_prf(); 51 52 return errors; 53 } 54