Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146620069
D3441.id8086.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D3441.id8086.diff
View Options
Index: tools/regression/net80211/ccmp/test_ccmp.c
===================================================================
--- tools/regression/net80211/ccmp/test_ccmp.c
+++ tools/regression/net80211/ccmp/test_ccmp.c
@@ -53,6 +53,7 @@
#include <sys/socket.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_media.h>
#include <net80211/ieee80211_var.h>
@@ -591,12 +592,12 @@
}
static int
-runtest(struct ieee80211com *ic, struct ciphertest *t)
+runtest(struct ieee80211vap *vap, struct ciphertest *t)
{
struct ieee80211_key key;
struct mbuf *m = NULL;
const struct ieee80211_cipher *cip;
- u_int8_t mac[IEEE80211_ADDR_LEN];
+ int hdrlen;
printf("%s: ", t->name);
@@ -606,7 +607,7 @@
memset(&key, 0, sizeof(key));
key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
key.wk_cipher = &ieee80211_cipher_none;
- if (!ieee80211_crypto_newkey(ic, t->cipher,
+ if (!ieee80211_crypto_newkey(vap, t->cipher,
IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, &key)) {
printf("FAIL: ieee80211_crypto_newkey failed\n");
goto bad;
@@ -614,9 +615,9 @@
memcpy(key.wk_key, t->key, t->key_len);
key.wk_keylen = t->key_len;
- key.wk_keyrsc = 0;
+ memset(key.wk_keyrsc, 0, sizeof(key.wk_keyrsc));
key.wk_keytsc = t->pn-1; /* PN-1 since we do encap */
- if (!ieee80211_crypto_setkey(ic, &key, mac)) {
+ if (!ieee80211_crypto_setkey(vap, &key)) {
printf("FAIL: ieee80211_crypto_setkey failed\n");
goto bad;
}
@@ -630,6 +631,7 @@
memcpy(mtod(m, void *), t->plaintext, t->plaintext_len);
m->m_len = t->plaintext_len;
m->m_pkthdr.len = m->m_len;
+ hdrlen = ieee80211_anyhdrsize(mtod(m, void *));
/*
* Encrypt frame w/ MIC.
@@ -660,7 +662,7 @@
/*
* Decrypt frame; strip MIC.
*/
- if (!cip->ic_decap(&key, m)) {
+ if (!cip->ic_decap(&key, m, hdrlen)) {
printf("FAIL: ccmp decap failed\n");
printtest(t);
cmpfail(mtod(m, const void *), m->m_len,
@@ -680,17 +682,17 @@
printf("FAIL: decap botch; data does not compare\n");
printtest(t);
cmpfail(mtod(m, const void *), m->m_pkthdr.len,
- t->plaintext, t_plaintext_len);
+ t->plaintext, t->plaintext_len);
goto bad;
}
m_freem(m);
- ieee80211_crypto_delkey(ic, &key);
+ ieee80211_crypto_delkey(vap, &key);
printf("PASS\n");
return 1;
bad:
if (m != NULL)
m_freem(m);
- ieee80211_crypto_delkey(ic, &key);
+ ieee80211_crypto_delkey(vap, &key);
return 0;
}
@@ -704,26 +706,38 @@
static int
init_crypto_ccmp_test(void)
{
-#define N(a) (sizeof(a)/sizeof(a[0]))
struct ieee80211com ic;
+ struct ieee80211vap vap;
+ struct ifnet ifp;
int i, pass, total;
memset(&ic, 0, sizeof(ic));
- if (debug)
- ic.ic_debug = IEEE80211_MSG_CRYPTO;
+ memset(&vap, 0, sizeof(vap));
+ memset(&ifp, 0, sizeof(ifp));
+
ieee80211_crypto_attach(&ic);
+ /* some minimal initialization */
+ strncpy(ifp.if_xname, "test_ccmp", sizeof(ifp.if_xname));
+ vap.iv_ic = ⁣
+ vap.iv_ifp = &ifp;
+ if (debug)
+ vap.iv_debug = IEEE80211_MSG_CRYPTO;
+ ieee80211_crypto_vattach(&vap);
+
pass = 0;
total = 0;
- for (i = 0; i < N(ccmptests); i++)
+ for (i = 0; i < nitems(ccmptests); i++)
if (tests & (1<<i)) {
total++;
- pass += runtest(&ic, &ccmptests[i]);
+ pass += runtest(&vap, &ccmptests[i]);
}
printf("%u of %u 802.11i AES-CCMP test vectors passed\n", pass, total);
+
+ ieee80211_crypto_vdetach(&vap);
ieee80211_crypto_detach(&ic);
+
return (pass == total ? 0 : -1);
-#undef N
}
static int
Index: tools/regression/net80211/tkip/test_tkip.c
===================================================================
--- tools/regression/net80211/tkip/test_tkip.c
+++ tools/regression/net80211/tkip/test_tkip.c
@@ -43,6 +43,7 @@
#include <sys/socket.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_media.h>
#include <net80211/ieee80211_var.h>
@@ -179,14 +180,14 @@
}
static int
-runtest(struct ieee80211com *ic, struct ciphertest *t)
+runtest(struct ieee80211vap *vap, struct ciphertest *t)
{
struct tkip_ctx *ctx;
struct ieee80211_key key;
struct mbuf *m = NULL;
const struct ieee80211_cipher *cip;
- u_int8_t mac[IEEE80211_ADDR_LEN];
u_int len;
+ int hdrlen;
printf("%s: ", t->name);
@@ -196,7 +197,7 @@
memset(&key, 0, sizeof(key));
key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
key.wk_cipher = &ieee80211_cipher_none;
- if (!ieee80211_crypto_newkey(ic, IEEE80211_CIPHER_TKIP,
+ if (!ieee80211_crypto_newkey(vap, t->cipher,
IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, &key)) {
printf("FAIL: ieee80211_crypto_newkey failed\n");
goto bad;
@@ -204,9 +205,9 @@
memcpy(key.wk_key, t->key, t->key_len);
key.wk_keylen = 128/NBBY;
- key.wk_keyrsc = 0;
+ memset(key.wk_keyrsc, 0, sizeof(key.wk_keyrsc));
key.wk_keytsc = t->pn;
- if (!ieee80211_crypto_setkey(ic, &key, mac)) {
+ if (!ieee80211_crypto_setkey(vap, &key)) {
printf("FAIL: ieee80211_crypto_setkey failed\n");
goto bad;
}
@@ -221,11 +222,12 @@
memcpy(mtod(m, void *), t->plaintext, len);
m->m_len = len;
m->m_pkthdr.len = m->m_len;
+ hdrlen = ieee80211_anyhdrsize(mtod(m, void *));
/*
* Add MIC.
*/
- if (!ieee80211_crypto_enmic(ic, &key, m)) {
+ if (!ieee80211_crypto_enmic(vap, &key, m, 1)) {
printf("FAIL: tkip enmic failed\n");
goto bad;
}
@@ -281,7 +283,7 @@
/*
* Decrypt frame.
*/
- if (!cip->ic_decap(&key, m)) {
+ if (!cip->ic_decap(&key, m, hdrlen)) {
printf("tkip decap failed\n");
/*
* Check reason for failure: phase1, phase2, frame data (ICV).
@@ -319,17 +321,19 @@
/*
* De-MIC decrypted frame.
*/
- if (!ieee80211_crypto_demic(ic, &key, m)) {
+ if (!ieee80211_crypto_demic(vap, &key, m, 1)) {
printf("FAIL: tkip demic failed\n");
goto bad;
}
/* XXX check frame length and contents... */
+ m_freem(m);
+ ieee80211_crypto_delkey(vap, &key);
printf("PASS\n");
return 1;
bad:
if (m != NULL)
m_freem(m);
- ieee80211_crypto_delkey(ic, &key);
+ ieee80211_crypto_delkey(vap, &key);
return 0;
}
@@ -343,26 +347,38 @@
static int
init_crypto_tkip_test(void)
{
-#define N(a) (sizeof(a)/sizeof(a[0]))
struct ieee80211com ic;
+ struct ieee80211vap vap;
+ struct ifnet ifp;
int i, pass, total;
memset(&ic, 0, sizeof(ic));
- if (debug)
- ic.ic_debug = IEEE80211_MSG_CRYPTO;
+ memset(&vap, 0, sizeof(vap));
+ memset(&ifp, 0, sizeof(ifp));
+
ieee80211_crypto_attach(&ic);
+ /* some minimal initialization */
+ strncpy(ifp.if_xname, "test_ccmp", sizeof(ifp.if_xname));
+ vap.iv_ic = ⁣
+ vap.iv_ifp = &ifp;
+ if (debug)
+ vap.iv_debug = IEEE80211_MSG_CRYPTO;
+ ieee80211_crypto_vattach(&vap);
+
pass = 0;
total = 0;
- for (i = 0; i < N(tkiptests); i++)
+ for (i = 0; i < nitems(tkiptests); i++)
if (tests & (1<<i)) {
total++;
- pass += runtest(&ic, &tkiptests[i]);
+ pass += runtest(&vap, &tkiptests[i]);
}
printf("%u of %u 802.11i TKIP test vectors passed\n", pass, total);
+
+ ieee80211_crypto_vdetach(&vap);
ieee80211_crypto_detach(&ic);
+
return (pass == total ? 0 : -1);
-#undef N
}
static int
Index: tools/regression/net80211/wep/test_wep.c
===================================================================
--- tools/regression/net80211/wep/test_wep.c
+++ tools/regression/net80211/wep/test_wep.c
@@ -53,6 +53,7 @@
#include <sys/socket.h>
#include <net/if.h>
+#include <net/if_var.h>
#include <net/if_media.h>
#include <net80211/ieee80211_var.h>
@@ -178,18 +179,19 @@
}
struct wep_ctx_hw { /* for use with h/w support */
- struct ieee80211com *wc_ic; /* for diagnostics */
- u_int32_t wc_iv; /* initial vector for crypto */
+ struct ieee80211vap *wc_vap; /* for diagnostics+statistics */
+ struct ieee80211com *wc_ic;
+ uint32_t wc_iv; /* initial vector for crypto */
};
static int
-runtest(struct ieee80211com *ic, struct ciphertest *t)
+runtest(struct ieee80211vap *vap, struct ciphertest *t)
{
struct ieee80211_key key;
struct mbuf *m = NULL;
const struct ieee80211_cipher *cip;
- u_int8_t mac[IEEE80211_ADDR_LEN];
struct wep_ctx_hw *ctx;
+ int hdrlen;
printf("%s: ", t->name);
@@ -199,7 +201,7 @@
memset(&key, 0, sizeof(key));
key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
key.wk_cipher = &ieee80211_cipher_none;
- if (!ieee80211_crypto_newkey(ic, t->cipher,
+ if (!ieee80211_crypto_newkey(vap, t->cipher,
IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, &key)) {
printf("FAIL: ieee80211_crypto_newkey failed\n");
goto bad;
@@ -207,11 +209,10 @@
memcpy(key.wk_key, t->key, t->key_len);
key.wk_keylen = t->key_len;
- if (!ieee80211_crypto_setkey(ic, &key, mac)) {
+ if (!ieee80211_crypto_setkey(vap, &key)) {
printf("FAIL: ieee80211_crypto_setkey failed\n");
goto bad;
}
- cip = key.wk_cipher;
/*
* Craft frame from plaintext data.
@@ -221,11 +222,12 @@
memcpy(mtod(m, void *), t->encrypted, t->encrypted_len);
m->m_len = t->encrypted_len;
m->m_pkthdr.len = m->m_len;
+ hdrlen = ieee80211_anyhdrsize(mtod(m, void *));
/*
* Decrypt frame.
*/
- if (!cip->ic_decap(&key, m)) {
+ if (!cip->ic_decap(&key, m, hdrlen)) {
printf("FAIL: wep decap failed\n");
cmpfail(mtod(m, const void *), m->m_pkthdr.len,
t->plaintext, t->plaintext_len);
@@ -250,6 +252,8 @@
* Encrypt frame.
*/
ctx = (struct wep_ctx_hw *) key.wk_private;
+ ctx->wc_vap = vap;
+ ctx->wc_ic = vap->iv_ic;
memcpy(&ctx->wc_iv, t->iv, sizeof(t->iv)); /* for encap/encrypt */
if (!cip->ic_encap(&key, m, t->keyix<<6)) {
printf("FAIL: wep encap failed\n");
@@ -271,13 +275,13 @@
goto bad;
}
m_freem(m);
- ieee80211_crypto_delkey(ic, &key);
+ ieee80211_crypto_delkey(vap, &key);
printf("PASS\n");
return 1;
bad:
if (m != NULL)
m_freem(m);
- ieee80211_crypto_delkey(ic, &key);
+ ieee80211_crypto_delkey(vap, &key);
return 0;
}
@@ -291,25 +295,38 @@
static int
init_crypto_wep_test(void)
{
-#define N(a) (sizeof(a)/sizeof(a[0]))
struct ieee80211com ic;
+ struct ieee80211vap vap;
+ struct ifnet ifp;
int i, pass, total;
memset(&ic, 0, sizeof(ic));
- if (debug)
- ic.ic_debug = IEEE80211_MSG_CRYPTO;
+ memset(&vap, 0, sizeof(vap));
+ memset(&ifp, 0, sizeof(ifp));
+
ieee80211_crypto_attach(&ic);
+
+ /* some minimal initialization */
+ strncpy(ifp.if_xname, "test_ccmp", sizeof(ifp.if_xname));
+ vap.iv_ic = ⁣
+ vap.iv_ifp = &ifp;
+ if (debug)
+ vap.iv_debug = IEEE80211_MSG_CRYPTO;
+ ieee80211_crypto_vattach(&vap);
+
pass = 0;
total = 0;
- for (i = 0; i < N(weptests); i++)
+ for (i = 0; i < nitems(weptests); i++)
if (tests & (1<<i)) {
total++;
- pass += runtest(&ic, &weptests[i]);
+ pass += runtest(&vap, &weptests[i]);
}
printf("%u of %u 802.11i WEP test vectors passed\n", pass, total);
+
+ ieee80211_crypto_vdetach(&vap);
ieee80211_crypto_detach(&ic);
+
return (pass == total ? 0 : -1);
-#undef N
}
static int
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 5, 4:18 AM (19 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29270366
Default Alt Text
D3441.id8086.diff (10 KB)
Attached To
Mode
D3441: tools/regression/net80211: unbreak
Attached
Detach File
Event Timeline
Log In to Comment