From 4987746ee659f3d29999234ce40e49ee16bd605c Mon Sep 17 00:00:00 2001 From: Utkarsh Bhatnagar Date: Fri, 24 Jul 2020 19:26:27 +0530 Subject: [PATCH] qcacmn: Change WAPI Tx IV PN Sequence Change the receive and transmit Iv in wlan_crypto_set_wapi_key such as: tx_iv[16] = {0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36}; rx_iv[16] = {0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x36, 0x5c, 0x37}; This is done as wpi_key_tsc_counter sequence was been sent in reverse order. 0x365C365C365C365C365C365C365C365C was sent although 0x5C365C365C365C365C365C365C365C36 was expected. This is because new chipset firware expects the format to be in big endian. Also, taken care for the backward compatibility required for the old chipset firware with the feature flag. Change-Id: I8c795df5a9143e5089e93aaebe7787e51b570c74 CRs-Fixed: 2743162 --- target_if/crypto/src/target_if_crypto.c | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/target_if/crypto/src/target_if_crypto.c b/target_if/crypto/src/target_if_crypto.c index c1c8218bcf12..934501daaddd 100644 --- a/target_if/crypto/src/target_if_crypto.c +++ b/target_if/crypto/src/target_if_crypto.c @@ -38,6 +38,48 @@ #include #ifdef FEATURE_WLAN_WAPI +#ifdef FEATURE_WAPI_BIG_ENDIAN +/* + * All lithium firmware expects WAPI in big endian + * format , whereas helium firmware's expect otherwise + */ + +static void wlan_crypto_set_wapi_key(struct wlan_objmgr_vdev *vdev, + bool pairwise, + enum wlan_crypto_cipher_type cipher_type, + struct set_key_params *params) +{ + static const unsigned char tx_iv[16] = {0x5c, 0x36, 0x5c, 0x36, 0x5c, + 0x36, 0x5c, 0x36, 0x5c, 0x36, + 0x5c, 0x36, 0x5c, 0x36, 0x5c, + 0x36}; + + static const unsigned char rx_iv[16] = {0x5c, 0x36, 0x5c, 0x36, 0x5c, + 0x36, 0x5c, 0x36, 0x5c, 0x36, + 0x5c, 0x36, 0x5c, 0x36, 0x5c, + 0x37}; + + if (cipher_type != WLAN_CRYPTO_CIPHER_WAPI_SMS4 && + cipher_type != WLAN_CRYPTO_CIPHER_WAPI_GCM4) + return; + + if (vdev->vdev_mlme.vdev_opmode == QDF_SAP_MODE || + vdev->vdev_mlme.vdev_opmode == QDF_P2P_GO_MODE) { + qdf_mem_copy(¶ms->rx_iv, &tx_iv, + WLAN_CRYPTO_WAPI_IV_SIZE); + qdf_mem_copy(params->tx_iv, &rx_iv, + WLAN_CRYPTO_WAPI_IV_SIZE); + } else { + qdf_mem_copy(params->rx_iv, &rx_iv, + WLAN_CRYPTO_WAPI_IV_SIZE); + qdf_mem_copy(params->tx_iv, &tx_iv, + WLAN_CRYPTO_WAPI_IV_SIZE); + } + + params->key_txmic_len = WLAN_CRYPTO_MIC_LEN; + params->key_rxmic_len = WLAN_CRYPTO_MIC_LEN; +} +#else static void wlan_crypto_set_wapi_key(struct wlan_objmgr_vdev *vdev, bool pairwise, enum wlan_crypto_cipher_type cipher_type, @@ -75,6 +117,7 @@ static void wlan_crypto_set_wapi_key(struct wlan_objmgr_vdev *vdev, params->key_txmic_len = WLAN_CRYPTO_MIC_LEN; params->key_rxmic_len = WLAN_CRYPTO_MIC_LEN; } +#endif /* FEATURE_WAPI_BIG_ENDIAN */ #else static inline void wlan_crypto_set_wapi_key(struct wlan_objmgr_vdev *vdev, bool pairwise,