diff --git a/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h b/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h index 1abe076462a9..0cc96a6bd1e1 100644 --- a/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h +++ b/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h @@ -283,26 +283,26 @@ QDF_STATUS wlan_crypto_rsnie_check(struct wlan_crypto_params *, uint8_t *frm); /** * wlan_crypto_build_wpaie - called by mlme to build wpaie * - * @crypto params: crypto params + * @vdev: vdev * @iebuf: ie buffer * - * This function gets called by mlme to build wpaie from given crypto params + * This function gets called by mlme to build wpaie from given vdev * * Return: end of buffer */ -uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *, +uint8_t *wlan_crypto_build_wpaie(struct wlan_objmgr_vdev *vdev, uint8_t *iebuf); /** * wlan_crypto_build_rsnie - called by mlme to build rsnie * - * @crypto params: crypto params + * @vdev: vdev * @iebuf: ie buffer * - * This function gets called by mlme to build rsnie from given crypto params + * This function gets called by mlme to build rsnie from given vdev * * Return: end of buffer */ -uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *, +uint8_t *wlan_crypto_build_rsnie(struct wlan_objmgr_vdev *vdev, uint8_t *iebuf); /** diff --git a/umac/cmn_services/crypto/src/wlan_crypto_def_i.h b/umac/cmn_services/crypto/src/wlan_crypto_def_i.h index 602e1a7f0d0d..e8df380f0bdf 100644 --- a/umac/cmn_services/crypto/src/wlan_crypto_def_i.h +++ b/umac/cmn_services/crypto/src/wlan_crypto_def_i.h @@ -212,67 +212,57 @@ static inline void wlan_crypto_put_be64(u8 *a, u64 val) (((uint32_t) (c)) << 8) | \ (uint32_t) (d)) -#define WPA_TYPE_OUI WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 1) +#define WPA_TYPE_OUI WLAN_WPA_SEL(WLAN_WPA_OUI_TYPE) #define WLAN_CRYPTO_WAPI_IE_LEN 20 #define WLAN_CRYPTO_WAPI_SMS4_CIPHER 0x01 -#define WPA_AUTH_KEY_MGMT_NONE \ - WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 0) -#define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X \ - WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 1) +#define WPA_AUTH_KEY_MGMT_NONE WLAN_WPA_SEL(WLAN_ASE_NONE) +#define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X WLAN_WPA_SEL(WLAN_ASE_8021X_UNSPEC) #define WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X \ - WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 2) -#define WPA_AUTH_KEY_MGMT_CCKM \ - WLAN_CRYPTO_SELECTOR(0x00, 0x40, 0x96, 0) + WLAN_WPA_SEL(WLAN_ASE_8021X_PSK) +#define WPA_AUTH_KEY_MGMT_CCKM WLAN_WPA_CCKM_AKM -#define WPA_CIPHER_SUITE_NONE WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 0) -#define WPA_CIPHER_SUITE_WEP40 WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 1) -#define WPA_CIPHER_SUITE_WEP104 WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 5) -#define WPA_CIPHER_SUITE_TKIP WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 2) -#define WPA_CIPHER_SUITE_CCMP WLAN_CRYPTO_SELECTOR(0x00, 0x50, 0xf2, 4) +#define WPA_CIPHER_SUITE_NONE WLAN_WPA_SEL(WLAN_CSE_NONE) +#define WPA_CIPHER_SUITE_WEP40 WLAN_WPA_SEL(WLAN_CSE_WEP40) +#define WPA_CIPHER_SUITE_WEP104 WLAN_WPA_SEL(WLAN_CSE_WEP104) +#define WPA_CIPHER_SUITE_TKIP WLAN_WPA_SEL(WLAN_CSE_TKIP) +#define WPA_CIPHER_SUITE_CCMP WLAN_WPA_SEL(WLAN_CSE_CCMP) -#define RSN_AUTH_KEY_MGMT_NONE WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 0) -#define RSN_AUTH_KEY_MGMT_UNSPEC_802_1X \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 1) -#define RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 2) -#define RSN_AUTH_KEY_MGMT_FT_802_1X \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 3) -#define RSN_AUTH_KEY_MGMT_FT_PSK \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 4) -#define RSN_AUTH_KEY_MGMT_802_1X_SHA256 \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 5) -#define RSN_AUTH_KEY_MGMT_PSK_SHA256 \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 6) -#define RSN_AUTH_KEY_MGMT_TPK_HANDSHAKE \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 7) -#define RSN_AUTH_KEY_MGMT_SAE WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 8) -#define RSN_AUTH_KEY_MGMT_FT_SAE WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 9) -#define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 11) -#define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B_192 \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 12) -#define RSN_AUTH_KEY_MGMT_FT_802_1X_SUITE_B_192 \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 13) -#define RSN_AUTH_KEY_MGMT_CCKM WLAN_CRYPTO_SELECTOR(0x00, 0x40, 0x96, 0x00) -#define RSN_AUTH_KEY_MGMT_OSEN WLAN_CRYPTO_SELECTOR(0x50, 0x6f, 0x9a, 0x01) +#define RSN_AUTH_KEY_MGMT_NONE WLAN_RSN_SEL(0) +#define RSN_AUTH_KEY_MGMT_UNSPEC_802_1X WLAN_RSN_SEL(1) +#define RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X\ + WLAN_RSN_SEL(2) +#define RSN_AUTH_KEY_MGMT_FT_802_1X WLAN_RSN_SEL(3) +#define RSN_AUTH_KEY_MGMT_FT_PSK WLAN_RSN_SEL(4) +#define RSN_AUTH_KEY_MGMT_802_1X_SHA256\ + WLAN_RSN_SEL(5) +#define RSN_AUTH_KEY_MGMT_PSK_SHA256 WLAN_RSN_SEL(6) +#define RSN_AUTH_KEY_MGMT_WPS WLAN_RSN_SEL(7) +#define RSN_AUTH_KEY_MGMT_SAE WLAN_RSN_SEL(8) +#define RSN_AUTH_KEY_MGMT_FT_SAE WLAN_RSN_SEL(9) +#define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B\ + WLAN_RSN_SEL(11) +#define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B_192\ + WLAN_RSN_SEL(12) +#define RSN_AUTH_KEY_MGMT_FT_802_1X_SUITE_B_192\ + WLAN_RSN_SEL(13) -#define RSN_CIPHER_SUITE_NONE WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 0) -#define RSN_CIPHER_SUITE_WEP40 WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 1) -#define RSN_CIPHER_SUITE_TKIP WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 2) -#define RSN_CIPHER_SUITE_WEP104 WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 5) -#define RSN_CIPHER_SUITE_CCMP WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 4) -#define RSN_CIPHER_SUITE_AES_CMAC WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 6) -#define RSN_CIPHER_SUITE_GCMP WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 8) -#define RSN_CIPHER_SUITE_GCMP_256 WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 9) -#define RSN_CIPHER_SUITE_CCMP_256 WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 10) -#define RSN_CIPHER_SUITE_BIP_GMAC_128 \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 11) -#define RSN_CIPHER_SUITE_BIP_GMAC_256 \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 12) -#define RSN_CIPHER_SUITE_BIP_CMAC_256 \ - WLAN_CRYPTO_SELECTOR(0x00, 0x0f, 0xac, 13) +#define RSN_AUTH_KEY_MGMT_CCKM WLAN_RSN_CCKM_AKM +#define RSN_AUTH_KEY_MGMT_OSEN (0x019a6f50) + +#define RSN_CIPHER_SUITE_NONE WLAN_RSN_SEL(WLAN_CSE_NONE) +#define RSN_CIPHER_SUITE_WEP40 WLAN_RSN_SEL(WLAN_CSE_WEP40) +#define RSN_CIPHER_SUITE_TKIP WLAN_RSN_SEL(WLAN_CSE_TKIP) +#define RSN_CIPHER_SUITE_WEP104 WLAN_RSN_SEL(WLAN_CSE_WEP104) +#define RSN_CIPHER_SUITE_CCMP WLAN_RSN_SEL(WLAN_CSE_CCMP) +#define RSN_CIPHER_SUITE_AES_CMAC WLAN_RSN_SEL(WLAN_CSE_AES_CMAC) +#define RSN_CIPHER_SUITE_GCMP WLAN_RSN_SEL(WLAN_CSE_GCMP_128) +#define RSN_CIPHER_SUITE_GCMP_256 WLAN_RSN_SEL(WLAN_CSE_GCMP_256) +#define RSN_CIPHER_SUITE_CCMP_256 WLAN_RSN_SEL(WLAN_CSE_CCMP_256) +#define RSN_CIPHER_SUITE_BIP_GMAC_128 WLAN_RSN_SEL(WLAN_CSE_BIP_GMAC_128) +#define RSN_CIPHER_SUITE_BIP_GMAC_256 WLAN_RSN_SEL(WLAN_CSE_BIP_GMAC_256) +#define RSN_CIPHER_SUITE_BIP_CMAC_256 WLAN_RSN_SEL(WLAN_CSE_BIP_CMAC_256) #define RESET_PARAM(__param) ((__param) = 0) #define SET_PARAM(__param, __val) ((__param) |= (1<<(__val))) diff --git a/umac/cmn_services/crypto/src/wlan_crypto_global_api.c b/umac/cmn_services/crypto/src/wlan_crypto_global_api.c index cc599da50ad3..4d54d5b9e0f6 100644 --- a/umac/cmn_services/crypto/src/wlan_crypto_global_api.c +++ b/umac/cmn_services/crypto/src/wlan_crypto_global_api.c @@ -1641,14 +1641,13 @@ wlan_crypto_wpa_keymgmt_to_suite(uint32_t keymgmt) return status; } /** - * * Convert a WPA cipher selector OUI to an internal * cipher algorithm. Where appropriate we also * record any key length. */ static int32_t wlan_crypto_wpa_suite_to_cipher(uint8_t *sel) { - uint32_t w = BE_READ_4(sel); + uint32_t w = LE_READ_4(sel); int32_t status = -1; switch (w) { @@ -1669,7 +1668,7 @@ static int32_t wlan_crypto_wpa_suite_to_cipher(uint8_t *sel) */ static int32_t wlan_crypto_wpa_suite_to_keymgmt(uint8_t *sel) { - uint32_t w = BE_READ_4(sel); + uint32_t w = LE_READ_4(sel); int32_t status = -1; switch (w) { @@ -1692,7 +1691,7 @@ static int32_t wlan_crypto_wpa_suite_to_keymgmt(uint8_t *sel) */ static int32_t wlan_crypto_rsn_suite_to_cipher(uint8_t *sel) { - uint32_t w = BE_READ_4(sel); + uint32_t w = LE_READ_4(sel); int32_t status = -1; switch (w) { @@ -1726,7 +1725,7 @@ static int32_t wlan_crypto_rsn_suite_to_cipher(uint8_t *sel) */ static int32_t wlan_crypto_rsn_suite_to_keymgmt(uint8_t *sel) { - uint32_t w = BE_READ_4(sel); + uint32_t w = LE_READ_4(sel); int32_t status = -1; switch (w) { @@ -1938,18 +1937,27 @@ QDF_STATUS wlan_crypto_rsnie_check(struct wlan_crypto_params *crypto_params, /** * wlan_crypto_build_wpaie - called by mlme to build wpaie * - * @crypto params: crypto params + * @vdev: vdev * @iebuf: ie buffer * - * This function gets called by mlme to build wpaie from given crypto params + * This function gets called by mlme to build wpaie from given vdev * * Return: end of buffer */ -uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *crypto_params, - uint8_t *iebuf){ +uint8_t *wlan_crypto_build_wpaie(struct wlan_objmgr_vdev *vdev, + uint8_t *iebuf){ uint8_t *frm = iebuf; uint8_t *selcnt; - uint32_t mcastcipher; + struct wlan_crypto_comp_priv *crypto_priv; + struct wlan_crypto_params *crypto_params; + + if (!frm) + return NULL; + + crypto_params = wlan_crypto_vdev_get_comp_params(vdev, &crypto_priv); + + if (!crypto_params) + return NULL; *frm++ = WLAN_ELEMID_VENDOR; *frm++ = 0; @@ -1958,10 +1966,15 @@ uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *crypto_params, /* multicast cipher */ - mcastcipher = wlan_crypto_get_mcastcipher(crypto_params); - WLAN_CRYPTO_ADDSELECTOR(frm, - wlan_crypto_wpa_cipher_to_suite(mcastcipher)); - + if (MCIPHER_IS_TKIP(crypto_params)) { + WLAN_CRYPTO_ADDSELECTOR(frm, + wlan_crypto_wpa_cipher_to_suite( + WLAN_CRYPTO_CIPHER_TKIP)); + } else if (MCIPHER_IS_CCMP128(crypto_params)) { + WLAN_CRYPTO_ADDSELECTOR(frm, + wlan_crypto_wpa_cipher_to_suite( + WLAN_CRYPTO_CIPHER_AES_CCM)); + } /* unicast cipher list */ selcnt = frm; WLAN_CRYPTO_ADDSHORT(frm, 0); @@ -1978,12 +1991,6 @@ uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *crypto_params, wlan_crypto_wpa_cipher_to_suite( WLAN_CRYPTO_CIPHER_AES_CCM)); } - if (UCIPHER_IS_CLEAR(crypto_params)) { - selcnt[0]++; - WLAN_CRYPTO_ADDSELECTOR(frm, - wlan_crypto_wpa_cipher_to_suite( - WLAN_CRYPTO_CIPHER_AES_CCM)); - } /* authenticator selector list */ selcnt = frm; @@ -2010,7 +2017,6 @@ uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *crypto_params, wlan_crypto_wpa_keymgmt_to_suite( WLAN_CRYPTO_KEY_MGMT_NONE)); } - /* calculate element length */ iebuf[1] = frm - iebuf - 2; @@ -2020,18 +2026,29 @@ uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *crypto_params, /** * wlan_crypto_build_rsnie - called by mlme to build rsnie * - * @crypto params: crypto params + * @vdev: vdev * @iebuf: ie buffer * - * This function gets called by mlme to build rsnie from given crypto params + * This function gets called by mlme to build rsnie from given vdev * * Return: end of buffer */ -uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *crypto_params, - uint8_t *iebuf){ +uint8_t *wlan_crypto_build_rsnie(struct wlan_objmgr_vdev *vdev, + uint8_t *iebuf){ uint8_t *frm = iebuf; uint8_t *selcnt; - uint32_t mcastcipher; + struct wlan_crypto_comp_priv *crypto_priv; + struct wlan_crypto_params *crypto_params; + + if (!frm) { + return NULL; + } + + crypto_params = wlan_crypto_vdev_get_comp_params(vdev, &crypto_priv); + + if (!crypto_params) { + return NULL; + } *frm++ = WLAN_ELEMID_RSN; *frm++ = 0; @@ -2039,9 +2056,27 @@ uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *crypto_params, /* multicast cipher */ - mcastcipher = wlan_crypto_get_mcastcipher(crypto_params); - WLAN_CRYPTO_ADDSELECTOR(frm, - wlan_crypto_rsn_cipher_to_suite(mcastcipher)); + if (MCIPHER_IS_TKIP(crypto_params)) { + WLAN_CRYPTO_ADDSELECTOR(frm, + wlan_crypto_rsn_cipher_to_suite( + WLAN_CRYPTO_CIPHER_TKIP)); + } else if (MCIPHER_IS_CCMP128(crypto_params)) { + WLAN_CRYPTO_ADDSELECTOR(frm, + wlan_crypto_rsn_cipher_to_suite( + WLAN_CRYPTO_CIPHER_AES_CCM)); + } else if (MCIPHER_IS_CCMP256(crypto_params)) { + WLAN_CRYPTO_ADDSELECTOR(frm, + wlan_crypto_rsn_cipher_to_suite( + WLAN_CRYPTO_CIPHER_AES_CCM_256)); + } else if (MCIPHER_IS_GCMP128(crypto_params)) { + WLAN_CRYPTO_ADDSELECTOR(frm, + wlan_crypto_rsn_cipher_to_suite( + WLAN_CRYPTO_CIPHER_AES_GCM)); + } else if (MCIPHER_IS_GCMP256(crypto_params)) { + WLAN_CRYPTO_ADDSELECTOR(frm, + wlan_crypto_rsn_cipher_to_suite( + WLAN_CRYPTO_CIPHER_AES_GCM_256)); + } /* unicast cipher list */ selcnt = frm; @@ -2050,13 +2085,13 @@ uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *crypto_params, if (UCIPHER_IS_TKIP(crypto_params)) { selcnt[0]++; WLAN_CRYPTO_ADDSELECTOR(frm, - wlan_crypto_rsn_cipher_to_suite( + wlan_crypto_rsn_cipher_to_suite( WLAN_CRYPTO_CIPHER_TKIP)); } if (UCIPHER_IS_CCMP128(crypto_params)) { selcnt[0]++; WLAN_CRYPTO_ADDSELECTOR(frm, - wlan_crypto_rsn_cipher_to_suite( + wlan_crypto_rsn_cipher_to_suite( WLAN_CRYPTO_CIPHER_AES_CCM)); } if (UCIPHER_IS_CCMP256(crypto_params)) { @@ -2078,12 +2113,6 @@ uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *crypto_params, wlan_crypto_rsn_cipher_to_suite( WLAN_CRYPTO_CIPHER_AES_GCM_256)); } - if (UCIPHER_IS_CLEAR(crypto_params)) { - selcnt[0]++; - WLAN_CRYPTO_ADDSELECTOR(frm, - wlan_crypto_rsn_cipher_to_suite( - WLAN_CRYPTO_CIPHER_AES_CCM)); - } /* authenticator selector list */ @@ -2143,12 +2172,11 @@ uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *crypto_params, } } + WLAN_CRYPTO_ADDSHORT(frm, crypto_params->rsn_caps); /* optional capabilities */ if (crypto_params->rsn_caps != 0 && crypto_params->rsn_caps != WLAN_CRYPTO_RSN_CAP_PREAUTH){ - WLAN_CRYPTO_ADDSHORT(frm, crypto_params->rsn_caps); - if (HAS_MGMT_CIPHER(crypto_params, WLAN_CRYPTO_CIPHER_AES_CMAC)) { selcnt[0]++; @@ -2179,6 +2207,7 @@ uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *crypto_params, WLAN_CRYPTO_CIPHER_AES_GMAC_256)); } } + /* calculate element length */ iebuf[1] = frm - iebuf - 2;