New upstream version 5.3.9~git20210504.6146193
This commit is contained in:
@@ -2133,8 +2133,7 @@ BIP_exit:
|
||||
#ifndef PLATFORM_FREEBSD
|
||||
#if defined(CONFIG_TDLS)
|
||||
/* compress 512-bits */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
|
||||
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;
|
||||
@@ -2180,11 +2179,9 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf)
|
||||
md->state[i] = md->state[i] + S[i];
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the hash state */
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
|
||||
static void sha256_init(struct sha256_state *md)
|
||||
static void rtw_sha256_init(struct rtw_sha256_state *md)
|
||||
{
|
||||
md->curlen = 0;
|
||||
md->length = 0;
|
||||
@@ -2197,7 +2194,6 @@ static void sha256_init(struct sha256_state *md)
|
||||
md->state[6] = 0x1F83D9ABUL;
|
||||
md->state[7] = 0x5BE0CD19UL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
Process a block of memory though the hash
|
||||
@@ -2206,9 +2202,7 @@ static void sha256_init(struct sha256_state *md)
|
||||
@param inlen The length of the data (octets)
|
||||
@return CRYPT_OK if successful
|
||||
*/
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
|
||||
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;
|
||||
@@ -2219,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;
|
||||
@@ -2231,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;
|
||||
@@ -2241,7 +2235,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in,
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
Terminate the hash to get the digest
|
||||
@@ -2249,8 +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
|
||||
*/
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
|
||||
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;
|
||||
|
||||
@@ -2270,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;
|
||||
}
|
||||
|
||||
@@ -2280,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++)
|
||||
@@ -2288,7 +2281,6 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* sha256_vector - SHA256 hash for data vector
|
||||
@@ -2298,23 +2290,20 @@ static int sha256_done(struct sha256_state *md, unsigned char *out)
|
||||
* @mac: Buffer for the hash
|
||||
* Returns: 0 on success, -1 of failure
|
||||
*/
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
static u8 os_strlen(const char *s)
|
||||
{
|
||||
@@ -2355,7 +2344,6 @@ static int os_memcmp(const void *s1, const void *s2, u8 n)
|
||||
* @mac: Buffer for the hash (32 bytes)
|
||||
*/
|
||||
#if defined(CONFIG_TDLS)
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
|
||||
static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem,
|
||||
u8 *addr[], size_t *len, u8 *mac)
|
||||
{
|
||||
@@ -2374,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;
|
||||
}
|
||||
@@ -2402,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);
|
||||
@@ -2415,9 +2403,8 @@ 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
|
||||
#endif /* CONFIG_TDLS */
|
||||
#endif /* PLATFORM_FREEBSD */
|
||||
/**
|
||||
@@ -2435,8 +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)
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0))
|
||||
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;
|
||||
@@ -2460,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);
|
||||
@@ -2473,7 +2459,6 @@ static void sha256_prf(u8 *key, size_t key_len, char *label,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* PLATFORM_FREEBSD Baron */
|
||||
|
||||
/* AES tables*/
|
||||
@@ -3123,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",
|
||||
@@ -3142,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));
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user