qcacmn: Integrate crypto service and sw files
Integrate crypto service and crypto sw files from hostapd Change-Id: I1e461269a603beffd9d05e304817418e5d0e4f1c
This commit is contained in:

committed by
Sandeep Puligilla

parent
c365d5fbb5
commit
13e9f9bb19
@@ -342,4 +342,15 @@ QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev,
|
|||||||
QDF_STATUS wlan_crypto_register_crypto_rx_ops(
|
QDF_STATUS wlan_crypto_register_crypto_rx_ops(
|
||||||
struct wlan_lmac_if_crypto_rx_ops *crypto_rx_ops);
|
struct wlan_lmac_if_crypto_rx_ops *crypto_rx_ops);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wlan_crypto_get_crypto_rx_ops - get crypto_rx_ops from psoc
|
||||||
|
*
|
||||||
|
* @psoc: psoc
|
||||||
|
*
|
||||||
|
* This function gets called by umac to get the crypto_rx_ops
|
||||||
|
*
|
||||||
|
* Return: crypto_rx_ops
|
||||||
|
*/
|
||||||
|
struct wlan_lmac_if_crypto_rx_ops *wlan_crypto_get_crypto_rx_ops(
|
||||||
|
struct wlan_objmgr_psoc *psoc);
|
||||||
#endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */
|
#endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
#ifndef _WLAN_CRYPTO_GLOBAL_DEF_H_
|
#ifndef _WLAN_CRYPTO_GLOBAL_DEF_H_
|
||||||
#define _WLAN_CRYPTO_GLOBAL_DEF_H_
|
#define _WLAN_CRYPTO_GLOBAL_DEF_H_
|
||||||
|
|
||||||
|
#include <wlan_cmn.h>
|
||||||
|
|
||||||
#define WLAN_CRYPTO_TID_SIZE (17)
|
#define WLAN_CRYPTO_TID_SIZE (17)
|
||||||
#define WLAN_CRYPTO_KEYBUF_SIZE (32)
|
#define WLAN_CRYPTO_KEYBUF_SIZE (32)
|
||||||
#define WLAN_CRYPTO_MICBUF_SIZE (16)
|
#define WLAN_CRYPTO_MICBUF_SIZE (16)
|
||||||
@@ -293,4 +295,15 @@ struct wlan_lmac_if_crypto_rx_ops {
|
|||||||
uint8_t *mac_addr);
|
uint8_t *mac_addr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define WLAN_CRYPTO_RX_OPS_ENCAP(crypto_rx_ops) \
|
||||||
|
(crypto_rx_ops->crypto_encap)
|
||||||
|
#define WLAN_CRYPTO_RX_OPS_DECAP(crypto_rx_ops) \
|
||||||
|
(crypto_rx_ops->crypto_decap)
|
||||||
|
#define WLAN_CRYPTO_RX_OPS_ENMIC(crypto_rx_ops) \
|
||||||
|
(crypto_rx_ops->crypto_enmic)
|
||||||
|
#define WLAN_CRYPTO_RX_OPS_DEMIC(crypto_rx_ops) \
|
||||||
|
(crypto_rx_ops->crypto_demic)
|
||||||
|
#define WLAN_CRYPTO_RX_OPS_SET_PEER_WEP_KEYS(crypto_rx_ops) \
|
||||||
|
(crypto_rx_ops->set_peer_wep_keys)
|
||||||
|
|
||||||
#endif /* end of _WLAN_CRYPTO_GLOBAL_DEF_H_ */
|
#endif /* end of _WLAN_CRYPTO_GLOBAL_DEF_H_ */
|
||||||
|
@@ -39,15 +39,18 @@ static void aes_ccm_auth_start(void *aes, size_t M, size_t L,
|
|||||||
b[0] |= (((M - 2) / 2) /* M' */ << 3);
|
b[0] |= (((M - 2) / 2) /* M' */ << 3);
|
||||||
b[0] |= (L - 1) /* L' */;
|
b[0] |= (L - 1) /* L' */;
|
||||||
qdf_mem_copy(&b[1], nonce, 15 - L);
|
qdf_mem_copy(&b[1], nonce, 15 - L);
|
||||||
WPA_PUT_BE16(&b[AES_BLOCK_SIZE - L], plain_len);
|
wlan_crypto_put_be16(&b[AES_BLOCK_SIZE - L], plain_len);
|
||||||
|
|
||||||
wpa_hexdump_key(MSG_EXCESSIVE, "CCM B_0", b, AES_BLOCK_SIZE);
|
wpa_hexdump_key(MSG_EXCESSIVE, "CCM B_0", b, AES_BLOCK_SIZE);
|
||||||
wlan_crypto_aes_encrypt(aes, b, x); /* X_1 = E(K, B_0) */
|
wlan_crypto_aes_encrypt(aes, b, x); /* X_1 = E(K, B_0) */
|
||||||
|
|
||||||
if (!aad_len)
|
if (!aad_len) {
|
||||||
|
qdf_print("%s[%d] aad length should be non zero\n",
|
||||||
|
__func__, __LINE__);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WPA_PUT_BE16(aad_buf, aad_len);
|
wlan_crypto_put_be16(aad_buf, aad_len);
|
||||||
qdf_mem_copy(aad_buf + 2, aad, aad_len);
|
qdf_mem_copy(aad_buf + 2, aad, aad_len);
|
||||||
qdf_mem_set(aad_buf + 2 + aad_len, 0, sizeof(aad_buf) - 2 - aad_len);
|
qdf_mem_set(aad_buf + 2 + aad_len, 0, sizeof(aad_buf) - 2 - aad_len);
|
||||||
|
|
||||||
@@ -97,7 +100,7 @@ static void aes_ccm_encr(void *aes, size_t L, const uint8_t *in, size_t len,
|
|||||||
|
|
||||||
/* crypt = msg XOR (S_1 | S_2 | ... | S_n) */
|
/* crypt = msg XOR (S_1 | S_2 | ... | S_n) */
|
||||||
for (i = 1; i <= len / AES_BLOCK_SIZE; i++) {
|
for (i = 1; i <= len / AES_BLOCK_SIZE; i++) {
|
||||||
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
|
wlan_crypto_put_be16(&a[AES_BLOCK_SIZE - 2], i);
|
||||||
/* S_i = E(K, A_i) */
|
/* S_i = E(K, A_i) */
|
||||||
wlan_crypto_aes_encrypt(aes, a, out);
|
wlan_crypto_aes_encrypt(aes, a, out);
|
||||||
xor_aes_block(out, in);
|
xor_aes_block(out, in);
|
||||||
@@ -105,7 +108,7 @@ static void aes_ccm_encr(void *aes, size_t L, const uint8_t *in, size_t len,
|
|||||||
in += AES_BLOCK_SIZE;
|
in += AES_BLOCK_SIZE;
|
||||||
}
|
}
|
||||||
if (last) {
|
if (last) {
|
||||||
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], i);
|
wlan_crypto_put_be16(&a[AES_BLOCK_SIZE - 2], i);
|
||||||
wlan_crypto_aes_encrypt(aes, a, out);
|
wlan_crypto_aes_encrypt(aes, a, out);
|
||||||
/* XOR zero-padded last block */
|
/* XOR zero-padded last block */
|
||||||
for (i = 0; i < last; i++)
|
for (i = 0; i < last; i++)
|
||||||
@@ -121,7 +124,7 @@ static void aes_ccm_encr_auth(void *aes, size_t M, uint8_t *x, uint8_t *a,
|
|||||||
|
|
||||||
wpa_hexdump_key(MSG_EXCESSIVE, "CCM T", x, M);
|
wpa_hexdump_key(MSG_EXCESSIVE, "CCM T", x, M);
|
||||||
/* U = T XOR S_0; S_0 = E(K, A_0) */
|
/* U = T XOR S_0; S_0 = E(K, A_0) */
|
||||||
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
|
wlan_crypto_put_be16(&a[AES_BLOCK_SIZE - 2], 0);
|
||||||
wlan_crypto_aes_encrypt(aes, a, tmp);
|
wlan_crypto_aes_encrypt(aes, a, tmp);
|
||||||
for (i = 0; i < M; i++)
|
for (i = 0; i < M; i++)
|
||||||
auth[i] = x[i] ^ tmp[i];
|
auth[i] = x[i] ^ tmp[i];
|
||||||
@@ -136,7 +139,7 @@ static void aes_ccm_decr_auth(void *aes, size_t M, uint8_t *a,
|
|||||||
|
|
||||||
wpa_hexdump_key(MSG_EXCESSIVE, "CCM U", auth, M);
|
wpa_hexdump_key(MSG_EXCESSIVE, "CCM U", auth, M);
|
||||||
/* U = T XOR S_0; S_0 = E(K, A_0) */
|
/* U = T XOR S_0; S_0 = E(K, A_0) */
|
||||||
WPA_PUT_BE16(&a[AES_BLOCK_SIZE - 2], 0);
|
wlan_crypto_put_be16(&a[AES_BLOCK_SIZE - 2], 0);
|
||||||
wlan_crypto_aes_encrypt(aes, a, tmp);
|
wlan_crypto_aes_encrypt(aes, a, tmp);
|
||||||
for (i = 0; i < M; i++)
|
for (i = 0; i < M; i++)
|
||||||
t[i] = auth[i] ^ tmp[i];
|
t[i] = auth[i] ^ tmp[i];
|
||||||
|
@@ -19,9 +19,9 @@
|
|||||||
static void inc32(uint8_t *block)
|
static void inc32(uint8_t *block)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
val = WPA_GET_BE32(block + AES_BLOCK_SIZE - 4);
|
val = wlan_crypto_get_be32(block + AES_BLOCK_SIZE - 4);
|
||||||
val++;
|
val++;
|
||||||
WPA_PUT_BE32(block + AES_BLOCK_SIZE - 4, val);
|
wlan_crypto_put_be32(block + AES_BLOCK_SIZE - 4, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,27 +40,27 @@ static void shift_right_block(uint8_t *v)
|
|||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
|
||||||
val = WPA_GET_BE32(v + 12);
|
val = wlan_crypto_get_be32(v + 12);
|
||||||
val >>= 1;
|
val >>= 1;
|
||||||
if (v[11] & 0x01)
|
if (v[11] & 0x01)
|
||||||
val |= 0x80000000;
|
val |= 0x80000000;
|
||||||
WPA_PUT_BE32(v + 12, val);
|
wlan_crypto_put_be32(v + 12, val);
|
||||||
|
|
||||||
val = WPA_GET_BE32(v + 8);
|
val = wlan_crypto_get_be32(v + 8);
|
||||||
val >>= 1;
|
val >>= 1;
|
||||||
if (v[7] & 0x01)
|
if (v[7] & 0x01)
|
||||||
val |= 0x80000000;
|
val |= 0x80000000;
|
||||||
WPA_PUT_BE32(v + 8, val);
|
wlan_crypto_put_be32(v + 8, val);
|
||||||
|
|
||||||
val = WPA_GET_BE32(v + 4);
|
val = wlan_crypto_get_be32(v + 4);
|
||||||
val >>= 1;
|
val >>= 1;
|
||||||
if (v[3] & 0x01)
|
if (v[3] & 0x01)
|
||||||
val |= 0x80000000;
|
val |= 0x80000000;
|
||||||
WPA_PUT_BE32(v + 4, val);
|
wlan_crypto_put_be32(v + 4, val);
|
||||||
|
|
||||||
val = WPA_GET_BE32(v);
|
val = wlan_crypto_get_be32(v);
|
||||||
val >>= 1;
|
val >>= 1;
|
||||||
WPA_PUT_BE32(v, val);
|
wlan_crypto_put_be32(v, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -208,8 +208,8 @@ static void aes_gcm_prepare_j0(const uint8_t *iv, size_t iv_len,
|
|||||||
*/
|
*/
|
||||||
ghash_start(J0);
|
ghash_start(J0);
|
||||||
ghash(H, iv, iv_len, J0);
|
ghash(H, iv, iv_len, J0);
|
||||||
WPA_PUT_BE64(len_buf, 0);
|
wlan_crypto_put_be64(len_buf, 0);
|
||||||
WPA_PUT_BE64(len_buf + 8, iv_len * 8);
|
wlan_crypto_put_be64(len_buf + 8, iv_len * 8);
|
||||||
ghash(H, len_buf, sizeof(len_buf), J0);
|
ghash(H, len_buf, sizeof(len_buf), J0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,8 +242,8 @@ static void aes_gcm_ghash(const uint8_t *H, const uint8_t *aad, size_t aad_len,
|
|||||||
ghash_start(S);
|
ghash_start(S);
|
||||||
ghash(H, aad, aad_len, S);
|
ghash(H, aad, aad_len, S);
|
||||||
ghash(H, crypt, crypt_len, S);
|
ghash(H, crypt, crypt_len, S);
|
||||||
WPA_PUT_BE64(len_buf, aad_len * 8);
|
wlan_crypto_put_be64(len_buf, aad_len * 8);
|
||||||
WPA_PUT_BE64(len_buf + 8, crypt_len * 8);
|
wlan_crypto_put_be64(len_buf + 8, crypt_len * 8);
|
||||||
ghash(H, len_buf, sizeof(len_buf), S);
|
ghash(H, len_buf, sizeof(len_buf), S);
|
||||||
|
|
||||||
wpa_hexdump_key(MSG_EXCESSIVE, "S = GHASH_H(...)", S, 16);
|
wpa_hexdump_key(MSG_EXCESSIVE, "S = GHASH_H(...)", S, 16);
|
||||||
|
@@ -12,6 +12,13 @@
|
|||||||
#ifndef WLAN_CRYPTO_AES_I_H
|
#ifndef WLAN_CRYPTO_AES_I_H
|
||||||
#define WLAN_CRYPTO_AES_I_H
|
#define WLAN_CRYPTO_AES_I_H
|
||||||
|
|
||||||
|
#include <wlan_cmn.h>
|
||||||
|
#include <wlan_objmgr_cmn.h>
|
||||||
|
#include <wlan_objmgr_global_obj.h>
|
||||||
|
#include <wlan_objmgr_psoc_obj.h>
|
||||||
|
#include <wlan_objmgr_pdev_obj.h>
|
||||||
|
#include <wlan_objmgr_vdev_obj.h>
|
||||||
|
#include <wlan_objmgr_peer_obj.h>
|
||||||
#include "wlan_crypto_global_def.h"
|
#include "wlan_crypto_global_def.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -182,29 +189,24 @@ struct ieee80211_hdr_qos_addr4 {
|
|||||||
int wlan_crypto_rijndaelKeySetupEnc(uint32_t rk[], const uint8_t cipherKey[],
|
int wlan_crypto_rijndaelKeySetupEnc(uint32_t rk[], const uint8_t cipherKey[],
|
||||||
int keyBits);
|
int keyBits);
|
||||||
|
|
||||||
uint8_t *wlan_crypto_ccmp_encrypt(const uint8_t *tk, uint8_t *frame, size_t len,
|
uint8_t *wlan_crypto_ccmp_encrypt(const uint8_t *key, uint8_t *frame,
|
||||||
size_t hdrlen, uint8_t *qos,
|
size_t len, size_t hdrlen);
|
||||||
uint8_t *pn, int keyid,
|
|
||||||
size_t *encrypted_len);
|
|
||||||
|
|
||||||
uint8_t *wlan_crypto_ccmp_decrypt(const uint8_t *tk,
|
uint8_t *wlan_crypto_ccmp_decrypt(const uint8_t *key,
|
||||||
const struct ieee80211_hdr *hdr,
|
const struct ieee80211_hdr *hdr,
|
||||||
const uint8_t *data, size_t data_len,
|
uint8_t *data, size_t data_len);
|
||||||
size_t *decrypted_len);
|
|
||||||
|
|
||||||
uint8_t *wlan_crypto_tkip_encrypt(const uint8_t *tk, uint8_t *frame, size_t len,
|
uint8_t *wlan_crypto_tkip_encrypt(const uint8_t *key, uint8_t *frame,
|
||||||
size_t hdrlen, uint8_t *qos, uint8_t *pn,
|
size_t len, size_t hdrlen);
|
||||||
int keyid, size_t *encrypted_len);
|
|
||||||
|
|
||||||
uint8_t *wlan_crypto_tkip_decrypt(const uint8_t *tk,
|
uint8_t *wlan_crypto_tkip_decrypt(const uint8_t *key,
|
||||||
const struct ieee80211_hdr *hdr,
|
const struct ieee80211_hdr *hdr,
|
||||||
const uint8_t *data, size_t data_len,
|
uint8_t *data, size_t data_len);
|
||||||
size_t *decrypted_len);
|
|
||||||
|
|
||||||
|
uint8_t *wlan_crypto_wep_encrypt(const uint8_t *key, uint16_t key_len,
|
||||||
|
uint8_t *data, size_t data_len);
|
||||||
uint8_t *wlan_crypto_wep_decrypt(const uint8_t *key, uint16_t key_len,
|
uint8_t *wlan_crypto_wep_decrypt(const uint8_t *key, uint16_t key_len,
|
||||||
const struct ieee80211_hdr *hdr,
|
uint8_t *data, size_t data_len);
|
||||||
const uint8_t *data, size_t data_len,
|
|
||||||
size_t *decrypted_len);
|
|
||||||
|
|
||||||
void wlan_crypto_wep_crypt(uint8_t *key, uint8_t *buf, size_t plen);
|
void wlan_crypto_wep_crypt(uint8_t *key, uint8_t *buf, size_t plen);
|
||||||
|
|
||||||
@@ -242,4 +244,8 @@ void wlan_crypto_aes_encrypt_deinit(void *ctx);
|
|||||||
void *wlan_crypto_aes_decrypt_init(const uint8_t *key, size_t len);
|
void *wlan_crypto_aes_decrypt_init(const uint8_t *key, size_t len);
|
||||||
void wlan_crypto_aes_decrypt(void *ctx, const uint8_t *crypt, uint8_t *plain);
|
void wlan_crypto_aes_decrypt(void *ctx, const uint8_t *crypt, uint8_t *plain);
|
||||||
void wlan_crypto_aes_decrypt_deinit(void *ctx);
|
void wlan_crypto_aes_decrypt_deinit(void *ctx);
|
||||||
|
int omac1_aes_128(const uint8_t *key, const uint8_t *data,
|
||||||
|
size_t data_len, uint8_t *mac);
|
||||||
|
int omac1_aes_256(const uint8_t *key, const uint8_t *data,
|
||||||
|
size_t data_len, uint8_t *mac);
|
||||||
#endif /* WLAN_CRYPTO_AES_I_H */
|
#endif /* WLAN_CRYPTO_AES_I_H */
|
||||||
|
@@ -32,26 +32,11 @@
|
|||||||
#include "wlan_crypto_def_i.h"
|
#include "wlan_crypto_def_i.h"
|
||||||
#include "wlan_crypto_main_i.h"
|
#include "wlan_crypto_main_i.h"
|
||||||
#include "wlan_crypto_obj_mgr_i.h"
|
#include "wlan_crypto_obj_mgr_i.h"
|
||||||
#include "wlan_crypto_ccmp_i.h"
|
|
||||||
|
|
||||||
#define MAX_CCMP_PN_GAP_ERR_CHECK 0
|
#define MAX_CCMP_PN_GAP_ERR_CHECK 0
|
||||||
|
|
||||||
static QDF_STATUS ccmp_setkey(struct wlan_crypto_key *key)
|
static QDF_STATUS ccmp_setkey(struct wlan_crypto_key *key)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct wlan_crypto_ccmp_ctx *ctx;
|
|
||||||
|
|
||||||
if (key->private == NULL) {
|
|
||||||
key->private = qdf_mem_malloc(
|
|
||||||
sizeof(struct wlan_crypto_ccmp_ctx));
|
|
||||||
if (key->private == NULL)
|
|
||||||
return QDF_STATUS_E_NOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx = key->private;
|
|
||||||
wlan_crypto_rijndael_set_key(&ctx->cc_aes, key->keyval,
|
|
||||||
(key->keylen*NBBY));
|
|
||||||
|
|
||||||
return QDF_STATUS_SUCCESS;
|
return QDF_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,12 +45,12 @@ static QDF_STATUS ccmp_encap(struct wlan_crypto_key *key,
|
|||||||
uint8_t encapdone,
|
uint8_t encapdone,
|
||||||
uint8_t hdrlen){
|
uint8_t hdrlen){
|
||||||
uint8_t *ivp;
|
uint8_t *ivp;
|
||||||
struct ieee80211_frame *wh;
|
struct ieee80211_hdr *hdr;
|
||||||
struct wlan_crypto_cipher *cipher_table;
|
struct wlan_crypto_cipher *cipher_table;
|
||||||
|
|
||||||
cipher_table = (struct wlan_crypto_cipher *)key->cipher_table;
|
cipher_table = (struct wlan_crypto_cipher *)key->cipher_table;
|
||||||
|
|
||||||
wh = (struct ieee80211_frame *)qdf_nbuf_data(wbuf);
|
hdr = (struct ieee80211_hdr *)qdf_nbuf_data(wbuf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy down 802.11 header and add the IV, KeyID, and ExtIV.
|
* Copy down 802.11 header and add the IV, KeyID, and ExtIV.
|
||||||
@@ -77,8 +62,8 @@ static QDF_STATUS ccmp_encap(struct wlan_crypto_key *key,
|
|||||||
ivp = (uint8_t *)qdf_nbuf_push_head(wbuf,
|
ivp = (uint8_t *)qdf_nbuf_push_head(wbuf,
|
||||||
cipher_table->header);
|
cipher_table->header);
|
||||||
qdf_mem_move(ivp, ivp + cipher_table->header, hdrlen);
|
qdf_mem_move(ivp, ivp + cipher_table->header, hdrlen);
|
||||||
/* recompute wh */
|
/* recompute hdr */
|
||||||
wh = (struct ieee80211_frame *) qdf_nbuf_data(wbuf);
|
hdr = (struct ieee80211_hdr *) qdf_nbuf_data(wbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
ivp += hdrlen;
|
ivp += hdrlen;
|
||||||
@@ -99,8 +84,9 @@ static QDF_STATUS ccmp_encap(struct wlan_crypto_key *key,
|
|||||||
* Finally, do software encrypt if neeed.
|
* Finally, do software encrypt if neeed.
|
||||||
*/
|
*/
|
||||||
if (key->flags & WLAN_CRYPTO_KEY_SWENCRYPT) {
|
if (key->flags & WLAN_CRYPTO_KEY_SWENCRYPT) {
|
||||||
if (!wlan_crypto_ccmp_encrypt(key, wbuf, hdrlen,
|
if (!wlan_crypto_ccmp_encrypt(key->keyval,
|
||||||
IEEE80211_IS_MFP_FRAME(wh))) {
|
qdf_nbuf_data(wbuf),
|
||||||
|
qdf_nbuf_len(wbuf), hdrlen)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,7 +100,7 @@ static QDF_STATUS ccmp_decap(struct wlan_crypto_key *key,
|
|||||||
qdf_nbuf_t wbuf,
|
qdf_nbuf_t wbuf,
|
||||||
uint8_t tid,
|
uint8_t tid,
|
||||||
uint8_t hdrlen){
|
uint8_t hdrlen){
|
||||||
struct ieee80211_frame *wh;
|
struct ieee80211_hdr *hdr;
|
||||||
uint8_t *ivp, *origHdr;
|
uint8_t *ivp, *origHdr;
|
||||||
uint64_t pn;
|
uint64_t pn;
|
||||||
uint8_t update_keyrsc = 1;
|
uint8_t update_keyrsc = 1;
|
||||||
@@ -127,7 +113,7 @@ static QDF_STATUS ccmp_decap(struct wlan_crypto_key *key,
|
|||||||
* verify the former and validate the latter.
|
* verify the former and validate the latter.
|
||||||
*/
|
*/
|
||||||
origHdr = (uint8_t *)qdf_nbuf_data(wbuf);
|
origHdr = (uint8_t *)qdf_nbuf_data(wbuf);
|
||||||
wh = (struct ieee80211_frame *)origHdr;
|
hdr = (struct ieee80211_hdr *)origHdr;
|
||||||
|
|
||||||
ivp = origHdr + hdrlen;
|
ivp = origHdr + hdrlen;
|
||||||
|
|
||||||
@@ -136,20 +122,8 @@ static QDF_STATUS ccmp_decap(struct wlan_crypto_key *key,
|
|||||||
return QDF_STATUS_E_INVAL;
|
return QDF_STATUS_E_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tid = IEEE80211_NON_QOS_SEQ;
|
tid = wlan_get_tid(qdf_nbuf_data(wbuf));
|
||||||
|
|
||||||
if (IEEE80211_QOS_HAS_SEQ(wh)) {
|
|
||||||
if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK)
|
|
||||||
== IEEE80211_FC1_DIR_DSTODS) {
|
|
||||||
tid = ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0]
|
|
||||||
& IEEE80211_QOS_TID;
|
|
||||||
} else {
|
|
||||||
tid = ((struct ieee80211_qosframe *)wh)->i_qos[0]
|
|
||||||
& IEEE80211_QOS_TID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* NB: assume IEEEE80211_WEP_MINLEN covers the extended IV */
|
|
||||||
pn = READ_6(ivp[0], ivp[1], ivp[4], ivp[5], ivp[6], ivp[7]);
|
pn = READ_6(ivp[0], ivp[1], ivp[4], ivp[5], ivp[6], ivp[7]);
|
||||||
|
|
||||||
if (pn <= key->keyrsc[tid]) {
|
if (pn <= key->keyrsc[tid]) {
|
||||||
@@ -160,8 +134,10 @@ static QDF_STATUS ccmp_decap(struct wlan_crypto_key *key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((key->flags & WLAN_CRYPTO_KEY_SWDECRYPT)) {
|
if ((key->flags & WLAN_CRYPTO_KEY_SWDECRYPT)) {
|
||||||
if (!wlan_crypto_ccmp_decrypt(key,
|
if (!wlan_crypto_ccmp_decrypt(key->keyval,
|
||||||
pn, wbuf, hdrlen, IEEE80211_IS_MFP_FRAME(wh))) {
|
(struct ieee80211_hdr *)origHdr,
|
||||||
|
(origHdr + hdrlen),
|
||||||
|
(qdf_nbuf_len(wbuf) - hdrlen))) {
|
||||||
return QDF_STATUS_CRYPTO_DECRYPT_FAILED;
|
return QDF_STATUS_CRYPTO_DECRYPT_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,13 +46,13 @@ static void ccmp_aad_nonce(const struct ieee80211_hdr *hdr, const uint8_t *data,
|
|||||||
|
|
||||||
fc &= ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT | WLAN_FC_MOREDATA);
|
fc &= ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT | WLAN_FC_MOREDATA);
|
||||||
fc |= WLAN_FC_ISWEP;
|
fc |= WLAN_FC_ISWEP;
|
||||||
WPA_PUT_LE16(aad, fc);
|
wlan_crypto_put_le16(aad, fc);
|
||||||
pos = aad + 2;
|
pos = aad + 2;
|
||||||
qdf_mem_copy(pos, hdr->addr1, 3 * WLAN_ALEN);
|
qdf_mem_copy(pos, hdr->addr1, 3 * WLAN_ALEN);
|
||||||
pos += 3 * WLAN_ALEN;
|
pos += 3 * WLAN_ALEN;
|
||||||
seq = qdf_le16_to_cpu(hdr->seq_ctrl);
|
seq = qdf_le16_to_cpu(hdr->seq_ctrl);
|
||||||
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
|
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
|
||||||
WPA_PUT_LE16(pos, seq);
|
wlan_crypto_put_le16(pos, seq);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
qdf_mem_copy(pos, hdr + 1, addr4 * WLAN_ALEN + qos * 2);
|
qdf_mem_copy(pos, hdr + 1, addr4 * WLAN_ALEN + qos * 2);
|
||||||
@@ -79,8 +79,7 @@ static void ccmp_aad_nonce(const struct ieee80211_hdr *hdr, const uint8_t *data,
|
|||||||
|
|
||||||
uint8_t *wlan_crypto_ccmp_decrypt(const uint8_t *tk,
|
uint8_t *wlan_crypto_ccmp_decrypt(const uint8_t *tk,
|
||||||
const struct ieee80211_hdr *hdr,
|
const struct ieee80211_hdr *hdr,
|
||||||
const uint8_t *data, size_t data_len,
|
uint8_t *data, size_t data_len){
|
||||||
size_t *decrypted_len){
|
|
||||||
uint8_t aad[30], nonce[13];
|
uint8_t aad[30], nonce[13];
|
||||||
size_t aad_len;
|
size_t aad_len;
|
||||||
size_t mlen;
|
size_t mlen;
|
||||||
@@ -116,8 +115,9 @@ uint8_t *wlan_crypto_ccmp_decrypt(const uint8_t *tk,
|
|||||||
}
|
}
|
||||||
wpa_hexdump(MSG_EXCESSIVE, "CCMP decrypted", plain, mlen);
|
wpa_hexdump(MSG_EXCESSIVE, "CCMP decrypted", plain, mlen);
|
||||||
|
|
||||||
*decrypted_len = mlen;
|
qdf_mem_copy(data, plain, data_len);
|
||||||
return plain;
|
qdf_mem_free(plain);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -133,9 +133,7 @@ void ccmp_get_pn(uint8_t *pn, const uint8_t *data)
|
|||||||
|
|
||||||
|
|
||||||
uint8_t *wlan_crypto_ccmp_encrypt(const uint8_t *tk, uint8_t *frame,
|
uint8_t *wlan_crypto_ccmp_encrypt(const uint8_t *tk, uint8_t *frame,
|
||||||
size_t len, size_t hdrlen, uint8_t *qos,
|
size_t len, size_t hdrlen){
|
||||||
uint8_t *pn, int keyid,
|
|
||||||
size_t *encrypted_len){
|
|
||||||
uint8_t aad[30], nonce[13];
|
uint8_t aad[30], nonce[13];
|
||||||
size_t aad_len, plen;
|
size_t aad_len, plen;
|
||||||
uint8_t *crypt, *pos;
|
uint8_t *crypt, *pos;
|
||||||
@@ -152,17 +150,10 @@ uint8_t *wlan_crypto_ccmp_encrypt(const uint8_t *tk, uint8_t *frame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
qdf_mem_copy(crypt, frame, hdrlen);
|
qdf_mem_copy(crypt, frame, hdrlen);
|
||||||
|
|
||||||
hdr = (struct ieee80211_hdr *) crypt;
|
hdr = (struct ieee80211_hdr *) crypt;
|
||||||
hdr->frame_control |= qdf_cpu_to_le16(WLAN_FC_ISWEP);
|
hdr->frame_control |= qdf_cpu_to_le16(WLAN_FC_ISWEP);
|
||||||
pos = crypt + hdrlen;
|
pos = crypt + hdrlen + 8;
|
||||||
*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 */
|
|
||||||
|
|
||||||
qdf_mem_set(aad, 0, sizeof(aad));
|
qdf_mem_set(aad, 0, sizeof(aad));
|
||||||
ccmp_aad_nonce(hdr, crypt + hdrlen, aad, &aad_len, nonce);
|
ccmp_aad_nonce(hdr, crypt + hdrlen, aad, &aad_len, nonce);
|
||||||
@@ -175,11 +166,11 @@ uint8_t *wlan_crypto_ccmp_encrypt(const uint8_t *tk, uint8_t *frame,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qdf_mem_copy(frame, crypt, len);
|
||||||
wpa_hexdump(MSG_EXCESSIVE, "CCMP encrypted", crypt + hdrlen + 8, plen);
|
wpa_hexdump(MSG_EXCESSIVE, "CCMP encrypted", crypt + hdrlen + 8, plen);
|
||||||
|
qdf_mem_free(crypt);
|
||||||
|
|
||||||
*encrypted_len = hdrlen + 8 + plen + 8;
|
return frame;
|
||||||
|
|
||||||
return crypt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -93,34 +93,34 @@
|
|||||||
|
|
||||||
/* Macros for handling unaligned memory accesses */
|
/* Macros for handling unaligned memory accesses */
|
||||||
|
|
||||||
static inline uint16_t WPA_GET_BE16(const uint8_t *a)
|
static inline uint16_t wlan_crypto_get_be16(const uint8_t *a)
|
||||||
{
|
{
|
||||||
return (a[0] << 8) | a[1];
|
return (a[0] << 8) | a[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void WPA_PUT_BE16(uint8_t *a, uint16_t val)
|
static inline void wlan_crypto_put_be16(uint8_t *a, uint16_t val)
|
||||||
{
|
{
|
||||||
a[0] = val >> 8;
|
a[0] = val >> 8;
|
||||||
a[1] = val & 0xff;
|
a[1] = val & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t WPA_GET_LE16(const uint8_t *a)
|
static inline uint16_t wlan_crypto_get_le16(const uint8_t *a)
|
||||||
{
|
{
|
||||||
return (a[1] << 8) | a[0];
|
return (a[1] << 8) | a[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void WPA_PUT_LE16(uint8_t *a, uint16_t val)
|
static inline void wlan_crypto_put_le16(uint8_t *a, uint16_t val)
|
||||||
{
|
{
|
||||||
a[1] = val >> 8;
|
a[1] = val >> 8;
|
||||||
a[0] = val & 0xff;
|
a[0] = val & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t WPA_GET_BE32(const uint8_t *a)
|
static inline uint32_t wlan_crypto_get_be32(const uint8_t *a)
|
||||||
{
|
{
|
||||||
return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
|
return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void WPA_PUT_BE32(uint8_t *a, uint32_t val)
|
static inline void wlan_crypto_put_be32(uint8_t *a, uint32_t val)
|
||||||
{
|
{
|
||||||
a[0] = (val >> 24) & 0xff;
|
a[0] = (val >> 24) & 0xff;
|
||||||
a[1] = (val >> 16) & 0xff;
|
a[1] = (val >> 16) & 0xff;
|
||||||
@@ -128,12 +128,12 @@ static inline void WPA_PUT_BE32(uint8_t *a, uint32_t val)
|
|||||||
a[3] = val & 0xff;
|
a[3] = val & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t WPA_GET_LE32(const uint8_t *a)
|
static inline uint32_t wlan_crypto_get_le32(const uint8_t *a)
|
||||||
{
|
{
|
||||||
return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
|
return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void WPA_PUT_LE32(uint8_t *a, uint32_t val)
|
static inline void wlan_crypto_put_le32(uint8_t *a, uint32_t val)
|
||||||
{
|
{
|
||||||
a[3] = (val >> 24) & 0xff;
|
a[3] = (val >> 24) & 0xff;
|
||||||
a[2] = (val >> 16) & 0xff;
|
a[2] = (val >> 16) & 0xff;
|
||||||
@@ -141,7 +141,7 @@ static inline void WPA_PUT_LE32(uint8_t *a, uint32_t val)
|
|||||||
a[0] = val & 0xff;
|
a[0] = val & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void WPA_PUT_BE64(u8 *a, u64 val)
|
static inline void wlan_crypto_put_be64(u8 *a, u64 val)
|
||||||
{
|
{
|
||||||
a[0] = val >> 56;
|
a[0] = val >> 56;
|
||||||
a[1] = val >> 48;
|
a[1] = val >> 48;
|
||||||
@@ -390,6 +390,7 @@ struct wlan_crypto_comp_priv {
|
|||||||
struct wlan_crypto_params crypto_params;
|
struct wlan_crypto_params crypto_params;
|
||||||
struct wlan_crypto_key *key[4];
|
struct wlan_crypto_key *key[4];
|
||||||
struct wlan_crypto_key *igtk_key;
|
struct wlan_crypto_key *igtk_key;
|
||||||
|
uint32_t igtk_key_type;
|
||||||
uint8_t def_tx_keyid;
|
uint8_t def_tx_keyid;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -432,7 +433,7 @@ static inline int ieee80211_hdrsize(const void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (((WLAN_FC_GET_STYPE(hdr->frame_control)
|
if (((WLAN_FC_GET_STYPE(hdr->frame_control)
|
||||||
== WLAN_FC_STYPE_QOS_DATA)) {
|
== WLAN_FC_STYPE_QOS_DATA))) {
|
||||||
size += sizeof(uint16_t);
|
size += sizeof(uint16_t);
|
||||||
/* Qos frame with Order bit set indicates an HTC frame */
|
/* Qos frame with Order bit set indicates an HTC frame */
|
||||||
if (hdr->frame_control & WLAN_FC_ORDER)
|
if (hdr->frame_control & WLAN_FC_ORDER)
|
||||||
@@ -446,7 +447,7 @@ static inline int wlan_get_tid(const void *data)
|
|||||||
const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)data;
|
const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)data;
|
||||||
|
|
||||||
if (((WLAN_FC_GET_STYPE(hdr->frame_control)
|
if (((WLAN_FC_GET_STYPE(hdr->frame_control)
|
||||||
== WLAN_FC_STYPE_QOS_DATA)) {
|
== WLAN_FC_STYPE_QOS_DATA))) {
|
||||||
if ((hdr->frame_control & (WLAN_FC_TODS | WLAN_FC_FROMDS))
|
if ((hdr->frame_control & (WLAN_FC_TODS | WLAN_FC_FROMDS))
|
||||||
== (WLAN_FC_TODS | WLAN_FC_FROMDS)) {
|
== (WLAN_FC_TODS | WLAN_FC_FROMDS)) {
|
||||||
return ((struct ieee80211_hdr_qos_addr4 *)data)->qos
|
return ((struct ieee80211_hdr_qos_addr4 *)data)->qos
|
||||||
|
@@ -41,13 +41,13 @@ static void gcmp_aad_nonce(const struct ieee80211_hdr *hdr, const uint8_t *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fc &= ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT | WLAN_FC_MOREDATA);
|
fc &= ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT | WLAN_FC_MOREDATA);
|
||||||
WPA_PUT_LE16(aad, fc);
|
wlan_crypto_put_le16(aad, fc);
|
||||||
pos = aad + 2;
|
pos = aad + 2;
|
||||||
qdf_mem_copy(pos, hdr->addr1, 3 * WLAN_ALEN);
|
qdf_mem_copy(pos, hdr->addr1, 3 * WLAN_ALEN);
|
||||||
pos += 3 * WLAN_ALEN;
|
pos += 3 * WLAN_ALEN;
|
||||||
seq = qdf_le16_to_cpu(hdr->seq_ctrl);
|
seq = qdf_le16_to_cpu(hdr->seq_ctrl);
|
||||||
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
|
seq &= ~0xfff0; /* Mask Seq#; do not modify Frag# */
|
||||||
WPA_PUT_LE16(pos, seq);
|
wlan_crypto_put_le16(pos, seq);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
qdf_mem_copy(pos, hdr + 1, addr4 * WLAN_ALEN + qos * 2);
|
qdf_mem_copy(pos, hdr + 1, addr4 * WLAN_ALEN + qos * 2);
|
||||||
|
@@ -33,12 +33,10 @@
|
|||||||
#include "wlan_crypto_def_i.h"
|
#include "wlan_crypto_def_i.h"
|
||||||
#include "wlan_crypto_param_handling_i.h"
|
#include "wlan_crypto_param_handling_i.h"
|
||||||
#include "wlan_crypto_obj_mgr_i.h"
|
#include "wlan_crypto_obj_mgr_i.h"
|
||||||
#include "wlan_crypto_pmf_i.h"
|
|
||||||
|
|
||||||
|
|
||||||
const struct wlan_crypto_cipher *wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_MAX];
|
const struct wlan_crypto_cipher *wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_MAX];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wlan_crypto_vdev_get_crypto_params - called by mlme to get crypto params
|
* wlan_crypto_vdev_get_crypto_params - called by mlme to get crypto params
|
||||||
*
|
*
|
||||||
@@ -84,6 +82,10 @@ static struct wlan_crypto_params *wlan_crypto_peer_get_comp_params(
|
|||||||
return &((*crypto_priv)->crypto_params);
|
return &((*crypto_priv)->crypto_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QDF_STATUS wlan_crypto_set_igtk_key(struct wlan_crypto_key *key)
|
||||||
|
{
|
||||||
|
return QDF_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* wlan_crypto_set_param - called by ucfg to set crypto param
|
* wlan_crypto_set_param - called by ucfg to set crypto param
|
||||||
*
|
*
|
||||||
@@ -223,8 +225,9 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
uint8_t *macaddr = NULL;
|
uint8_t *macaddr = NULL;
|
||||||
bool isbcast;
|
bool isbcast;
|
||||||
|
|
||||||
if (!req_key || req_key->keylen > (sizeof(req_key->keydata))) {
|
if (!vdev || !req_key || req_key->keylen > (sizeof(req_key->keydata))) {
|
||||||
qdf_print("%s[%d] req_key invalid\n", __func__, __LINE__);
|
qdf_print("%s[%d] Invalid params vdev%p, req_key%p\n",
|
||||||
|
__func__, __LINE__, vdev, req_key);
|
||||||
return QDF_STATUS_E_INVAL;
|
return QDF_STATUS_E_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +271,7 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
if (req_key->keyix == WLAN_CRYPTO_KEYIX_NONE) {
|
if (req_key->keyix == WLAN_CRYPTO_KEYIX_NONE) {
|
||||||
if (req_key->flags != (WLAN_CRYPTO_KEY_XMIT
|
if (req_key->flags != (WLAN_CRYPTO_KEY_XMIT
|
||||||
| WLAN_CRYPTO_KEY_RECV)) {
|
| WLAN_CRYPTO_KEY_RECV)) {
|
||||||
req_key->flags = (WLAN_CRYPTO_KEY_XMIT
|
req_key->flags |= (WLAN_CRYPTO_KEY_XMIT
|
||||||
| WLAN_CRYPTO_KEY_RECV);
|
| WLAN_CRYPTO_KEY_RECV);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -277,7 +280,7 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
return QDF_STATUS_E_INVAL;
|
return QDF_STATUS_E_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
req_key->flags = (WLAN_CRYPTO_KEY_XMIT
|
req_key->flags |= (WLAN_CRYPTO_KEY_XMIT
|
||||||
| WLAN_CRYPTO_KEY_RECV);
|
| WLAN_CRYPTO_KEY_RECV);
|
||||||
req_key->flags |= WLAN_CRYPTO_KEY_GROUP;
|
req_key->flags |= WLAN_CRYPTO_KEY_GROUP;
|
||||||
}
|
}
|
||||||
@@ -296,6 +299,7 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
|
|
||||||
if (IS_MGMT_CIPHER(req_key->type)) {
|
if (IS_MGMT_CIPHER(req_key->type)) {
|
||||||
key = crypto_priv->igtk_key;
|
key = crypto_priv->igtk_key;
|
||||||
|
crypto_priv->igtk_key_type = req_key->type;
|
||||||
} else {
|
} else {
|
||||||
if (!HAS_MCAST_CIPHER(crypto_params, req_key->type)
|
if (!HAS_MCAST_CIPHER(crypto_params, req_key->type)
|
||||||
&& (req_key->type != WLAN_CRYPTO_CIPHER_WEP)) {
|
&& (req_key->type != WLAN_CRYPTO_CIPHER_WEP)) {
|
||||||
@@ -362,6 +366,10 @@ QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
else
|
else
|
||||||
key->keyix = req_key->keyix;
|
key->keyix = req_key->keyix;
|
||||||
|
|
||||||
|
if (req_key->flags & WLAN_CRYPTO_KEY_DEFAULT) {
|
||||||
|
crypto_priv->def_tx_keyid = key->keyix;
|
||||||
|
key->flags |= WLAN_CRYPTO_KEY_DEFAULT;
|
||||||
|
}
|
||||||
if ((req_key->type == WLAN_CRYPTO_CIPHER_WAPI_SMS4)
|
if ((req_key->type == WLAN_CRYPTO_CIPHER_WAPI_SMS4)
|
||||||
|| (req_key->type == WLAN_CRYPTO_CIPHER_WAPI_GCM4)) {
|
|| (req_key->type == WLAN_CRYPTO_CIPHER_WAPI_GCM4)) {
|
||||||
uint8_t iv_AP[16] = { 0x5c, 0x36, 0x5c, 0x36,
|
uint8_t iv_AP[16] = { 0x5c, 0x36, 0x5c, 0x36,
|
||||||
@@ -469,6 +477,7 @@ QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
uint8_t *mac_addr){
|
uint8_t *mac_addr){
|
||||||
struct wlan_crypto_comp_priv *crypto_priv;
|
struct wlan_crypto_comp_priv *crypto_priv;
|
||||||
struct wlan_crypto_params *crypto_params;
|
struct wlan_crypto_params *crypto_params;
|
||||||
|
struct wlan_crypto_cipher *cipher_table;
|
||||||
struct wlan_crypto_key *key;
|
struct wlan_crypto_key *key;
|
||||||
|
|
||||||
if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *)mac_addr)) {
|
if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *)mac_addr)) {
|
||||||
@@ -477,11 +486,8 @@ QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
if (crypto_priv == NULL) {
|
if (crypto_priv == NULL) {
|
||||||
qdf_print("%s[%d] crypto_priv NULL\n",
|
qdf_print("%s[%d] crypto_priv NULL\n",
|
||||||
__func__, __LINE__);
|
__func__, __LINE__);
|
||||||
|
return QDF_STATUS_E_INVAL;
|
||||||
}
|
}
|
||||||
return QDF_STATUS_E_INVAL;
|
|
||||||
|
|
||||||
if (!HAS_MCAST_CIPHER(crypto_params, req_key->type))
|
|
||||||
return QDF_STATUS_E_INVAL;
|
|
||||||
|
|
||||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||||
if (!key)
|
if (!key)
|
||||||
@@ -509,9 +515,6 @@ QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
return QDF_STATUS_E_INVAL;
|
return QDF_STATUS_E_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HAS_UCAST_CIPHER(crypto_params, req_key->type))
|
|
||||||
return QDF_STATUS_E_INVAL;
|
|
||||||
|
|
||||||
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
key = crypto_priv->key[crypto_priv->def_tx_keyid];
|
||||||
if (!key)
|
if (!key)
|
||||||
return QDF_STATUS_E_INVAL;
|
return QDF_STATUS_E_INVAL;
|
||||||
@@ -519,7 +522,7 @@ QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
|
|
||||||
if (key->valid) {
|
if (key->valid) {
|
||||||
qdf_mem_copy(req_key->keydata,
|
qdf_mem_copy(req_key->keydata,
|
||||||
key->keyval, sizeof(key->keyval));
|
key->keyval, key->keylen);
|
||||||
qdf_mem_copy((uint8_t *)(&req_key->keytsc),
|
qdf_mem_copy((uint8_t *)(&req_key->keytsc),
|
||||||
(uint8_t *)(&key->keytsc),
|
(uint8_t *)(&key->keytsc),
|
||||||
sizeof(req_key->keytsc));
|
sizeof(req_key->keytsc));
|
||||||
@@ -527,6 +530,9 @@ QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
(uint8_t *)(&key->keyrsc[0]),
|
(uint8_t *)(&key->keyrsc[0]),
|
||||||
sizeof(req_key->keyrsc));
|
sizeof(req_key->keyrsc));
|
||||||
req_key->keylen = key->keylen;
|
req_key->keylen = key->keylen;
|
||||||
|
req_key->flags = key->flags;
|
||||||
|
cipher_table = (struct wlan_crypto_cipher *)key->cipher_table;
|
||||||
|
req_key->type = cipher_table->cipher;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QDF_STATUS_SUCCESS;
|
return QDF_STATUS_SUCCESS;
|
||||||
@@ -551,6 +557,12 @@ QDF_STATUS wlan_crypto_delkey(struct wlan_objmgr_vdev *vdev,
|
|||||||
struct wlan_crypto_key *key;
|
struct wlan_crypto_key *key;
|
||||||
struct wlan_crypto_cipher *cipher_table;
|
struct wlan_crypto_cipher *cipher_table;
|
||||||
|
|
||||||
|
if (!vdev || !macaddr || (key_idx >= WLAN_CRYPTO_MAXKEYIDX)) {
|
||||||
|
qdf_print("%s[%d] Invalid params vdev %p, macaddr %p keyidx %d",
|
||||||
|
__func__, __LINE__, vdev,
|
||||||
|
macaddr, key_idx);
|
||||||
|
return QDF_STATUS_E_INVAL;
|
||||||
|
}
|
||||||
if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *)macaddr)) {
|
if (qdf_is_macaddr_broadcast((struct qdf_mac_addr *)macaddr)) {
|
||||||
crypto_params = wlan_crypto_vdev_get_comp_params(vdev,
|
crypto_params = wlan_crypto_vdev_get_comp_params(vdev,
|
||||||
&crypto_priv);
|
&crypto_priv);
|
||||||
@@ -683,6 +695,7 @@ QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev,
|
|||||||
WLAN_CRYPTO_TX_OPS_DEFAULTKEY(psoc)(vdev, key_idx,
|
WLAN_CRYPTO_TX_OPS_DEFAULTKEY(psoc)(vdev, key_idx,
|
||||||
macaddr);
|
macaddr);
|
||||||
}
|
}
|
||||||
|
crypto_priv->def_tx_keyid = key_idx;
|
||||||
|
|
||||||
return QDF_STATUS_SUCCESS;
|
return QDF_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -1031,12 +1044,18 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
|||||||
uint8_t *bfrm,
|
uint8_t *bfrm,
|
||||||
uint32_t len) {
|
uint32_t len) {
|
||||||
struct wlan_crypto_key *key;
|
struct wlan_crypto_key *key;
|
||||||
struct ieee80211_ath_mmie *mmie;
|
struct wlan_crypto_mmie *mmie;
|
||||||
uint8_t *pn, aad[20], *efrm, nounce[12];
|
uint8_t *pn, *aad, *buf, *efrm, nounce[12];
|
||||||
struct ieee80211_frame *wh;
|
struct ieee80211_hdr *hdr;
|
||||||
uint32_t i, hdrlen;
|
uint32_t i, hdrlen, mic_len, aad_len;
|
||||||
struct wlan_crypto_comp_priv *crypto_priv;
|
struct wlan_crypto_comp_priv *crypto_priv;
|
||||||
struct wlan_crypto_params *crypto_params;
|
struct wlan_crypto_params *crypto_params;
|
||||||
|
int32_t ret;
|
||||||
|
|
||||||
|
if (!bfrm) {
|
||||||
|
qdf_print("%s[%d] frame is NULL\n", __func__, __LINE__);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
crypto_params = wlan_crypto_vdev_get_comp_params(vdev,
|
crypto_params = wlan_crypto_vdev_get_comp_params(vdev,
|
||||||
&crypto_priv);
|
&crypto_priv);
|
||||||
@@ -1046,20 +1065,19 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
key = crypto_priv->igtk_key;
|
key = crypto_priv->igtk_key;
|
||||||
if (!key)
|
if (!key) {
|
||||||
return NULL;
|
qdf_print("%s[%d] No igtk key present\n", __func__, __LINE__);
|
||||||
|
|
||||||
if (!key && !bfrm) {
|
|
||||||
/* Invalid Key or frame */
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
mic_len = (crypto_priv->igtk_key_type
|
||||||
|
== WLAN_CRYPTO_CIPHER_AES_CMAC) ? 8 : 16;
|
||||||
|
|
||||||
efrm = bfrm + len;
|
efrm = bfrm + len;
|
||||||
len += sizeof(*mmie);
|
aad_len = 20;
|
||||||
hdrlen = sizeof(*wh);
|
hdrlen = sizeof(struct ieee80211_hdr);
|
||||||
|
|
||||||
mmie = (struct ieee80211_ath_mmie *) efrm;
|
mmie = (struct wlan_crypto_mmie *) efrm;
|
||||||
mmie->element_id = IEEE80211_ELEMID_MMIE;
|
mmie->element_id = WLAN_ELEMID_MMIE;
|
||||||
mmie->length = sizeof(*mmie) - 2;
|
mmie->length = sizeof(*mmie) - 2;
|
||||||
mmie->key_id = qdf_cpu_to_le16(key->keyix);
|
mmie->key_id = qdf_cpu_to_le16(key->keyix);
|
||||||
|
|
||||||
@@ -1075,43 +1093,57 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
|||||||
/* Copy IPN */
|
/* Copy IPN */
|
||||||
qdf_mem_copy(mmie->sequence_number, pn, 6);
|
qdf_mem_copy(mmie->sequence_number, pn, 6);
|
||||||
|
|
||||||
wh = (struct ieee80211_frame *) bfrm;
|
hdr = (struct ieee80211_hdr *) bfrm;
|
||||||
|
|
||||||
|
buf = qdf_mem_malloc(len - hdrlen);
|
||||||
|
if (!buf) {
|
||||||
|
qdf_print("%s[%d] malloc failed\n", __func__, __LINE__);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
aad = buf;
|
||||||
/* generate BIP AAD: FC(masked) || A1 || A2 || A3 */
|
/* generate BIP AAD: FC(masked) || A1 || A2 || A3 */
|
||||||
|
|
||||||
/* FC type/subtype */
|
/* FC type/subtype */
|
||||||
aad[0] = wh->i_fc[0];
|
aad[0] = hdr->frame_control & 0xff;
|
||||||
/* Mask FC Retry, PwrMgt, MoreData flags to zero */
|
/* Mask FC Retry, PwrMgt, MoreData flags to zero */
|
||||||
aad[1] = wh->i_fc[1] & ~(IEEE80211_FC1_RETRY | IEEE80211_FC1_PWR_MGT
|
aad[1] = (hdr->frame_control & ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT
|
||||||
| IEEE80211_FC1_MORE_DATA);
|
| WLAN_FC_MOREDATA)) >> 8;
|
||||||
/* A1 || A2 || A3 */
|
/* A1 || A2 || A3 */
|
||||||
qdf_mem_copy(aad + 2, wh->i_addr1, WLAN_ALEN);
|
qdf_mem_copy(aad + 2, hdr->addr1, WLAN_ALEN);
|
||||||
qdf_mem_copy(aad + 8, wh->i_addr2, WLAN_ALEN);
|
qdf_mem_copy(aad + 8, hdr->addr2, WLAN_ALEN);
|
||||||
qdf_mem_copy(aad + 14, wh->i_addr3, WLAN_ALEN);
|
qdf_mem_copy(aad + 14, hdr->addr3, WLAN_ALEN);
|
||||||
|
qdf_mem_zero(mmie->mic, 16);
|
||||||
/*
|
/*
|
||||||
* MIC = AES-128-CMAC(IGTK, AAD || Management Frame Body || MMIE, 64)
|
* MIC = AES-128-CMAC(IGTK, AAD || Management Frame Body || MMIE, 64)
|
||||||
*/
|
*/
|
||||||
|
qdf_mem_copy(buf + 20, bfrm + hdrlen, len - hdrlen);
|
||||||
if ((HAS_MGMT_CIPHER(crypto_params, WLAN_CRYPTO_CIPHER_AES_CMAC))
|
if (crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_CMAC) {
|
||||||
|| HAS_MGMT_CIPHER(crypto_params,
|
|
||||||
WLAN_CRYPTO_CIPHER_AES_CMAC_256)) {
|
|
||||||
/* size of MIC is 16 for GMAC, size of mic for CMAC is 8 */
|
|
||||||
len -= 8;
|
|
||||||
mmie->length -= 8;
|
mmie->length -= 8;
|
||||||
wlan_crypto_cmac_calc_mic(key, aad, bfrm + hdrlen,
|
ret = omac1_aes_128(key->keyval, buf,
|
||||||
len - hdrlen, mmie->mic);
|
len + aad_len - hdrlen, mmie->mic);
|
||||||
} else if ((HAS_MGMT_CIPHER(crypto_params, WLAN_CRYPTO_CIPHER_AES_GMAC))
|
} else if (crypto_priv->igtk_key_type
|
||||||
|| HAS_MGMT_CIPHER(crypto_params,
|
== WLAN_CRYPTO_CIPHER_AES_CMAC_256) {
|
||||||
WLAN_CRYPTO_CIPHER_AES_GMAC_256)) {
|
ret = omac1_aes_256(key->keyval, buf,
|
||||||
qdf_mem_copy(nounce, wh->i_addr2, WLAN_ALEN);
|
len + aad_len - hdrlen, mmie->mic);
|
||||||
|
} else if ((crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_GMAC)
|
||||||
|
|| (crypto_priv->igtk_key_type
|
||||||
|
== WLAN_CRYPTO_CIPHER_AES_GMAC_256)) {
|
||||||
|
qdf_mem_copy(nounce, hdr->addr2, WLAN_ALEN);
|
||||||
qdf_mem_copy(nounce + 6, pn, 6);
|
qdf_mem_copy(nounce + 6, pn, 6);
|
||||||
wlan_crypto_gmac_calc_mic(key, aad, bfrm + hdrlen, 20,
|
ret = wlan_crypto_aes_gmac(key->keyval, key->keylen, nounce,
|
||||||
mmie->mic, nounce);
|
sizeof(nounce), buf,
|
||||||
} else {
|
len + aad_len - hdrlen, mmie->mic);
|
||||||
qdf_print("%s CMAC/GMAC Not valid rsn\n", __func__);
|
}
|
||||||
|
qdf_mem_free(buf);
|
||||||
|
if (ret < 0) {
|
||||||
|
qdf_print("%s[%d] add mmie failed\n", __func__, __LINE__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len += sizeof(struct wlan_crypto_mmie);
|
||||||
|
if (mic_len == 8)
|
||||||
|
len -= 8;
|
||||||
|
key->keytsc++;
|
||||||
return bfrm + len;
|
return bfrm + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1129,18 +1161,23 @@ uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
|
|||||||
bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
|
bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
|
||||||
uint8_t *frm,
|
uint8_t *frm,
|
||||||
uint8_t *efrm){
|
uint8_t *efrm){
|
||||||
struct ieee80211_ath_mmie *mmie = NULL;
|
struct wlan_crypto_mmie *mmie = NULL;
|
||||||
uint8_t *ipn, aad[20], mic[16], nounce[12];
|
uint8_t *ipn, *aad, *buf, mic[16], nounce[12];
|
||||||
struct wlan_crypto_key *key;
|
struct wlan_crypto_key *key;
|
||||||
struct ieee80211_frame *wh;
|
struct ieee80211_hdr *hdr;
|
||||||
uint8_t mic_length;
|
uint16_t mic_len, hdrlen, len;
|
||||||
struct wlan_crypto_comp_priv *crypto_priv;
|
struct wlan_crypto_comp_priv *crypto_priv;
|
||||||
struct wlan_crypto_params *crypto_params;
|
struct wlan_crypto_params *crypto_params;
|
||||||
|
uint8_t aad_len = 20;
|
||||||
|
int32_t ret;
|
||||||
|
|
||||||
/* check if frame is illegal length */
|
/* check if frame is illegal length */
|
||||||
if ((efrm < frm) || ((efrm - frm) < sizeof(*wh)))
|
if (!frm || !efrm || (efrm < frm)
|
||||||
|
|| ((efrm - frm) < sizeof(struct ieee80211_hdr))) {
|
||||||
|
qdf_print("%s[%d] Invalid params\n", __func__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
len = efrm - frm;
|
||||||
crypto_priv = (struct wlan_crypto_comp_priv *)
|
crypto_priv = (struct wlan_crypto_comp_priv *)
|
||||||
wlan_get_vdev_crypto_obj(vdev);
|
wlan_get_vdev_crypto_obj(vdev);
|
||||||
if (crypto_priv == NULL) {
|
if (crypto_priv == NULL) {
|
||||||
@@ -1149,68 +1186,89 @@ bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
crypto_params = &(crypto_priv->crypto_params);
|
crypto_params = &(crypto_priv->crypto_params);
|
||||||
key = crypto_priv->igtk_key;
|
|
||||||
if (!key)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ((HAS_MGMT_CIPHER(crypto_params, WLAN_CRYPTO_CIPHER_AES_CMAC))
|
key = crypto_priv->igtk_key;
|
||||||
|| HAS_MGMT_CIPHER(crypto_params,
|
if (!key) {
|
||||||
WLAN_CRYPTO_CIPHER_AES_CMAC_256)) {
|
qdf_print("%s[%d] No igtk key present\n", __func__, __LINE__);
|
||||||
mmie = (struct ieee80211_ath_mmie *)(efrm - sizeof(*mmie) + 8);
|
return false;
|
||||||
} else if ((HAS_MGMT_CIPHER(crypto_params,
|
|
||||||
WLAN_CRYPTO_CIPHER_AES_GMAC))
|
|
||||||
|| HAS_MGMT_CIPHER(crypto_params,
|
|
||||||
WLAN_CRYPTO_CIPHER_AES_GMAC_256)) {
|
|
||||||
mmie = (struct ieee80211_ath_mmie *)(efrm - sizeof(*mmie));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mic_len = (crypto_priv->igtk_key_type
|
||||||
|
== WLAN_CRYPTO_CIPHER_AES_CMAC) ? 8 : 16;
|
||||||
|
hdrlen = sizeof(struct ieee80211_hdr);
|
||||||
|
|
||||||
|
if (mic_len == 8)
|
||||||
|
mmie = (struct wlan_crypto_mmie *)(efrm - sizeof(*mmie) + 8);
|
||||||
|
else
|
||||||
|
mmie = (struct wlan_crypto_mmie *)(efrm - sizeof(*mmie));
|
||||||
|
|
||||||
|
|
||||||
/* check Elem ID*/
|
/* check Elem ID*/
|
||||||
if ((mmie == NULL) || (mmie->element_id != IEEE80211_ELEMID_MMIE)) {
|
if ((mmie == NULL) || (mmie->element_id != WLAN_ELEMID_MMIE)) {
|
||||||
/* IE is not Mgmt MIC IE */
|
qdf_print("%s[%d] IE is not MMIE\n", __func__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* validate ipn */
|
/* validate ipn */
|
||||||
ipn = mmie->sequence_number;
|
ipn = mmie->sequence_number;
|
||||||
if (qdf_mem_cmp(ipn, key->keyrsc, 6) <= 0) {
|
if (qdf_mem_cmp(ipn, key->keyrsc, 6) <= 0) {
|
||||||
/* replay error */
|
qdf_print("%s[%d] replay error\n", __func__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf = qdf_mem_malloc(len - hdrlen);
|
||||||
|
if (!buf) {
|
||||||
|
qdf_print("%s[%d] malloc failed\n", __func__, __LINE__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
aad = buf;
|
||||||
|
|
||||||
/* construct AAD */
|
/* construct AAD */
|
||||||
wh = (struct ieee80211_frame *)frm;
|
hdr = (struct ieee80211_hdr *)frm;
|
||||||
/* generate BIP AAD: FC(masked) || A1 || A2 || A3 */
|
/* generate BIP AAD: FC(masked) || A1 || A2 || A3 */
|
||||||
|
|
||||||
/* FC type/subtype */
|
/* FC type/subtype */
|
||||||
aad[0] = wh->i_fc[0];
|
aad[0] = hdr->frame_control & 0xff;
|
||||||
/* Mask FC Retry, PwrMgt, MoreData flags to zero */
|
/* Mask FC Retry, PwrMgt, MoreData flags to zero */
|
||||||
aad[1] = wh->i_fc[1] & ~(IEEE80211_FC1_RETRY | IEEE80211_FC1_PWR_MGT
|
aad[1] = (hdr->frame_control & ~(WLAN_FC_RETRY | WLAN_FC_PWRMGT
|
||||||
| IEEE80211_FC1_MORE_DATA);
|
| WLAN_FC_MOREDATA)) >> 8;
|
||||||
/* A1 || A2 || A3 */
|
/* A1 || A2 || A3 */
|
||||||
qdf_mem_copy(aad + 2, wh->i_addr_all, 3 * WLAN_ALEN);
|
qdf_mem_copy(aad + 2, hdr->addr1, 3 * WLAN_ALEN);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MIC = AES-128-CMAC(IGTK, AAD || Management Frame Body || MMIE, 64)
|
* MIC = AES-128-CMAC(IGTK, AAD || Management Frame Body || MMIE, 64)
|
||||||
*/
|
*/
|
||||||
if ((HAS_MGMT_CIPHER(crypto_params, WLAN_CRYPTO_CIPHER_AES_CMAC))
|
qdf_mem_copy(buf + 20, frm + hdrlen, len - hdrlen);
|
||||||
|| HAS_MGMT_CIPHER(crypto_params,
|
if (crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_CMAC) {
|
||||||
WLAN_CRYPTO_CIPHER_AES_CMAC_256)) {
|
mmie->length -= 8;
|
||||||
mic_length = 8;
|
ret = omac1_aes_128(key->keyval, buf,
|
||||||
wlan_crypto_cmac_calc_mic(key, aad, (uint8_t *)(wh+1),
|
len + aad_len - hdrlen, mic);
|
||||||
(efrm - (uint8_t *)(wh+1)), mic);
|
} else if (crypto_priv->igtk_key_type
|
||||||
} else if ((HAS_MGMT_CIPHER(crypto_params, WLAN_CRYPTO_CIPHER_AES_GMAC))
|
== WLAN_CRYPTO_CIPHER_AES_CMAC_256) {
|
||||||
|| HAS_MGMT_CIPHER(crypto_params,
|
ret = omac1_aes_256(key->keyval, buf,
|
||||||
WLAN_CRYPTO_CIPHER_AES_GMAC_256)) {
|
len + aad_len - hdrlen, mic);
|
||||||
mic_length = 16;
|
} else if ((crypto_priv->igtk_key_type == WLAN_CRYPTO_CIPHER_AES_GMAC)
|
||||||
qdf_mem_copy(nounce, wh->i_addr2, WLAN_ALEN);
|
|| (crypto_priv->igtk_key_type
|
||||||
|
== WLAN_CRYPTO_CIPHER_AES_GMAC_256)) {
|
||||||
|
qdf_mem_copy(nounce, hdr->addr2, WLAN_ALEN);
|
||||||
qdf_mem_copy(nounce + 6, ipn, 6);
|
qdf_mem_copy(nounce + 6, ipn, 6);
|
||||||
wlan_crypto_gmac_calc_mic(key, aad, (uint8_t *)(wh+1),
|
ret = wlan_crypto_aes_gmac(key->keyval, key->keylen, nounce,
|
||||||
20, mic, nounce);
|
sizeof(nounce), buf,
|
||||||
} else
|
len + aad_len - hdrlen, mic);
|
||||||
return false;
|
}
|
||||||
|
|
||||||
if (qdf_mem_cmp(mic, mmie->mic, mic_length) != 0)
|
qdf_mem_free(buf);
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
|
qdf_print("%s[%d] genarate mmie failed\n", __func__, __LINE__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qdf_mem_cmp(mic, mmie->mic, mic_len) != 0) {
|
||||||
|
qdf_print("%s[%d] mmie mismatch\n", __func__, __LINE__);
|
||||||
/* MMIE MIC mismatch */
|
/* MMIE MIC mismatch */
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the receive sequence number */
|
/* Update the receive sequence number */
|
||||||
qdf_mem_copy(key->keyrsc, ipn, 6);
|
qdf_mem_copy(key->keyrsc, ipn, 6);
|
||||||
@@ -1640,7 +1698,7 @@ uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *crypto_params,
|
|||||||
uint8_t *selcnt;
|
uint8_t *selcnt;
|
||||||
uint32_t mcastcipher;
|
uint32_t mcastcipher;
|
||||||
|
|
||||||
*frm++ = IEEE80211_ELEMID_VENDOR;
|
*frm++ = WLAN_ELEMID_VENDOR;
|
||||||
*frm++ = 0;
|
*frm++ = 0;
|
||||||
WLAN_CRYPTO_ADDSELECTOR(frm, WPA_TYPE_OUI);
|
WLAN_CRYPTO_ADDSELECTOR(frm, WPA_TYPE_OUI);
|
||||||
WLAN_CRYPTO_ADDSHORT(frm, WPA_VERSION);
|
WLAN_CRYPTO_ADDSHORT(frm, WPA_VERSION);
|
||||||
@@ -1722,7 +1780,7 @@ uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *crypto_params,
|
|||||||
uint8_t *selcnt;
|
uint8_t *selcnt;
|
||||||
uint32_t mcastcipher;
|
uint32_t mcastcipher;
|
||||||
|
|
||||||
*frm++ = IEEE80211_ELEMID_RSN;
|
*frm++ = WLAN_ELEMID_RSN;
|
||||||
*frm++ = 0;
|
*frm++ = 0;
|
||||||
WLAN_CRYPTO_ADDSHORT(frm, RSN_VERSION);
|
WLAN_CRYPTO_ADDSHORT(frm, RSN_VERSION);
|
||||||
|
|
||||||
@@ -2053,3 +2111,20 @@ QDF_STATUS wlan_crypto_register_crypto_rx_ops(
|
|||||||
|
|
||||||
return QDF_STATUS_SUCCESS;
|
return QDF_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wlan_crypto_get_crypto_rx_ops - get crypto_rx_ops from psoc
|
||||||
|
*
|
||||||
|
* @psoc: psoc
|
||||||
|
*
|
||||||
|
* This function gets called by umac to get the crypto_rx_ops
|
||||||
|
*
|
||||||
|
* Return: crypto_rx_ops
|
||||||
|
*/
|
||||||
|
struct wlan_lmac_if_crypto_rx_ops *wlan_crypto_get_crypto_rx_ops(
|
||||||
|
struct wlan_objmgr_psoc *psoc)
|
||||||
|
{
|
||||||
|
|
||||||
|
return &(psoc->soc_cb.rx_ops.crypto_rx_ops);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(wlan_crypto_get_crypto_rx_ops);
|
||||||
|
@@ -50,16 +50,6 @@ static QDF_STATUS wlan_crypto_register_all_ciphers(
|
|||||||
struct wlan_crypto_params *crypto_param)
|
struct wlan_crypto_params *crypto_param)
|
||||||
{
|
{
|
||||||
|
|
||||||
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_WEP] = wep_register();
|
|
||||||
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_TKIP] = tkip_register();
|
|
||||||
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_AES_CCM]
|
|
||||||
= ccmp_register();
|
|
||||||
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_AES_CCM_256]
|
|
||||||
= ccmp256_register();
|
|
||||||
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_AES_GCM]
|
|
||||||
= gcmp_register();
|
|
||||||
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_AES_GCM_256]
|
|
||||||
= gcmp256_register();
|
|
||||||
if (HAS_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_WEP)) {
|
if (HAS_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_WEP)) {
|
||||||
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_WEP]
|
wlan_crypto_cipher_ops[WLAN_CRYPTO_CIPHER_WEP]
|
||||||
= wep_register();
|
= wep_register();
|
||||||
@@ -117,20 +107,22 @@ static QDF_STATUS wlan_crypto_vdev_obj_create_handler(
|
|||||||
|
|
||||||
crypto_param = &(crypto_priv->crypto_params);
|
crypto_param = &(crypto_priv->crypto_params);
|
||||||
pdev = wlan_vdev_get_pdev(vdev);
|
pdev = wlan_vdev_get_pdev(vdev);
|
||||||
|
|
||||||
wlan_pdev_obj_lock(pdev);
|
wlan_pdev_obj_lock(pdev);
|
||||||
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_WEP))
|
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_WEP))
|
||||||
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_WEP);
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_WEP);
|
||||||
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_TKIP))
|
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_TKIP))
|
||||||
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_TKIP_MIC);
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_TKIP_MIC);
|
||||||
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_AES))
|
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_AES)) {
|
||||||
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_AES);
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_AES);
|
||||||
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_CCM256);
|
||||||
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_GCM);
|
||||||
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_GCM_256);
|
||||||
|
}
|
||||||
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_CKIP))
|
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_CKIP))
|
||||||
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_CKIP);
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_CKIP);
|
||||||
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_WAPI))
|
if (wlan_pdev_nif_fw_cap_get(pdev, WLAN_SOC_C_WAPI))
|
||||||
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_WAPI_SMS4);
|
SET_CIPHER_CAP(crypto_param, WLAN_CRYPTO_CAP_WAPI_SMS4);
|
||||||
wlan_pdev_obj_unlock(pdev);
|
wlan_pdev_obj_unlock(pdev);
|
||||||
|
|
||||||
/* update the crypto cipher table based on the fw caps*/
|
/* update the crypto cipher table based on the fw caps*/
|
||||||
/* update the fw_caps into ciphercaps then attach to objmgr*/
|
/* update the fw_caps into ciphercaps then attach to objmgr*/
|
||||||
wlan_crypto_register_all_ciphers(crypto_param);
|
wlan_crypto_register_all_ciphers(crypto_param);
|
||||||
@@ -178,13 +170,22 @@ static void wlan_crypto_free_key(struct wlan_crypto_comp_priv *crypto_priv)
|
|||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
for (i = 0; i < WLAN_CRYPTO_MAXKEYIDX; i++) {
|
if (!crypto_priv) {
|
||||||
if (crypto_priv->key[i])
|
qdf_print("%s[%d] crypto_priv NULL\n", __func__, __LINE__);
|
||||||
qdf_mem_free(crypto_priv->key[i]);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crypto_priv->igtk_key)
|
for (i = 0; i < WLAN_CRYPTO_MAXKEYIDX; i++) {
|
||||||
|
if (crypto_priv->key[i]) {
|
||||||
|
qdf_mem_free(crypto_priv->key[i]);
|
||||||
|
crypto_priv->key[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crypto_priv->igtk_key) {
|
||||||
qdf_mem_free(crypto_priv->igtk_key);
|
qdf_mem_free(crypto_priv->igtk_key);
|
||||||
|
crypto_priv->igtk_key = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,9 +194,18 @@ static QDF_STATUS wlan_crypto_vdev_obj_destroy_handler(
|
|||||||
void *arg){
|
void *arg){
|
||||||
struct wlan_crypto_comp_priv *crypto_priv;
|
struct wlan_crypto_comp_priv *crypto_priv;
|
||||||
|
|
||||||
|
if (!vdev) {
|
||||||
|
qdf_print("%s[%d] Vdev NULL\n", __func__, __LINE__);
|
||||||
|
return QDF_STATUS_E_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
crypto_priv = (struct wlan_crypto_comp_priv *)
|
crypto_priv = (struct wlan_crypto_comp_priv *)
|
||||||
wlan_get_vdev_crypto_obj(vdev);
|
wlan_get_vdev_crypto_obj(vdev);
|
||||||
|
|
||||||
|
if (!crypto_priv) {
|
||||||
|
qdf_print("%s[%d] crypto_priv NULL\n", __func__, __LINE__);
|
||||||
|
return QDF_STATUS_E_INVAL;
|
||||||
|
}
|
||||||
wlan_objmgr_vdev_component_obj_detach(vdev,
|
wlan_objmgr_vdev_component_obj_detach(vdev,
|
||||||
WLAN_UMAC_COMP_CRYPTO,
|
WLAN_UMAC_COMP_CRYPTO,
|
||||||
(void *)crypto_priv);
|
(void *)crypto_priv);
|
||||||
@@ -210,8 +220,16 @@ static QDF_STATUS wlan_crypto_peer_obj_destroy_handler(
|
|||||||
void *arg){
|
void *arg){
|
||||||
struct wlan_crypto_comp_priv *crypto_priv;
|
struct wlan_crypto_comp_priv *crypto_priv;
|
||||||
|
|
||||||
|
if (!peer) {
|
||||||
|
qdf_print("%s[%d] Peer NULL\n", __func__, __LINE__);
|
||||||
|
return QDF_STATUS_E_INVAL;
|
||||||
|
}
|
||||||
crypto_priv = (struct wlan_crypto_comp_priv *)
|
crypto_priv = (struct wlan_crypto_comp_priv *)
|
||||||
wlan_get_peer_crypto_obj(peer);
|
wlan_get_peer_crypto_obj(peer);
|
||||||
|
if (!crypto_priv) {
|
||||||
|
qdf_print("%s[%d] crypto_priv NULL\n", __func__, __LINE__);
|
||||||
|
return QDF_STATUS_E_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
wlan_objmgr_peer_component_obj_detach(peer,
|
wlan_objmgr_peer_component_obj_detach(peer,
|
||||||
WLAN_UMAC_COMP_CRYPTO,
|
WLAN_UMAC_COMP_CRYPTO,
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
#include "wlan_crypto_def_i.h"
|
#include "wlan_crypto_def_i.h"
|
||||||
#include "wlan_crypto_main_i.h"
|
#include "wlan_crypto_main_i.h"
|
||||||
#include "wlan_crypto_obj_mgr_i.h"
|
#include "wlan_crypto_obj_mgr_i.h"
|
||||||
#include "wlan_crypto_tkip_i.h"
|
|
||||||
|
|
||||||
|
|
||||||
static QDF_STATUS tkip_enmic(struct wlan_crypto_key *key, qdf_nbuf_t wbuf,
|
static QDF_STATUS tkip_enmic(struct wlan_crypto_key *key, qdf_nbuf_t wbuf,
|
||||||
@@ -43,7 +42,7 @@ static QDF_STATUS tkip_demic(struct wlan_crypto_key *key, qdf_nbuf_t wbuf,
|
|||||||
|
|
||||||
static QDF_STATUS tkip_setkey(struct wlan_crypto_key *key)
|
static QDF_STATUS tkip_setkey(struct wlan_crypto_key *key)
|
||||||
{
|
{
|
||||||
struct wlan_crypto_tkip_ctx *ctx;
|
/* struct wlan_crypto_tkip_ctx *ctx;
|
||||||
|
|
||||||
if (key->private == NULL) {
|
if (key->private == NULL) {
|
||||||
key->private = qdf_mem_malloc(
|
key->private = qdf_mem_malloc(
|
||||||
@@ -53,7 +52,7 @@ static QDF_STATUS tkip_setkey(struct wlan_crypto_key *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx = key->private;
|
ctx = key->private;
|
||||||
|
*/
|
||||||
return QDF_STATUS_SUCCESS;
|
return QDF_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +61,9 @@ static QDF_STATUS tkip_encap(struct wlan_crypto_key *key,
|
|||||||
uint8_t encapdone,
|
uint8_t encapdone,
|
||||||
uint8_t hdrlen){
|
uint8_t hdrlen){
|
||||||
uint8_t *ivp;
|
uint8_t *ivp;
|
||||||
struct ieee80211_frame *wh;
|
|
||||||
qdf_nbuf_t wbuf0;
|
|
||||||
uint16_t pktlen;
|
|
||||||
struct wlan_crypto_cipher *cipher_table;
|
struct wlan_crypto_cipher *cipher_table;
|
||||||
|
|
||||||
cipher_table = key->cipher_table;
|
cipher_table = key->cipher_table;
|
||||||
wh = (struct ieee80211_frame *)qdf_nbuf_data(wbuf);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy down 802.11 header and add the IV, KeyID, and ExtIV.
|
* Copy down 802.11 header and add the IV, KeyID, and ExtIV.
|
||||||
@@ -76,12 +71,10 @@ static QDF_STATUS tkip_encap(struct wlan_crypto_key *key,
|
|||||||
if (encapdone) {
|
if (encapdone) {
|
||||||
ivp = (uint8_t *)qdf_nbuf_data(wbuf);
|
ivp = (uint8_t *)qdf_nbuf_data(wbuf);
|
||||||
} else {
|
} else {
|
||||||
ivp = (uint8_t *)qdf_nbuf_push_head(wbuf, cipher_table->header);
|
ivp = qdf_nbuf_push_head(wbuf, cipher_table->header);
|
||||||
qdf_mem_move(ivp, (ivp + cipher_table->header), hdrlen);
|
qdf_mem_move(ivp, (ivp + cipher_table->header), hdrlen);
|
||||||
wh = (struct ieee80211_frame *) qdf_nbuf_data(wbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ivp += hdrlen;
|
|
||||||
key->keytsc++; /* XXX wrap at 48 bits */
|
key->keytsc++; /* XXX wrap at 48 bits */
|
||||||
|
|
||||||
ivp[0] = key->keytsc >> 8; /* TSC1 */
|
ivp[0] = key->keytsc >> 8; /* TSC1 */
|
||||||
@@ -93,24 +86,24 @@ static QDF_STATUS tkip_encap(struct wlan_crypto_key *key,
|
|||||||
ivp[6] = key->keytsc >> 32; /* PN4 */
|
ivp[6] = key->keytsc >> 32; /* PN4 */
|
||||||
ivp[7] = key->keytsc >> 40; /* PN5 */
|
ivp[7] = key->keytsc >> 40; /* PN5 */
|
||||||
|
|
||||||
wbuf0 = wbuf;
|
/* wbuf0 = wbuf;
|
||||||
pktlen = qdf_nbuf_len(wbuf);
|
pktlen = qdf_nbuf_len(wbuf);
|
||||||
while (qdf_nbuf_queue_next(wbuf0) != NULL) {
|
while (qdf_nbuf_queue_next(wbuf0) != NULL) {
|
||||||
wbuf = qdf_nbuf_queue_next(wbuf0);
|
wbuf = qdf_nbuf_queue_next(wbuf0);
|
||||||
pktlen += qdf_nbuf_len(wbuf0);
|
pktlen += qdf_nbuf_len(wbuf0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
* Finally, do software encrypt if neeed.
|
* Finally, do software encrypt if neeed.
|
||||||
*/
|
*/
|
||||||
if (key->flags & WLAN_CRYPTO_KEY_SWENCRYPT) {
|
if (key->flags & WLAN_CRYPTO_KEY_SWENCRYPT) {
|
||||||
/*if not frag frame then do mic calculation */
|
qdf_nbuf_realloc_tailroom(wbuf, cipher_table->miclen);
|
||||||
if (tkip_enmic(key, wbuf, encapdone, hdrlen)
|
if (qdf_nbuf_realloc_tailroom(wbuf, cipher_table->miclen)
|
||||||
!= QDF_STATUS_SUCCESS) {
|
&& (!wlan_crypto_tkip_encrypt(key->keyval,
|
||||||
|
qdf_nbuf_data(wbuf), qdf_nbuf_len(wbuf),
|
||||||
|
hdrlen))){
|
||||||
return QDF_STATUS_CRYPTO_ENCRYPT_FAILED;
|
return QDF_STATUS_CRYPTO_ENCRYPT_FAILED;
|
||||||
}
|
}
|
||||||
if (!wlan_crypto_tkip_encrypt(key, wbuf, hdrlen))
|
|
||||||
return QDF_STATUS_CRYPTO_ENCRYPT_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QDF_STATUS_SUCCESS;
|
return QDF_STATUS_SUCCESS;
|
||||||
@@ -120,7 +113,7 @@ static QDF_STATUS tkip_decap(struct wlan_crypto_key *key,
|
|||||||
qdf_nbuf_t wbuf,
|
qdf_nbuf_t wbuf,
|
||||||
uint8_t tid,
|
uint8_t tid,
|
||||||
uint8_t hdrlen){
|
uint8_t hdrlen){
|
||||||
struct ieee80211_frame *wh;
|
struct ieee80211_hdr *hdr;
|
||||||
uint8_t *ivp, *origHdr;
|
uint8_t *ivp, *origHdr;
|
||||||
uint64_t pn;
|
uint64_t pn;
|
||||||
struct wlan_crypto_cipher *cipher_table;
|
struct wlan_crypto_cipher *cipher_table;
|
||||||
@@ -132,37 +125,29 @@ static QDF_STATUS tkip_decap(struct wlan_crypto_key *key,
|
|||||||
* verify the former and validate the latter.
|
* verify the former and validate the latter.
|
||||||
*/
|
*/
|
||||||
origHdr = (uint8_t *)qdf_nbuf_data(wbuf);
|
origHdr = (uint8_t *)qdf_nbuf_data(wbuf);
|
||||||
wh = (struct ieee80211_frame *)origHdr;
|
hdr = (struct ieee80211_hdr *)origHdr;
|
||||||
|
|
||||||
ivp = origHdr + hdrlen;
|
ivp = origHdr + hdrlen;
|
||||||
|
|
||||||
if ((ivp[WLAN_CRYPTO_IV_LEN] & WLAN_CRYPTO_EXT_IV_BIT) == 0)
|
if ((ivp[WLAN_CRYPTO_IV_LEN] & WLAN_CRYPTO_EXT_IV_BIT) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tid = 16; /* non QoS*/
|
tid = wlan_get_tid(qdf_nbuf_data(wbuf));
|
||||||
if ((((wh)->i_fc[0] & (0x0c | 0x80)) == (0x00 | 0x80))) {
|
|
||||||
if ((wh->i_fc[1] & 0x03) == 0x03) {
|
|
||||||
tid = ((struct ieee80211_qosframe_addr4 *)wh)->i_qos[0]
|
|
||||||
& 0x0f;
|
|
||||||
} else {
|
|
||||||
tid = ((struct ieee80211_qosframe *)wh)->i_qos[0]
|
|
||||||
& 0x0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* NB: assume IEEEE80211_WEP_MINLEN covers the extended IV */
|
|
||||||
pn = READ_6(ivp[0], ivp[1], ivp[4], ivp[5], ivp[6], ivp[7]);
|
pn = READ_6(ivp[0], ivp[1], ivp[4], ivp[5], ivp[6], ivp[7]);
|
||||||
|
|
||||||
if (pn <= key->keyrsc[tid]) {
|
if (pn <= key->keyrsc[tid]) {
|
||||||
/* Replay violation.*/
|
/* Replay violation.*/
|
||||||
return 0;
|
return QDF_STATUS_CRYPTO_DECRYPT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((key->flags & WLAN_CRYPTO_KEY_SWDECRYPT)) {
|
if ((key->flags & WLAN_CRYPTO_KEY_SWDECRYPT)) {
|
||||||
if (!wlan_crypto_tkip_decrypt(key, wbuf, hdrlen) == 0)
|
if (!wlan_crypto_tkip_decrypt(key->keyval,
|
||||||
|
(struct ieee80211_hdr *)origHdr,
|
||||||
|
(origHdr + hdrlen),
|
||||||
|
(qdf_nbuf_len(wbuf) - hdrlen)))
|
||||||
return QDF_STATUS_CRYPTO_DECRYPT_FAILED;
|
return QDF_STATUS_CRYPTO_DECRYPT_FAILED;
|
||||||
}
|
}
|
||||||
/* PN will be updated in tkip_demic*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy up 802.11 header and strip crypto bits.
|
* Copy up 802.11 header and strip crypto bits.
|
||||||
@@ -170,8 +155,8 @@ static QDF_STATUS tkip_decap(struct wlan_crypto_key *key,
|
|||||||
qdf_mem_move(origHdr + cipher_table->header, origHdr, hdrlen);
|
qdf_mem_move(origHdr + cipher_table->header, origHdr, hdrlen);
|
||||||
|
|
||||||
qdf_nbuf_pull_head(wbuf, cipher_table->header);
|
qdf_nbuf_pull_head(wbuf, cipher_table->header);
|
||||||
while (qdf_nbuf_queue_next(wbuf) != NULL)
|
/*while (qdf_nbuf_queue_next(wbuf) != NULL)
|
||||||
wbuf = qdf_nbuf_queue_next(wbuf);
|
wbuf = qdf_nbuf_queue_next(wbuf);*/
|
||||||
qdf_nbuf_trim_tail(wbuf, cipher_table->trailer);
|
qdf_nbuf_trim_tail(wbuf, cipher_table->trailer);
|
||||||
|
|
||||||
return QDF_STATUS_SUCCESS;
|
return QDF_STATUS_SUCCESS;
|
||||||
|
@@ -159,12 +159,12 @@ static void tkip_mixing_phase2(uint8_t *WEPSeed, const uint8_t *TK,
|
|||||||
WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
|
WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
|
||||||
WEPSeed[2] = Lo8(IV16);
|
WEPSeed[2] = Lo8(IV16);
|
||||||
WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((uint16_t *) &TK[0])) >> 1);
|
WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((uint16_t *) &TK[0])) >> 1);
|
||||||
WPA_PUT_LE16(&WEPSeed[4], PPK[0]);
|
wlan_crypto_put_le16(&WEPSeed[4], PPK[0]);
|
||||||
WPA_PUT_LE16(&WEPSeed[6], PPK[1]);
|
wlan_crypto_put_le16(&WEPSeed[6], PPK[1]);
|
||||||
WPA_PUT_LE16(&WEPSeed[8], PPK[2]);
|
wlan_crypto_put_le16(&WEPSeed[8], PPK[2]);
|
||||||
WPA_PUT_LE16(&WEPSeed[10], PPK[3]);
|
wlan_crypto_put_le16(&WEPSeed[10], PPK[3]);
|
||||||
WPA_PUT_LE16(&WEPSeed[12], PPK[4]);
|
wlan_crypto_put_le16(&WEPSeed[12], PPK[4]);
|
||||||
WPA_PUT_LE16(&WEPSeed[14], PPK[5]);
|
wlan_crypto_put_le16(&WEPSeed[14], PPK[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -197,24 +197,24 @@ static void michael_mic(const uint8_t *key, const uint8_t *hdr,
|
|||||||
uint32_t l, r;
|
uint32_t l, r;
|
||||||
int i, blocks, last;
|
int i, blocks, last;
|
||||||
|
|
||||||
l = WPA_GET_LE32(key);
|
l = wlan_crypto_get_le32(key);
|
||||||
r = WPA_GET_LE32(key + 4);
|
r = wlan_crypto_get_le32(key + 4);
|
||||||
|
|
||||||
/* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
|
/* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
|
||||||
l ^= WPA_GET_LE32(hdr);
|
l ^= wlan_crypto_get_le32(hdr);
|
||||||
michael_block(l, r);
|
michael_block(l, r);
|
||||||
l ^= WPA_GET_LE32(&hdr[4]);
|
l ^= wlan_crypto_get_le32(&hdr[4]);
|
||||||
michael_block(l, r);
|
michael_block(l, r);
|
||||||
l ^= WPA_GET_LE32(&hdr[8]);
|
l ^= wlan_crypto_get_le32(&hdr[8]);
|
||||||
michael_block(l, r);
|
michael_block(l, r);
|
||||||
l ^= WPA_GET_LE32(&hdr[12]);
|
l ^= wlan_crypto_get_le32(&hdr[12]);
|
||||||
michael_block(l, r);
|
michael_block(l, r);
|
||||||
|
|
||||||
/* 32-bit blocks of data */
|
/* 32-bit blocks of data */
|
||||||
blocks = data_len / 4;
|
blocks = data_len / 4;
|
||||||
last = data_len % 4;
|
last = data_len % 4;
|
||||||
for (i = 0; i < blocks; i++) {
|
for (i = 0; i < blocks; i++) {
|
||||||
l ^= WPA_GET_LE32(&data[4 * i]);
|
l ^= wlan_crypto_get_le32(&data[4 * i]);
|
||||||
michael_block(l, r);
|
michael_block(l, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,8 +238,8 @@ static void michael_mic(const uint8_t *key, const uint8_t *hdr,
|
|||||||
/* l ^= 0; */
|
/* l ^= 0; */
|
||||||
michael_block(l, r);
|
michael_block(l, r);
|
||||||
|
|
||||||
WPA_PUT_LE32(mic, l);
|
wlan_crypto_put_le32(mic, l);
|
||||||
WPA_PUT_LE32(mic + 4, r);
|
wlan_crypto_put_le32(mic + 4, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -281,8 +281,7 @@ static void michael_mic_hdr(const struct ieee80211_hdr *hdr11, uint8_t *hdr)
|
|||||||
|
|
||||||
uint8_t *wlan_crypto_tkip_decrypt(const uint8_t *tk,
|
uint8_t *wlan_crypto_tkip_decrypt(const uint8_t *tk,
|
||||||
const struct ieee80211_hdr *hdr,
|
const struct ieee80211_hdr *hdr,
|
||||||
const uint8_t *data, size_t data_len,
|
uint8_t *data, size_t data_len){
|
||||||
size_t *decrypted_len){
|
|
||||||
uint16_t iv16;
|
uint16_t iv16;
|
||||||
uint32_t iv32;
|
uint32_t iv32;
|
||||||
uint16_t ttak[5];
|
uint16_t ttak[5];
|
||||||
@@ -299,7 +298,7 @@ uint8_t *wlan_crypto_tkip_decrypt(const uint8_t *tk,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
iv16 = (data[0] << 8) | data[2];
|
iv16 = (data[0] << 8) | data[2];
|
||||||
iv32 = WPA_GET_LE32(&data[4]);
|
iv32 = wlan_crypto_get_le32(&data[4]);
|
||||||
wpa_printf(MSG_EXCESSIVE, "TKIP decrypt: iv32=%08x iv16=%04x",
|
wpa_printf(MSG_EXCESSIVE, "TKIP decrypt: iv32=%08x iv16=%04x",
|
||||||
iv32, iv16);
|
iv32, iv16);
|
||||||
|
|
||||||
@@ -309,16 +308,11 @@ uint8_t *wlan_crypto_tkip_decrypt(const uint8_t *tk,
|
|||||||
wpa_hexdump(MSG_EXCESSIVE, "TKIP RC4KEY", rc4key, sizeof(rc4key));
|
wpa_hexdump(MSG_EXCESSIVE, "TKIP RC4KEY", rc4key, sizeof(rc4key));
|
||||||
|
|
||||||
plain_len = data_len - 8;
|
plain_len = data_len - 8;
|
||||||
plain = qdf_mem_malloc(plain_len);
|
plain = data + 8;
|
||||||
if (plain == NULL) {
|
|
||||||
qdf_print("%s[%d] mem alloc failed\n", __func__, __LINE__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
qdf_mem_copy(plain, data + 8, plain_len);
|
|
||||||
wlan_crypto_wep_crypt(rc4key, plain, plain_len);
|
wlan_crypto_wep_crypt(rc4key, plain, plain_len);
|
||||||
|
|
||||||
icv = wlan_crypto_crc32(plain, plain_len - 4);
|
icv = wlan_crypto_crc32(plain, plain_len - 4);
|
||||||
rx_icv = WPA_GET_LE32(plain + plain_len - 4);
|
rx_icv = wlan_crypto_get_le32(plain + plain_len - 4);
|
||||||
if (icv != rx_icv) {
|
if (icv != rx_icv) {
|
||||||
wpa_printf(MSG_INFO, "TKIP ICV mismatch in frame from " MACSTR,
|
wpa_printf(MSG_INFO, "TKIP ICV mismatch in frame from " MACSTR,
|
||||||
MAC2STR(hdr->addr2));
|
MAC2STR(hdr->addr2));
|
||||||
@@ -347,12 +341,10 @@ uint8_t *wlan_crypto_tkip_decrypt(const uint8_t *tk,
|
|||||||
wpa_hexdump(MSG_DEBUG, "TKIP: Calculated MIC", mic, 8);
|
wpa_hexdump(MSG_DEBUG, "TKIP: Calculated MIC", mic, 8);
|
||||||
wpa_hexdump(MSG_DEBUG, "TKIP: Received MIC",
|
wpa_hexdump(MSG_DEBUG, "TKIP: Received MIC",
|
||||||
plain + plain_len - 8, 8);
|
plain + plain_len - 8, 8);
|
||||||
qdf_mem_free(plain);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*decrypted_len = plain_len - 8;
|
return data;
|
||||||
return plain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -368,14 +360,13 @@ void tkip_get_pn(uint8_t *pn, const uint8_t *data)
|
|||||||
|
|
||||||
|
|
||||||
uint8_t *wlan_crypto_tkip_encrypt(const uint8_t *tk, uint8_t *frame,
|
uint8_t *wlan_crypto_tkip_encrypt(const uint8_t *tk, uint8_t *frame,
|
||||||
size_t len, size_t hdrlen, uint8_t *qos,
|
size_t len, size_t hdrlen){
|
||||||
uint8_t *pn, int keyid, size_t *encrypted_len){
|
|
||||||
uint8_t michael_hdr[16];
|
uint8_t michael_hdr[16];
|
||||||
uint8_t mic[8];
|
uint8_t mic[8];
|
||||||
struct ieee80211_hdr *hdr;
|
struct ieee80211_hdr *hdr;
|
||||||
uint16_t fc;
|
uint16_t fc;
|
||||||
const uint8_t *mic_key;
|
const uint8_t *mic_key;
|
||||||
uint8_t *crypt, *pos;
|
uint8_t *pos;
|
||||||
uint16_t iv16;
|
uint16_t iv16;
|
||||||
uint32_t iv32;
|
uint32_t iv32;
|
||||||
uint16_t ttak[5];
|
uint16_t ttak[5];
|
||||||
@@ -390,35 +381,22 @@ uint8_t *wlan_crypto_tkip_encrypt(const uint8_t *tk, uint8_t *frame,
|
|||||||
mic_key = tk + ((fc & WLAN_FC_FROMDS) ? 16 : 24);
|
mic_key = tk + ((fc & WLAN_FC_FROMDS) ? 16 : 24);
|
||||||
michael_mic(mic_key, michael_hdr, frame + hdrlen, len - hdrlen, mic);
|
michael_mic(mic_key, michael_hdr, frame + hdrlen, len - hdrlen, mic);
|
||||||
wpa_hexdump(MSG_EXCESSIVE, "TKIP: MIC", mic, sizeof(mic));
|
wpa_hexdump(MSG_EXCESSIVE, "TKIP: MIC", mic, sizeof(mic));
|
||||||
|
pos = frame + hdrlen;
|
||||||
|
|
||||||
iv32 = WPA_GET_BE32(pn);
|
iv32 = wlan_crypto_get_be32(pos);
|
||||||
iv16 = WPA_GET_BE16(pn + 4);
|
iv16 = wlan_crypto_get_be16(pos + 4);
|
||||||
tkip_mixing_phase1(ttak, tk, hdr->addr2, iv32);
|
tkip_mixing_phase1(ttak, tk, hdr->addr2, iv32);
|
||||||
wpa_hexdump(MSG_EXCESSIVE, "TKIP TTAK", (uint8_t *) ttak, sizeof(ttak));
|
wpa_hexdump(MSG_EXCESSIVE, "TKIP TTAK", (uint8_t *) ttak, sizeof(ttak));
|
||||||
tkip_mixing_phase2(rc4key, tk, ttak, iv16);
|
tkip_mixing_phase2(rc4key, tk, ttak, iv16);
|
||||||
wpa_hexdump(MSG_EXCESSIVE, "TKIP RC4KEY", rc4key, sizeof(rc4key));
|
wpa_hexdump(MSG_EXCESSIVE, "TKIP RC4KEY", rc4key, sizeof(rc4key));
|
||||||
|
|
||||||
crypt = qdf_mem_malloc(len + 8 + sizeof(mic) + 4);
|
|
||||||
if (crypt == NULL) {
|
|
||||||
qdf_print("%s[%d] mem alloc failed\n", __func__, __LINE__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
qdf_mem_copy(crypt, frame, hdrlen);
|
|
||||||
pos = crypt + hdrlen;
|
|
||||||
qdf_mem_copy(pos, rc4key, 3);
|
qdf_mem_copy(pos, rc4key, 3);
|
||||||
pos += 3;
|
pos += 8;
|
||||||
*pos++ = keyid << 6 | BIT(5);
|
|
||||||
*pos++ = pn[3];
|
|
||||||
*pos++ = pn[2];
|
|
||||||
*pos++ = pn[1];
|
|
||||||
*pos++ = pn[0];
|
|
||||||
|
|
||||||
qdf_mem_copy(pos, frame + hdrlen, len - hdrlen);
|
|
||||||
qdf_mem_copy(pos + len - hdrlen, mic, sizeof(mic));
|
qdf_mem_copy(pos + len - hdrlen, mic, sizeof(mic));
|
||||||
WPA_PUT_LE32(pos + len - hdrlen + sizeof(mic),
|
wlan_crypto_put_le32(pos + len - hdrlen + sizeof(mic),
|
||||||
wlan_crypto_crc32(pos, len - hdrlen + sizeof(mic)));
|
wlan_crypto_crc32(pos, len - hdrlen + sizeof(mic)));
|
||||||
wlan_crypto_wep_crypt(rc4key, pos, len - hdrlen + sizeof(mic) + 4);
|
wlan_crypto_wep_crypt(rc4key, pos, len - hdrlen + sizeof(mic) + 4);
|
||||||
|
|
||||||
*encrypted_len = len + 8 + sizeof(mic) + 4;
|
return frame;
|
||||||
return crypt;
|
|
||||||
}
|
}
|
||||||
|
@@ -33,9 +33,6 @@
|
|||||||
#include "wlan_crypto_main_i.h"
|
#include "wlan_crypto_main_i.h"
|
||||||
#include "wlan_crypto_obj_mgr_i.h"
|
#include "wlan_crypto_obj_mgr_i.h"
|
||||||
|
|
||||||
#include "wlan_crypto_rijndael.h"
|
|
||||||
#include "wlan_crypto_tkip_i.h"
|
|
||||||
|
|
||||||
|
|
||||||
static QDF_STATUS wep_setkey(struct wlan_crypto_key *key)
|
static QDF_STATUS wep_setkey(struct wlan_crypto_key *key)
|
||||||
{
|
{
|
||||||
@@ -48,11 +45,8 @@ static QDF_STATUS wep_encap(struct wlan_crypto_key *key,
|
|||||||
uint8_t hdrlen)
|
uint8_t hdrlen)
|
||||||
{
|
{
|
||||||
uint8_t *ivp;
|
uint8_t *ivp;
|
||||||
struct ieee80211_frame *wh;
|
|
||||||
struct wlan_crypto_cipher *cipher_table;
|
struct wlan_crypto_cipher *cipher_table;
|
||||||
uint16_t off, data_len;
|
|
||||||
|
|
||||||
wh = (struct ieee80211_frame *)qdf_nbuf_data(wbuf);
|
|
||||||
cipher_table = key->cipher_table;
|
cipher_table = key->cipher_table;
|
||||||
/*
|
/*
|
||||||
* Copy down 802.11 header and add the IV, KeyID, and ExtIV.
|
* Copy down 802.11 header and add the IV, KeyID, and ExtIV.
|
||||||
@@ -64,8 +58,6 @@ static QDF_STATUS wep_encap(struct wlan_crypto_key *key,
|
|||||||
ivp = (uint8_t *)qdf_nbuf_push_head(wbuf,
|
ivp = (uint8_t *)qdf_nbuf_push_head(wbuf,
|
||||||
cipher_table->header);
|
cipher_table->header);
|
||||||
memmove(ivp, ivp + cipher_table->header, hdrlen);
|
memmove(ivp, ivp + cipher_table->header, hdrlen);
|
||||||
/* recompute wh */
|
|
||||||
wh = (struct ieee80211_frame *) qdf_nbuf_data(wbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ivp += hdrlen;
|
ivp += hdrlen;
|
||||||
@@ -84,10 +76,9 @@ static QDF_STATUS wep_encap(struct wlan_crypto_key *key,
|
|||||||
/*
|
/*
|
||||||
* Finally, do software encrypt if neeed.
|
* Finally, do software encrypt if neeed.
|
||||||
*/
|
*/
|
||||||
off = hdrlen + cipher_table->header;
|
|
||||||
data_len = qdf_nbuf_len(wbuf) - off;
|
|
||||||
if ((key->flags & WLAN_CRYPTO_KEY_SWENCRYPT) &&
|
if ((key->flags & WLAN_CRYPTO_KEY_SWENCRYPT) &&
|
||||||
!wlan_crypto_wep_encrypt(key->keyval, wbuf, off, data_len)) {
|
!wlan_crypto_wep_encrypt(key->keyval, key->keylen,
|
||||||
|
qdf_nbuf_data(wbuf), qdf_nbuf_len(wbuf))) {
|
||||||
return QDF_STATUS_CRYPTO_ENCRYPT_FAILED;
|
return QDF_STATUS_CRYPTO_ENCRYPT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,12 +89,10 @@ static QDF_STATUS wep_decap(struct wlan_crypto_key *key,
|
|||||||
uint8_t tid,
|
uint8_t tid,
|
||||||
uint8_t hdrlen)
|
uint8_t hdrlen)
|
||||||
{
|
{
|
||||||
struct ieee80211_frame *wh;
|
|
||||||
struct wlan_crypto_cipher *cipher_table;
|
struct wlan_crypto_cipher *cipher_table;
|
||||||
uint8_t *origHdr = (uint8_t *)qdf_nbuf_data(wbuf);
|
uint8_t *origHdr = (uint8_t *)qdf_nbuf_data(wbuf);
|
||||||
uint16_t off, data_len;
|
uint16_t off, data_len;
|
||||||
|
|
||||||
wh = (struct ieee80211_frame *)origHdr;
|
|
||||||
cipher_table = key->cipher_table;
|
cipher_table = key->cipher_table;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -115,8 +104,9 @@ static QDF_STATUS wep_decap(struct wlan_crypto_key *key,
|
|||||||
off = hdrlen + cipher_table->header;
|
off = hdrlen + cipher_table->header;
|
||||||
data_len = qdf_nbuf_len(wbuf) - off - cipher_table->trailer;
|
data_len = qdf_nbuf_len(wbuf) - off - cipher_table->trailer;
|
||||||
if ((key->flags & WLAN_CRYPTO_KEY_SWDECRYPT) &&
|
if ((key->flags & WLAN_CRYPTO_KEY_SWDECRYPT) &&
|
||||||
!wlan_crypto_wep_decrypt(key->keyval, wbuf, off, data_len)) {
|
!wlan_crypto_wep_decrypt(key->keyval, key->keylen,
|
||||||
return 0;
|
qdf_nbuf_data(wbuf), qdf_nbuf_len(wbuf))) {
|
||||||
|
return QDF_STATUS_CRYPTO_DECRYPT_FAILED;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Copy up 802.11 header and strip crypto bits.
|
* Copy up 802.11 header and strip crypto bits.
|
||||||
|
@@ -44,13 +44,11 @@ void wlan_crypto_wep_crypt(uint8_t *key, uint8_t *buf, size_t plen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int wlan_crypto_try_wep(const uint8_t *key, size_t key_len,
|
void wlan_crypto_try_wep(const uint8_t *key, size_t key_len,
|
||||||
const uint8_t *data, size_t data_len,
|
uint8_t *data, size_t data_len,
|
||||||
uint8_t *plain){
|
uint32_t *icv){
|
||||||
uint32_t icv, rx_icv;
|
|
||||||
uint8_t k[16];
|
uint8_t k[16];
|
||||||
int i, j;
|
int i, j;
|
||||||
int32_t status = -1;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < sizeof(k); i++) {
|
for (i = 0, j = 0; i < sizeof(k); i++) {
|
||||||
k[i] = key[j];
|
k[i] = key[j];
|
||||||
@@ -59,46 +57,48 @@ static int wlan_crypto_try_wep(const uint8_t *key, size_t key_len,
|
|||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdf_mem_copy(plain, data, data_len);
|
wlan_crypto_wep_crypt(k, data, data_len);
|
||||||
wlan_crypto_wep_crypt(k, plain, data_len);
|
*icv = wlan_crypto_crc32(data, data_len - 4);
|
||||||
icv = wlan_crypto_crc32(plain, data_len - 4);
|
}
|
||||||
rx_icv = WPA_GET_LE32(plain + data_len - 4);
|
|
||||||
if (icv != rx_icv)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
return 0;
|
uint8_t *wlan_crypto_wep_encrypt(const uint8_t *key, uint16_t key_len,
|
||||||
|
uint8_t *data, size_t data_len){
|
||||||
|
uint8_t k[16];
|
||||||
|
uint32_t icv;
|
||||||
|
|
||||||
|
if (data_len < 4 + 4) {
|
||||||
|
qdf_print("%s[%d] invalid len\n", __func__, __LINE__);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
qdf_mem_copy(k, data, 3);
|
||||||
|
qdf_mem_copy(k + 3, key, key_len);
|
||||||
|
wlan_crypto_try_wep(k, 3 + key_len, data + 4, data_len - 4, &icv);
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *wlan_crypto_wep_decrypt(const uint8_t *key, uint16_t key_len,
|
uint8_t *wlan_crypto_wep_decrypt(const uint8_t *key, uint16_t key_len,
|
||||||
const struct ieee80211_hdr *hdr,
|
uint8_t *data, size_t data_len){
|
||||||
const uint8_t *data, size_t data_len,
|
|
||||||
size_t *decrypted_len){
|
|
||||||
|
|
||||||
uint8_t *plain;
|
|
||||||
int found = 0;
|
|
||||||
uint8_t k[16];
|
uint8_t k[16];
|
||||||
|
uint32_t icv, rx_icv;
|
||||||
|
|
||||||
if (data_len < 4 + 4)
|
if (data_len < 4 + 4) {
|
||||||
return NULL;
|
qdf_print("%s[%d] invalid len\n", __func__, __LINE__);
|
||||||
plain = qdf_mem_malloc(data_len - 4);
|
|
||||||
|
|
||||||
if (plain == NULL) {
|
|
||||||
qdf_print("%s[%d] mem alloc failed\n", __func__, __LINE__);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
qdf_mem_copy(k, data, 3);
|
qdf_mem_copy(k, data, 3);
|
||||||
qdf_mem_copy(k + 3, key, key_len);
|
qdf_mem_copy(k + 3, key, key_len);
|
||||||
|
|
||||||
if (wlan_crypto_try_wep(k, 3 + key_len, data + 4,
|
rx_icv = wlan_crypto_get_le32(data + data_len - 4);
|
||||||
data_len - 4, plain) == 0)
|
|
||||||
found = 1;
|
|
||||||
|
|
||||||
if (!found) {
|
wlan_crypto_try_wep(k, 3 + key_len, data + 4, data_len - 4, &icv);
|
||||||
qdf_mem_free(plain);
|
|
||||||
|
if (icv != rx_icv) {
|
||||||
|
qdf_print("%s[%d] iv mismatch\n", __func__, __LINE__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*decrypted_len = data_len - 4 - 4;
|
return data;
|
||||||
return plain;
|
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "wlan_atf_utils_defs.h"
|
#include "wlan_atf_utils_defs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WLAN_CRYPTO_SUPPORTED
|
#if WLAN_CONV_CRYPTO_SUPPORTED
|
||||||
#include "wlan_crypto_global_def.h"
|
#include "wlan_crypto_global_def.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ struct wlan_lmac_if_tx_ops {
|
|||||||
#ifdef WLAN_ATF_ENABLE
|
#ifdef WLAN_ATF_ENABLE
|
||||||
struct wlan_lmac_if_atf_tx_ops atf_tx_ops;
|
struct wlan_lmac_if_atf_tx_ops atf_tx_ops;
|
||||||
#endif
|
#endif
|
||||||
#if WLAN_CRYPTO_SUPPORTED
|
#if WLAN_CONV_CRYPTO_SUPPORTED
|
||||||
struct wlan_lmac_if_crypto_tx_ops crypto_tx_ops;
|
struct wlan_lmac_if_crypto_tx_ops crypto_tx_ops;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIFI_POS_CONVERGED
|
#ifdef WIFI_POS_CONVERGED
|
||||||
@@ -596,7 +596,7 @@ struct wlan_lmac_if_rx_ops {
|
|||||||
#ifdef WLAN_ATF_ENABLE
|
#ifdef WLAN_ATF_ENABLE
|
||||||
struct wlan_lmac_if_atf_rx_ops atf_rx_ops;
|
struct wlan_lmac_if_atf_rx_ops atf_rx_ops;
|
||||||
#endif
|
#endif
|
||||||
#if WLAN_CRYPTO_SUPPORTED
|
#if WLAN_CONV_CRYPTO_SUPPORTED
|
||||||
struct wlan_lmac_if_crypto_rx_ops crypto_rx_ops;
|
struct wlan_lmac_if_crypto_rx_ops crypto_rx_ops;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIFI_POS_CONVERGED
|
#ifdef WIFI_POS_CONVERGED
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
#include "target_if_nan.h"
|
#include "target_if_nan.h"
|
||||||
#endif /* WLAN_FEATURE_NAN_CONVERGENCE */
|
#endif /* WLAN_FEATURE_NAN_CONVERGENCE */
|
||||||
|
|
||||||
#if WLAN_CRYPTO_SUPPORTED
|
#if WLAN_CONV_CRYPTO_SUPPORTED
|
||||||
#include "wlan_crypto_global_api.h"
|
#include "wlan_crypto_global_api.h"
|
||||||
#endif
|
#endif
|
||||||
/* Function pointer for OL/WMA specific UMAC tx_ops
|
/* Function pointer for OL/WMA specific UMAC tx_ops
|
||||||
@@ -162,7 +162,7 @@ wlan_lmac_if_umac_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops)
|
|||||||
rx_ops->scan.scan_ev_handler = tgt_scan_event_handler;
|
rx_ops->scan.scan_ev_handler = tgt_scan_event_handler;
|
||||||
wlan_lmac_if_atf_rx_ops_register(rx_ops);
|
wlan_lmac_if_atf_rx_ops_register(rx_ops);
|
||||||
|
|
||||||
#if WLAN_CRYPTO_SUPPORTED
|
#if WLAN_CONV_CRYPTO_SUPPORTED
|
||||||
wlan_crypto_register_crypto_rx_ops(&rx_ops->crypto_rx_ops);
|
wlan_crypto_register_crypto_rx_ops(&rx_ops->crypto_rx_ops);
|
||||||
#endif
|
#endif
|
||||||
/* wifi_pos rx ops */
|
/* wifi_pos rx ops */
|
||||||
|
Reference in New Issue
Block a user