Skip to content

Commit

Permalink
dumbtest
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelscholle committed Mar 20, 2024
1 parent aad91d6 commit cbf50b3
Show file tree
Hide file tree
Showing 832 changed files with 671,274 additions and 69,915 deletions.
7 changes: 4 additions & 3 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
config RTL8822BU
tristate "Realtek 8822B USB WiFi"
config RTL8852BU
tristate "Realtek 8852B USB WiFi"
depends on USB
help
Help message of RTL8822B
Help message of RTL8852BU

2 changes: 1 addition & 1 deletion build_chroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if [[ -e /etc/os-release && $(grep -c "Raspbian" /etc/os-release) -gt 0 ]]; then
else
sudo apt update
sudo apt install -y build-essential flex bc bison dkms
make KSRC=/usr/src/linux-headers-6.3.13-060313-generic O="" modules
make ARCH=x86 CROSS_COMPILE= -C /usr/src/linux-headers-6.3.13-060313-generic M=/opt/additionalFiles modules
mkdir -p package/lib/modules/6.3.13-060313-generic/kernel/drivers/net/wireless/
cp *.ko package/lib/modules/6.3.13-060313-generic/kernel/drivers/net/wireless/
ls -a
Expand Down
142 changes: 142 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
########### OS_DEP PATH #################################
_OS_INTFS_FILES := os_dep/osdep_service.o \
os_dep/osdep_service_linux.o \
os_dep/linux/rtw_cfg.o \
os_dep/linux/os_intfs.o \
os_dep/linux/ioctl_linux.o \
os_dep/linux/xmit_linux.o \
os_dep/linux/mlme_linux.o \
os_dep/linux/recv_linux.o \
os_dep/linux/ioctl_cfg80211.o \
os_dep/linux/rtw_cfgvendor.o \
os_dep/linux/wifi_regd.o \
os_dep/linux/rtw_android.o \
os_dep/linux/rtw_proc.o \
os_dep/linux/nlrtw.o \
os_dep/linux/rtw_rhashtable.o

ifeq ($(CONFIG_HWSIM), y)
_OS_INTFS_FILES += os_dep/linux/hwsim/medium/local.o
_OS_INTFS_FILES += os_dep/linux/hwsim/medium/sock_udp.o
_OS_INTFS_FILES += os_dep/linux/hwsim/medium/loopback.o
_OS_INTFS_FILES += os_dep/linux/hwsim/core.o
_OS_INTFS_FILES += os_dep/linux/hwsim/txrx.o
_OS_INTFS_FILES += os_dep/linux/hwsim/netdev.o
_OS_INTFS_FILES += os_dep/linux/hwsim/cfg80211.o
_OS_INTFS_FILES += os_dep/linux/hwsim/platform_dev.o

_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_ops_linux.o
else
_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_intf.o
_OS_INTFS_FILES += os_dep/linux/$(HCI_NAME)_ops_linux.o
endif

ifeq ($(CONFIG_MP_INCLUDED), y)
_OS_INTFS_FILES += os_dep/linux/ioctl_mp.o \
os_dep/linux/ioctl_efuse.o
endif

ifeq ($(CONFIG_SDIO_HCI), y)
_OS_INTFS_FILES += os_dep/linux/custom_gpio_linux.o
endif

ifeq ($(CONFIG_GSPI_HCI), y)
_OS_INTFS_FILES += os_dep/linux/custom_gpio_linux.o
endif

########### CORE PATH #################################
_CORE_FILES := core/rtw_cmd.o \
core/rtw_security.o \
core/rtw_debug.o \
core/rtw_io.o \
core/rtw_ioctl_query.o \
core/rtw_ioctl_set.o \
core/rtw_ieee80211.o \
core/rtw_mlme.o \
core/rtw_mlme_ext.o \
core/rtw_sec_cam.o \
core/rtw_mi.o \
core/rtw_wlan_util.o \
core/rtw_vht.o \
core/rtw_he.o \
core/rtw_pwrctrl.o \
core/rtw_rf.o \
core/rtw_chplan.o \
core/monitor/rtw_radiotap.o \
core/rtw_recv.o \
core/rtw_recv_shortcut.o \
core/rtw_sta_mgt.o \
core/rtw_ap.o \
core/rtw_csa.o \
core/wds/rtw_wds.o \
core/mesh/rtw_mesh.o \
core/mesh/rtw_mesh_pathtbl.o \
core/mesh/rtw_mesh_hwmp.o \
core/rtw_xmit.o \
core/rtw_xmit_shortcut.o \
core/rtw_p2p.o \
core/rtw_tdls.o \
core/rtw_br_ext.o \
core/rtw_sreset.o \
core/rtw_rm.o \
core/rtw_rm_fsm.o \
core/rtw_rm_util.o \
core/rtw_trx.o \
core/rtw_beamforming.o \
core/rtw_scan.o
#core/efuse/rtw_efuse.o

