⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_ccmp.c

📁 madwifi driver, linux system
💻 C
📖 第 1 页 / 共 2 页
字号:
/*- * Copyright (c) 2004 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $Id: test_ccmp.c 3060 2007-12-14 06:36:03Z proski $ *//* * CCMP test module. * * Test vectors come from section I.7.4 of P802.11i/D7.0, October 2003. * * To use this tester load the net80211 layer (either as a module or * by statically configuring it into your kernel), then insmod this * module.  It should automatically run all test cases and print * information for each.  To run one or more tests you can specify a * tests parameter to the module that is a bit mask of the set of tests * you want; e.g. insmod ccmp_test tests=7 will run only test MPDUs * 1, 2, and 3. */#ifndef AUTOCONF_INCLUDED#include <linux/config.h>#endif#include <linux/version.h>#include <linux/module.h>#include <linux/init.h>#include <linux/skbuff.h>#include <linux/netdevice.h>#include "if_media.h"#include <net80211/ieee80211_var.h>/*==== CCMP test mpdu   1 ====-- MPDU Fields7  Version  = 08  Type     = 2   SubType  = 0  Data9  ToDS     = 0   FromDS   = 010  MoreFrag = 0   Retry    = 111  PwrMgt   = 0   moreData = 012  Encrypt  = 113  Order    = 014  Duration = 1145915  A1 = 0f-d2-e1-28-a5-7c    DA16  A2 = 50-30-f1-84-44-08    SA17  A3 = ab-ae-a5-b8-fc-ba    BSSID18  SC = 0x338019  seqNum = 824 (0x0338)  fraqNum = 0 (0x00)20  Algorithm = AES_CCM21  Key ID = 022  TK = c9 7c 1f 67 ce 37 11 85  51 4a 8a 19 f2 bd d5 2f23  PN = 199027030681356  (0xB5039776E70C)24  802.11 Header =  08 48 c3 2c 0f d2 e1 28 a5 7c 50 30 f1 84 44 0825  	ab ae a5 b8 fc ba 80 3326  Muted 802.11 Header =  08 40 0f d2 e1 28 a5 7c 50 30 f1 84 44 0827  	ab ae a5 b8 fc ba 00 0028  CCMP Header =  0c e7 00 20 76 97 03 b529  CCM Nonce = 00 50 30 f1 84 44 08 b5  03 97 76 e7 0c30 Plaintext Data = f8 ba 1a 55 d0 2f 85 ae 96 7b b6 2f b6 cd a8 eb1	7e 78 a0 502  CCM MIC =  78 45 ce 0b 16 f9 76 233  -- Encrypted MPDU with FCS4  08 48 c3 2c 0f d2 e1 28 a5 7c 50 30 f1 84 44 08 ab ae a5 b8 fc ba5  80 33 0c e7 00 20 76 97 03 b5 f3 d0 a2 fe 9a 3d bf 23 42 a6 43 e46  32 46 e8 0c 3c 04 d0 19 78 45 ce 0b 16 f9 76 23 1d 99 f0 66*/static const u_int8_t test1_key[] = {		/* TK */	0xc9, 0x7c, 0x1f, 0x67, 0xce, 0x37, 0x11, 0x85,  0x51, 0x4a, 0x8a,	0x19, 0xf2, 0xbd, 0xd5, 0x2f};static const u_int8_t test1_plaintext[] = {	/* Plaintext MPDU w/o MIC */	0x08, 0x48, 0xc3, 0x2c, 0x0f, 0xd2, 0xe1, 0x28,	/* 802.11 Header */	0xa5, 0x7c, 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08,	0xab, 0xae, 0xa5, 0xb8, 0xfc, 0xba, 0x80, 0x33,	0xf8, 0xba, 0x1a, 0x55, 0xd0, 0x2f, 0x85, 0xae,	/* Plaintext Data */	0x96, 0x7b, 0xb6, 0x2f, 0xb6, 0xcd, 0xa8, 0xeb,	0x7e, 0x78, 0xa0, 0x50,};static const u_int8_t test1_encrypted[] = {	/* Encrypted MPDU with MIC */	0x08, 0x48, 0xc3, 0x2c, 0x0f, 0xd2, 0xe1, 0x28,	0xa5, 0x7c, 0x50, 0x30, 0xf1, 0x84, 0x44, 0x08,	0xab, 0xae, 0xa5, 0xb8, 0xfc, 0xba, 0x80, 0x33,	0x0c, 0xe7, 0x00, 0x20, 0x76, 0x97, 0x03, 0xb5,	0xf3, 0xd0, 0xa2, 0xfe, 0x9a, 0x3d, 0xbf, 0x23,	0x42, 0xa6, 0x43, 0xe4, 0x32, 0x46, 0xe8, 0x0c,	0x3c, 0x04, 0xd0, 0x19, 0x78, 0x45, 0xce, 0x0b,	0x16, 0xf9, 0x76, 0x23,};/*==== CCMP test mpdu   2 ====-- MPDU Fields 9  Version  = 010  Type     = 2   SubType  = 3  Data+CF-Ack+CF-Poll11  ToDS     = 0   FromDS   = 012  MoreFrag = 0   Retry    = 013  PwrMgt   = 0   moreData = 014  Encrypt  = 115  Order    = 116  Duration = 2084217  A1 = ea-10-0c-84-68-50    DA18  A2 = ee-c1-76-2c-88-de    SA19  A3 = af-2e-e9-f4-6a-07    BSSID20  SC = 0xCCE021  seqNum = 3278 (0x0CCE)  fraqNum = 0 (0x00)22  Algorithm = AES_CCM23  Key ID = 224  TK = 8f 7a 05 3f a5 77 a5 59  75 29 27 20 97 a6 03 d525  PN = 54923164817386  (0x31F3CBBA97EA)26  802.11 Header =  38 c0 6a 51 ea 10 0c 84 68 50 ee c1 76 2c 88 de27  	af 2e e9 f4 6a 07 e0 cc28  Muted 802.11 Header =  08 c0 ea 10 0c 84 68 50 ee c1 76 2c 88 de29  	af 2e e9 f4 6a 07 00 0030  CCMP Header =  ea 97 00 a0 ba cb f3 3131  CCM Nonce = 00 ee c1 76 2c 88 de 31  f3 cb ba 97 ea32  Plaintext Data = 83 a0 63 4b 5e d7 62 7e b9 df 22 5e 05 74 03 4233  	de 19 41 1734  CCM MIC =  54 2f bf 8d a0 6a a4 ae35  -- Encrypted MPDU with FCS36  38 c0 6a 51 ea 10 0c 84 68 50 ee c1 76 2c 88 de af 2e e9 f4 6a 0737  e0 cc ea 97 00 a0 ba cb f3 31 81 4b 69 65 d0 5b f2 b2 ed 38 d4 be38  b0 69 fe 82 71 4a 61 0b 54 2f bf 8d a0 6a a4 ae 25 3c 47 38*/static const u_int8_t test2_key[] = {		/* TK */	0x8f, 0x7a, 0x05, 0x3f, 0xa5, 0x77, 0xa5, 0x59,  0x75, 0x29, 0x27,	0x20, 0x97, 0xa6, 0x03, 0xd5};static const u_int8_t test2_plaintext[] = {	/* Plaintext MPDU w/o MIC */	0x38, 0xc0, 0x6a, 0x51, 0xea, 0x10, 0x0c, 0x84, 0x68, 0x50, 0xee,	0xc1, 0x76, 0x2c, 0x88, 0xde, 0xaf, 0x2e, 0xe9, 0xf4, 0x6a, 0x07,	0xe0, 0xcc,	0x83, 0xa0, 0x63, 0x4b, 0x5e, 0xd7, 0x62, 0x7e, 0xb9, 0xdf, 0x22,	0x5e, 0x05, 0x74, 0x03, 0x42, 0xde, 0x19, 0x41, 0x17};static const u_int8_t test2_encrypted[] = {	/* Encrypted MPDU with MIC */	0x38, 0xc0, 0x6a, 0x51, 0xea, 0x10, 0x0c, 0x84, 0x68, 0x50, 0xee,	0xc1, 0x76, 0x2c, 0x88, 0xde, 0xaf, 0x2e, 0xe9, 0xf4, 0x6a, 0x07,	0xe0, 0xcc, 0xea, 0x97, 0x00, 0xa0, 0xba, 0xcb, 0xf3, 0x31, 0x81,	0x4b, 0x69, 0x65, 0xd0, 0x5b, 0xf2, 0xb2, 0xed, 0x38, 0xd4, 0xbe,	0xb0, 0x69, 0xfe, 0x82, 0x71, 0x4a, 0x61, 0x0b, 0x54, 0x2f, 0xbf,	0x8d, 0xa0, 0x6a, 0xa4, 0xae,};/*==== CCMP test mpdu   3 ====-- MPDU Fields41  Version  = 042  Type     = 2   SubType  = 1143  ToDS     = 0   FromDS   = 044  MoreFrag = 0   Retry    = 145  PwrMgt   = 0   moreData = 046  Encrypt  = 147  Order    = 148  Duration = 2505249  A1 = d9-57-7d-f7-63-c8    DA50 A2 = b6-a8-8a-df-36-91    SA1  A3 = dc-4a-8b-ca-94-dd    BSSID2  SC = 0x82603  seqNum = 2086 (0x0826)  fraqNum = 0 (0x00)4  QC = 0x00005  MSDU Priority = 0 (0x0)6  Algorithm = AES_CCM7  Key ID = 28  TK = 40 cf b7 a6 2e 88 01 3b  d6 d3 af fc c1 91 04 1e9  PN = 52624639632814  (0x2FDCA0F3A5AE)10  802.11 Header =  b8 c8 dc 61 d9 57 7d f7 63 c8 b6 a8 8a df 36 9111  	dc 4a 8b ca 94 dd 60 82 20 8512  Muted 802.11 Header =  88 c0 d9 57 7d f7 63 c8 b6 a8 8a df 36 9113  	dc 4a 8b ca 94 dd 00 00 00 0014  CCMP Header =  ae a5 00 a0 f3 a0 dc 2f15  CCM Nonce = 00 b6 a8 8a df 36 91 2f dc a0 f3 a5 ae16  Plaintext Data  = 2c 1b d0 36 83 1c 95 49 6c 5f 4d bf 3d 55 9e 7217  	de 80 2a 1818  CCM MIC =  fd 1f 1f 61 a9 fb 4b b319  -- Encrypted MPDU with FCS20  b8 c8 dc 61 d9 57 7d f7 63 c8 b6 a8 8a df 36 91 dc 4a 8b ca 94 dd21  60 82 20 85 ae a5 00 a0 f3 a0 dc 2f 89 d8 58 03 40 b6 26 a0 b6 d422  d0 13 bf 18 f2 91 b8 96 46 c8 fd 1f 1f 61 a9 fb 4b b3 60 3f 5a ad*/static const u_int8_t test3_key[] = {		/* TK */	0x40, 0xcf, 0xb7, 0xa6, 0x2e, 0x88, 0x01, 0x3b,  0xd6, 0xd3,	0xaf, 0xfc, 0xc1, 0x91, 0x04, 0x1e};static const u_int8_t test3_plaintext[] = {	/* Plaintext MPDU w/o MIC */	0xb8, 0xc8, 0xdc, 0x61, 0xd9, 0x57, 0x7d, 0xf7, 0x63, 0xc8,	0xb6, 0xa8, 0x8a, 0xdf, 0x36, 0x91, 0xdc, 0x4a, 0x8b, 0xca,	0x94, 0xdd, 0x60, 0x82, 0x20, 0x85,	0x2c, 0x1b, 0xd0, 0x36, 0x83, 0x1c, 0x95, 0x49, 0x6c, 0x5f,	0x4d, 0xbf, 0x3d, 0x55, 0x9e, 0x72, 0xde, 0x80, 0x2a, 0x18};static const u_int8_t test3_encrypted[] = {	/* Encrypted MPDU with MIC */	0xb8, 0xc8, 0xdc, 0x61, 0xd9, 0x57, 0x7d, 0xf7, 0x63, 0xc8,	0xb6, 0xa8, 0x8a, 0xdf, 0x36, 0x91, 0xdc, 0x4a, 0x8b, 0xca,	0x94, 0xdd, 0x60, 0x82, 0x20, 0x85, 0xae, 0xa5, 0x00, 0xa0,	0xf3, 0xa0, 0xdc, 0x2f, 0x89, 0xd8, 0x58, 0x03, 0x40, 0xb6,	0x26, 0xa0, 0xb6, 0xd4, 0xd0, 0x13, 0xbf, 0x18, 0xf2, 0x91,	0xb8, 0x96, 0x46, 0xc8, 0xfd, 0x1f, 0x1f, 0x61, 0xa9, 0xfb,	0x4b, 0xb3,};/*==== CCMP test mpdu  4 ==== -- MPDU Fields25  Version  = 026  Type     = 2   SubType  = 1027  ToDS     = 0   FromDS   = 128  MoreFrag = 0   Retry    = 129  PwrMgt   = 0   moreData = 030  Encrypt  = 131  Order    = 132  Duration = 441033  A1 = 71-2a-9d-df-11-db    DA34  A2 = 8e-f8-22-73-47-01    BSSID35  A3 = 59-14-0d-d6-46-a2    SA36  SC = 0x2FC037  seqNum = 764 (0x02FC)  fraqNum = 0 (0x00)38  QC = 0x000739  MSDU Priority = 7 (0x0)40  Algorithm = AES_CCM41  Key ID = 042  TK = 8c 89 a2 eb c9 6c 76 02  70 7f cf 24 b3 2d 38 3343  PN = 270963670912995  (0xF670A55A0FE3)44  802.11 Header =  a8 ca 3a 11 71 2a 9d df 11 db 8e f8 22 73 47 0145  	59 14 0d d6 46 a2 c0 2f 67 a546  Muted 802.11 Header =  88 c2 71 2a 9d df 11 db 8e f8 22 73 47 0147  	59 14 0d d6 46 a2 00 00 07 0048  CCMP Header =  e3 0f 00 20 5a a5 70 f649  CCM Nonce = 07 8e f8 22 73 47 01 f6  70 a5 5a 0f e350  Plaintext Data = 4f ad 2b 1c 29 0f a5 eb d8 72 fb c3 f3 a0 74 8951  	8f 8b 2f bb52  CCM MIC =  31 fc 88 00 4f 35 ee 3d-- Encrypted MPDU with FCS2  a8 ca 3a 11 71 2a 9d df 11 db 8e f8 22 73 47 01 59 14 0d d6 46 a23  c0 2f 67 a5 e3 0f 00 20 5a a5 70 f6 9d 59 b1 5f 37 14 48 c2 30 f44  d7 39 05 2e 13 ab 3b 1a 7b 10 31 fc 88 00 4f 35 ee 3d 45 a7 4a 30*/static const u_int8_t test4_key[] = {		/* TK */	0x8c, 0x89, 0xa2, 0xeb, 0xc9, 0x6c, 0x76, 0x02,	0x70, 0x7f, 0xcf, 0x24, 0xb3, 0x2d, 0x38, 0x33,};static const u_int8_t test4_plaintext[] = {	/* Plaintext MPDU w/o MIC */	0xa8, 0xca, 0x3a, 0x11, 0x71, 0x2a, 0x9d, 0xdf, 0x11, 0xdb,	0x8e, 0xf8, 0x22, 0x73, 0x47, 0x01, 0x59, 0x14, 0x0d, 0xd6,	0x46, 0xa2, 0xc0, 0x2f, 0x67, 0xa5,	0x4f, 0xad, 0x2b, 0x1c, 0x29, 0x0f, 0xa5, 0xeb, 0xd8, 0x72,	0xfb, 0xc3, 0xf3, 0xa0, 0x74, 0x89, 0x8f, 0x8b, 0x2f, 0xbb,};static const u_int8_t test4_encrypted[] = {	/* Encrypted MPDU with MIC */	0xa8, 0xca, 0x3a, 0x11, 0x71, 0x2a, 0x9d, 0xdf, 0x11, 0xdb,	0x8e, 0xf8, 0x22, 0x73, 0x47, 0x01, 0x59, 0x14, 0x0d, 0xd6,	0x46, 0xa2, 0xc0, 0x2f, 0x67, 0xa5, 0xe3, 0x0f, 0x00, 0x20,	0x5a, 0xa5, 0x70, 0xf6, 0x9d, 0x59, 0xb1, 0x5f, 0x37, 0x14,	0x48, 0xc2, 0x30, 0xf4, 0xd7, 0x39, 0x05, 0x2e, 0x13, 0xab,	0x3b, 0x1a, 0x7b, 0x10, 0x31, 0xfc, 0x88, 0x00, 0x4f, 0x35,	0xee, 0x3d,};/*==== CCMP test mpdu   5 ====-- MPDU Fields7  Version  = 08  Type     = 2   SubType  = 89  ToDS     = 0   FromDS   = 110  MoreFrag = 0   Retry    = 111  PwrMgt   = 1   moreData = 012  Encrypt  = 113  Order    = 114  Duration = 1666415  A1 = 45-de-c6-9a-74-80    DA16  A2 = f3-51-94-6b-c9-6b    BSSID17  A3 = e2-76-fb-e6-c1-27    SA18  SC = 0xF28019  seqNum = 3880 (0x0F28)  fraqNum = 0 (0x00)20  QC = 0x000b21  MSDU Priority = 0 (0x0)22  Algorithm = AES_CCM23  Key ID = 224  TK = a5 74 d5 14 3b b2 5e fd  de ff 30 12 2f df d0 6625  PN = 184717420531255  (0xA7FFE03C0E37)26  802.11 Header =  88 da 18 41 45 de c6 9a 74 80 f3 51 94 6b c9 6b27  	e2 76 fb e6 c1 27 80 f2 4b 1928  Muted 802.11 Header =  88 c2 45 de c6 9a 74 80 f3 51 94 6b c9 6b29  	e2 76 fb e6 c1 27 00 00 0b 0030  CCMP Header =  37 0e 00 a0 3c e0 ff a731  CCM Nonce = 0b f3 51 94 6b c9 6b a7 ff e0 3c 0e 3732  Plaintext Data = 28 96 9b 95 4f 26 3a 80 18 a9 ef 70 a8 b0 51 4633  	24 81 92 2e34  CCM MIC =  ce 0c 3b e1 97 d3 05 eb35  -- Encrypted MPDU with FCS36  88 da 18 41 45 de c6 9a 74 80 f3 51 94 6b c9 6b e2 76 fb e6 c1 2737  80 f2 4b 19 37 0e 00 a0 3c e0 ff a7 eb 4a e4 95 6a 80 1d a9 62 4b38  7e 0c 18 b2 3e 61 5e c0 3a f6 ce 0c 3b e1 97 d3 05 eb c8 9e a1 b5*/static const u_int8_t test5_key[] = {		/* TK */	0xa5, 0x74, 0xd5, 0x14, 0x3b, 0xb2, 0x5e, 0xfd,	0xde, 0xff, 0x30, 0x12, 0x2f, 0xdf, 0xd0, 0x66,};static const u_int8_t test5_plaintext[] = {	/* Plaintext MPDU w/o MIC */	0x88, 0xda, 0x18, 0x41, 0x45, 0xde, 0xc6, 0x9a, 0x74, 0x80,	0xf3, 0x51, 0x94, 0x6b, 0xc9, 0x6b, 0xe2, 0x76, 0xfb, 0xe6,	0xc1, 0x27, 0x80, 0xf2, 0x4b, 0x19,	0x28, 0x96, 0x9b, 0x95, 0x4f, 0x26, 0x3a, 0x80, 0x18, 0xa9,	0xef, 0x70, 0xa8, 0xb0, 0x51, 0x46, 0x24, 0x81, 0x92, 0x2e,};static const u_int8_t test5_encrypted[] = {	/* Encrypted MPDU with MIC */	0x88, 0xda, 0x18, 0x41, 0x45, 0xde, 0xc6, 0x9a, 0x74, 0x80,	0xf3, 0x51, 0x94, 0x6b, 0xc9, 0x6b, 0xe2, 0x76, 0xfb, 0xe6,	0xc1, 0x27, 0x80, 0xf2, 0x4b, 0x19, 0x37, 0x0e, 0x00, 0xa0,	0x3c, 0xe0, 0xff, 0xa7, 0xeb, 0x4a, 0xe4, 0x95, 0x6a, 0x80,	0x1d, 0xa9, 0x62, 0x4b, 0x7e, 0x0c, 0x18, 0xb2, 0x3e, 0x61,	0x5e, 0xc0, 0x3a, 0xf6, 0xce, 0x0c, 0x3b, 0xe1, 0x97, 0xd3,	0x05, 0xeb,};/*==== CCMP test mpdu   6 ====-- MPDU Fields41  Version  = 042  Type     = 2   SubType  = 843  ToDS     = 0   FromDS   = 144  MoreFrag = 0   Retry    = 045  PwrMgt   = 1   moreData = 046  Encrypt  = 147  Order    = 048  Duration = 816149  A1 = 5a-f2-84-30-fd-ab    DA50  A2 = bf-f9-43-b9-f9-a6    BSSID1   A3 = ab-1d-98-c7-fe-73    SA2  SC = 0x71503  seqNum = 1813 (0x0715)  fraqNum = 0 (0x00)4  QC = 0x000d5  PSDU Priority = 13 (0xd)6  Algorithm = AES_CCM7  Key ID = 18  TK = f7 1e ea 4e 1f 58 80 4b 97 17 23 0a d0 61 46 419  PN    = 118205765159305  (0x6B81ECA48989)10  802.11 Header =  88 52 e1 1f 5a f2 84 30 fd ab bf f9 43 b9 f9 a6

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -