mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
wifi: add marvell 88W8977 wifi module driver
Change-Id: Ia1e254e2c084621141d837be385d9198962be1cd Signed-off-by: Qiang Wu <xianlee.wu@rock-chips.com>
This commit is contained in:
@@ -37,5 +37,6 @@ source "drivers/net/wireless/rockchip_wlan/rtl8723bu/Kconfig"
|
||||
source "drivers/net/wireless/rockchip_wlan/rtl8723cs/Kconfig"
|
||||
source "drivers/net/wireless/rockchip_wlan/rtl8723ds/Kconfig"
|
||||
source "drivers/net/wireless/rockchip_wlan/rtl8822be/Kconfig"
|
||||
source "drivers/net/wireless/rockchip_wlan/mvl88w8977/Kconfig"
|
||||
|
||||
endif # WL_ROCKCHIP
|
||||
|
||||
@@ -9,5 +9,6 @@ obj-$(CONFIG_RTL8723BU) += rtl8723bu/
|
||||
obj-$(CONFIG_RTL8723CS) += rtl8723cs/
|
||||
obj-$(CONFIG_RTL8723DS) += rtl8723ds/
|
||||
obj-$(CONFIG_RTL8822BE) += rtl8822be/
|
||||
obj-$(CONFIG_MVL88W8977) += mvl88w8977/
|
||||
obj-$(CONFIG_WL_ROCKCHIP) += wifi_sys/rkwifi_sys_iface.o
|
||||
obj-$(CONFIG_WL_ROCKCHIP) += rkwifi/rk_wifi_config.o
|
||||
|
||||
5
drivers/net/wireless/rockchip_wlan/mvl88w8977/Kconfig
Normal file
5
drivers/net/wireless/rockchip_wlan/mvl88w8977/Kconfig
Normal file
@@ -0,0 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
config MVL88W8977
|
||||
tristate "Marvell 88W8977 SDIO WiFi"
|
||||
---help---
|
||||
Help message of MVL88W8977
|
||||
567
drivers/net/wireless/rockchip_wlan/mvl88w8977/Makefile
Normal file
567
drivers/net/wireless/rockchip_wlan/mvl88w8977/Makefile
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,356 @@
|
||||
/** @file AssocAp_src_rom.c
|
||||
*
|
||||
* @brief This file defines the function for checking security type and ie
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#include "wltypes.h"
|
||||
#include "hostsa_ext_def.h"
|
||||
#include "IEEE_types.h"
|
||||
|
||||
#include "authenticator.h"
|
||||
#include "AssocAp_srv_rom.h"
|
||||
#include "parser.h"
|
||||
#include "keyMgmtAp.h"
|
||||
|
||||
BOOLEAN
|
||||
AssocSrvAp_checkCipherSupport(Cipher_t cipher, Cipher_t allowedCiphers)
|
||||
{
|
||||
BOOLEAN match = FALSE;
|
||||
|
||||
if (cipher.ccmp && (allowedCiphers.ccmp)) {
|
||||
match = TRUE;
|
||||
} else if (cipher.tkip && (allowedCiphers.tkip)) {
|
||||
match = TRUE;
|
||||
} else if (cipher.wep40 && (allowedCiphers.wep40)) {
|
||||
match = TRUE;
|
||||
} else if (cipher.wep104 && (allowedCiphers.wep104)) {
|
||||
match = TRUE;
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
UINT16
|
||||
AssocSrvAp_checkAkm(phostsa_private priv, AkmSuite_t *pAkm, UINT16 allowedAkms)
|
||||
{
|
||||
hostsa_util_fns *util_fns = &priv->util_fns;
|
||||
UINT16 matchedAkms;
|
||||
|
||||
matchedAkms = 0;
|
||||
|
||||
if ((memcmp(util_fns, pAkm->akmOui, wpa_oui, sizeof(wpa_oui)) != 0) &&
|
||||
((memcmp(util_fns, pAkm->akmOui, kde_oui, sizeof(kde_oui)) != 0))) {
|
||||
return matchedAkms;
|
||||
}
|
||||
|
||||
switch (pAkm->akmType) {
|
||||
case AKM_1X:
|
||||
matchedAkms = (allowedAkms & UAP_HOSTCMD_KEYMGMT_EAP);
|
||||
break;
|
||||
|
||||
case AKM_PSK:
|
||||
matchedAkms = (allowedAkms & UAP_HOSTCMD_KEYMGMT_PSK);
|
||||
break;
|
||||
case AKM_SHA256_PSK:
|
||||
matchedAkms = (allowedAkms & UAP_HOSTCMD_KEYMGMT_PSK_SHA256);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return matchedAkms;
|
||||
}
|
||||
|
||||
WL_STATUS
|
||||
assocSrvAp_validate4WayHandshakeIe(phostsa_private priv,
|
||||
SecurityMode_t secType,
|
||||
Cipher_t pwCipher,
|
||||
Cipher_t grpCipher,
|
||||
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
|
||||
UINT8 akmType,
|
||||
UINT16 rsnCap, Cipher_t config_mcstCipher)
|
||||
{
|
||||
hostsa_util_fns *util_fns = &priv->util_fns;
|
||||
|
||||
if (memcmp
|
||||
(util_fns, (void *)&secType, (void *)&pKeyMgmtInfo->staSecType,
|
||||
sizeof(secType)) != 0) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (memcmp(util_fns, (void *)&grpCipher,
|
||||
(void *)&config_mcstCipher, sizeof(grpCipher)) != 0) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (memcmp
|
||||
(util_fns, (void *)&pwCipher, (void *)&pKeyMgmtInfo->staUcstCipher,
|
||||
sizeof(pwCipher)) != 0) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (akmType != pKeyMgmtInfo->staAkmType) {
|
||||
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
AssocSrvAp_InitKeyMgmtInfo(phostsa_private priv,
|
||||
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
|
||||
SecurityMode_t *secType, Cipher_t *pwCipher,
|
||||
UINT16 staRsnCap, UINT8 akmType)
|
||||
{
|
||||
hostsa_util_fns *util_fns = &priv->util_fns;
|
||||
pKeyMgmtInfo->keyMgmtState = HSK_NOT_STARTED;
|
||||
memcpy(util_fns, (void *)&pKeyMgmtInfo->staSecType, (void *)secType,
|
||||
sizeof(SecurityMode_t));
|
||||
memcpy(util_fns, (void *)&pKeyMgmtInfo->staUcstCipher, (void *)pwCipher,
|
||||
sizeof(Cipher_t));
|
||||
pKeyMgmtInfo->staAkmType = akmType;
|
||||
if (secType->wpa2) {
|
||||
pKeyMgmtInfo->staRsnCap = staRsnCap;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AssocSrvAp_InitStaKeyInfo(cm_Connection *connPtr,
|
||||
SecurityMode_t *secType,
|
||||
Cipher_t *pwCipher, UINT16 staRsnCap, UINT8 akmType)
|
||||
{
|
||||
apKeyMgmtInfoSta_t *pKeyMgmtInfo;
|
||||
|
||||
phostsa_private priv = (phostsa_private)connPtr->priv;
|
||||
hostsa_util_fns *util_fns = &priv->util_fns;
|
||||
|
||||
KeyMgmtStopHskTimer(connPtr);
|
||||
|
||||
pKeyMgmtInfo = &connPtr->staData.keyMgmtInfo;
|
||||
memset(util_fns, (void *)pKeyMgmtInfo, 0x00,
|
||||
sizeof(apKeyMgmtInfoSta_t));
|
||||
AssocSrvAp_InitKeyMgmtInfo(priv, &pKeyMgmtInfo->rom, secType, pwCipher,
|
||||
staRsnCap, akmType);
|
||||
pKeyMgmtInfo->EAPOLProtoVersion = EAPOL_PROTOCOL_V1;
|
||||
}
|
||||
|
||||
WL_STATUS
|
||||
assocSrvAp_checkRsnWpa(cm_Connection *connPtr,
|
||||
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
|
||||
Cipher_t apWpaCipher,
|
||||
Cipher_t apWpa2Cipher,
|
||||
Cipher_t apMcstCipher,
|
||||
UINT16 apAuthKey,
|
||||
SecurityMode_t *pSecType,
|
||||
IEEEtypes_RSNElement_t *pRsn,
|
||||
IEEEtypes_WPAElement_t *pWpa,
|
||||
BOOLEAN validate4WayHandshakeIE)
|
||||
{
|
||||
phostsa_private priv = (phostsa_private)connPtr->priv;
|
||||
hostsa_util_fns *util_fns = &priv->util_fns;
|
||||
WL_STATUS result = SUCCESS;
|
||||
Cipher_t apCipher;
|
||||
Cipher_t pwCipher;
|
||||
Cipher_t grpCipher;
|
||||
SecurityMode_t wpaType;
|
||||
AkmSuite_t akm[AKM_SUITE_MAX];
|
||||
UINT8 minimumRsnLen;
|
||||
|
||||
/* staRsnCap field is only used to compare RsnCap received in AssocRequest
|
||||
with rsnCap received in 4 way handshake PWKMsg2.
|
||||
|
||||
we use 0xFFFF signature. If rsnCap is not present in pRsn,
|
||||
signature 0xFFFF would be saved in pKeyMgmtInfo->staRsnCap.
|
||||
*/
|
||||
|
||||
union {
|
||||
UINT16 shortInt;
|
||||
IEEEtypes_RSNCapability_t cfg;
|
||||
} staRsnCap;
|
||||
|
||||
memset(util_fns, &wpaType, 0x00, sizeof(wpaType));
|
||||
memset(util_fns, &apCipher, 0x00, sizeof(apCipher));
|
||||
memset(util_fns, &pwCipher, 0x00, sizeof(pwCipher));
|
||||
memset(util_fns, &grpCipher, 0x00, sizeof(grpCipher));
|
||||
staRsnCap.shortInt = 0xFFFF;
|
||||
|
||||
if (pRsn && (pSecType->wpa2 == 1)) {
|
||||
|
||||
/*
|
||||
In pRsn , All elements after Ver field are optional per the spec.
|
||||
|
||||
we reject Assoc Request, if GrpKeyCipher, pwsKey and AuthKey
|
||||
is not present.
|
||||
|
||||
we can rely on minimum length check as we are rejecting Assoc Request
|
||||
having pwsKeyCnt > 1 and AuthKeyCnt > 1
|
||||
|
||||
*/
|
||||
|
||||
minimumRsnLen = (unsigned long)&pRsn->RsnCap -
|
||||
(unsigned long)&pRsn->Ver;
|
||||
|
||||
if (pRsn->Len < minimumRsnLen) {
|
||||
PRINTM(MERROR, "pRsn->Len %x < minimumRsnLen %x\n",
|
||||
pRsn->Len, minimumRsnLen);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (pRsn->PwsKeyCnt == 1 && pRsn->AuthKeyCnt == 1) {
|
||||
apCipher = apWpa2Cipher;
|
||||
|
||||
supplicantParseRsnIe(priv, pRsn,
|
||||
&wpaType,
|
||||
&grpCipher,
|
||||
&pwCipher,
|
||||
akm,
|
||||
NELEMENTS(akm),
|
||||
&staRsnCap.cfg, NULL);
|
||||
} else {
|
||||
PRINTM(MERROR,
|
||||
"pRsn->PwsKeyCnt %x pRsn->AuthKeyCnt %x\n",
|
||||
pRsn->PwsKeyCnt, pRsn->AuthKeyCnt);
|
||||
result = FAIL;
|
||||
}
|
||||
} else if (pWpa && (pSecType->wpa == 1)) {
|
||||
if (pWpa->PwsKeyCnt == 1 && pWpa->AuthKeyCnt == 1) {
|
||||
apCipher = apWpaCipher;
|
||||
supplicantParseWpaIe(priv, pWpa,
|
||||
&wpaType,
|
||||
&grpCipher,
|
||||
&pwCipher, akm, NELEMENTS(akm));
|
||||
} else {
|
||||
PRINTM(MERROR,
|
||||
"pWpa->PwsKeyCnt %x pWpa->AuthKeyCnt %x\n",
|
||||
pWpa->PwsKeyCnt, pWpa->AuthKeyCnt);
|
||||
result = FAIL;
|
||||
}
|
||||
} else {
|
||||
PRINTM(MERROR, "No wpa or rsn\n");
|
||||
result = FAIL;
|
||||
}
|
||||
|
||||
if ((pwCipher.ccmp == 0) && (pwCipher.tkip == 0)) {
|
||||
PRINTM(MERROR,
|
||||
"(pwCipher.ccmp(%x) == 0) && (pwCipher.tkip(%x) == 0)\n",
|
||||
pwCipher.ccmp, pwCipher.tkip);
|
||||
result = FAIL;
|
||||
}
|
||||
|
||||
if ((grpCipher.ccmp == 0) && (grpCipher.tkip == 0)) {
|
||||
PRINTM(MERROR,
|
||||
"((grpCipher.ccmp(%x) == 0) && (grpCipher.tkip(%x) == 0))\n",
|
||||
grpCipher.ccmp, grpCipher.tkip);
|
||||
result = FAIL;
|
||||
}
|
||||
DBG_HEXDUMP(MCMD_D, " akm", (t_u8 *)&akm[0], sizeof(AkmSuite_t));
|
||||
if (SUCCESS == result) {
|
||||
#ifdef DOT11W
|
||||
if (staRsnCap.shortInt != 0xFFFF) {
|
||||
/* Save the peer STA PMF capability, which will later used to enable PMF */
|
||||
connPtr->staData.peerPMFCapable = staRsnCap.cfg.MFPC;
|
||||
}
|
||||
#endif
|
||||
if (validate4WayHandshakeIE == MFALSE) {
|
||||
if ((AssocSrvAp_checkCipherSupport(pwCipher, apCipher)
|
||||
== TRUE) &&
|
||||
(AssocSrvAp_checkCipherSupport
|
||||
(grpCipher, apMcstCipher)
|
||||
== TRUE) &&
|
||||
(AssocSrvAp_checkAkm(priv, akm, apAuthKey) != 0)) {
|
||||
AssocSrvAp_InitStaKeyInfo(connPtr, &wpaType,
|
||||
&pwCipher,
|
||||
staRsnCap.shortInt,
|
||||
akm[0].akmType);
|
||||
} else {
|
||||
result = FAIL;
|
||||
}
|
||||
} else {
|
||||
result = assocSrvAp_validate4WayHandshakeIe(priv,
|
||||
wpaType,
|
||||
pwCipher,
|
||||
grpCipher,
|
||||
pKeyMgmtInfo,
|
||||
akm[0].
|
||||
akmType,
|
||||
staRsnCap.
|
||||
shortInt,
|
||||
apMcstCipher);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
SINT32
|
||||
assocSrvAp_CheckSecurity(cm_Connection *connPtr,
|
||||
IEEEtypes_WPSElement_t *pWps,
|
||||
IEEEtypes_RSNElement_t *pRsn,
|
||||
IEEEtypes_WPAElement_t *pWpa,
|
||||
IEEEtypes_WAPIElement_t *pWapi,
|
||||
IEEEtypes_StatusCode_t *pResult)
|
||||
{
|
||||
phostsa_private priv = (phostsa_private)connPtr->priv;
|
||||
apInfo_t *pApInfo = &priv->apinfo;
|
||||
BssConfig_t *pBssConfig = NULL;
|
||||
SINT32 retval = MLME_FAILURE;
|
||||
|
||||
*pResult = IEEEtypes_STATUS_INVALID_RSN_CAPABILITIES;
|
||||
|
||||
pBssConfig = &pApInfo->bssConfig;
|
||||
|
||||
PRINTM(MMSG, "assocSrvAp_CheckSecurity Sectyep wpa %x wpa2 %x\n",
|
||||
pBssConfig->SecType.wpa, pBssConfig->SecType.wpa2);
|
||||
if ((pBssConfig->SecType.wpa == 1) || (pBssConfig->SecType.wpa2 == 1)) {
|
||||
apKeyMgmtInfoSta_t *pKeyMgmtInfo =
|
||||
&connPtr->staData.keyMgmtInfo;
|
||||
Cipher_t wpaUcastCipher = pBssConfig->RsnConfig.wpaUcstCipher;
|
||||
Cipher_t wpa2UcastCipher = pBssConfig->RsnConfig.wpa2UcstCipher;
|
||||
DBG_HEXDUMP(MCMD_D, " wpa2UcstCipher",
|
||||
(t_u8 *)&wpa2UcastCipher, sizeof(Cipher_t));
|
||||
DBG_HEXDUMP(MCMD_D, " wpaUcastCipher",
|
||||
(t_u8 *)&wpaUcastCipher, sizeof(Cipher_t));
|
||||
connPtr->staData.RSNEnabled = 0;
|
||||
if (assocSrvAp_checkRsnWpa(connPtr, &pKeyMgmtInfo->rom,
|
||||
wpaUcastCipher,
|
||||
wpa2UcastCipher,
|
||||
pBssConfig->RsnConfig.mcstCipher,
|
||||
pBssConfig->RsnConfig.AuthKey,
|
||||
&pBssConfig->SecType, pRsn, pWpa,
|
||||
MFALSE) == SUCCESS) {
|
||||
retval = MLME_SUCCESS;
|
||||
connPtr->staData.RSNEnabled = 1;
|
||||
}
|
||||
} else if (pBssConfig->SecType.wepStatic == 1) {
|
||||
if (!pRsn || !pWpa) {
|
||||
retval = MLME_SUCCESS;
|
||||
}
|
||||
} else if (pBssConfig->SecType.wapi) {
|
||||
/* if (wapi_ie_check(pBssConfig, pWapi, pResult))
|
||||
{
|
||||
*pResult = 0;
|
||||
retval = MLME_SUCCESS;
|
||||
} */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/** @file AssocAp_src_rom.h
|
||||
*
|
||||
* @brief This file contains define check rsn/wpa ie
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#ifndef ASSOCAP_SRV_ROM_H_
|
||||
#define ASSOCAP_SRV_ROM_H_
|
||||
|
||||
#include "wltypes.h"
|
||||
#include "IEEE_types.h"
|
||||
#include "keyMgmtStaTypes.h"
|
||||
#include "keyMgmtApTypes_rom.h"
|
||||
#include "authenticator.h"
|
||||
|
||||
WL_STATUS assocSrvAp_checkRsnWpa(cm_Connection *connPtr,
|
||||
apKeyMgmtInfoStaRom_t *pKeyMgmtInfo,
|
||||
Cipher_t apWpaCipher,
|
||||
Cipher_t apWpa2Cipher,
|
||||
Cipher_t apMcstCipher,
|
||||
UINT16 apAuthKey,
|
||||
SecurityMode_t *pSecType,
|
||||
IEEEtypes_RSNElement_t *pRsn,
|
||||
IEEEtypes_WPAElement_t *pWpa,
|
||||
BOOLEAN validate4WayHandshakeIE);
|
||||
|
||||
SINT32 assocSrvAp_CheckSecurity(cm_Connection *connPtr,
|
||||
IEEEtypes_WPSElement_t *pWps,
|
||||
IEEEtypes_RSNElement_t *pRsn,
|
||||
IEEEtypes_WPAElement_t *pWpa,
|
||||
IEEEtypes_WAPIElement_t *pWapi,
|
||||
IEEEtypes_StatusCode_t *pResult);
|
||||
#endif
|
||||
@@ -0,0 +1,126 @@
|
||||
/** @file KeyApiStaDefs.h
|
||||
*
|
||||
* @brief This file Contains data structures and defines related to key material.
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#ifndef _KEY_API_STA_DEFS_H
|
||||
#define _KEY_API_STA_DEFS_H
|
||||
/******************************************************************/
|
||||
/*!
|
||||
* \ingroup wpa_supplicant
|
||||
* \file keyApiStaDefs.h
|
||||
* \brief Contains data structures and defines related to key material
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
/* Key Material for TKIP type key */
|
||||
#define CRYPTO_TKIP_KEY_LEN_MAX 16
|
||||
#define CRYPTO_KEY_LEN_MAX 16
|
||||
#define MIC_KEY_LEN_MAX 8
|
||||
|
||||
/* Key Material for AES type key */
|
||||
#define CRYPTO_AES_KEY_LEN_MAX 16
|
||||
|
||||
#define WAPI_KEY_LEN 16
|
||||
#define WAPI_MIC_LEN 16
|
||||
#define WAPI_PN_LEN 16
|
||||
|
||||
#define CRYPTO_AES_CMAC_KEY_LEN 16
|
||||
#define CRYPTO_AES_CMAC_IPN_LEN 6
|
||||
#define CRYPTO_WEP_KEY_LEN_MAX 13
|
||||
|
||||
/*
|
||||
WIN7 softAP (uAP) :
|
||||
BIT14 and BIT15 of keyInfo is used to pass keyID for broadcast frame
|
||||
*/
|
||||
|
||||
#define KEYDATA_KEY_ID_MASK (BIT14 | BIT15)
|
||||
#define KEYDATA_KEY_ID_OFFSET 14
|
||||
|
||||
#define KEY_INFO_MULTICAST 0x1
|
||||
#define KEY_INFO_UNICAST 0x2
|
||||
#define KEY_INFO_ENABLED 0x4
|
||||
#define KEY_INFO_DEFAULT 0x8
|
||||
#define KEY_INFO_TX 0x10
|
||||
#define KEY_INFO_RX 0x20
|
||||
#define KEY_INFO_MULTICAST_IGTK 0x400
|
||||
|
||||
typedef MLAN_PACK_START struct {
|
||||
UINT8 key[CRYPTO_TKIP_KEY_LEN_MAX];
|
||||
UINT8 txMicKey[MIC_KEY_LEN_MAX];
|
||||
UINT8 rxMicKey[MIC_KEY_LEN_MAX];
|
||||
} MLAN_PACK_END key_Type_TKIP_t;
|
||||
|
||||
/* This struct is used in ROM and existing fields should not be changed.
|
||||
* New fields can be added at the end.
|
||||
*/
|
||||
typedef MLAN_PACK_START struct {
|
||||
UINT8 keyIndex;
|
||||
UINT8 isDefaultTx;
|
||||
UINT8 key[CRYPTO_WEP_KEY_LEN_MAX];
|
||||
} MLAN_PACK_END key_Type_WEP_t;
|
||||
|
||||
typedef MLAN_PACK_START struct {
|
||||
UINT8 key[CRYPTO_AES_KEY_LEN_MAX];
|
||||
} MLAN_PACK_END key_Type_AES_t;
|
||||
|
||||
typedef MLAN_PACK_START struct {
|
||||
UINT8 keyIndex;
|
||||
UINT8 isDefKey;
|
||||
UINT8 key[WAPI_KEY_LEN];
|
||||
UINT8 mickey[WAPI_MIC_LEN];
|
||||
UINT8 rxPN[WAPI_PN_LEN];
|
||||
} MLAN_PACK_END key_Type_WAPI_t;
|
||||
|
||||
typedef MLAN_PACK_START struct {
|
||||
UINT8 ipn[CRYPTO_AES_CMAC_IPN_LEN];
|
||||
UINT8 reserved[2];
|
||||
UINT8 key[CRYPTO_AES_CMAC_KEY_LEN];
|
||||
} MLAN_PACK_END key_Type_AES_CMAC_t;
|
||||
|
||||
typedef MLAN_PACK_START struct {
|
||||
UINT16 keyType;
|
||||
UINT16 keyInfo;
|
||||
UINT16 keyLen;
|
||||
MLAN_PACK_START union {
|
||||
key_Type_TKIP_t TKIP;
|
||||
key_Type_AES_t AES;
|
||||
key_Type_WEP_t WEP;
|
||||
|
||||
//#if defined(WAPI_HW_SUPPORT) || defined(WAPI_FW_SUPPORT)
|
||||
// key_Type_WAPI_t WAPI;
|
||||
//#endif
|
||||
key_Type_AES_CMAC_t iGTK;
|
||||
|
||||
} MLAN_PACK_END keyEncypt;
|
||||
} MLAN_PACK_END key_MgtMaterial_t;
|
||||
|
||||
/* deprecated but still around for backwards compatibility */
|
||||
#define KEY_INFO_TKIP_MULTICAST 0x1
|
||||
#define KEY_INFO_TKIP_UNICAST 0x2
|
||||
#define KEY_INFO_TKIP_ENABLED 0x4
|
||||
|
||||
#define KEY_INFO_AES_MULTICAST 0x1
|
||||
#define KEY_INFO_AES_UNICAST 0x2
|
||||
#define KEY_INFO_AES_ENABLED 0x4
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,367 @@
|
||||
/** @file authenticator.h
|
||||
*
|
||||
* @brief This file contains the data structure for authenticator and supplicant.
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#ifndef _AUTHENTICATOR_H
|
||||
#define _AUTHENTICATOR_H
|
||||
|
||||
#include "wltypes.h"
|
||||
#include "IEEE_types.h"
|
||||
#include "wl_mib_rom.h"
|
||||
#include "KeyApiStaDefs.h"
|
||||
#include "keyApiStaTypes.h"
|
||||
#include "keyCommonDef.h"
|
||||
#include "keyMgmtApTypes.h"
|
||||
#include "pmkCache_rom.h"
|
||||
|
||||
#include "hostsa_def.h"
|
||||
|
||||
extern const uint8 wpa_oui02[4]; /* WPA TKIP */
|
||||
extern const uint8 wpa_oui04[4]; /* WPA AES */
|
||||
extern const uint8 wpa_oui01[4]; /* WPA WEP-40 */
|
||||
extern const uint8 wpa_oui05[4]; /* WPA WEP-104 */
|
||||
extern const uint8 wpa_oui_none[4]; /* WPA NONE */
|
||||
|
||||
extern const uint8 wpa2_oui02[4]; /* WPA2 TKIP */
|
||||
extern const uint8 wpa2_oui04[4]; /* WPA2 AES */
|
||||
extern const uint8 wpa2_oui01[4]; /* WPA2 WEP-40 */
|
||||
extern const uint8 wpa2_oui05[4]; /* WPA2 WEP-104 */
|
||||
|
||||
extern const uint8 wpa_oui[3];
|
||||
extern const uint8 kde_oui[3];
|
||||
|
||||
typedef enum {
|
||||
NO_MIC_FAILURE,
|
||||
FIRST_MIC_FAIL_IN_60_SEC,
|
||||
SECOND_MIC_FAIL_IN_60_SEC
|
||||
} MIC_Fail_State_e;
|
||||
|
||||
typedef struct {
|
||||
MIC_Fail_State_e status;
|
||||
BOOLEAN MICCounterMeasureEnabled;
|
||||
UINT32 disableStaAsso;
|
||||
} MIC_Error_t;
|
||||
|
||||
typedef struct {
|
||||
UINT8 TKIPICVErrors;
|
||||
UINT8 TKIPLocalMICFailures;
|
||||
UINT8 TKIPCounterMeasuresInvoked;
|
||||
|
||||
} customMIB_RSNStats_t;
|
||||
|
||||
typedef struct {
|
||||
UINT8 kck[16]; /* PTK_KCK = L(PTK, 0, 128); */
|
||||
UINT8 kek[16]; /* PTK_KEK = L(PTK, 128, 128); */
|
||||
UINT8 tk[16]; /* PTK_TK = L(PTK, 256, 128); */
|
||||
|
||||
} CcmPtk_t;
|
||||
|
||||
typedef struct {
|
||||
UINT8 kck[16]; /* PTK_KCK = L(PTK, 0, 128); */
|
||||
UINT8 kek[16]; /* PTK_KEK = L(PTK, 128, 128); */
|
||||
UINT8 tk[16]; /* PTK_TK = L(PTK, 256, 128); */
|
||||
UINT8 rxMicKey[8];
|
||||
UINT8 txMicKey[8];
|
||||
|
||||
} TkipPtk_t;
|
||||
|
||||
typedef struct {
|
||||
MIC_Error_t apMicError;
|
||||
t_void *apMicTimer;
|
||||
|
||||
UINT32 ageOutCnt;
|
||||
UINT32 stateInfo;
|
||||
//key mgmt data
|
||||
apKeyMgmtInfoSta_t keyMgmtInfo;
|
||||
|
||||
t_u8 RSNEnabled;
|
||||
UINT16 deauthReason;
|
||||
|
||||
UINT8 txPauseState;
|
||||
//RateChangeInfo[] is used by MAC HW to decide the start TX rate.
|
||||
//It should be placed in SQ. If staData_t is placed in ITCM/DTCM then put
|
||||
//staRateTable in SQ and use a pointer here
|
||||
//staRateTable RateChangeInfo;
|
||||
UINT16 stickyTimCount;
|
||||
BOOLEAN stickyTimEnabled;
|
||||
|
||||
#ifdef DOT11W
|
||||
/* Peer STA PMF capability */
|
||||
BOOLEAN peerPMFCapable;
|
||||
#endif
|
||||
|
||||
} staData_t;
|
||||
/**connectioninfo*/
|
||||
typedef struct _cm_Connection {
|
||||
/**Hand shake timer*/
|
||||
t_void *HskTimer;
|
||||
/** Timer set flag */
|
||||
t_u8 timer_is_set;
|
||||
/** authenticator Private pointer */
|
||||
t_void *priv;
|
||||
t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH];
|
||||
/**sta data for authenticator*/
|
||||
staData_t staData;
|
||||
/**handshake data*/
|
||||
eapolHskData_t hskData;
|
||||
} cm_Connection;
|
||||
|
||||
typedef struct {
|
||||
IEEEtypes_CapInfo_t CapInfo;
|
||||
UINT32 AssocStationsCnt;
|
||||
|
||||
BOOLEAN updatePassPhrase;
|
||||
|
||||
KeyData_t grpKeyData;
|
||||
UINT8 GNonce[32];
|
||||
|
||||
/* Following two variables contain that multiple of BI which is just
|
||||
** greater than user configured ageout time in normal and PS mode. These
|
||||
** variables get updated at bss_start, and then are used whenever FW
|
||||
** resets STA age.
|
||||
*/
|
||||
UINT32 staAgeOutBcnCnt;
|
||||
UINT32 psStaAgeOutBcnCnt;
|
||||
|
||||
// Store group rekey time as a multiple of beacon interval.
|
||||
UINT32 grpRekeyCntConfigured;
|
||||
UINT32 grpRekeyCntRemaining;
|
||||
|
||||
} BssData_t;
|
||||
|
||||
typedef struct {
|
||||
UINT16 keyExchange:1;
|
||||
UINT16 authenticate:1;
|
||||
UINT16 reserved:14;
|
||||
} Operation_t;
|
||||
|
||||
typedef struct {
|
||||
Cipher_t mcstCipher;
|
||||
UINT8 mcstCipherCount;
|
||||
|
||||
Cipher_t wpaUcstCipher;
|
||||
UINT8 wpaUcstCipherCount;
|
||||
|
||||
Cipher_t wpa2UcstCipher;
|
||||
UINT8 wpa2UcstCipherCount;
|
||||
|
||||
UINT16 AuthKey;
|
||||
UINT16 AuthKeyCount;
|
||||
Operation_t Akmp;
|
||||
UINT32 GrpReKeyTime;
|
||||
UINT8 PSKPassPhrase[PSK_PASS_PHRASE_LEN_MAX];
|
||||
UINT8 PSKPassPhraseLen;
|
||||
UINT8 PSKValue[PMK_LEN_MAX];
|
||||
UINT8 MaxPwsHskRetries;
|
||||
UINT8 MaxGrpHskRetries;
|
||||
UINT32 PwsHskTimeOut;
|
||||
UINT32 GrpHskTimeOut;
|
||||
UINT8 RSNReplayProtEn; /* RSN Replay Attack Protection flag */
|
||||
} apRsnConfig_t;
|
||||
|
||||
typedef struct {
|
||||
UINT8 ieSet;
|
||||
UINT8 version;
|
||||
/* UINT8 akmCnt ; */
|
||||
UINT8 akmTypes;
|
||||
/* UINT8 uCastCnt ; */
|
||||
UINT8 uCastTypes;
|
||||
UINT8 mCastTypes;
|
||||
UINT8 capInfo;
|
||||
} wapi_ie_cfg_t;
|
||||
|
||||
typedef struct {
|
||||
/* The This section only used for initialization of the connPtr */
|
||||
IEEEtypes_SsId_t SsId;
|
||||
IEEEtypes_Len_t SsIdLen;
|
||||
// odd-sized ele clubbed together to keep even alignment
|
||||
IEEEtypes_DtimPeriod_t DtimPeriod;
|
||||
IEEEtypes_BcnInterval_t BcnPeriod;
|
||||
|
||||
IEEEtypes_MacAddr_t BssId;
|
||||
UINT16 RtsThresh;
|
||||
UINT16 FragThresh;
|
||||
UINT8 ShortRetryLim;
|
||||
UINT8 LongRetryLim;
|
||||
|
||||
// Used in MBSS mode for software beacon suppression
|
||||
UINT8 MbssBcnIntFac;
|
||||
UINT8 MbssCurBcnIntCnt;
|
||||
UINT16 Reserved;
|
||||
} CommonMlmeData_t;
|
||||
|
||||
typedef struct {
|
||||
IEEEtypes_SsId_t SsId;
|
||||
IEEEtypes_Len_t SsIdLen;
|
||||
|
||||
UINT8 wpa_ie[MAX_IE_SIZE];
|
||||
UINT16 wpa_ielen;
|
||||
UINT8 rsn_ie[MAX_IE_SIZE];
|
||||
UINT16 rsn_ielen;
|
||||
UINT32 StaAgeOutTime;
|
||||
UINT32 PsStaAgeOutTime;
|
||||
|
||||
/* If the BssAddr field is not aligned on word boundary the hal
|
||||
functions which update mac registers are unsafe for non-word
|
||||
aligned pointers. Avoid direct use of the pointer to BssId
|
||||
field in the hal functions */
|
||||
/* this field is no longer used and we use mibOpdata_p->StaMacAddr
|
||||
in its place now */
|
||||
IEEEtypes_MacAddr_t EepromMacAddr_defunct;
|
||||
IEEEtypes_DataRate_t OpRateSet[IEEEtypes_MAX_DATA_RATES_G];
|
||||
|
||||
// odd-sized ele clubbed together to keep even alignment
|
||||
UINT8 AuthType;
|
||||
UINT8 TxPowerLevel;
|
||||
IEEEtypes_DataRate_t TxDataRate;
|
||||
IEEEtypes_DataRate_t TxMCBCDataRate;
|
||||
UINT8 MaxStaSupported;
|
||||
|
||||
SecurityMode_t SecType;
|
||||
UINT8 Padding1[1]; //****** Use this for adding new members *******
|
||||
BOOLEAN apWmmEn;
|
||||
IEEEtypes_WMM_ParamElement_t apWmmParamSet;
|
||||
|
||||
BOOLEAN ap11nEn;
|
||||
|
||||
cipher_key_buf_t *pWepKeyBuf;
|
||||
cipher_key_buf_t *pGtkKeyBuf;
|
||||
UINT8 ScanChanCount;
|
||||
UINT8 AclStaCnt;
|
||||
|
||||
UINT8 Padding3[1]; //****** Use this for adding new members *******
|
||||
apRsnConfig_t RsnConfig;
|
||||
BOOLEAN apWmmPsEn;
|
||||
channelInfo_t ScanChanList[IEEEtypes_MAX_CHANNELS]; /* Channels to scan */
|
||||
CommonMlmeData_t comData;
|
||||
IEEEtypes_OBSS_ScanParam_t ObssScanParam;
|
||||
|
||||
cipher_key_buf_t *piGtkKeyBuf;
|
||||
UINT32 mgmtFrameSubtypeFwdEn;
|
||||
UINT8 Ht2040CoexEn; // Enable/Disable 2040 Coex feature in uAP
|
||||
|
||||
UINT8 Padding4[1]; //****** Use this for adding new members *******
|
||||
|
||||
wapi_ie_cfg_t wapiCfg;
|
||||
IEEEtypes_ExtCapability_t ExtCap;
|
||||
UINT8 Padding6[1]; //****** Use this for adding new members *******
|
||||
} BssConfig_t;
|
||||
|
||||
typedef struct {
|
||||
BssConfig_t bssConfig;
|
||||
BssData_t bssData;
|
||||
} apInfo_t;
|
||||
#ifdef DRV_EMBEDDED_SUPPLICANT
|
||||
typedef struct {
|
||||
/* This structure is ROM'd */
|
||||
|
||||
UINT8 RSNEnabled:1; /* WPA, WPA2 */
|
||||
UINT8 pmkidValid:1; /* PMKID valid */
|
||||
UINT8 rsnCapValid:1;
|
||||
UINT8 grpMgmtCipherValid:1;
|
||||
UINT8 rsvd:4; /* rsvd */
|
||||
|
||||
SecurityMode_t wpaType;
|
||||
Cipher_t mcstCipher;
|
||||
Cipher_t ucstCipher;
|
||||
AkmSuite_t AKM;
|
||||
UINT8 PMKID[16];
|
||||
|
||||
IEEEtypes_RSNCapability_t rsnCap;
|
||||
|
||||
Cipher_t grpMgmtCipher;
|
||||
|
||||
} RSNConfig_t;
|
||||
|
||||
typedef struct {
|
||||
UINT8 ANonce[NONCE_SIZE];
|
||||
UINT8 SNonce[NONCE_SIZE];
|
||||
UINT8 EAPOL_MIC_Key[EAPOL_MIC_KEY_SIZE];
|
||||
UINT8 EAPOL_Encr_Key[EAPOL_ENCR_KEY_SIZE];
|
||||
UINT32 apCounterLo; /* last valid replay counter from authenticator */
|
||||
UINT32 apCounterHi;
|
||||
UINT32 apCounterZeroDone; /* have we processed replay == 0? */
|
||||
UINT32 staCounterLo; /* counter used in request EAPOL frames */
|
||||
UINT32 staCounterHi;
|
||||
|
||||
BOOLEAN RSNDataTrafficEnabled; /* Enabled after 4way handshake */
|
||||
BOOLEAN RSNSecured; /* Enabled after group key is established */
|
||||
BOOLEAN pwkHandshakeComplete;
|
||||
cipher_key_t *pRxDecryptKey;
|
||||
|
||||
KeyData_t PWKey;
|
||||
KeyData_t GRKey;
|
||||
|
||||
KeyData_t newPWKey;
|
||||
|
||||
MIC_Error_t sta_MIC_Error;
|
||||
t_void *rsnTimer;
|
||||
t_void *micTimer;
|
||||
t_void *deauthDelayTimer; /* hacked in to delay the deauth */
|
||||
|
||||
//phostsa_private psapriv;
|
||||
|
||||
KeyData_t IGtk;
|
||||
|
||||
} keyMgmtInfoSta_t;
|
||||
|
||||
typedef struct supplicantData {
|
||||
BOOLEAN inUse;
|
||||
BOOLEAN suppInitialized;
|
||||
IEEEtypes_SsIdElement_t hashSsId;
|
||||
IEEEtypes_MacAddr_t localBssid;
|
||||
IEEEtypes_MacAddr_t localStaAddr;
|
||||
customMIB_RSNStats_t customMIB_RSNStats;
|
||||
RSNConfig_t customMIB_RSNConfig;
|
||||
keyMgmtInfoSta_t keyMgmtInfoSta;
|
||||
SecurityParams_t currParams;
|
||||
UINT8 wpa_rsn_ie[MAX_IE_SIZE];
|
||||
} supplicantData_t;
|
||||
#endif
|
||||
|
||||
/** supplicant/authenticator private structure */
|
||||
typedef struct _hostsa_private {
|
||||
/** pmlan_private */
|
||||
t_void *pmlan_private;
|
||||
/** pmlan_adapter */
|
||||
t_void *pmlan_adapter;
|
||||
/** Utility functions table */
|
||||
hostsa_util_fns util_fns;
|
||||
/** MLAN APIs table */
|
||||
hostsa_mlan_fns mlan_fns;
|
||||
/**apinf_t*/
|
||||
apInfo_t apinfo;
|
||||
/**group rekey timer*/
|
||||
t_void *GrpRekeytimer;
|
||||
/**Group rekey timer set flag*/
|
||||
t_u8 GrpRekeyTimerIsSet;
|
||||
/**local mac address*/
|
||||
t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH];
|
||||
#ifdef DRV_EMBEDDED_SUPPLICANT
|
||||
/**supplicant data*/
|
||||
supplicantData_t *suppData;
|
||||
#endif
|
||||
/* GTK installed status */
|
||||
t_u8 gtk_installed;
|
||||
} hostsa_private, *phostsa_private;
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,70 @@
|
||||
/** @file Authenticator_api.h
|
||||
*
|
||||
* @brief This file delare the main APIs for authenticator.
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#ifndef _AUTHENTICATORAPI_H
|
||||
#define _AUTHENTICATORAPI_H
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/01/2014: Initial version
|
||||
******************************************************/
|
||||
#ifdef DRV_EMBEDDED_AUTHENTICATOR
|
||||
extern t_u8 IsAuthenticatorEnabled(void *priv);
|
||||
extern void AuthenitcatorInitBssConfig(void *priv);
|
||||
extern void AuthenticatorKeyMgmtInit(void *priv, t_u8 *addr);
|
||||
extern void AuthenticatorkeyClear(void *priv);
|
||||
extern void authenticator_init_client(void *priv, void **ppconnPtr, t_u8 *mac);
|
||||
extern void authenticator_free_client(void *priv, void *ppconnPtr);
|
||||
extern void authenticator_get_sta_security_info(void *priv,
|
||||
t_void *pconnPtr, t_u8 *pIe,
|
||||
t_u8 ieLen);
|
||||
extern t_void AuthenticatorSendEapolPacket(t_void *priv, t_void *pconnPtr);
|
||||
extern t_u8 AuthenticatorProcessEapolPacket(void *priv, t_u8 *pbuf, t_u32 len);
|
||||
extern t_u8 AuthenticatorBssConfig(void *priv, t_u8 *pbss_config, t_u8 appendIE,
|
||||
t_u8 clearIE, t_u8 SetConfigToMlan);
|
||||
#endif
|
||||
mlan_status supplicant_authenticator_init(t_void **pphostsa_priv,
|
||||
t_void *psa_util_fns,
|
||||
t_void *psa_mlan_fns, t_u8 *addr);
|
||||
mlan_status supplicant_authenticator_free(t_void *phostsa_priv);
|
||||
#ifdef DRV_EMBEDDED_SUPPLICANT
|
||||
extern void supplicantClrEncryptKey(void *priv);
|
||||
extern void *processRsnWpaInfo(void *priv, void *prsnwpa_ie);
|
||||
extern void pmkCacheDeletePMK(void *priv, t_u8 *pBssid);
|
||||
extern void supplicantInitSession(void *priv,
|
||||
t_u8 *pSsid,
|
||||
t_u16 len, t_u8 *pBssid, t_u8 *pStaAddr);
|
||||
extern void supplicantStopSessionTimer(void *priv);
|
||||
extern t_u8 supplicantIsEnabled(void *priv);
|
||||
extern void supplicantQueryPassphraseAndEnable(void *priv, t_u8 *pbuf);
|
||||
extern void supplicantDisable(void *priv);
|
||||
extern t_u8 ProcessEAPoLPkt(void *priv, mlan_buffer *pmbuf);
|
||||
extern t_u8 EAPoLKeyPkt_Validation(mlan_buffer *pmbuf);
|
||||
extern void SupplicantClearPMK(void *priv, void *pPassphrase);
|
||||
extern t_u16 SupplicantSetPassphrase(void *priv, void *pPassphraseBuf);
|
||||
extern void SupplicantQueryPassphrase(void *priv, void *pPassphraseBuf);
|
||||
extern t_u8 supplicantFormatRsnWpaTlv(void *priv, void *rsn_wpa_ie,
|
||||
void *rsn_ie_tlv);
|
||||
#endif
|
||||
#endif /**_AUTHENTICATORAPI_H*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
||||
/** @file aes_cmac.h
|
||||
*
|
||||
* @brief This file contains defines for aes_cmac
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#ifndef _AES_CMAC_H_
|
||||
#define _AES_CMAC_H_
|
||||
|
||||
#include "wltypes.h"
|
||||
#include "aes_cmac_rom.h"
|
||||
|
||||
/* ROM Pointers Init */
|
||||
extern void aes_cmacRomInit(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,183 @@
|
||||
/** @file aes_cmac_rom.c
|
||||
*
|
||||
* @brief This file defines aes cmac related function
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#include "wl_macros.h"
|
||||
#include "wltypes.h"
|
||||
#include "hostsa_ext_def.h"
|
||||
#include "authenticator.h"
|
||||
|
||||
#include "crypt_new_rom.h"
|
||||
#include "aes_cmac_rom.h"
|
||||
|
||||
//#pragma diag_default 144
|
||||
//#pragma arm section rwdata
|
||||
// End - patch table entries
|
||||
|
||||
/* For CMAC Calculation */
|
||||
static UINT8 const_Rb[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87
|
||||
};
|
||||
|
||||
void
|
||||
mrvl_aes_128(UINT8 *key, UINT8 *input, UINT8 *output)
|
||||
{
|
||||
// BOOLEAN weuEnabled;
|
||||
|
||||
#if 0
|
||||
if (IS_AEU_CLK_ENBLD()) {
|
||||
weuEnabled = TRUE;
|
||||
} else {
|
||||
weuEnabled = FALSE;
|
||||
}
|
||||
#endif
|
||||
/* keyLen = 128 bit / 8 bits/byte / 8 for MRVL API encoding == 2 */
|
||||
MRVL_AesEncrypt(key, (128 / 8) / 8, input, output);
|
||||
|
||||
}
|
||||
|
||||
/* Basic Functions */
|
||||
void
|
||||
xor_128(UINT8 *a, UINT8 *b, UINT8 *out)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++) {
|
||||
out[i] = a[i] ^ b[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* AES-CMAC Generation Function */
|
||||
|
||||
void
|
||||
leftshift_onebit(UINT8 *input, UINT8 *output)
|
||||
{
|
||||
int i;
|
||||
UINT8 overflow = 0;
|
||||
|
||||
for (i = 15; i >= 0; i--) {
|
||||
output[i] = input[i] << 1;
|
||||
output[i] |= overflow;
|
||||
overflow = (input[i] & 0x80) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
generate_subkey(phostsa_private priv, UINT8 *key, UINT8 *K1, UINT8 *K2)
|
||||
{
|
||||
hostsa_util_fns *util_fns = &priv->util_fns;
|
||||
|
||||
UINT8 L[16];
|
||||
UINT8 Z[16];
|
||||
UINT8 tmp[16];
|
||||
|
||||
memset(util_fns, Z, 0x00, sizeof(Z));
|
||||
|
||||
mrvl_aes_128(key, Z, L);
|
||||
|
||||
if ((L[0] & 0x80) == 0) {
|
||||
/* If MSB(L) = 0, then K1 = L << 1 */
|
||||
leftshift_onebit(L, K1);
|
||||
} else {
|
||||
/* Else K1 = ( L << 1 ) (+) Rb */
|
||||
leftshift_onebit(L, tmp);
|
||||
xor_128(tmp, const_Rb, K1);
|
||||
}
|
||||
|
||||
if ((K1[0] & 0x80) == 0) {
|
||||
leftshift_onebit(K1, K2);
|
||||
} else {
|
||||
leftshift_onebit(K1, tmp);
|
||||
xor_128(tmp, const_Rb, K2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
padding(UINT8 *lastb, UINT8 *pad, int length)
|
||||
{
|
||||
int j;
|
||||
|
||||
/* original last block */
|
||||
for (j = 0; j < 16; j++) {
|
||||
if (j < length) {
|
||||
pad[j] = lastb[j];
|
||||
} else if (j == length) {
|
||||
pad[j] = 0x80;
|
||||
} else {
|
||||
pad[j] = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mrvl_aes_cmac(phostsa_private priv, UINT8 *key, UINT8 *input, int length,
|
||||
UINT8 *mac)
|
||||
{
|
||||
hostsa_util_fns *util_fns = &priv->util_fns;
|
||||
UINT8 X[16];
|
||||
UINT8 Y[16];
|
||||
UINT8 M_last[16];
|
||||
UINT8 padded[16];
|
||||
UINT8 K1[16];
|
||||
UINT8 K2[16];
|
||||
int n, i, flag;
|
||||
|
||||
generate_subkey(priv, key, K1, K2);
|
||||
|
||||
n = (length + 15) / 16; /* n is number of rounds */
|
||||
|
||||
if (n == 0) {
|
||||
n = 1;
|
||||
flag = 0;
|
||||
} else {
|
||||
if ((length % 16) == 0) {
|
||||
/* last block is a complete block */
|
||||
flag = 1;
|
||||
} else {
|
||||
/* last block is not complete block */
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
/* last block is complete block */
|
||||
xor_128(&input[16 * (n - 1)], K1, M_last);
|
||||
} else {
|
||||
padding(&input[16 * (n - 1)], padded, length % 16);
|
||||
xor_128(padded, K2, M_last);
|
||||
}
|
||||
|
||||
memset(util_fns, X, 0x00, sizeof(X));
|
||||
|
||||
for (i = 0; i < n - 1; i++) {
|
||||
xor_128(X, &input[16 * i], Y); /* Y := Mi (+) X */
|
||||
mrvl_aes_128(key, Y, X); /* X := AES-128(KEY, Y); */
|
||||
}
|
||||
|
||||
xor_128(X, M_last, Y);
|
||||
mrvl_aes_128(key, Y, X);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
mac[i] = X[i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/** @file aes_cmac_rom.h
|
||||
*
|
||||
* @brief This file contains the define for aes_cmac_rom
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#ifndef _AES_CMAC_ROM_H_
|
||||
#define _AES_CMAC_ROM_H_
|
||||
|
||||
#include "wltypes.h"
|
||||
|
||||
extern BOOLEAN (*mrvl_aes_cmac_hook) (UINT8 *key, UINT8 *input, int length,
|
||||
UINT8 *mac);
|
||||
extern void mrvl_aes_cmac(phostsa_private priv, UINT8 *key, UINT8 *input,
|
||||
int length, UINT8 *mac);
|
||||
|
||||
extern BOOLEAN (*mrvl_aes_128_hook) (UINT8 *key, UINT8 *input, UINT8 *output);
|
||||
extern void mrvl_aes_128(UINT8 *key, UINT8 *input, UINT8 *output);
|
||||
|
||||
/* RAM Linkages */
|
||||
extern void (*rom_hal_EnableWEU) (void);
|
||||
extern void (*rom_hal_DisableWEU) (void);
|
||||
|
||||
extern void xor_128(UINT8 *a, UINT8 *b, UINT8 *out);
|
||||
extern void leftshift_onebit(UINT8 *input, UINT8 *output);
|
||||
extern void padding(UINT8 *lastb, UINT8 *pad, int length);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/** @file crypt_new.h
|
||||
*
|
||||
* @brief This file contains define for rc4 decrypt/encrypt
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
/*
|
||||
* AES API header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CRYPT_NEW_H_
|
||||
#define _CRYPT_NEW_H_
|
||||
|
||||
#include "crypt_new_rom.h"
|
||||
|
||||
/* forward decl */
|
||||
typedef void (*MRVL_ENDECRYPT_FUNC_p) (MRVL_ENDECRYPT_t *enDeCrypt, int *pErr);
|
||||
#if 0
|
||||
#if (HW_IP_AEU_VERSION < 100000)
|
||||
|
||||
#ifdef WAPI_HW_SUPPORT
|
||||
extern void MRVL_WapiEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
extern void MRVL_WapiDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
|
||||
#define MRVL_WAPI_ENCRYPT MRVL_WapiEncrypt
|
||||
#define MRVL_WAPI_DECRYPT MRVL_WapiDecrypt
|
||||
#endif
|
||||
|
||||
#ifdef DIAG_AES_CCM
|
||||
#define MRVL_AES_CCM_ENCRYPT MRVL_AesCCMEncrypt
|
||||
#define MRVL_AES_CCM_DECRYPT MRVL_AesCCMDecrypt
|
||||
#endif
|
||||
|
||||
#endif /*(HW_IP_AEU_VERSION < 100000) */
|
||||
#endif
|
||||
#define MRVL_AES_PRIMITIVE_ENCRYPT MRVL_AesPrimitiveEncrypt
|
||||
#define MRVL_AES_PRIMITIVE_DECRYPT MRVL_AesPrimitiveDecrypt
|
||||
#define MRVL_AES_WRAP_ENCRYPT MRVL_AesWrapEncrypt
|
||||
#define MRVL_AES_WRAP_DECRYPT MRVL_AesWrapDecrypt
|
||||
|
||||
#ifdef RC4
|
||||
|
||||
#define MRVL_RC4_ENCRYPT MRVL_Rc4Cryption
|
||||
#define MRVL_RC4_DECRYPT MRVL_Rc4Cryption
|
||||
|
||||
#endif /* RC4 */
|
||||
|
||||
typedef struct {
|
||||
MRVL_ENDECRYPT_e action;
|
||||
MRVL_ENDECRYPT_FUNC_p pActionFunc;
|
||||
|
||||
} MRVL_ENDECRYPT_SETUP_t;
|
||||
|
||||
extern MRVL_ENDECRYPT_SETUP_t mrvlEnDecryptSetup[2][6];
|
||||
|
||||
extern void cryptNewRomInit(void);
|
||||
|
||||
#endif /* _CRYPT_NEW_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,167 @@
|
||||
/** @file crypt_new_rom.c
|
||||
*
|
||||
* @brief This file contains the api for AES based functions
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#ifndef _CRYPT_NEW_ROM_H_
|
||||
#define _CRYPT_NEW_ROM_H_
|
||||
|
||||
#define MRVL_AES_CMD_REQUEST_TYPE_INVALID (1)
|
||||
#define MRVL_AES_ALGORITHM_INVALID (1<<1)
|
||||
#define MRVL_AES_KEY_SIZE_INVALID (1<<2)
|
||||
#define MRVL_AES_KEY_IV_SIZE_INVALID (1<<3)
|
||||
#define MRVL_AES_ENCRYPT_DATA_OVER_127 (1<<4)
|
||||
#define MRVL_AES_ENCRYPT_DATA_LESS_2 (1<<5)
|
||||
#define MRVL_AES_NOT_EN_AND_DECRYPT (1<<6)
|
||||
#define MRVL_AES_KEY_IV_INVALID_AES (1<<7)
|
||||
#define MRVL_AES_KEY_IV_INVALID_AES_WRAP (1<<8)
|
||||
#define MRVL_AES_KEY_IV_INVALID_RC4 (1<<9)
|
||||
#define MRVL_AES_DATA_SIZE_INVALID (1<<10)
|
||||
|
||||
#define MRVL_AES_NONCE_INVALID (1<<11)
|
||||
#define MRVL_AES_AAD_INVALID (1<<12)
|
||||
|
||||
#define host_AES_ENCRYPT 0x1
|
||||
#define host_AES_DECRYPT 0x0
|
||||
|
||||
#define MRVL_CRYPTO_TEST_RC4 1
|
||||
#define MRVL_CRYPTO_TEST_AES_ECB 2
|
||||
#define MRVL_CRYPTO_TEST_AES_WRAP 3
|
||||
#define MRVL_CRYPTO_TEST_AEC_CCM 4
|
||||
#define MRVL_CRYPTO_TEST_WAPI 5
|
||||
|
||||
/* basic data structs to support AES feature */
|
||||
/* enum for encrypt/decrypt */
|
||||
typedef enum {
|
||||
CRYPT_DECRYPT = 0,
|
||||
CRYPT_ENCRYPT = 1,
|
||||
CRYPT_UNKNOWN
|
||||
} MRVL_ENDECRYPT_e;
|
||||
|
||||
/* data strcut to hold action type and data to be processed */
|
||||
typedef struct {
|
||||
UINT8 enDeAction; /* encrypt or decrypt */
|
||||
UINT8 *pData;
|
||||
} MRVL_ENDECRYPT_t;
|
||||
|
||||
#ifdef WAPI_HW_SUPPORT
|
||||
extern void MRVL_WapiEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
extern void MRVL_WapiDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
#endif
|
||||
|
||||
extern BOOLEAN (*MRVL_AesPrimitiveEncrypt_hook) (MRVL_ENDECRYPT_t *crypt,
|
||||
int *pErr);
|
||||
extern void MRVL_AesPrimitiveEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
|
||||
extern BOOLEAN (*MRVL_AesPrimitiveDecrypt_hook) (MRVL_ENDECRYPT_t *crypt,
|
||||
int *pErr);
|
||||
extern void MRVL_AesPrimitiveDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
|
||||
extern BOOLEAN (*MRVL_AesWrapEncrypt_hook) (MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
extern void MRVL_AesWrapEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
|
||||
extern BOOLEAN (*MRVL_AesWrapDecrypt_hook) (MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
extern void MRVL_AesWrapDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
|
||||
#ifdef DIAG_AES_CCM
|
||||
extern BOOLEAN (*MRVL_AesCCMPollingMode_hook) (MRVL_ENDECRYPT_t *crypt,
|
||||
int *pErr, int decEnable);
|
||||
extern void MRVL_AesCCMPollingMode(MRVL_ENDECRYPT_t *crypt, int *pErr,
|
||||
int decEnable);
|
||||
#endif
|
||||
|
||||
extern BOOLEAN (*MRVL_AesEncrypt_hook) (UINT8 *kek, UINT8 kekLen, UINT8 *data,
|
||||
UINT8 *ret, int *ptr_val);
|
||||
extern int MRVL_AesEncrypt(UINT8 *kek, UINT8 kekLen, UINT8 *data, UINT8 *ret);
|
||||
|
||||
extern BOOLEAN (*MRVL_AesValidateHostRequest_hook) (UINT32 *pBitMap,
|
||||
UINT8 *pCmdPtr,
|
||||
UINT8 *pCryptData,
|
||||
SINT8 *pAESWrapEnc,
|
||||
int *ptr_val);
|
||||
extern int MRVL_AesValidateHostRequest(UINT32 *pBitMap, UINT8 *pCmdPtr,
|
||||
UINT8 *pCryptData, SINT8 *pAESWrapEnc);
|
||||
|
||||
#ifdef RC4
|
||||
extern BOOLEAN (*MRVL_Rc4Cryption_hook) (MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
extern void MRVL_Rc4Cryption(void *priv, MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
#endif
|
||||
|
||||
extern BOOLEAN (*MRVL_AesWrap_hook) (UINT8 *kek, UINT8 kekLen, UINT32 n,
|
||||
UINT8 *plain, UINT8 *keyIv, UINT8 *cipher,
|
||||
int *ptr_val);
|
||||
extern int MRVL_AesWrap(UINT8 *kek, UINT8 kekLen, UINT32 n, UINT8 *plain,
|
||||
UINT8 *keyIv, UINT8 *cipher);
|
||||
|
||||
extern BOOLEAN (*MRVL_AesUnWrap_hook) (UINT8 *kek, UINT8 kekLen, UINT32 n,
|
||||
UINT8 *cipher, UINT8 *keyIv,
|
||||
UINT8 *plain, int *ptr_val);
|
||||
extern int MRVL_AesUnWrap(UINT8 *kek, UINT8 kekLen, UINT32 n, UINT8 *cipher,
|
||||
UINT8 *keyIv, UINT8 *plain);
|
||||
|
||||
extern BOOLEAN (*MRVL_AesSetKey_hook) (const UINT8 *kek, UINT8 kekLen,
|
||||
int *ptr_val);
|
||||
extern int MRVL_AesSetKey(const UINT8 *kek, UINT8 kekLen);
|
||||
|
||||
/* AES related defines */
|
||||
#define MRVL_AES_KEY_UPDATE_DONE 5
|
||||
#define MRVL_AES_DONE 6
|
||||
#define MRVL_AES_ENGINE_BITS_POS 12
|
||||
|
||||
#define MRVL_AES_KEYUPDATE_LOC 0x00000900
|
||||
#define MRVL_AES_ENABLE_ENCR_LOC 0x00000500
|
||||
#define MRVL_AES_ENABLE_DECR_LOC 0x00000700
|
||||
|
||||
/* convert 4 individual bytes into a 4 byte unsigned int */
|
||||
#define MRVL_AES_GET_UINT32(x) ((x[3]<<24)|(x[2]<<16)|(x[1]<<8)|x[0])
|
||||
|
||||
/* convert 4 byte unsigned int back to a 4 individual bytes */
|
||||
#define MRVL_AES_CONVERT_UINT32_UINT8(x,u) \
|
||||
*u = (UINT8)((((UINT32)x)&0x000000ff)); \
|
||||
*(u + 1)= (UINT8)((((UINT32)x)&0x0000ff00)>>8); \
|
||||
*(u + 2)= (UINT8)((((UINT32)x)&0x00ff0000)>>16); \
|
||||
*(u + 3)= (UINT8)((((UINT32)x)&0xff000000)>>24) \
|
||||
|
||||
|
||||
/* HW register read macros */
|
||||
#define MRVL_AES_READ32(x) (WL_REGS32(x))
|
||||
#define MRVL_AES_READ16(x) (WL_REGS16(x))
|
||||
#define MRVL_AES_READ8(x) (WL_REGS8(x) )
|
||||
|
||||
/* HW register write macros */
|
||||
#define MRVL_AES_WRITE32(reg,val) (WL_WRITE_REGS32(reg,val))
|
||||
#define MRVL_AES_WRITE16(reg,val) (WL_WRITE_REGS16(reg,val))
|
||||
#define MRVL_AES_WRITE8(reg,val) (WL_WRITE_REGS8(reg,val))
|
||||
|
||||
extern UINT32 (*ramHook_CryptNew_EnterCritical) (void);
|
||||
extern void (*ramHook_CryptNew_ExitCritical) (UINT32 intSave);
|
||||
|
||||
extern int MRVL_AES_MEMCMP(UINT8 *dst, UINT8 *src, int len);
|
||||
extern void MRVL_AES_MEMSET(UINT8 *dst, UINT8 val, int size);
|
||||
extern void MRVL_AES_MEMCPY(UINT8 *dst, UINT8 *src, int size);
|
||||
extern int MRVL_AesInterCheck(UINT8 *inter, UINT8 *d);
|
||||
#ifdef DIAG_AES_CCM
|
||||
extern void MRVL_AesCCMEncrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
extern void MRVL_AesCCMDecrypt(MRVL_ENDECRYPT_t *crypt, int *pErr);
|
||||
#endif
|
||||
|
||||
#endif /* _CRYPT_NEW_ROM_H_ */
|
||||
@@ -0,0 +1,106 @@
|
||||
/** @file hmac_md5.c
|
||||
*
|
||||
* @brief This file defines algorithm for hmac md5
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
|
||||
#include "wltypes.h"
|
||||
#include "md5.h"
|
||||
|
||||
#include "hostsa_ext_def.h"
|
||||
#include "authenticator.h"
|
||||
|
||||
void
|
||||
Mrvl_hmac_md5(void *priv, UINT8 *text_data, int text_len, UINT8 *key,
|
||||
int key_len, void *digest)
|
||||
{
|
||||
phostsa_private psapriv = (phostsa_private)priv;
|
||||
hostsa_util_fns *util_fns = &psapriv->util_fns;
|
||||
//BufferDesc_t * pDesc = NULL;
|
||||
UINT8 buf[400] = { 0 };
|
||||
Mrvl_MD5_CTX *context;
|
||||
unsigned char *k_pad; /* padding - key XORd with i/opad */
|
||||
int i;
|
||||
#if 0
|
||||
/* Wait forever ensures a buffer */
|
||||
pDesc = (BufferDesc_t *) bml_AllocBuffer(ramHook_encrPoolConfig,
|
||||
400, BML_WAIT_FOREVER);
|
||||
#endif
|
||||
/* WLAN buffers are aligned, so k_pad start at a UINT32 boundary */
|
||||
//k_pad = (unsigned char *)BML_DATA_PTR(pDesc);
|
||||
k_pad = (unsigned char *)buf;
|
||||
context = (Mrvl_MD5_CTX *)(k_pad + 64);
|
||||
|
||||
/* if key is longer than 64 bytes reset it to key=MD5(key) */
|
||||
if (key_len > 64) {
|
||||
Mrvl_MD5_CTX tctx;
|
||||
|
||||
wpa_MD5Init(&tctx);
|
||||
wpa_MD5Update((void *)priv, &tctx, key, key_len);
|
||||
wpa_MD5Final((void *)priv, context->buffer, &tctx);
|
||||
|
||||
key = context->buffer;
|
||||
key_len = 16;
|
||||
}
|
||||
|
||||
/* the HMAC_MD5 transform looks like: */
|
||||
/* */
|
||||
/* MD5(K XOR opad, MD5(K XOR ipad, text)) */
|
||||
/* */
|
||||
/* where K is an n byte key */
|
||||
/* ipad is the byte 0x36 repeated 64 times */
|
||||
/* opad is the byte 0x5c repeated 64 times */
|
||||
/* and text is the data being protected */
|
||||
|
||||
/* start out by storing key in pads */
|
||||
memset(util_fns, k_pad, 0, 64);
|
||||
memcpy(util_fns, k_pad, key, key_len);
|
||||
|
||||
/* XOR key with ipad and opad values */
|
||||
for (i = 0; i < 16; i++) {
|
||||
((UINT32 *)k_pad)[i] ^= 0x36363636;
|
||||
}
|
||||
|
||||
/* perform inner MD5 */
|
||||
wpa_MD5Init(context); /* init context for 1st pass */
|
||||
wpa_MD5Update((void *)priv, context, k_pad, 64); /* start with inner pad */
|
||||
wpa_MD5Update((void *)priv, context, text_data, text_len); /* then text of datagram */
|
||||
wpa_MD5Final((void *)priv, digest, context); /* finish up 1st pass */
|
||||
|
||||
/* start out by storing key in pads */
|
||||
memset(util_fns, k_pad, 0, 64);
|
||||
memcpy(util_fns, k_pad, key, key_len);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
((UINT32 *)k_pad)[i] ^= 0x5c5c5c5c;
|
||||
}
|
||||
|
||||
/* perform outer MD5 */
|
||||
wpa_MD5Init(context); /* init context for 2nd pass */
|
||||
wpa_MD5Update((void *)priv, context, k_pad, 64);
|
||||
/* start with outer pad */
|
||||
wpa_MD5Update((void *)priv, context, digest, 16);
|
||||
/* then results of 1st hash */
|
||||
wpa_MD5Final((void *)priv, digest, context); /* finish up 2nd pass */
|
||||
|
||||
// bml_FreeBuffer((UINT32)pDesc);
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/** @file hmac_sha1.c
|
||||
*
|
||||
* @brief This file defines algorithm for hmac sha1
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#include "wltypes.h"
|
||||
#include "wl_macros.h"
|
||||
#include "sha1.h"
|
||||
#include "hostsa_ext_def.h"
|
||||
#include "authenticator.h"
|
||||
|
||||
void
|
||||
Mrvl_hmac_sha1(void *priv, unsigned char **ppText,
|
||||
int *pTextLen,
|
||||
int textNum,
|
||||
unsigned char *key,
|
||||
int key_len, unsigned char *output, int outputLen)
|
||||
{
|
||||
/*
|
||||
Note- Some of the variables are made static in this function
|
||||
becuase currently this function executes in the idle task.
|
||||
The idle task dosent have enough stack space to accomodate
|
||||
these varables. In the future if this function in executed in
|
||||
a different task or if we increase the stack size of the idle
|
||||
task then we can put these variables on the stack
|
||||
*/
|
||||
//BufferDesc_t * pDesc = NULL;
|
||||
phostsa_private psapriv = (phostsa_private)priv;
|
||||
hostsa_util_fns *util_fns = &psapriv->util_fns;
|
||||
UINT8 buf[400] = { 0 };
|
||||
Mrvl_SHA1_CTX *context;
|
||||
unsigned char *k_pad; /* padding - key XORd with i/opad */
|
||||
unsigned char *digest;
|
||||
int i;
|
||||
|
||||
k_pad = (unsigned char *)buf;
|
||||
digest = k_pad + 64;
|
||||
context = (Mrvl_SHA1_CTX *)(k_pad + 64 + 20);
|
||||
|
||||
/* if key is longer than 64 bytes reset it to key=SHA1(key) */
|
||||
if (key_len > 64) {
|
||||
Mrvl_SHA1Init(context);
|
||||
Mrvl_SHA1Update(context, key, key_len);
|
||||
Mrvl_SHA1Final((void *)priv, context, key);
|
||||
|
||||
key_len = 20;
|
||||
}
|
||||
|
||||
/*
|
||||
* the HMAC_SHA1 transform looks like:
|
||||
*
|
||||
* SHA1(K XOR opad, SHA1(K XOR ipad, text))
|
||||
*
|
||||
* where K is an n byte key
|
||||
* ipad is the byte 0x36 repeated 64 times
|
||||
* opad is the byte 0x5c repeated 64 times
|
||||
* and text is the data being protected
|
||||
*/
|
||||
|
||||
/* perform inner SHA1 */
|
||||
/* start out by storing key in pads */
|
||||
memset(util_fns, k_pad, 0, 64);
|
||||
memcpy(util_fns, k_pad, key, key_len);
|
||||
|
||||
/* XOR key with ipad and opad values */
|
||||
for (i = 0; i < 8; i++) {
|
||||
((UINT64 *)k_pad)[i] ^= 0x3636363636363636ULL;
|
||||
}
|
||||
|
||||
Mrvl_SHA1Init(context); /* init context for 1st pass */
|
||||
Mrvl_SHA1Update(context, k_pad, 64); /* start with inner pad */
|
||||
for (i = 0; i < textNum; i++) {
|
||||
/* then text of datagram */
|
||||
Mrvl_SHA1Update(context, ppText[i], pTextLen[i]);
|
||||
}
|
||||
|
||||
Mrvl_SHA1Final((void *)priv, context, digest); /* finish up 1st pass */
|
||||
|
||||
/* perform outer SHA1 */
|
||||
/* start out by storing key in pads */
|
||||
memset(util_fns, k_pad, 0, 64);
|
||||
memcpy(util_fns, k_pad, key, key_len);
|
||||
|
||||
/* XOR key with ipad and opad values */
|
||||
for (i = 0; i < 8; i++) {
|
||||
((UINT64 *)k_pad)[i] ^= 0x5c5c5c5c5c5c5c5cULL;
|
||||
}
|
||||
|
||||
Mrvl_SHA1Init(context); /* init context for 2nd pass */
|
||||
Mrvl_SHA1Update(context, k_pad, 64); /* start with outer pad */
|
||||
Mrvl_SHA1Update(context, digest, 20); /* then results of 1st hash */
|
||||
Mrvl_SHA1Final((void *)priv, context, digest); /* finish up 2nd pass */
|
||||
memcpy(util_fns, output, digest, outputLen);
|
||||
|
||||
// bml_FreeBuffer((UINT32)pDesc);
|
||||
}
|
||||
|
||||
/*
|
||||
* PRF -- Length of output is in octets rather than bits
|
||||
* since length is always a multiple of 8 output array is
|
||||
* organized so first N octets starting from 0 contains PRF output
|
||||
*
|
||||
* supported inputs are 16, 32, 48, 64
|
||||
* output array must be 80 octets to allow for sha1 overflow
|
||||
*/
|
||||
void
|
||||
Mrvl_PRF(void *priv, unsigned char *key, int key_len,
|
||||
unsigned char *prefix, int prefix_len,
|
||||
unsigned char *data, int data_len, unsigned char *output, int len)
|
||||
{
|
||||
phostsa_private psapriv = (phostsa_private)priv;
|
||||
hostsa_util_fns *util_fns = &psapriv->util_fns;
|
||||
int i;
|
||||
int currentindex = 0;
|
||||
int total_len;
|
||||
UINT8 prf_input[120]; /* concatenated input */
|
||||
unsigned char *pText = prf_input;
|
||||
SINT8 remain = len;
|
||||
|
||||
memset(util_fns, prf_input, 0x00, sizeof(prf_input));
|
||||
|
||||
if (prefix) {
|
||||
memcpy(util_fns, prf_input, prefix, prefix_len);
|
||||
prf_input[prefix_len] = 0; /* single octet 0 */
|
||||
memcpy(util_fns, &prf_input[prefix_len + 1], data, data_len);
|
||||
total_len = prefix_len + 1 + data_len;
|
||||
} else {
|
||||
memcpy(util_fns, prf_input, data, data_len);
|
||||
total_len = data_len;
|
||||
}
|
||||
|
||||
prf_input[total_len] = 0; /* single octet count, starts at 0 */
|
||||
total_len++;
|
||||
for (i = 0; i < (len + 19) / 20; i++) {
|
||||
Mrvl_hmac_sha1(priv, (UINT8 **)&pText,
|
||||
&total_len,
|
||||
1,
|
||||
key,
|
||||
key_len, &output[currentindex], MIN(20, remain));
|
||||
currentindex += MIN(20, remain); /* next concatenation location */
|
||||
remain -= 20;
|
||||
prf_input[total_len - 1]++; /* increment octet count */
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
/** @file md5.c
|
||||
*
|
||||
* @brief This file defines the function for md5
|
||||
*
|
||||
* Copyright (C) 2014-2017, Marvell International Ltd.
|
||||
*
|
||||
* This software file (the "File") is distributed by Marvell International
|
||||
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
||||
* (the "License"). You may use, redistribute and/or modify this File in
|
||||
* accordance with the terms and conditions of the License, a copy of which
|
||||
* is available by writing to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
||||
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
||||
*
|
||||
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
||||
* this warranty disclaimer.
|
||||
*/
|
||||
|
||||
/******************************************************
|
||||
Change log:
|
||||
03/07/2014: Initial version
|
||||
******************************************************/
|
||||
#include "wltypes.h"
|
||||
#include "md5.h"
|
||||
|
||||
#include "hostsa_ext_def.h"
|
||||
#include "authenticator.h"
|
||||
|
||||
/* Constants for wpa_MD5Transform routine.
|
||||
*/
|
||||
#define S11 7
|
||||
#define S12 12
|
||||
#define S13 17
|
||||
#define S14 22
|
||||
#define S21 5
|
||||
#define S22 9
|
||||
#define S23 14
|
||||
#define S24 20
|
||||
#define S31 4
|
||||
#define S32 11
|
||||
#define S33 16
|
||||
#define S34 23
|
||||
#define S41 6
|
||||
#define S42 10
|
||||
#define S43 15
|
||||
#define S44 21
|
||||
|
||||
#define Mrvl_MD5_memcpy(utils, output, input, len) memcpy(utils, output, input, len)
|
||||
#define Mrvl_MD5_memset(utils, output, value, len) memset(utils, output, value, len)
|
||||
#define Encode(utils, output, input, len) memcpy(utils, output, input, len)
|
||||
|
||||
static void wpa_MD5Transform(void *priv, UINT32 *state, unsigned int *block);
|
||||
|
||||
static const unsigned char PADDING[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
/* F, G, H and I are basic MD5 functions.
|
||||
*/
|
||||
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
|
||||
/* ROTATE_LEFT rotates x left n bits.
|
||||
*/
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||
|
||||
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
||||
Rotation is separate from addition to prevent recomputation.
|
||||
*/
|
||||
#define FF(a, b, c, d, x, s, ac) { \
|
||||
(a) += F ((b), (c), (d)) + (x) + (UINT32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b);}
|
||||
|
||||
#define GG(a, b, c, d, x, s, ac) { \
|
||||
(a) += G ((b), (c), (d)) + (x) + (UINT32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define HH(a, b, c, d, x, s, ac) { \
|
||||
(a) += H ((b), (c), (d)) + (x) + (UINT32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define II(a, b, c, d, x, s, ac) { \
|
||||
(a) += I ((b), (c), (d)) + (x) + (UINT32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
/* MD5 initialization. Begins an MD5 operation, writing a new context.
|
||||
*/
|
||||
void
|
||||
wpa_MD5Init(Mrvl_MD5_CTX *context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants. */
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xefcdab89;
|
||||
context->state[2] = 0x98badcfe;
|
||||
context->state[3] = 0x10325476;
|
||||
}
|
||||
|
||||
/* MD5 block update operation. Continues an MD5 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
void
|
||||
wpa_MD5Update(void *priv, Mrvl_MD5_CTX *context, UINT8 *input, UINT32 inputLen)
|
||||
{
|
||||
phostsa_private psapriv = (phostsa_private)priv;
|
||||
hostsa_util_fns *util_fns = &psapriv->util_fns;
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((UINT32)inputLen << 3))
|
||||
< ((UINT32)inputLen << 3)) {
|
||||
context->count[1]++;
|
||||
}
|
||||
context->count[1] += ((UINT32)inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible. */
|
||||
if (inputLen >= partLen) {
|
||||
Mrvl_MD5_memcpy(util_fns, &context->buffer[index], input,
|
||||
partLen);
|
||||
wpa_MD5Transform((void *)priv, context->state,
|
||||
(UINT32 *)context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64) {
|
||||
Mrvl_MD5_memcpy(util_fns, context->scratch, (input + i),
|
||||
64);
|
||||
wpa_MD5Transform((void *)priv, context->state,
|
||||
context->scratch);
|
||||
}
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
Mrvl_MD5_memcpy(util_fns, &context->buffer[index], &input[i],
|
||||
inputLen - i);
|
||||
}
|
||||
|
||||
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
void
|
||||
wpa_MD5Final(void *priv, unsigned char digest[16], Mrvl_MD5_CTX *context)
|
||||
{
|
||||
phostsa_private psapriv = (phostsa_private)priv;
|
||||
hostsa_util_fns *util_fns = &psapriv->util_fns;
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(util_fns, bits, context->count, 8);
|
||||
|
||||
/* Pad out to 56 mod 64. */
|
||||
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
wpa_MD5Update(priv, context, (UINT8 *)PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
wpa_MD5Update(priv, context, bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
Encode(util_fns, digest, context->state, 16);
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
Mrvl_MD5_memset(util_fns, context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
/* MD5 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void
|
||||
wpa_MD5Transform(void *priv, UINT32 *state, unsigned int *block)
|
||||
{
|
||||
phostsa_private psapriv = (phostsa_private)priv;
|
||||
hostsa_util_fns *util_fns = &psapriv->util_fns;
|
||||
UINT32 a = state[0], b = state[1], c = state[2], d = state[3], *x;
|
||||
|
||||
/* Decode (x, block, 64); */
|
||||
x = block;
|
||||
|
||||
/* Round 1 */
|
||||
FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
|
||||
FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
|
||||
FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
|
||||
FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
|
||||
FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
|
||||
FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
|
||||
FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
|
||||
FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
|
||||
FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
|
||||
FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
|
||||
FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
||||
FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
||||
FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
||||
FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
||||
FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
||||
FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
||||
|
||||
/* Round 2 */
|
||||
GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
|
||||
GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
|
||||
GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
||||
GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
|
||||
GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
|
||||
GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
||||
GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
||||
GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
|
||||
GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
|
||||
GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
||||
GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
|
||||
|
||||
GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
|
||||
GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
||||
GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
|
||||
GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
|
||||
GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
||||
|
||||
/* Round 3 */
|
||||
HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
|
||||
HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
|
||||
HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
||||
HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
||||
HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
|
||||
HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
|
||||
HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
|
||||
HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
||||
HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
||||
HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
|
||||
HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
|
||||
HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
|
||||
HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
|
||||
HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
||||
HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
||||
HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
|
||||
|
||||
/* Round 4 */
|
||||
II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
|
||||
II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
|
||||
II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
||||
II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
|
||||
II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
||||
II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
|
||||
II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
||||
II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
|
||||
II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
|
||||
II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
||||
II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
|
||||
II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
||||
II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
|
||||
II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
||||
II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
|
||||
II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
Mrvl_MD5_memset(util_fns, x, 0, sizeof(x));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user