test_vectors.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /*
  2. * test_vectors - IEEE 802.11 test vector generator
  3. * Copyright (c) 2012, 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 "utils/includes.h"
  9. #include "utils/common.h"
  10. #include "utils/eloop.h"
  11. #include "wlantest.h"
  12. extern int wpa_debug_level;
  13. extern int wpa_debug_show_keys;
  14. static void test_vector_tkip(void)
  15. {
  16. u8 tk[] = {
  17. 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
  18. 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12,
  19. 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78,
  20. 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34
  21. };
  22. u8 pn[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
  23. u8 frame[] = {
  24. 0x08, 0x42, 0x2c, 0x00, 0x02, 0x03, 0x04, 0x05,
  25. 0x06, 0x08, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  26. 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0xd0, 0x02,
  27. /* 0x00, 0x20, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, */
  28. 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
  29. 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00,
  30. 0x40, 0x01, 0xa5, 0x55, 0xc0, 0xa8, 0x0a, 0x02,
  31. 0xc0, 0xa8, 0x0a, 0x01, 0x08, 0x00, 0x3a, 0xb0,
  32. 0x00, 0x00, 0x00, 0x00, 0xcd, 0x4c, 0x05, 0x00,
  33. 0x00, 0x00, 0x00, 0x00, 0x08, 0x09, 0x0a, 0x0b,
  34. 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
  35. 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
  36. 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
  37. 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
  38. 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
  39. 0x34, 0x35, 0x36, 0x37,
  40. /* 0x68, 0x81, 0xa3, 0xf3, 0xd6, 0x48, 0xd0, 0x3c */
  41. };
  42. u8 *enc, *plain;
  43. size_t enc_len, plain_len;
  44. wpa_printf(MSG_INFO, "\nIEEE Std 802.11-2012, M.6.3 TKIP test "
  45. "vector\n");
  46. wpa_hexdump(MSG_INFO, "TK", tk, sizeof(tk));
  47. wpa_hexdump(MSG_INFO, "PN", pn, sizeof(pn));
  48. wpa_hexdump(MSG_INFO, "Plaintext MPDU", frame, sizeof(frame));
  49. enc = tkip_encrypt(tk, frame, sizeof(frame), 24, NULL, pn, 0, &enc_len);
  50. if (enc == NULL) {
  51. wpa_printf(MSG_ERROR, "Failed to encrypt TKIP frame");
  52. return;
  53. }
  54. wpa_hexdump(MSG_INFO, "Encrypted MPDU (without FCS)", enc, enc_len);
  55. wpa_debug_level = MSG_INFO;
  56. plain = tkip_decrypt(tk, (const struct ieee80211_hdr *) enc,
  57. enc + 24, enc_len - 24, &plain_len);
  58. wpa_debug_level = MSG_EXCESSIVE;
  59. os_free(enc);
  60. if (plain == NULL) {
  61. wpa_printf(MSG_ERROR, "Failed to decrypt TKIP frame");
  62. return;
  63. }
  64. if (plain_len != sizeof(frame) - 24 ||
  65. os_memcmp(plain, frame + 24, plain_len) != 0) {
  66. wpa_hexdump(MSG_ERROR, "Decryption result did not match",
  67. plain, plain_len);
  68. }
  69. os_free(plain);
  70. }
  71. static void test_vector_ccmp(void)
  72. {
  73. u8 tk[] = { 0xc9, 0x7c, 0x1f, 0x67, 0xce, 0x37, 0x11, 0x85,
  74. 0x51, 0x4a, 0x8a, 0x19, 0xf2, 0xbd, 0xd5, 0x2f };
  75. u8 pn[] = { 0xB5, 0x03, 0x97, 0x76, 0xE7, 0x0C };
  76. u8 frame[] = {
  77. 0x08, 0x48, 0xc3, 0x2c, 0x0f, 0xd2, 0xe1, 0x28,
  78. 0xa5, 0x7c, 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08,
  79. 0xab, 0xae, 0xa5, 0xb8, 0xfc, 0xba, 0x80, 0x33,
  80. 0xf8, 0xba, 0x1a, 0x55, 0xd0, 0x2f, 0x85, 0xae,
  81. 0x96, 0x7b, 0xb6, 0x2f, 0xb6, 0xcd, 0xa8, 0xeb,
  82. 0x7e, 0x78, 0xa0, 0x50
  83. };
  84. u8 *enc, *plain;
  85. size_t enc_len, plain_len;
  86. u8 fcs[4];
  87. wpa_printf(MSG_INFO, "\nIEEE Std 802.11-2012, M.6.4 CCMP test "
  88. "vector\n");
  89. wpa_hexdump(MSG_INFO, "TK", tk, sizeof(tk));
  90. wpa_hexdump(MSG_INFO, "PN", pn, sizeof(pn));
  91. wpa_hexdump(MSG_INFO, "802.11 Header", frame, 24);
  92. wpa_hexdump(MSG_INFO, "Plaintext Data", frame + 24, sizeof(frame) - 24);
  93. enc = ccmp_encrypt(tk, frame, sizeof(frame), 24, NULL, pn, 0, &enc_len);
  94. if (enc == NULL) {
  95. wpa_printf(MSG_ERROR, "Failed to encrypt CCMP frame");
  96. return;
  97. }
  98. wpa_hexdump(MSG_INFO, "Encrypted MPDU (without FCS)", enc, enc_len);
  99. WPA_PUT_LE32(fcs, crc32(enc, enc_len));
  100. wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
  101. wpa_debug_level = MSG_INFO;
  102. plain = ccmp_decrypt(tk, (const struct ieee80211_hdr *) enc,
  103. enc + 24, enc_len - 24, &plain_len);
  104. wpa_debug_level = MSG_EXCESSIVE;
  105. os_free(enc);
  106. if (plain == NULL) {
  107. wpa_printf(MSG_ERROR, "Failed to decrypt CCMP frame");
  108. return;
  109. }
  110. if (plain_len != sizeof(frame) - 24 ||
  111. os_memcmp(plain, frame + 24, plain_len) != 0) {
  112. wpa_hexdump(MSG_ERROR, "Decryption result did not match",
  113. plain, plain_len);
  114. }
  115. os_free(plain);
  116. }
  117. static void test_vector_bip(void)
  118. {
  119. u8 igtk[] = {
  120. 0x4e, 0xa9, 0x54, 0x3e, 0x09, 0xcf, 0x2b, 0x1e,
  121. 0xca, 0x66, 0xff, 0xc5, 0x8b, 0xde, 0xcb, 0xcf
  122. };
  123. u8 ipn[] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 };
  124. u8 frame[] = {
  125. 0xc0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  126. 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
  127. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
  128. 0x02, 0x00
  129. };
  130. u8 *prot;
  131. size_t prot_len;
  132. wpa_printf(MSG_INFO, "\nIEEE Std 802.11-2012, M.9.1 BIP with broadcast "
  133. "Deauthentication frame\n");
  134. wpa_hexdump(MSG_INFO, "IGTK", igtk, sizeof(igtk));
  135. wpa_hexdump(MSG_INFO, "IPN", ipn, sizeof(ipn));
  136. wpa_hexdump(MSG_INFO, "Plaintext frame", frame, sizeof(frame));
  137. prot = bip_protect(igtk, frame, sizeof(frame), ipn, 4, &prot_len);
  138. if (prot == NULL) {
  139. wpa_printf(MSG_ERROR, "Failed to protect BIP frame");
  140. return;
  141. }
  142. wpa_hexdump(MSG_INFO, "Protected MPDU (without FCS)", prot, prot_len);
  143. os_free(prot);
  144. }
  145. static void test_vector_ccmp_mgmt(void)
  146. {
  147. u8 tk[] = { 0x66, 0xed, 0x21, 0x04, 0x2f, 0x9f, 0x26, 0xd7,
  148. 0x11, 0x57, 0x06, 0xe4, 0x04, 0x14, 0xcf, 0x2e };
  149. u8 pn[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
  150. u8 frame[] = {
  151. 0xc0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  152. 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
  153. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00,
  154. 0x02, 0x00
  155. };
  156. u8 *enc, *plain;
  157. size_t enc_len, plain_len;
  158. wpa_printf(MSG_INFO, "\nIEEE Std 802.11-2012, M.9.2 CCMP with unicast "
  159. "Deauthentication frame\n");
  160. wpa_hexdump(MSG_INFO, "TK", tk, sizeof(tk));
  161. wpa_hexdump(MSG_INFO, "PN", pn, sizeof(pn));
  162. wpa_hexdump(MSG_INFO, "802.11 Header", frame, 24);
  163. wpa_hexdump(MSG_INFO, "Plaintext Data", frame + 24, sizeof(frame) - 24);
  164. enc = ccmp_encrypt(tk, frame, sizeof(frame), 24, NULL, pn, 0, &enc_len);
  165. if (enc == NULL) {
  166. wpa_printf(MSG_ERROR, "Failed to encrypt CCMP frame");
  167. return;
  168. }
  169. wpa_hexdump(MSG_INFO, "Encrypted MPDU (without FCS)", enc, enc_len);
  170. wpa_debug_level = MSG_INFO;
  171. plain = ccmp_decrypt(tk, (const struct ieee80211_hdr *) enc,
  172. enc + 24, enc_len - 24, &plain_len);
  173. wpa_debug_level = MSG_EXCESSIVE;
  174. os_free(enc);
  175. if (plain == NULL) {
  176. wpa_printf(MSG_ERROR, "Failed to decrypt CCMP frame");
  177. return;
  178. }
  179. if (plain_len != sizeof(frame) - 24 ||
  180. os_memcmp(plain, frame + 24, plain_len) != 0) {
  181. wpa_hexdump(MSG_ERROR, "Decryption result did not match",
  182. plain, plain_len);
  183. }
  184. os_free(plain);
  185. }
  186. static void test_vector_gcmp(void)
  187. {
  188. u8 tk[] = { 0xc9, 0x7c, 0x1f, 0x67, 0xce, 0x37, 0x11, 0x85,
  189. 0x51, 0x4a, 0x8a, 0x19, 0xf2, 0xbd, 0xd5, 0x2f };
  190. u8 pn[] = {
  191. 0x00, 0x89, 0x5F, 0x5F, 0x2B, 0x08
  192. };
  193. u8 frame[] = {
  194. 0x88, 0x48, 0x0b, 0x00, 0x0f, 0xd2, 0xe1, 0x28,
  195. 0xa5, 0x7c, 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08,
  196. 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08, 0x80, 0x33,
  197. 0x03, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
  198. 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
  199. 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
  200. 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
  201. 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
  202. 0x26, 0x27
  203. };
  204. u8 *enc, *plain;
  205. size_t enc_len, plain_len;
  206. u8 fcs[4];
  207. wpa_printf(MSG_INFO, "\nIEEE P802.11ad/D9.0, M.11.1 GCMP test "
  208. "vector #2\n");
  209. wpa_hexdump(MSG_INFO, "TK", tk, sizeof(tk));
  210. wpa_hexdump(MSG_INFO, "PN", pn, sizeof(pn));
  211. wpa_hexdump(MSG_INFO, "802.11 Header", frame, 26);
  212. wpa_hexdump(MSG_INFO, "Plaintext Data", frame + 26, sizeof(frame) - 26);
  213. enc = gcmp_encrypt(tk, sizeof(tk), frame, sizeof(frame), 26, frame + 24,
  214. pn, 0, &enc_len);
  215. if (enc == NULL) {
  216. wpa_printf(MSG_ERROR, "Failed to encrypt GCMP frame");
  217. return;
  218. }
  219. wpa_hexdump(MSG_INFO, "Encrypted MPDU (without FCS)", enc, enc_len);
  220. WPA_PUT_LE32(fcs, crc32(enc, enc_len));
  221. wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
  222. wpa_debug_level = MSG_INFO;
  223. plain = gcmp_decrypt(tk, sizeof(tk), (const struct ieee80211_hdr *) enc,
  224. enc + 26, enc_len - 26, &plain_len);
  225. wpa_debug_level = MSG_EXCESSIVE;
  226. os_free(enc);
  227. if (plain == NULL) {
  228. wpa_printf(MSG_ERROR, "Failed to decrypt GCMP frame");
  229. return;
  230. }
  231. if (plain_len != sizeof(frame) - 26 ||
  232. os_memcmp(plain, frame + 26, plain_len) != 0) {
  233. wpa_hexdump(MSG_ERROR, "Decryption result did not match",
  234. plain, plain_len);
  235. }
  236. os_free(plain);
  237. }
  238. static void test_vector_gcmp_256(void)
  239. {
  240. u8 tk[] = { 0xc9, 0x7c, 0x1f, 0x67, 0xce, 0x37, 0x11, 0x85,
  241. 0x51, 0x4a, 0x8a, 0x19, 0xf2, 0xbd, 0xd5, 0x2f,
  242. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  243. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
  244. u8 pn[] = {
  245. 0x00, 0x89, 0x5F, 0x5F, 0x2B, 0x08
  246. };
  247. u8 frame[] = {
  248. 0x88, 0x48, 0x0b, 0x00, 0x0f, 0xd2, 0xe1, 0x28,
  249. 0xa5, 0x7c, 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08,
  250. 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08, 0x80, 0x33,
  251. 0x03, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
  252. 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
  253. 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
  254. 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
  255. 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
  256. 0x26, 0x27
  257. };
  258. u8 *enc, *plain;
  259. size_t enc_len, plain_len;
  260. u8 fcs[4];
  261. wpa_printf(MSG_INFO, "\nGCMP-256 test vector\n");
  262. wpa_hexdump(MSG_INFO, "TK", tk, sizeof(tk));
  263. wpa_hexdump(MSG_INFO, "PN", pn, sizeof(pn));
  264. wpa_hexdump(MSG_INFO, "802.11 Header", frame, 26);
  265. wpa_hexdump(MSG_INFO, "Plaintext Data", frame + 26, sizeof(frame) - 26);
  266. enc = gcmp_encrypt(tk, sizeof(tk), frame, sizeof(frame), 26, frame + 24,
  267. pn, 0, &enc_len);
  268. if (enc == NULL) {
  269. wpa_printf(MSG_ERROR, "Failed to encrypt GCMP frame");
  270. return;
  271. }
  272. wpa_hexdump(MSG_INFO, "Encrypted MPDU (without FCS)", enc, enc_len);
  273. WPA_PUT_LE32(fcs, crc32(enc, enc_len));
  274. wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
  275. wpa_debug_level = MSG_INFO;
  276. plain = gcmp_decrypt(tk, sizeof(tk), (const struct ieee80211_hdr *) enc,
  277. enc + 26, enc_len - 26, &plain_len);
  278. wpa_debug_level = MSG_EXCESSIVE;
  279. os_free(enc);
  280. if (plain == NULL) {
  281. wpa_printf(MSG_ERROR, "Failed to decrypt GCMP frame");
  282. return;
  283. }
  284. if (plain_len != sizeof(frame) - 26 ||
  285. os_memcmp(plain, frame + 26, plain_len) != 0) {
  286. wpa_hexdump(MSG_ERROR, "Decryption result did not match",
  287. plain, plain_len);
  288. }
  289. os_free(plain);
  290. }
  291. static void test_vector_ccmp_256(void)
  292. {
  293. u8 tk[] = { 0xc9, 0x7c, 0x1f, 0x67, 0xce, 0x37, 0x11, 0x85,
  294. 0x51, 0x4a, 0x8a, 0x19, 0xf2, 0xbd, 0xd5, 0x2f,
  295. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  296. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
  297. u8 pn[] = { 0xB5, 0x03, 0x97, 0x76, 0xE7, 0x0C };
  298. u8 frame[] = {
  299. 0x08, 0x48, 0xc3, 0x2c, 0x0f, 0xd2, 0xe1, 0x28,
  300. 0xa5, 0x7c, 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08,
  301. 0xab, 0xae, 0xa5, 0xb8, 0xfc, 0xba, 0x80, 0x33,
  302. 0xf8, 0xba, 0x1a, 0x55, 0xd0, 0x2f, 0x85, 0xae,
  303. 0x96, 0x7b, 0xb6, 0x2f, 0xb6, 0xcd, 0xa8, 0xeb,
  304. 0x7e, 0x78, 0xa0, 0x50
  305. };
  306. u8 *enc, *plain;
  307. size_t enc_len, plain_len;
  308. u8 fcs[4];
  309. wpa_printf(MSG_INFO, "\nCCMP-256 test vector\n");
  310. wpa_hexdump(MSG_INFO, "TK", tk, sizeof(tk));
  311. wpa_hexdump(MSG_INFO, "PN", pn, sizeof(pn));
  312. wpa_hexdump(MSG_INFO, "802.11 Header", frame, 24);
  313. wpa_hexdump(MSG_INFO, "Plaintext Data", frame + 24, sizeof(frame) - 24);
  314. enc = ccmp_256_encrypt(tk, frame, sizeof(frame), 24, NULL, pn, 0,
  315. &enc_len);
  316. if (enc == NULL) {
  317. wpa_printf(MSG_ERROR, "Failed to encrypt CCMP frame");
  318. return;
  319. }
  320. wpa_hexdump(MSG_INFO, "Encrypted MPDU (without FCS)", enc, enc_len);
  321. WPA_PUT_LE32(fcs, crc32(enc, enc_len));
  322. wpa_hexdump(MSG_INFO, "FCS", fcs, sizeof(fcs));
  323. wpa_debug_level = MSG_INFO;
  324. plain = ccmp_256_decrypt(tk, (const struct ieee80211_hdr *) enc,
  325. enc + 24, enc_len - 24, &plain_len);
  326. wpa_debug_level = MSG_EXCESSIVE;
  327. os_free(enc);
  328. if (plain == NULL) {
  329. wpa_printf(MSG_ERROR, "Failed to decrypt CCMP-256 frame");
  330. return;
  331. }
  332. if (plain_len != sizeof(frame) - 24 ||
  333. os_memcmp(plain, frame + 24, plain_len) != 0) {
  334. wpa_hexdump(MSG_ERROR, "Decryption result did not match",
  335. plain, plain_len);
  336. }
  337. os_free(plain);
  338. }
  339. static void test_vector_bip_gmac_128(void)
  340. {
  341. u8 igtk[] = {
  342. 0x4e, 0xa9, 0x54, 0x3e, 0x09, 0xcf, 0x2b, 0x1e,
  343. 0xca, 0x66, 0xff, 0xc5, 0x8b, 0xde, 0xcb, 0xcf
  344. };
  345. u8 ipn[] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 };
  346. u8 frame[] = {
  347. 0xc0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  348. 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
  349. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
  350. 0x02, 0x00
  351. };
  352. u8 *prot;
  353. size_t prot_len;
  354. wpa_printf(MSG_INFO, "\nBIP-GMAC-128 with broadcast "
  355. "Deauthentication frame\n");
  356. wpa_hexdump(MSG_INFO, "IGTK", igtk, sizeof(igtk));
  357. wpa_hexdump(MSG_INFO, "IPN", ipn, sizeof(ipn));
  358. wpa_hexdump(MSG_INFO, "Plaintext frame", frame, sizeof(frame));
  359. prot = bip_gmac_protect(igtk, sizeof(igtk), frame, sizeof(frame),
  360. ipn, 4, &prot_len);
  361. if (prot == NULL) {
  362. wpa_printf(MSG_ERROR, "Failed to protect BIP-GMAC-128 frame");
  363. return;
  364. }
  365. wpa_hexdump(MSG_INFO, "Protected MPDU (without FCS)", prot, prot_len);
  366. os_free(prot);
  367. }
  368. static void test_vector_bip_gmac_256(void)
  369. {
  370. u8 igtk[] = {
  371. 0x4e, 0xa9, 0x54, 0x3e, 0x09, 0xcf, 0x2b, 0x1e,
  372. 0xca, 0x66, 0xff, 0xc5, 0x8b, 0xde, 0xcb, 0xcf,
  373. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  374. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
  375. };
  376. u8 ipn[] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 };
  377. u8 frame[] = {
  378. 0xc0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  379. 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
  380. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
  381. 0x02, 0x00
  382. };
  383. u8 *prot;
  384. size_t prot_len;
  385. wpa_printf(MSG_INFO, "\nBIP-GMAC-256 with broadcast "
  386. "Deauthentication frame\n");
  387. wpa_hexdump(MSG_INFO, "IGTK", igtk, sizeof(igtk));
  388. wpa_hexdump(MSG_INFO, "IPN", ipn, sizeof(ipn));
  389. wpa_hexdump(MSG_INFO, "Plaintext frame", frame, sizeof(frame));
  390. prot = bip_gmac_protect(igtk, sizeof(igtk), frame, sizeof(frame),
  391. ipn, 4, &prot_len);
  392. if (prot == NULL) {
  393. wpa_printf(MSG_ERROR, "Failed to protect BIP-GMAC-256 frame");
  394. return;
  395. }
  396. wpa_hexdump(MSG_INFO, "Protected MPDU (without FCS)", prot, prot_len);
  397. os_free(prot);
  398. }
  399. int main(int argc, char *argv[])
  400. {
  401. wpa_debug_level = MSG_EXCESSIVE;
  402. wpa_debug_show_keys = 1;
  403. if (os_program_init())
  404. return -1;
  405. test_vector_tkip();
  406. test_vector_ccmp();
  407. test_vector_bip();
  408. test_vector_ccmp_mgmt();
  409. test_vector_gcmp();
  410. test_vector_gcmp_256();
  411. test_vector_ccmp_256();
  412. test_vector_bip_gmac_128();
  413. test_vector_bip_gmac_256();
  414. os_program_deinit();
  415. return 0;
  416. }