_CORE_FILES += core/rtw_phl.o \
core/rtw_phl_cmd.o

EXTRA_CFLAGS += -I$(src)/core/crypto
_CORE_FILES += core/crypto/aes-internal.o \
core/crypto/aes-internal-enc.o \
core/crypto/aes-gcm.o \
core/crypto/aes-ccm.o \
core/crypto/aes-omac1.o \
core/crypto/ccmp.o \
core/crypto/gcmp.o \
core/crypto/aes-siv.o \
core/crypto/aes-ctr.o \
core/crypto/sha256-internal.o \
core/crypto/sha256.o \
core/crypto/sha256-prf.o \
core/crypto/rtw_crypto_wrap.o \
core/rtw_swcrypto.o

ifeq ($(CONFIG_WOWLAN), y)
_CORE_FILES += core/rtw_wow.o
endif

ifeq ($(CONFIG_PCI_HCI), y)
_CORE_FILES += core/rtw_trx_pci.o
endif

ifeq ($(CONFIG_USB_HCI), y)
_CORE_FILES += core/rtw_trx_usb.o
endif

ifeq ($(CONFIG_SDIO_HCI), y)
_CORE_FILES += core/rtw_sdio.o
_CORE_FILES += core/rtw_trx_sdio.o
endif

ifeq ($(CONFIG_MP_INCLUDED), y)
_CORE_FILES += core/rtw_mp.o
endif

ifeq ($(CONFIG_WAPI_SUPPORT), y)
_CORE_FILES += core/rtw_wapi.o \
core/rtw_wapi_sms4.o
endif

ifeq ($(CONFIG_BTC), y)
_CORE_FILES += core/rtw_btc.o
endif

ifeq ($(CONFIG_RTW_MBO), y)
_CORE_FILES += core/rtw_mbo.o core/rtw_ft.o core/rtw_wnm.o
endif

