Compare commits

..

24 Commits

Author SHA1 Message Date
Sophie Brun
08116e23bd Update debian/changelog 2021-09-28 11:00:37 +02:00
Sophie Brun
ab187afc15 Refresh patches 2021-09-28 10:59:57 +02:00
Sophie Brun
167db73ddf Update upstream source from tag 'upstream/5.3.9_git20210504.6146193'
Update to upstream version '5.3.9~git20210504.6146193'
with Debian dir 89874ea436
2021-09-28 10:26:46 +02:00
Sophie Brun
e01e3993b3 New upstream version 5.3.9~git20210504.6146193 2021-09-28 10:26:41 +02:00
Sophie Brun
5e25e5ab54 Prepare for Release 2021-07-13 10:50:58 +02:00
Sophie Brun
5bb00118be Blacklist r8188eu 2021-07-13 10:50:03 +02:00
Sophie Brun
aa31120624 Bump Standards-Version to 4.5.1 2021-07-13 09:57:03 +02:00
Sophie Brun
9aa2cd13ac Prepare for Release 2021-04-14 17:25:54 +02:00
Sophie Brun
ca373d4356 Refresh patches 2021-04-14 17:24:58 +02:00
Sophie Brun
aae9cdee3b Update upstream source from tag 'upstream/5.3.9_git20210206.1e7145f'
Update to upstream version '5.3.9~git20210206.1e7145f'
with Debian dir 80bf993a47
2021-04-14 16:49:07 +02:00
Sophie Brun
322a5f0ea6 New upstream version 5.3.9~git20210206.1e7145f 2021-04-14 16:49:02 +02:00
Sophie Brun
e2969545f3 Update debian/watch 2021-04-14 16:45:01 +02:00
Sophie Brun
da9706496e Prepare for Release 2021-01-26 17:06:51 +01:00
Sophie Brun
e105322274 Refresh patches 2021-01-26 17:06:28 +01:00
Sophie Brun
f074eb5844 Update upstream source from tag 'upstream/5.3.9_git20201227'
Update to upstream version '5.3.9~git20201227'
with Debian dir 26f5989d84
2021-01-26 17:02:05 +01:00
Sophie Brun
f075fe14db New upstream version 5.3.9~git20201227 2021-01-26 17:01:57 +01:00
Sophie Brun
ec3c163afd Fix errors introduced in 5a7f22dc1f 2020-09-16 16:01:10 +02:00
Sophie Brun
fb75a987dd Prepare release 2020-09-16 15:17:16 +02:00
Sophie Brun
5a7f22dc1f Add lintian-overrides for dh-exec-subst-unknown-variable 2020-09-16 15:17:16 +02:00
Sophie Brun
6cdb6d8145 Bump Standards-Version to 4.5.0 2020-09-16 15:17:16 +02:00
Sophie Brun
3ed934f66a Add comment in debian/copyright 2020-09-16 15:17:16 +02:00
Sophie Brun
2e8ec02f30 Refresh patches 2020-09-16 15:17:16 +02:00
Sophie Brun
bb80d9b37d Update upstream source from tag 'upstream/5.3.9_git20200829'
Update to upstream version '5.3.9~git20200829'
with Debian dir e0e5993025
2020-09-16 15:00:55 +02:00
Sophie Brun
739e000bbf New upstream version 5.3.9~git20200829 2020-09-16 15:00:46 +02:00
24 changed files with 13890 additions and 88 deletions

0
.gitgnore Normal file
View File

View File

