From 51d11033764d220327ab9b9c2e3c3497dbd5e7fc Mon Sep 17 00:00:00 2001 From: Padma Raghunathan Date: Mon, 9 Apr 2018 10:21:37 +0530 Subject: [PATCH] qcacmn: [CRYPTO] Add apis to access key information APIs to retrieve following based on cipher type - 1. Header length 2. Trailer length 3. Miclen Change-Id: Ia9c3a8d6a1459e637af80fcf73077e2d6b5f310c CRs-Fixed: 2233228 --- .../crypto/inc/wlan_crypto_global_api.h | 31 +++++++++ .../crypto/src/wlan_crypto_global_api.c | 65 ++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-) 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 f7779c63e232..8b570cecf787 100644 --- a/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h +++ b/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h @@ -535,6 +535,37 @@ uint8_t wlan_crypto_get_peer_fils_aead(struct wlan_objmgr_peer *peer); */ void wlan_crypto_set_peer_fils_aead( struct wlan_objmgr_peer *peer, uint8_t value); + +/** + * wlan_crypto_get_key_header - get header length + * @key: key + * + * This function gets header length based on keytype + * + * Return: header length + */ +uint8_t wlan_crypto_get_key_header(struct wlan_crypto_key *key); + +/** + * wlan_crypto_get_key_trailer - get cipher trailer length + * @key: key + * + * This function gets cipher trailer length based on keytype + * + * Return: cipher trailer length + */ +uint8_t wlan_crypto_get_key_trailer(struct wlan_crypto_key *key); + +/** + * wlan_crypto_get_key_miclen - get cipher miclen length + * @key: key + * + * This function gets cipher miclen length based on keytype + * + * Return: cipher miclen length + */ +uint8_t wlan_crypto_get_key_miclen(struct wlan_crypto_key *key); + /** * wlan_crypto_get_keyid - get keyid from frame * @data: frame 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 6093a6b6f355..12aff6865e35 100644 --- a/umac/cmn_services/crypto/src/wlan_crypto_global_api.c +++ b/umac/cmn_services/crypto/src/wlan_crypto_global_api.c @@ -1180,7 +1180,7 @@ QDF_STATUS wlan_crypto_decap(struct wlan_objmgr_vdev *vdev, hdrlen = ieee80211_hdrspace(wlan_vdev_get_pdev(vdev), (uint8_t *)qdf_nbuf_data(wbuf)); - keyid = wlan_crypto_get_keyid((uint8_t *)qdf_nbuf_data(wbuf)); + keyid = wlan_crypto_get_keyid((uint8_t *)qdf_nbuf_data(wbuf), hdrlen); if (keyid >= WLAN_CRYPTO_MAXKEYIDX) return QDF_STATUS_E_INVAL; @@ -3112,6 +3112,69 @@ wlan_crypto_set_peer_fils_aead(struct wlan_objmgr_peer *peer, uint8_t value) crypto_priv->fils_aead_set = value; } +/** + * wlan_crypto_get_key_header - get header length + * @key: key + * + * This function gets header length based on keytype + * + * Return: header length + */ +uint8_t wlan_crypto_get_key_header(struct wlan_crypto_key *key) +{ + struct wlan_crypto_cipher *cipher_table; + + cipher_table = (struct wlan_crypto_cipher *)key->cipher_table; + if (cipher_table) + return cipher_table->header; + else + return 0; +} + +qdf_export_symbol(wlan_crypto_get_key_header); + +/** + * wlan_crypto_get_key_trailer - get cipher trailer length + * @key: key + * + * This function gets cipher trailer length based on keytype + * + * Return: cipher trailer length + */ +uint8_t wlan_crypto_get_key_trailer(struct wlan_crypto_key *key) +{ + struct wlan_crypto_cipher *cipher_table; + + cipher_table = (struct wlan_crypto_cipher *)key->cipher_table; + if (cipher_table) + return cipher_table->trailer; + else + return 0; +} + +qdf_export_symbol(wlan_crypto_get_key_trailer); + +/** + * wlan_crypto_get_key_miclen - get cipher miclen length + * @key: key + * + * This function gets cipher miclen length based on keytype + * + * Return: cipher miclen length + */ +uint8_t wlan_crypto_get_key_miclen(struct wlan_crypto_key *key) +{ + struct wlan_crypto_cipher *cipher_table; + + cipher_table = (struct wlan_crypto_cipher *)key->cipher_table; + if (cipher_table) + return cipher_table->miclen; + else + return 0; +} + +qdf_export_symbol(wlan_crypto_get_key_miclen); + /** * wlan_crypto_get_keyid - get keyid from frame * @data: frame