OBJS += $(_OS_INTFS_FILES) $(_CORE_FILES)
127 changes: 126 additions & 1 deletion core/crypto/ccmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void ccmp_aad_nonce(_adapter *padapter, const struct ieee80211_hdr *hdr,
fc |= WLAN_FC_ISWEP;
WPA_PUT_LE16(aad, fc);
pos = aad + 2;
os_memcpy(pos, GetAddr1Ptr((u8 *)hdr), 3 * ETH_ALEN);
os_memcpy(pos, hdr->addr1, 3 * ETH_ALEN);
pos += 3 * ETH_ALEN;
seq = le_to_host16(hdr->seq_ctrl);
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
Expand Down Expand Up @@ -383,3 +383,128 @@ u8 * ccmp_256_encrypt(_adapter *padapter, const u8 *tk, u8 *frame, size_t len, s

return crypt;
}

#if 0 //RTW_PHL_TX: mark un-finished codes for reading
void core_ccmp_encrypt(const u8 *tk, uint hdrlen, u8 *phdr, uint datalen, u8 *pdata,
u8 *qos, u8 *pn, int keyid, size_t *encrypted_len)
{
u8 aad[30], nonce[13];
size_t aad_len;
u8 *crypt, *pos;
struct ieee80211_hdr *hdr;
size_t enc_hdrlen, enc_datalen = 0;

if (hdrlen < 24)
return;

enc_hdrlen = hdrlen + 8;
enc_datalen = datalen + 8;

crypt = os_malloc(enc_hdrlen + enc_hdrlen + AES_BLOCK_SIZE);
if (crypt == NULL)
return;

if (pn == NULL) {
os_memcpy(crypt, phdr, hdrlen + 8);
hdr = (struct ieee80211_hdr *) crypt;
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
pos = crypt + hdrlen + 8;
} else {
os_memcpy(crypt, phdr, hdrlen);
hdr = (struct ieee80211_hdr *) crypt;
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
pos = crypt + hdrlen;
*pos++ = pn[5]; /* PN0 */
*pos++ = pn[4]; /* PN1 */
*pos++ = 0x00; /* Rsvd */
*pos++ = 0x20 | (keyid << 6);
*pos++ = pn[3]; /* PN2 */
*pos++ = pn[2]; /* PN3 */
*pos++ = pn[1]; /* PN4 */
*pos++ = pn[0]; /* PN5 */
}

os_memset(aad, 0, sizeof(aad));
ccmp_aad_nonce(hdr, crypt + hdrlen, aad, &aad_len, nonce);
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP AAD", aad, aad_len);
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP nonce", nonce, 13);

if (aes_ccm_ae(tk, 16, nonce, 8, pdata, datalen, aad, aad_len,
pos, pos + datalen) < 0) {
rtw_mfree(crypt, hdrlen + 8 + datalen + 8 + AES_BLOCK_SIZE);
return;
}

wpa_hexdump(_MSG_EXCESSIVE_, "CCMP encrypted", crypt + enc_hdrlen, datalen);

/* Copy @enc back to @frame and free @enc */
_rtw_memcpy(phdr, crypt, enc_hdrlen);
_rtw_memcpy(pdata, crypt + enc_hdrlen, enc_datalen);

rtw_mfree(crypt, enc_hdrlen+enc_datalen+AES_BLOCK_SIZE);

return;
}


void core_ccmp_256_encrypt(const u8 *tk, uint hdrlen, u8 *phdr, uint datalen, u8 *pdata,
u8 *qos, u8 *pn, int keyid, size_t *encrypted_len)
{
u8 aad[30], nonce[13];
size_t aad_len;
u8 *crypt, *pos;
struct ieee80211_hdr *hdr;
size_t enc_hdrlen, enc_datalen = 0;

if (hdrlen < 24)
return;

enc_hdrlen = hdrlen + 8;
enc_datalen = datalen + 16;

crypt = os_malloc(enc_hdrlen + enc_hdrlen + AES_BLOCK_SIZE);

if (crypt == NULL)
return;

if (pn == NULL) {
os_memcpy(crypt, phdr, hdrlen + 8);
hdr = (struct ieee80211_hdr *) crypt;
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
pos = crypt + hdrlen + 8;
} else {
os_memcpy(crypt, phdr, hdrlen);
hdr = (struct ieee80211_hdr *) crypt;
hdr->frame_control |= host_to_le16(WLAN_FC_ISWEP);
pos = crypt + hdrlen;
*pos++ = pn[5]; /* PN0 */
*pos++ = pn[4]; /* PN1 */
*pos++ = 0x00; /* Rsvd */
*pos++ = 0x20 | (keyid << 6);
*pos++ = pn[3]; /* PN2 */
*pos++ = pn[2]; /* PN3 */
*pos++ = pn[1]; /* PN4 */
*pos++ = pn[0]; /* PN5 */
}

os_memset(aad, 0, sizeof(aad));
ccmp_aad_nonce(hdr, crypt + hdrlen, aad, &aad_len, nonce);
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 AAD", aad, aad_len);
wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 nonce", nonce, 13);

if (aes_ccm_ae(tk, 32, nonce, 16, pdata, datalen, aad, aad_len,
pos, pos + datalen) < 0) {
rtw_mfree(crypt, enc_hdrlen + enc_datalen + AES_BLOCK_SIZE);
return;
}

wpa_hexdump(_MSG_EXCESSIVE_, "CCMP-256 encrypted", crypt + enc_hdrlen, datalen);

_rtw_memcpy(phdr, crypt, enc_hdrlen);
_rtw_memcpy(pdata, crypt + enc_hdrlen, enc_datalen);

rtw_mfree(crypt, enc_hdrlen+enc_datalen+AES_BLOCK_SIZE);
}


#endif
2 changes: 1 addition & 1 deletion core/crypto/gcmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void gcmp_aad_nonce(_adapter * padapter, const struct ieee80211_hdr *hdr,
fc &= ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT | WLAN_FC_MOREDATA);
WPA_PUT_LE16(aad, fc);
pos = aad + 2;
os_memcpy(pos, GetAddr1Ptr((u8 *)hdr), 3 * ETH_ALEN);
os_memcpy(pos, hdr->addr1, 3 * ETH_ALEN);
pos += 3 * ETH_ALEN;
seq = le_to_host16(hdr->seq_ctrl);
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
Expand Down
7 changes: 7 additions & 0 deletions core/crypto/wlancrypto_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ u8* gcmp_encrypt(_adapter *padapter, const u8 *tk, size_t tk_len, const u8 *fram
size_t hdrlen, const u8 *qos,
const u8 *pn, int keyid, size_t *encrypted_len);

#if 0 //RTW_PHL_TX: mark un-finished codes for reading
void core_ccmp_encrypt(const u8 *tk, uint hdrlen, u8 *phdr, uint datalen, u8 *pdata,
u8 *qos, u8 *pn, int keyid, size_t *encrypted_len);

void core_ccmp_256_encrypt(const u8 *tk, uint hdrlen, u8 *phdr, uint datalen, u8 *pdata,
u8 *qos, u8 *pn, int keyid, size_t *encrypted_len);
#endif
#endif /* WLANCRYPTO_WRAP_H */
Loading

0 comments on commit cbf50b3

Please sign in to comment.