@@ -10,6 +10,11 @@ EXTRA_CFLAGS += -Wno-unused
EXTRA_CFLAGS += -Wno-vla
EXTRA_CFLAGS += -Wno-date-time
REDHAT_VER := $(shell cut -f4 -d" " /etc/redhat-release |cut -d"." -f1,2 )
ifeq ($(REDHAT_VER), 7.9)
EXTRA_CFLAGS += -DRHEL79
endif
GCC_VER_49 := $(shell echo `$(CC) -dumpversion | cut -f1-2 -d.` \>= 4.9 | bc )
ifeq ($(GCC_VER_49),1)
EXTRA_CFLAGS += -Wno-date-time # Fix compile error && warning on gcc 4.9 and later
@@ -159,8 +164,6 @@ CONFIG_PLATFORM_PPC64LE = n
CONFIG_DRVEXT_MODULE = n
export TopDIR ?= $(shell pwd)
########### COMMON #################################
ifeq ($(CONFIG_GSPI_HCI), y)
HCI_NAME = gspi
@@ -775,16 +778,16 @@ endif
ifeq ($(CONFIG_AUTOCFG_CP), y)
ifeq ($(CONFIG_MULTIDRV), y)
$(shell cp $(TopDIR)/autoconf_multidrv_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
$(shell cp autoconf_multidrv_$(HCI_NAME)_linux.h include/autoconf.h)
else
ifeq ($(CONFIG_RTL8188E)$(CONFIG_SDIO_HCI),yy)
$(shell cp $(TopDIR)/autoconf_rtl8189e_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
$(shell cp autoconf_rtl8189e_$(HCI_NAME)_linux.h include/autoconf.h)
else ifeq ($(CONFIG_RTL8188F)$(CONFIG_SDIO_HCI),yy)
$(shell cp $(TopDIR)/autoconf_rtl8189f_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
$(shell cp autoconf_rtl8189f_$(HCI_NAME)_linux.h include/autoconf.h)
else ifeq ($(CONFIG_RTL8723C),y)
$(shell cp $(TopDIR)/autoconf_rtl8723c_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
$(shell cp autoconf_rtl8723c_$(HCI_NAME)_linux.h include/autoconf.h)
else
$(shell cp $(TopDIR)/autoconf_$(RTL871X)_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h)
$(shell cp autoconf_$(RTL871X)_$(HCI_NAME)_linux.h include/autoconf.h)
endif
endif
@@ -1032,7 +1035,8 @@ EXTRA_CFLAGS += -DDM_ODM_SUPPORT_TYPE=0x04
ifeq ($(CONFIG_PLATFORM_I386_PC), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
SUBARCH := $(shell uname -m | sed -e "s/i.86/i386/; s/ppc64le/powerpc/; s/ppc/powerpc/; s/armv.l/arm/; s/aarch64/arm64/;")ARCH ?= $(SUBARCH)
SUBARCH := $(shell uname -m | sed -e "s/i.86/i386/; s/ppc64le/powerpc/; s/ppc/powerpc/; s/armv.l/arm/; s/aarch64/arm64/;")
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
KVER := $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build

View File

@@ -1,3 +1,6 @@
Like https://github.com/cccooo/rtl8812au-centos-7.6, forked from aircrack-ng/rtl8188eus and modified for CentOS 7.9
as CentOS Kernel 3.10 contains many code from 4.x
## rtl8188eus v5.3.9
# Realtek rtl8188eus & rtl8188eu & rtl8188etv WiFi drivers
@@ -18,19 +21,19 @@
* MESH Support
* Monitor mode
* Frame injection
* Up to kernel v5.3+
* Up to kernel v5.8+
... And a bunch of various wifi chipsets
# Howto build/install
1. You will need to blacklist another driver in order to use this one.
2. "echo "blacklist r8188eu" > "/etc/modprobe.d/realtek.conf"
3. "make && make install"<br>
2. `echo 'blacklist r8188eu'|sudo tee -a '/etc/modprobe.d/realtek.conf'`
3. `make && sudo make install`
4. Reboot in order to blacklist and load the new driver/module.
# MONITOR MODE howto
Use these steps to enter monitor mode.
```
$ sudo airmon-ng check-kill
$ sudo airmon-ng check kill
$ sudo ip link set <interface> down
$ sudo iw dev <interface> set type monitor
```
@@ -42,7 +45,7 @@ $ aireplay -9 <interface>
# NetworkManager configuration
Add these lines below to "NetworkManager.conf" and ADD YOUR ADAPTER MAC below [keyfile]
This will make the Network-Manager ignore the device, and therefor don't cause problems.
This will make the Network-Manager ignore the device, and therefore don't cause problems.
```
[device]
wifi.scan-rand-mac-address=no

View File

@@ -2133,7 +2133,7 @@ BIP_exit:
#ifndef PLATFORM_FREEBSD
#if defined(CONFIG_TDLS)
/* compress 512-bits */
static int sha256_compress(struct sha256_state *md, unsigned char *buf)
static int rtw_sha256_compress(struct rtw_sha256_state *md, unsigned char *buf)
{
u32 S[8], W[64], t0, t1;
u32 t;
@@ -2181,7 +2181,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
}
/* Initialize the hash state */
static void sha256_init(struct sha256_state *md)
static void rtw_sha256_init(struct rtw_sha256_state *md)
{
md->curlen = 0;
md->length = 0;
@@ -2202,7 +2202,7 @@ static void sha256_init(struct sha256_state *md)
@param inlen The length of the data (octets)
@return CRYPT_OK if successful
*/
static int sha256_process(struct sha256_state *md, unsigned char *in,
static int rtw_sha256_process(struct rtw_sha256_state *md, unsigned char *in,
unsigned long inlen)
{
unsigned long n;
@@ -2213,7 +2213,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
while (inlen > 0) {
if (md->curlen == 0 && inlen >= block_size) {
if (sha256_compress(md, (unsigned char *) in) < 0)
if (rtw_sha256_compress(md, (unsigned char *) in) < 0)
return -1;
md->length += block_size * 8;
in += block_size;
@@ -2225,7 +2225,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
in += n;
inlen -= n;
if (md->curlen == block_size) {
if (sha256_compress(md, md->buf) < 0)
if (rtw_sha256_compress(md, md->buf) < 0)
return -1;
md->length += 8 * block_size;
md->curlen = 0;
@@ -2243,7 +2243,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
@param out [out] The destination of the hash (32 bytes)
@return CRYPT_OK if successful
*/
static int sha256_done(struct sha256_state *md, unsigned char *out)
static int rtw_sha256_done(struct rtw_sha256_state *md, unsigned char *out)
{
int i;
@@ -2263,7 +2263,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
if (md->curlen > 56) {
while (md->curlen < 64)
md->buf[md->curlen++] = (unsigned char) 0;
sha256_compress(md, md->buf);
rtw_sha256_compress(md, md->buf);
md->curlen = 0;
}
@@ -2273,7 +2273,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
/* store length */
WPA_PUT_BE64(md->buf + 56, md->length);
sha256_compress(md, md->buf);
rtw_sha256_compress(md, md->buf);
/* copy output */
for (i = 0; i < 8; i++)
@@ -2290,17 +2290,17 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
* @mac: Buffer for the hash
* Returns: 0 on success, -1 of failure
*/
static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
static int rtw_sha256_vector(size_t num_elem, u8 *addr[], size_t *len,
u8 *mac)
{
struct sha256_state ctx;
struct rtw_sha256_state ctx;
size_t i;
sha256_init(&ctx);
rtw_sha256_init(&ctx);
for (i = 0; i < num_elem; i++)
if (sha256_process(&ctx, addr[i], len[i]))
if (rtw_sha256_process(&ctx, addr[i], len[i]))
return -1;
if (sha256_done(&ctx, mac))
if (rtw_sha256_done(&ctx, mac))
return -1;
return 0;
}
@@ -2362,7 +2362,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem,
/* if key is longer than 64 bytes reset it to key = SHA256(key) */
if (key_len > 64) {
sha256_vector(1, &key, &key_len, tk);
rtw_sha256_vector(1, &key, &key_len, tk);
key = tk;
key_len = 32;
}
@@ -2390,7 +2390,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem,
_addr[i + 1] = addr[i];
_len[i + 1] = len[i];
}
sha256_vector(1 + num_elem, _addr, _len, mac);
rtw_sha256_vector(1 + num_elem, _addr, _len, mac);
_rtw_memset(k_pad, 0, sizeof(k_pad));
_rtw_memcpy(k_pad, key, key_len);
@@ -2403,7 +2403,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem,
_len[0] = 64;
_addr[1] = mac;
_len[1] = 32;
sha256_vector(2, _addr, _len, mac);
rtw_sha256_vector(2, _addr, _len, mac);
}
#endif /* CONFIG_TDLS */
#endif /* PLATFORM_FREEBSD */
@@ -2422,7 +2422,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem,
*/
#ifndef PLATFORM_FREEBSD /* Baron */
#if defined(CONFIG_TDLS)
static void sha256_prf(u8 *key, size_t key_len, char *label,
static void rtw_sha256_prf(u8 *key, size_t key_len, char *label,
u8 *data, size_t data_len, u8 *buf, size_t buf_len)
{
u16 counter = 1;
@@ -2446,10 +2446,10 @@ static void sha256_prf(u8 *key, size_t key_len, char *label,
while (pos < buf_len) {
plen = buf_len - pos;
WPA_PUT_LE16(counter_le, counter);
if (plen >= SHA256_MAC_LEN) {
if (plen >= RTW_SHA256_MAC_LEN) {
hmac_sha256_vector(key, key_len, 4, addr, len,
&buf[pos]);
pos += SHA256_MAC_LEN;
pos += RTW_SHA256_MAC_LEN;
} else {
hmac_sha256_vector(key, key_len, 4, addr, len, hash);
_rtw_memcpy(&buf[pos], hash, plen);
@@ -3108,7 +3108,7 @@ void wpa_tdls_generate_tpk(_adapter *padapter, void *sta)
nonce[1] = SNonce;
}
sha256_vector(2, nonce, len, key_input);
rtw_sha256_vector(2, nonce, len, key_input);
/*
* TPK-Key-Data = KDF-N_KEY(TPK-Key-Input, "TDLS PMK",
@@ -3127,7 +3127,7 @@ void wpa_tdls_generate_tpk(_adapter *padapter, void *sta)
}
_rtw_memcpy(data + 2 * ETH_ALEN, get_bssid(pmlmepriv), ETH_ALEN);
sha256_prf(key_input, SHA256_MAC_LEN, "TDLS PMK", data, sizeof(data), (u8 *) &psta->tpk, sizeof(psta->tpk));
rtw_sha256_prf(key_input, RTW_SHA256_MAC_LEN, "TDLS PMK", data, sizeof(data), (u8 *) &psta->tpk, sizeof(psta->tpk));
}

45
debian/changelog vendored
View File

@@ -1,3 +1,48 @@
realtek-rtl8188eus-dkms (5.3.9~git20210504.6146193-0kali1) kali-dev; urgency=medium
* New upstream version 5.3.9~git20210504.6146193
* Refresh patches
-- Sophie Brun <sophie@offensive-security.com> Tue, 28 Sep 2021 11:00:05 +0200
realtek-rtl8188eus-dkms (5.3.9~git20210206.1e7145f-0kali2) kali-dev; urgency=medium
* Bump Standards-Version to 4.5.1
* Blacklist r8188eu
-- Sophie Brun <sophie@offensive-security.com> Tue, 13 Jul 2021 10:50:42 +0200
realtek-rtl8188eus-dkms (5.3.9~git20210206.1e7145f-0kali1) kali-dev; urgency=medium
* Update debian/watch
* New upstream version 5.3.9~git20210206.1e7145f
* Refresh patches
-- Sophie Brun <sophie@offensive-security.com> Wed, 14 Apr 2021 17:25:11 +0200
realtek-rtl8188eus-dkms (5.3.9~git20201227-0kali1) kali-dev; urgency=medium
* New upstream version 5.3.9~git20201227
* Refresh patches
-- Sophie Brun <sophie@offensive-security.com> Tue, 26 Jan 2021 17:04:18 +0100
realtek-rtl8188eus-dkms (5.3.9~git20200829-0kali2) kali-dev; urgency=medium
* Fix errors introduced in 5a7f22 (lintian-overrides)
-- Sophie Brun <sophie@offensive-security.com> Wed, 16 Sep 2020 15:54:13 +0200
realtek-rtl8188eus-dkms (5.3.9~git20200829-0kali1) kali-dev; urgency=medium
* New upstream version 5.3.9~git20200829
* Refresh patches
* Add comment in debian/copyright
* Bump Standards-Version to 4.5.0
* Add lintian-overrides for dh-exec-subst-unknown-variable
-- Sophie Brun <sophie@offensive-security.com> Wed, 16 Sep 2020 15:07:29 +0200
realtek-rtl8188eus-dkms (5.3.9~git20200710-0kali1) kali-dev; urgency=medium
* New upstream version 5.3.9~20200710

2
debian/control vendored
View File

@@ -4,7 +4,7 @@ Priority: optional
Maintainer: Kali Developers <devel@kali.org>
Uploaders: Sophie Brun <sophie@offensive-security.com>
Build-Depends: debhelper-compat (= 12), dkms, dh-exec
Standards-Version: 4.4.1
Standards-Version: 4.5.1
Homepage: https://github.com/aircrack-ng/rtl8188eus
Vcs-Browser: https://gitlab.com/kalilinux/packages/realtek-rtl8188eus-dkms
Vcs-Git: https://gitlab.com/kalilinux/packages/realtek-rtl8188eus-dkms.git

1
debian/copyright vendored
View File

@@ -1,6 +1,7 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: realtek-rtl8188eus-dkms
Source: https://github.com/aircrack-ng/rtl8188eus
Comment: dkms package built during installation
Files: *
Copyright: 2007 - 2017 Realtek Corporation.

View File

@@ -2,18 +2,19 @@ From: Sophie Brun <sophie@offensive-security.com>
Date: Fri, 10 Jul 2020 08:49:31 +0200
Subject: Change dkms version
Forwarded: not-needed
---
dkms.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dkms.conf b/dkms.conf
index 1c14127..85db2c2 100644
index 1c14127..bc56f1e 100644
--- a/dkms.conf
+++ b/dkms.conf
@@ -1,5 +1,5 @@
PACKAGE_NAME="realtek-rtl8188eus"
-PACKAGE_VERSION="5.3.9~20200316"
+PACKAGE_VERSION="5.3.9~20200710"
+PACKAGE_VERSION="5.3.9~git20210504.6146193"
CLEAN="'make' clean"
BUILT_MODULE_NAME[0]=8188eu
PROCS_NUM=`nproc`

2
debian/r8188eus-dkms.conf vendored Normal file
View File

@@ -0,0 +1,2 @@
# blacklist the driver
blacklist r8188eu

View File

@@ -1,2 +1,3 @@
#!/usr/bin/dh-exec
core hal include Kconfig Makefile os_dep platform usr/src/realtek-rtl8188eus-${DEB_VERSION_UPSTREAM}
debian/r8188eus-dkms.conf etc/modprobe.d

22
debian/script-targz vendored Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
set -e
if [ "$1" = '--upstream-version' ]; then
new_version="$2"
else
printf "Missing --upstream-version argument" 1>&2
exit 1
fi
DEB_SOURCE="$(dpkg-parsechangelog -SSource)"
default_branch="$(git remote show https://github.com/aircrack-ng/rtl8188eus.git | grep 'HEAD' | sed 's/.*: v//')"
version="$(echo ${new_version} | sed 's/~git.*//')"
# fails if the upstream default branch has changed and is no longer the
# version mentioned in debian/watch
if [ "${default_branch}" != "${version}" ]; then
exit 1
fi

2
debian/source/lintian-overrides vendored Normal file
View File

@@ -0,0 +1,2 @@
#we export the variable provided by /usr/share/dpkg/pkg-info.mk
realtek-rtl8188eus-dkms source: dh-exec-subst-unknown-variable debian/realtek-rtl8188eus-dkms.install DEB_VERSION_UPSTREAM

11
debian/watch vendored
View File

@@ -1,4 +1,9 @@
version=4
opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%realtek-rtl8188eus-dkms-$1.tar.gz%" \
https://github.com/aircrack-ng/rtl8188eus/tags \
(?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate
opts="mode=git, pretty=5.3.9~git%cd.%h, pgpmode=none" \
https://github.com/aircrack-ng/rtl8188eus.git \
HEAD debian debian/script-targz
# Use the following when upstream starts to tag releases:
#opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%realtek-rtl8188eus-dkms-$1.tar.gz%" \
# https://github.com/aircrack-ng/rtl8188eus/tags \
# (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate

View File

@@ -41,7 +41,7 @@ const char *security_type_str(u8 value);
#define _WPA_IE_ID_ 0xdd
#define _WPA2_IE_ID_ 0x30
#define SHA256_MAC_LEN 32
#define RTW_SHA256_MAC_LEN 32
#define AES_BLOCK_SIZE 16
#define AES_PRIV_SIZE (4 * 44)
@@ -249,7 +249,7 @@ struct security_priv {
#define SEC_IS_BIP_KEY_INSTALLED(sec) _FALSE
#endif
struct sha256_state {
struct rtw_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];

9771
ioctl_cfg80211.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -27,7 +27,7 @@
#define DBG_RTW_CFG80211_MESH_CONF 0
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) || defined(RHEL79))
#define STATION_INFO_INACTIVE_TIME BIT(NL80211_STA_INFO_INACTIVE_TIME)
#define STATION_INFO_LLID BIT(NL80211_STA_INFO_LLID)
#define STATION_INFO_PLID BIT(NL80211_STA_INFO_PLID)
@@ -289,7 +289,7 @@ static const char *nl80211_chan_width_str(enum nl80211_chan_width cwidth)
return "80+80";
case NL80211_CHAN_WIDTH_160:
return "160";
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) || defined(RHEL79))
case NL80211_CHAN_WIDTH_5:
return "5";
case NL80211_CHAN_WIDTH_10:
@@ -390,7 +390,7 @@ static void rtw_get_chbw_from_cfg80211_chan_def(struct cfg80211_chan_def *chdef,
*ch = chan->hw_value;
break;
case NL80211_CHAN_WIDTH_80P80:
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) || defined(RHEL79))
case NL80211_CHAN_WIDTH_5:
case NL80211_CHAN_WIDTH_10:
#endif
@@ -686,18 +686,12 @@ static int rtw_cfg80211_sync_iftype(_adapter *adapter)
static u64 rtw_get_systime_us(void)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
struct timespec64 ts;
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0))
struct timespec ts;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
getboottime64(&ts);
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
getboottime(&ts);
#else
get_monotonic_boottime(&ts);
#endif
return ((u64)ts.tv_sec * 1000000) + ts.tv_nsec / 1000;
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0))
return ktime_to_us(ktime_get_boottime());
#else
struct timeval tv;
do_gettimeofday(&tv);
@@ -950,7 +944,7 @@ void rtw_cfg80211_ibss_indicate_connect(_adapter *padapter)
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
struct wireless_dev *pwdev = padapter->rtw_wdev;
struct cfg80211_bss *bss = NULL;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0) || defined(RHEL79))
struct wiphy *wiphy = pwdev->wiphy;
int freq = 2412;
struct ieee80211_channel *notify_channel;
@@ -1008,7 +1002,7 @@ void rtw_cfg80211_ibss_indicate_connect(_adapter *padapter)
RTW_PRINT(FUNC_ADPT_FMT" BSS not found !!\n", FUNC_ADPT_ARG(padapter));
}
/* notify cfg80211 that device joined an IBSS */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0) || defined(RHEL79))
notify_channel = ieee80211_get_channel(wiphy, freq);
cfg80211_ibss_joined(padapter->pnetdev, cur_network->network.MacAddress, notify_channel, GFP_ATOMIC);
#else
@@ -1096,7 +1090,7 @@ check_bss:
struct ieee80211_channel *notify_channel;
u32 freq;
u16 channel = cur_network->network.Configuration.DSConfig;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) || defined(RHEL79))
struct cfg80211_roam_info roam_info;
#endif
@@ -1104,7 +1098,7 @@ check_bss:
notify_channel = ieee80211_get_channel(wiphy, freq);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) || defined(RHEL79))
roam_info.bssid = cur_network->network.MacAddress;
roam_info.req_ie = pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2;
roam_info.req_ie_len = pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2;
@@ -1132,7 +1126,7 @@ check_bss:
rtw_ft_set_status(padapter, RTW_FT_ASSOCIATED_STA);
#endif
} else {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE)
#if !defined(RHEL79) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE))
RTW_INFO("pwdev->sme_state(b)=%d\n", pwdev->sme_state);
#endif
@@ -1143,7 +1137,7 @@ check_bss:
, pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6
, pmlmepriv->assoc_rsp_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 6
, WLAN_STATUS_SUCCESS, GFP_ATOMIC);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE)
#if defined(RHEL79) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE))
RTW_INFO("pwdev->sme_state(a)=%d\n", pwdev->sme_state);
#endif
}
@@ -1199,7 +1193,7 @@ void rtw_cfg80211_indicate_disconnect(_adapter *padapter, u16 reason, u8 locally
_enter_critical_bh(&pwdev_priv->connect_req_lock, &irqL);
if (padapter->ndev_unregistering || !rtw_wdev_not_indic_disco(pwdev_priv)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE)
#if (!defined(RHEL79) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE)))
RTW_INFO("pwdev->sme_state(b)=%d\n", pwdev->sme_state);
if (pwdev->sme_state == CFG80211_SME_CONNECTING) {
@@ -2454,7 +2448,7 @@ void rtw_cfg80211_indicate_scan_done(_adapter *adapter, bool aborted)
struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(adapter);
_irqL irqL;
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE)
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE || defined(RHEL79))
struct cfg80211_scan_info info;
memset(&info, 0, sizeof(info));
@@ -2471,7 +2465,7 @@ void rtw_cfg80211_indicate_scan_done(_adapter *adapter, bool aborted)
if (pwdev_priv->scan_request->wiphy != pwdev_priv->rtw_wdev->wiphy)
RTW_INFO("error wiphy compare\n");
else
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE)
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE || defined(RHEL79))
cfg80211_scan_done(pwdev_priv->scan_request, &info);
#else
cfg80211_scan_done(pwdev_priv->scan_request, aborted);
@@ -3061,7 +3055,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy
check_need_indicate_scan_done:
if (_TRUE == need_indicate_scan_done) {
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE)
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE || defined(RHEL79))
struct cfg80211_scan_info info;
memset(&info, 0, sizeof(info));
@@ -3069,7 +3063,7 @@ check_need_indicate_scan_done:
#endif
_rtw_cfg80211_surveydone_event_callback(padapter, request);
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE)
#if (KERNEL_VERSION(4, 7, 0) <= LINUX_VERSION_CODE || defined(RHEL79))
cfg80211_scan_done(request, &info);
#else
cfg80211_scan_done(request, 0);
@@ -4466,6 +4460,12 @@ static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name,
goto out;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))
mon_ndev->min_mtu = WLAN_MIN_ETHFRM_LEN;
mon_ndev->mtu = WLAN_DATA_MAXLEN;
mon_ndev->max_mtu = WLAN_DATA_MAXLEN;
#endif
mon_ndev->type = ARPHRD_IEEE80211_RADIOTAP;
strncpy(mon_ndev->name, name, IFNAMSIZ);
mon_ndev->name[IFNAMSIZ - 1] = 0;
@@ -7094,6 +7094,11 @@ exit:
return ret;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
static void cfg80211_rtw_update_mgmt_frame_register(struct wiphy *wiphy,
struct wireless_dev *wdev,
struct mgmt_frame_regs *upd)
#else
static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct wireless_dev *wdev,
@@ -7101,12 +7106,12 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
struct net_device *ndev,
#endif
u16 frame_type, bool reg)
#endif
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
struct net_device *ndev = wdev_to_ndev(wdev);
#endif
_adapter *adapter;
struct rtw_wdev_priv *pwdev_priv;
if (ndev == NULL)
@@ -7120,20 +7125,6 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy,
frame_type, reg);
#endif
/* Wait QC Verify */
return;
switch (frame_type) {
case IEEE80211_STYPE_PROBE_REQ: /* 0x0040 */
SET_CFG80211_REPORT_MGMT(pwdev_priv, IEEE80211_STYPE_PROBE_REQ, reg);
break;
case IEEE80211_STYPE_ACTION: /* 0x00D0 */
SET_CFG80211_REPORT_MGMT(pwdev_priv, IEEE80211_STYPE_ACTION, reg);
break;
default:
break;
}
exit:
return;
}
@@ -9121,7 +9112,8 @@ static void rtw_cfg80211_preinit_wiphy(_adapter *adapter, struct wiphy *wiphy)
#endif
#if defined(CONFIG_PM) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0))
LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) && \
!defined(RHEL79))
wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
#ifdef CONFIG_PNO_SUPPORT
wiphy->max_sched_scan_ssids = MAX_PNO_LIST_COUNT;
@@ -9132,7 +9124,7 @@ static void rtw_cfg80211_preinit_wiphy(_adapter *adapter, struct wiphy *wiphy)
#endif
#if defined(CONFIG_PM) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0))
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) && !defined(RHEL79))
wiphy->wowlan = wowlan_stub;
#else
wiphy->wowlan = &wowlan_stub;
@@ -9438,7 +9430,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
.mgmt_tx = cfg80211_rtw_mgmt_tx,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
.update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_register,
#else
.mgmt_frame_register = cfg80211_rtw_mgmt_frame_register,
#endif
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
.action = cfg80211_rtw_mgmt_tx,
#endif

View File

@@ -168,6 +168,10 @@ struct rtw_wdev_priv {
bool block_scan;
bool power_mgmt;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)
u32 mgmt_mask;
#endif
/* report mgmt_frame registered */
u16 report_mgmt;
@@ -358,7 +362,7 @@ void rtw_cfg80211_deinit_rfkill(struct wiphy *wiphy);
#define rtw_cfg80211_connect_result(wdev, bssid, req_ie, req_ie_len, resp_ie, resp_ie_len, status, gfp) cfg80211_connect_result(wdev_to_ndev(wdev), bssid, req_ie, req_ie_len, resp_ie, resp_ie_len, status, gfp)
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) && !defined(RHEL79))
#define rtw_cfg80211_disconnected(wdev, reason, ie, ie_len, locally_generated, gfp) cfg80211_disconnected(wdev_to_ndev(wdev), reason, ie, ie_len, gfp)
#else
#define rtw_cfg80211_disconnected(wdev, reason, ie, ie_len, locally_generated, gfp) cfg80211_disconnected(wdev_to_ndev(wdev), reason, ie, ie_len, locally_generated, gfp)
@@ -380,7 +384,7 @@ void rtw_cfg80211_deinit_rfkill(struct wiphy *wiphy);
u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset, u8 ht);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) && !defined(RHEL79) )
#define NL80211_BAND_2GHZ IEEE80211_BAND_2GHZ
#define NL80211_BAND_5GHZ IEEE80211_BAND_5GHZ
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))

View File

@@ -1513,6 +1513,12 @@ struct net_device *rtw_init_netdev(_adapter *old_padapter)
if (!pnetdev)
return NULL;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))
pnetdev->min_mtu = WLAN_MIN_ETHFRM_LEN;
pnetdev->mtu = WLAN_DATA_MAXLEN;
pnetdev->max_mtu = WLAN_DATA_MAXLEN;
#endif
padapter = rtw_netdev_priv(pnetdev);
padapter->pnetdev = pnetdev;

View File

@@ -354,7 +354,11 @@ static int napi_recv(_adapter *padapter, int budget)
#ifdef CONFIG_RTW_GRO
if (pregistrypriv->en_gro) {
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0))
if (rtw_napi_gro_receive(&padapter->napi, pskb) != GRO_DROP)
#else
if (rtw_napi_gro_receive(&padapter->napi, pskb) != GRO_MERGED_FREE)
#endif
rx_ok = _TRUE;
goto next;
}

View File

@@ -158,6 +158,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
{USB_DEVICE(0x2001, 0x330F), .driver_info = RTL8188E}, /* DLink DWA-125 REV D1 */
{USB_DEVICE(0x2001, 0x3310), .driver_info = RTL8188E}, /* Dlink DWA-123 REV D1 */
{USB_DEVICE(0x2001, 0x3311), .driver_info = RTL8188E}, /* DLink GO-USB-N150 REV B1 */
{USB_DEVICE(0x2001, 0x331B), .driver_info = RTL8188E}, /* DLink DWA-121 REV B1 */
{USB_DEVICE(0x056E, 0x4008), .driver_info = RTL8188E}, /* Elecom WDC-150SU2M */
#endif

View File

@@ -294,7 +294,7 @@ void rtw_regd_apply_flags(struct wiphy *wiphy)
&& rtw_odm_dfs_domain_unknown(padapter)
#endif
) {
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) && !defined(RHEL79))
ch->flags = (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_PASSIVE_SCAN);
#else
ch->flags = IEEE80211_CHAN_NO_IR;
@@ -309,7 +309,7 @@ void rtw_regd_apply_flags(struct wiphy *wiphy)
#endif
) {
ch->flags |= IEEE80211_CHAN_RADAR;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) && !defined(RHEL79))
ch->flags |= (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_PASSIVE_SCAN);
#else
ch->flags |= IEEE80211_CHAN_NO_IR;
@@ -374,7 +374,7 @@ static void _rtw_regd_init_wiphy(struct rtw_regulatory *reg, struct wiphy *wiphy
wiphy->reg_notifier = rtw_reg_notifier;
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) && !defined(RHEL79))
wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy->flags &= ~WIPHY_FLAG_STRICT_REGULATORY;
wiphy->flags &= ~WIPHY_FLAG_DISABLE_BEACON_HINTS;

View File

@@ -2139,15 +2139,19 @@ static int isFileReadable(const char *path, u32 *sz)
{
struct file *fp;
int ret = 0;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs;
#endif
char buf;
fp = filp_open(path, O_RDONLY, 0);
if (IS_ERR(fp))
ret = PTR_ERR(fp);
else {
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
if (1 != readFile(fp, &buf, 1))
ret = PTR_ERR(fp);
@@ -2159,8 +2163,9 @@ static int isFileReadable(const char *path, u32 *sz)
*sz = i_size_read(fp->f_dentry->d_inode);
#endif
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
filp_close(fp, NULL);
}
return ret;
@@ -2176,7 +2181,9 @@ static int isFileReadable(const char *path, u32 *sz)
static int retriveFromFile(const char *path, u8 *buf, u32 sz)
{
int ret = -1;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs;
#endif
struct file *fp;
if (path && buf) {
@@ -2184,10 +2191,14 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
ret = readFile(fp, buf, sz);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
closeFile(fp);
RTW_INFO("%s readFile, ret:%d\n", __FUNCTION__, ret);
@@ -2211,7 +2222,9 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
static int storeToFile(const char *path, u8 *buf, u32 sz)
{
int ret = 0;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs;
#endif
struct file *fp;
if (path && buf) {
@@ -2219,10 +2232,14 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
ret = writeFile(fp, buf, sz);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
closeFile(fp);
RTW_INFO("%s writeFile, ret:%d\n", __FUNCTION__, ret);
@@ -2324,6 +2341,12 @@ struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_p
if (!pnetdev)
goto RETURN;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))
pnetdev->min_mtu = WLAN_MIN_ETHFRM_LEN;
pnetdev->mtu = WLAN_MAX_ETHFRM_LEN;
pnetdev->max_mtu = WLAN_DATA_MAXLEN;
#endif
pnpi = netdev_priv(pnetdev);
pnpi->priv = old_priv;
pnpi->sizeof_priv = sizeof_priv;
@@ -2345,6 +2368,12 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv)
if (!pnetdev)
goto RETURN;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))
pnetdev->min_mtu = WLAN_MIN_ETHFRM_LEN;
pnetdev->mtu = WLAN_MAX_ETHFRM_LEN;
pnetdev->max_mtu = WLAN_DATA_MAXLEN;
#endif
pnpi = netdev_priv(pnetdev);
pnpi->priv = rtw_zvmalloc(sizeof_priv);

3408
rtw_security.c Normal file

File diff suppressed because it is too large Load Diff

497
rtw_security.h Normal file
View File

@@ -0,0 +1,497 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*****************************************************************************/
#ifndef __RTW_SECURITY_H_
#define __RTW_SECURITY_H_
#define _NO_PRIVACY_ 0x0
#define _WEP40_ 0x1
#define _TKIP_ 0x2
#define _TKIP_WTMIC_ 0x3
#define _AES_ 0x4
#define _WEP104_ 0x5
#define _SMS4_ 0x06
#define _WEP_WPA_MIXED_ 0x07 /* WEP + WPA */
#define _BIP_ 0x8
/* 802.11W use wrong key */
#define IEEE80211W_RIGHT_KEY 0x0
#define IEEE80211W_WRONG_KEY 0x1
#define IEEE80211W_NO_KEY 0x2
#define CCMPH_2_PN(ch) ((ch) & 0x000000000000ffff) \
| (((ch) & 0xffffffff00000000) >> 16)
#define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_))
const char *security_type_str(u8 value);
#define _WPA_IE_ID_ 0xdd
#define _WPA2_IE_ID_ 0x30
#define RTW_SHA256_MAC_LEN 32
#define AES_BLOCK_SIZE 16
#define AES_PRIV_SIZE (4 * 44)
#define RTW_KEK_LEN 16
#define RTW_KCK_LEN 16
#define RTW_TKIP_MIC_LEN 8
#define RTW_REPLAY_CTR_LEN 8
#define INVALID_SEC_MAC_CAM_ID 0xFF
typedef enum {
ENCRYP_PROTOCOL_OPENSYS, /* open system */
ENCRYP_PROTOCOL_WEP, /* WEP */
ENCRYP_PROTOCOL_WPA, /* WPA */
ENCRYP_PROTOCOL_WPA2, /* WPA2 */
ENCRYP_PROTOCOL_WAPI, /* WAPI: Not support in this version */
ENCRYP_PROTOCOL_MAX
} ENCRYP_PROTOCOL_E;
#ifndef Ndis802_11AuthModeWPA2
#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1)
#endif
#ifndef Ndis802_11AuthModeWPA2PSK
#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2)
#endif
union pn48 {
u64 val;
#ifdef CONFIG_LITTLE_ENDIAN
struct {
u8 TSC0;
u8 TSC1;
u8 TSC2;
u8 TSC3;
u8 TSC4;
u8 TSC5;
u8 TSC6;
u8 TSC7;
} _byte_;
#elif defined(CONFIG_BIG_ENDIAN)
struct {
u8 TSC7;
u8 TSC6;
u8 TSC5;
u8 TSC4;
u8 TSC3;
u8 TSC2;
u8 TSC1;
u8 TSC0;
} _byte_;
#endif
};
union Keytype {
u8 skey[16];
u32 lkey[4];
};
typedef struct _RT_PMKID_LIST {
u8 bUsed;
u8 Bssid[6];
u8 PMKID[16];
u8 SsidBuf[33];
u8 *ssid_octet;
u16 ssid_length;
} RT_PMKID_LIST, *PRT_PMKID_LIST;
struct security_priv {
u32 dot11AuthAlgrthm; /* 802.11 auth, could be open, shared, 8021x and authswitch */
u32 dot11PrivacyAlgrthm; /* This specify the privacy for shared auth. algorithm. */
/* WEP */
u32 dot11PrivacyKeyIndex; /* this is only valid for legendary wep, 0~3 for key id. (tx key index) */
union Keytype dot11DefKey[6]; /* this is only valid for def. key */
u32 dot11DefKeylen[6];
u8 dot11Def_camid[6];
u8 key_mask; /* use to restore wep key after hal_init */
u32 dot118021XGrpPrivacy; /* This specify the privacy algthm. used for Grp key */
u32 dot118021XGrpKeyid; /* key id used for Grp Key ( tx key index) */
union Keytype dot118021XGrpKey[6]; /* 802.1x Group Key, for inx0 and inx1 */
union Keytype dot118021XGrptxmickey[6];
union Keytype dot118021XGrprxmickey[6];
union pn48 dot11Grptxpn; /* PN48 used for Grp Key xmit. */
union pn48 dot11Grprxpn; /* PN48 used for Grp Key recv. */
u8 iv_seq[4][8];
#ifdef CONFIG_IEEE80211W
u32 dot11wBIPKeyid; /* key id used for BIP Key ( tx key index) */
union Keytype dot11wBIPKey[6]; /* BIP Key, for index4 and index5 */
union pn48 dot11wBIPtxpn; /* PN48 used for BIP xmit. */
union pn48 dot11wBIPrxpn; /* PN48 used for BIP recv. */
#endif /* CONFIG_IEEE80211W */
#ifdef CONFIG_AP_MODE
/* extend security capabilities for AP_MODE */
unsigned int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
unsigned int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
unsigned int wpa_group_cipher;
unsigned int wpa2_group_cipher;
unsigned int wpa_pairwise_cipher;
unsigned int wpa2_pairwise_cipher;
u8 mfp_opt;
#endif
#ifdef CONFIG_CONCURRENT_MODE
u8 dot118021x_bmc_cam_id;
#endif
/*IEEE802.11-2012 Std. Table 8-101 AKM Suite Selectors*/
u32 rsn_akm_suite_type;
u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */
int wps_ie_len;
u8 binstallGrpkey;
#ifdef CONFIG_GTK_OL
u8 binstallKCK_KEK;
#endif /* CONFIG_GTK_OL */
#ifdef CONFIG_IEEE80211W
u8 binstallBIPkey;
#endif /* CONFIG_IEEE80211W */
u8 busetkipkey;
u8 bcheck_grpkey;
u8 bgrpkey_handshake;
/* u8 packet_cnt; */ /* unused, removed */
s32 sw_encrypt;/* from registry_priv */
s32 sw_decrypt;/* from registry_priv */
s32 hw_decrypted;/* if the rx packets is hw_decrypted==_FALSE, it means the hw has not been ready. */
/* keeps the auth_type & enc_status from upper layer ioctl(wpa_supplicant or wzc) */
u32 ndisauthtype; /* NDIS_802_11_AUTHENTICATION_MODE */
u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */
NDIS_802_11_WEP ndiswep;
#ifdef PLATFORM_WINDOWS
u8 KeyMaterial[16];/* variable length depending on above field. */
#endif
u8 assoc_info[600];
u8 szofcapability[256]; /* for wpa2 usage */
u8 oidassociation[512]; /* for wpa/wpa2 usage */
u8 authenticator_ie[256]; /* store ap security information element */
u8 supplicant_ie[256]; /* store sta security information element */
/* for tkip countermeasure */
systime last_mic_err_time;
u8 btkip_countermeasure;
u8 btkip_wait_report;
systime btkip_countermeasure_time;
/* --------------------------------------------------------------------------- */
/* For WPA2 Pre-Authentication. */
/* --------------------------------------------------------------------------- */
/* u8 RegEnablePreAuth; */ /* Default value: Pre-Authentication enabled or not, from registry "EnablePreAuth". Added by Annie, 2005-11-01. */
/* u8 EnablePreAuthentication; */ /* Current Value: Pre-Authentication enabled or not. */
RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE]; /* Renamed from PreAuthKey[NUM_PRE_AUTH_KEY]. Annie, 2006-10-13. */
u8 PMKIDIndex;
/* u32 PMKIDCount; */ /* Added by Annie, 2006-10-13. */
/* u8 szCapability[256]; */ /* For WPA2-PSK using zero-config, by Annie, 2005-09-20. */
u8 bWepDefaultKeyIdxSet;
#define DBG_SW_SEC_CNT
#ifdef DBG_SW_SEC_CNT
u64 wep_sw_enc_cnt_bc;
u64 wep_sw_enc_cnt_mc;
u64 wep_sw_enc_cnt_uc;
u64 wep_sw_dec_cnt_bc;
u64 wep_sw_dec_cnt_mc;
u64 wep_sw_dec_cnt_uc;
u64 tkip_sw_enc_cnt_bc;
u64 tkip_sw_enc_cnt_mc;
u64 tkip_sw_enc_cnt_uc;
u64 tkip_sw_dec_cnt_bc;
u64 tkip_sw_dec_cnt_mc;
u64 tkip_sw_dec_cnt_uc;
u64 aes_sw_enc_cnt_bc;
u64 aes_sw_enc_cnt_mc;
u64 aes_sw_enc_cnt_uc;
u64 aes_sw_dec_cnt_bc;
u64 aes_sw_dec_cnt_mc;
u64 aes_sw_dec_cnt_uc;
#endif /* DBG_SW_SEC_CNT */
};
#ifdef CONFIG_IEEE80211W
#define SEC_IS_BIP_KEY_INSTALLED(sec) ((sec)->binstallBIPkey)
#else
#define SEC_IS_BIP_KEY_INSTALLED(sec) _FALSE
#endif
struct rtw_sha256_state {
u64 length;
u32 state[8], curlen;
u8 buf[64];
};
#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst)\
do {\
switch (psecuritypriv->dot11AuthAlgrthm) {\
case dot11AuthAlgrthm_Open:\
case dot11AuthAlgrthm_Shared:\
case dot11AuthAlgrthm_Auto:\
encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm;\
break;\
case dot11AuthAlgrthm_8021X:\
if (bmcst)\
encry_algo = (u8)psecuritypriv->dot118021XGrpPrivacy;\
else\
encry_algo = (u8) psta->dot118021XPrivacy;\
break;\
case dot11AuthAlgrthm_WAPI:\
encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm;\
break;\
} \
} while (0)
#define _AES_IV_LEN_ 8
#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt)\
do {\
switch (encrypt) {\
case _WEP40_:\
case _WEP104_:\
iv_len = 4;\
icv_len = 4;\
break;\
case _TKIP_:\
iv_len = 8;\
icv_len = 4;\
break;\
case _AES_:\
iv_len = 8;\
icv_len = 8;\
break;\
case _SMS4_:\
iv_len = 18;\
icv_len = 16;\
break;\
default:\
iv_len = 0;\
icv_len = 0;\
break;\
} \
} while (0)
#define GET_TKIP_PN(iv, dot11txpn)\
do {\
dot11txpn._byte_.TSC0 = iv[2];\
dot11txpn._byte_.TSC1 = iv[0];\
dot11txpn._byte_.TSC2 = iv[4];\
dot11txpn._byte_.TSC3 = iv[5];\
dot11txpn._byte_.TSC4 = iv[6];\
dot11txpn._byte_.TSC5 = iv[7];\
} while (0)
#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
#define ROR32(A, n) ROL32((A), 32-(n))
struct mic_data {
u32 K0, K1; /* Key */
u32 L, R; /* Current state */
u32 M; /* Message accumulator (single word) */
u32 nBytesInM; /* # bytes in M */
};
extern const u32 Te0[256];
extern const u32 Te1[256];
extern const u32 Te2[256];
extern const u32 Te3[256];
extern const u32 Te4[256];
extern const u32 Td0[256];
extern const u32 Td1[256];
extern const u32 Td2[256];
extern const u32 Td3[256];
extern const u32 Td4[256];
extern const u32 rcon[10];
extern const u8 Td4s[256];
extern const u8 rcons[10];
#define RCON(i) (rcons[(i)] << 24)
static inline u32 rotr(u32 val, int bits)
{
return (val >> bits) | (val << (32 - bits));
}
#define TE0(i) Te0[((i) >> 24) & 0xff]
#define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8)
#define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16)
#define TE3(i) rotr(Te0[(i) & 0xff], 24)
#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000)
#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00)
#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff)
#define TD0(i) Td0[((i) >> 24) & 0xff]
#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8)
#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16)
#define TD3(i) rotr(Td0[(i) & 0xff], 24)
#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24)
#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16)
#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8)
#define TD44(i) (Td4s[(i) & 0xff])
#define TD0_(i) Td0[(i) & 0xff]
#define TD1_(i) rotr(Td0[(i) & 0xff], 8)
#define TD2_(i) rotr(Td0[(i) & 0xff], 16)
#define TD3_(i) rotr(Td0[(i) & 0xff], 24)
#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
#define PUTU32(ct, st) { \
(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \
(ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
#define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
(((u32) (a)[2]) << 8) | ((u32) (a)[3]))
#define WPA_PUT_LE16(a, val) \
do { \
(a)[1] = ((u16) (val)) >> 8; \
(a)[0] = ((u16) (val)) & 0xff; \
} while (0)
#define WPA_PUT_BE32(a, val) \
do { \
(a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
(a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
(a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
(a)[3] = (u8) (((u32) (val)) & 0xff); \
} while (0)
#define WPA_PUT_BE64(a, val) \
do { \
(a)[0] = (u8) (((u64) (val)) >> 56); \
(a)[1] = (u8) (((u64) (val)) >> 48); \
(a)[2] = (u8) (((u64) (val)) >> 40); \
(a)[3] = (u8) (((u64) (val)) >> 32); \
(a)[4] = (u8) (((u64) (val)) >> 24); \
(a)[5] = (u8) (((u64) (val)) >> 16); \
(a)[6] = (u8) (((u64) (val)) >> 8); \
(a)[7] = (u8) (((u64) (val)) & 0xff); \
} while (0)
/* the K array */
static const unsigned long K[64] = {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
};
/* Various logical functions */
#define RORc(x, y) \
(((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)
#define Ch(x, y, z) (z ^ (x & (y ^ z)))
#define Maj(x, y, z) (((x | y) & z) | (x & y))
#define S(x, n) RORc((x), (n))
#define R(x, n) (((x) & 0xFFFFFFFFUL)>>(n))
#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3))
#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10))
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#ifdef CONFIG_IEEE80211W
int omac1_aes_128(const u8 *key, const u8 *data, size_t data_len, u8 *mac);
#endif /* CONFIG_IEEE80211W */
#ifdef CONFIG_RTW_MESH_AEK
int aes_siv_encrypt(const u8 *key, const u8 *pw, size_t pwlen
, size_t num_elem, const u8 *addr[], const size_t *len, u8 *out);
int aes_siv_decrypt(const u8 *key, const u8 *iv_crypt, size_t iv_c_len
, size_t num_elem, const u8 *addr[], const size_t *len, u8 *out);
#endif
void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key);
void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b);
void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes);
void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst);
void rtw_seccalctkipmic(
u8 *key,
u8 *header,
u8 *data,
u32 data_len,
u8 *Miccode,
u8 priority);
u32 rtw_aes_encrypt(_adapter *padapter, u8 *pxmitframe);
u32 rtw_tkip_encrypt(_adapter *padapter, u8 *pxmitframe);
void rtw_wep_encrypt(_adapter *padapter, u8 *pxmitframe);
u32 rtw_aes_decrypt(_adapter *padapter, u8 *precvframe);
u32 rtw_tkip_decrypt(_adapter *padapter, u8 *precvframe);
void rtw_wep_decrypt(_adapter *padapter, u8 *precvframe);
#ifdef CONFIG_IEEE80211W
u32 rtw_BIP_verify(_adapter *padapter, u8 *whdr_pos, sint flen
, const u8 *key, u16 id, u64* ipn);
#endif
#ifdef CONFIG_TDLS
void wpa_tdls_generate_tpk(_adapter *padapter, PVOID sta);
int wpa_tdls_ftie_mic(u8 *kck, u8 trans_seq,
u8 *lnkid, u8 *rsnie, u8 *timeoutie, u8 *ftie,
u8 *mic);
int wpa_tdls_teardown_ftie_mic(u8 *kck, u8 *lnkid, u16 reason,
u8 dialog_token, u8 trans_seq, u8 *ftie, u8 *mic);
int tdls_verify_mic(u8 *kck, u8 trans_seq,
u8 *lnkid, u8 *rsnie, u8 *timeoutie, u8 *ftie);
#endif /* CONFIG_TDLS */
void rtw_sec_restore_wep_key(_adapter *adapter);
u8 rtw_handle_tkip_countermeasure(_adapter *adapter, const char *caller);
#ifdef CONFIG_WOWLAN
u16 rtw_calc_crc(u8 *pdata, int length);
#endif /*CONFIG_WOWLAN*/
#endif /* __RTL871X_SECURITY_H_ */