test_eap_sim_common.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Test program for EAP-SIM PRF
  3. * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #include "eap_common/eap_sim_common.c"
  9. static int test_eap_sim_prf(void)
  10. {
  11. /* http://csrc.nist.gov/encryption/dss/Examples-1024bit.pdf */
  12. u8 xkey[] = {
  13. 0xbd, 0x02, 0x9b, 0xbe, 0x7f, 0x51, 0x96, 0x0b,
  14. 0xcf, 0x9e, 0xdb, 0x2b, 0x61, 0xf0, 0x6f, 0x0f,
  15. 0xeb, 0x5a, 0x38, 0xb6
  16. };
  17. u8 w[] = {
  18. 0x20, 0x70, 0xb3, 0x22, 0x3d, 0xba, 0x37, 0x2f,
  19. 0xde, 0x1c, 0x0f, 0xfc, 0x7b, 0x2e, 0x3b, 0x49,
  20. 0x8b, 0x26, 0x06, 0x14, 0x3c, 0x6c, 0x18, 0xba,
  21. 0xcb, 0x0f, 0x6c, 0x55, 0xba, 0xbb, 0x13, 0x78,
  22. 0x8e, 0x20, 0xd7, 0x37, 0xa3, 0x27, 0x51, 0x16
  23. };
  24. u8 buf[40];
  25. printf("Testing EAP-SIM PRF (FIPS 186-2 + change notice 1)\n");
  26. eap_sim_prf(xkey, buf, sizeof(buf));
  27. if (memcmp(w, buf, sizeof(w)) != 0) {
  28. printf("eap_sim_prf failed\n");
  29. return 1;
  30. }
  31. return 0;
  32. }
  33. int main(int argc, char *argv[])
  34. {
  35. int errors = 0;
  36. errors += test_eap_sim_prf();
  37. return errors;
  38. }