Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/net80211 Initialize all avail ciphers.



details:   https://anonhg.NetBSD.org/src-all/rev/565a242dccc2
branches:  trunk
changeset: 374882:565a242dccc2
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Fri May 08 07:09:14 2020 +1000

description:
Initialize all avail ciphers.
Avoid an unnecessary panic if we don't have a particular cipher.

diffstat:

 sys/net80211/ieee80211_crypto.c      |  7 ++++++-
 sys/net80211/ieee80211_crypto.h      |  3 +++
 sys/net80211/ieee80211_crypto_ccmp.c |  6 +++---
 sys/net80211/ieee80211_crypto_tkip.c |  2 +-
 sys/net80211/ieee80211_crypto_wep.c  |  2 +-
 5 files changed, 14 insertions(+), 6 deletions(-)

diffs (84 lines):

diff -r cdc4f3504526 -r 565a242dccc2 sys/net80211/ieee80211_crypto.c
--- a/sys/net80211/ieee80211_crypto.c   Sat May 02 15:32:09 2020 +0200
+++ b/sys/net80211/ieee80211_crypto.c   Fri May 08 07:09:14 2020 +1000
@@ -165,6 +165,9 @@ ieee80211_crypto_attach(struct ieee80211
 {
        /* NB: we assume everything is pre-zero'd */
        ciphers[IEEE80211_CIPHER_NONE] = &ieee80211_cipher_none;
+       ciphers[IEEE80211_CIPHER_TKIP] = &tkip;
+       ciphers[IEEE80211_CIPHER_WEP] = &wep;
+       ciphers[IEEE80211_CIPHER_AES_CCM] = &ccmp;
 }
 
 /*
@@ -333,7 +336,9 @@ ieee80211_crypto_newkey(struct ieee80211
                        return 0;
                }
 #else
-               panic("wlan_cipher not usable.");    /* NNN NetBSD modules? */
+               IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
+                   "%s: no support for cipher %d\n", __func__, cipher);
+               return 0;
 #endif
        }
 
diff -r cdc4f3504526 -r 565a242dccc2 sys/net80211/ieee80211_crypto.h
--- a/sys/net80211/ieee80211_crypto.h   Sat May 02 15:32:09 2020 +0200
+++ b/sys/net80211/ieee80211_crypto.h   Fri May 08 07:09:14 2020 +1000
@@ -200,6 +200,9 @@ struct ieee80211_cipher {
        int     (*ic_demic)(struct ieee80211_key *, struct mbuf *, int);
 };
 extern const struct ieee80211_cipher ieee80211_cipher_none;
+extern const struct ieee80211_cipher tkip;
+extern const struct ieee80211_cipher ccmp;
+extern const struct ieee80211_cipher wep;
 
 #define        IEEE80211_KEY_UNDEFINED(k) \
        ((k)->wk_cipher == &ieee80211_cipher_none)
diff -r cdc4f3504526 -r 565a242dccc2 sys/net80211/ieee80211_crypto_ccmp.c
--- a/sys/net80211/ieee80211_crypto_ccmp.c      Sat May 02 15:32:09 2020 +0200
+++ b/sys/net80211/ieee80211_crypto_ccmp.c      Fri May 08 07:09:14 2020 +1000
@@ -92,7 +92,7 @@ static        int ccmp_decap(struct ieee80211_k
 static int ccmp_enmic(struct ieee80211_key *, struct mbuf *, int);
 static int ccmp_demic(struct ieee80211_key *, struct mbuf *, int);
 
-static const struct ieee80211_cipher ccmp = {
+const struct ieee80211_cipher ccmp = {
        .ic_name        = "AES-CCM",
        .ic_cipher      = IEEE80211_CIPHER_AES_CCM,
        .ic_header      = IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN +
@@ -259,8 +259,8 @@ ccmp_decap(struct ieee80211_key *k, stru
        struct ccmp_ctx *ctx = k->wk_private;
        struct ieee80211vap *vap = ctx->cc_vap;
        struct ieee80211_frame *wh;
-       uint8_t *ivp, tid;
-       uint64_t pn;
+       uint8_t *ivp, tid = 0;
+       uint64_t pn = 0;
 
        rxs = ieee80211_get_rx_params_ptr(m);
 
diff -r cdc4f3504526 -r 565a242dccc2 sys/net80211/ieee80211_crypto_tkip.c
--- a/sys/net80211/ieee80211_crypto_tkip.c      Sat May 02 15:32:09 2020 +0200
+++ b/sys/net80211/ieee80211_crypto_tkip.c      Fri May 08 07:09:14 2020 +1000
@@ -81,7 +81,7 @@ static        int tkip_enmic(struct ieee80211_k
 static int tkip_decap(struct ieee80211_key *, struct mbuf *, int);
 static int tkip_demic(struct ieee80211_key *, struct mbuf *, int);
 
-static const struct ieee80211_cipher tkip  = {
+const struct ieee80211_cipher tkip  = {
        .ic_name        = "TKIP",
        .ic_cipher      = IEEE80211_CIPHER_TKIP,
        .ic_header      = IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN +
diff -r cdc4f3504526 -r 565a242dccc2 sys/net80211/ieee80211_crypto_wep.c
--- a/sys/net80211/ieee80211_crypto_wep.c       Sat May 02 15:32:09 2020 +0200
+++ b/sys/net80211/ieee80211_crypto_wep.c       Fri May 08 07:09:14 2020 +1000
@@ -78,7 +78,7 @@ static        int wep_decap(struct ieee80211_ke
 static int wep_enmic(struct ieee80211_key *, struct mbuf *, int);
 static int wep_demic(struct ieee80211_key *, struct mbuf *, int);
 
-static const struct ieee80211_cipher wep = {
+const struct ieee80211_cipher wep = {
        .ic_name        = "WEP",
        .ic_cipher      = IEEE80211_CIPHER_WEP,
        .ic_header      = IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN,



Home | Main Index | Thread Index | Old Index