Author: avos
Date: Thu Oct 22 17:08:12 2015
New Revision: 289762
URL: https://svnweb.freebsd.org/changeset/base/289762
Log:
Unbreak regression testing tools for net80211 crypto cipher modules
Approved by: adrian (mentor)
Differential Revision:https://reviews.freebsd.org/D3441
Modified:
head/tools/regression/net80211/ccmp/test_ccmp.c
head/tools/regression/net80211/tkip/test_tkip.c
head/tools/regression/net80211/wep/test_wep.c
Modified: head/tools/regression/net80211/ccmp/test_ccmp.c
==
--- head/tools/regression/net80211/ccmp/test_ccmp.c Thu Oct 22 16:46:30
2015(r289761)
+++ head/tools/regression/net80211/ccmp/test_ccmp.c Thu Oct 22 17:08:12
2015(r289762)
@@ -53,6 +53,7 @@
#include
#include
+#include
#include
#include
@@ -591,32 +592,32 @@ printtest(const struct ciphertest *t)
}
static int
-runtest(struct ieee80211com *ic, struct ciphertest *t)
+runtest(struct ieee80211vap *vap, struct ciphertest *t)
{
- struct ieee80211_key key;
+ struct ieee80211_key *key = >iv_nw_keys[t->keyix];
struct mbuf *m = NULL;
const struct ieee80211_cipher *cip;
- u_int8_t mac[IEEE80211_ADDR_LEN];
+ int hdrlen;
printf("%s: ", t->name);
/*
* Setup key.
*/
- memset(, 0, sizeof(key));
- key.wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
- key.wk_cipher = _cipher_none;
- if (!ieee80211_crypto_newkey(ic, t->cipher,
- IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, )) {
+ memset(key, 0, sizeof(*key));
+ key->wk_flags = IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV;
+ key->wk_cipher = _cipher_none;
+ if (!ieee80211_crypto_newkey(vap, t->cipher,
+ IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, key)) {
printf("FAIL: ieee80211_crypto_newkey failed\n");
goto bad;
}
- memcpy(key.wk_key, t->key, t->key_len);
- key.wk_keylen = t->key_len;
- key.wk_keyrsc = 0;
- key.wk_keytsc = t->pn-1;/* PN-1 since we do encap */
- if (!ieee80211_crypto_setkey(ic, , mac)) {
+ memcpy(key->wk_key, t->key, t->key_len);
+ key->wk_keylen = t->key_len;
+ 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(vap, key)) {
printf("FAIL: ieee80211_crypto_setkey failed\n");
goto bad;
}
@@ -624,17 +625,18 @@ runtest(struct ieee80211com *ic, struct
/*
* Craft frame from plaintext data.
*/
- cip = key.wk_cipher;
+ cip = key->wk_cipher;
m = m_getcl(M_NOWAIT, MT_HEADER, M_PKTHDR);
m->m_data += cip->ic_header;
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.
*/
- if (!cip->ic_encap(, m, t->keyix<<6)) {
+ if (!cip->ic_encap(key, m)) {
printtest(t);
printf("FAIL: ccmp encap failed\n");
goto bad;
@@ -660,7 +662,7 @@ runtest(struct ieee80211com *ic, struct
/*
* Decrypt frame; strip MIC.
*/
- if (!cip->ic_decap(, 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 @@ runtest(struct ieee80211com *ic, struct
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, );
+ ieee80211_crypto_delkey(vap, key);
printf("PASS\n");
return 1;
bad:
if (m != NULL)
m_freem(m);
- ieee80211_crypto_delkey(ic, );
+ ieee80211_crypto_delkey(vap, key);
return 0;
}
@@ -704,26 +706,38 @@ staticint debug = 0;
static int
init_crypto_ccmp_test(void)
{
-#defineN(a)(sizeof(a)/sizeof(a[0]))
struct ieee80211com ic;
+ struct ieee80211vap vap;
+ struct ifnet ifp;
int i, pass, total;
memset(, 0, sizeof(ic));
- if (debug)
- ic.ic_debug = IEEE80211_MSG_CRYPTO;
+ memset(, 0, sizeof(vap));
+ memset(, 0, sizeof(ifp));
+
ieee80211_crypto_attach();
+ /* some minimal initialization */
+ strncpy(ifp.if_xname, "test_ccmp", sizeof(ifp.if_xname));
+ vap.iv_ic =
+ vap.iv_ifp =
+ if (debug)
+ vap.iv_debug