xref: /wlan-driver/qca-wifi-host-cmn/os_if/linux/crypto/inc/wlan_cfg80211_crypto.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: declares crypto functions interfacing with linux kernel
22  */
23 
24 #ifndef _WLAN_CFG80211_CRYPTO_H_
25 #define _WLAN_CFG80211_CRYPTO_H_
26 #include <net/cfg80211.h>
27 #include "wlan_crypto_global_def.h"
28 /**
29  * wlan_cfg80211_set_default_key() - to set the default key to be used
30  * @vdev: VDEV Object pointer
31  * @key_index: Index to be set as the default
32  * @bssid: BSSID for which the key is to be set
33  *
34  * Return: Zero for success and negative for failure.
35  */
36 int wlan_cfg80211_set_default_key(struct wlan_objmgr_vdev *vdev,
37 				  uint8_t key_index,
38 				  struct qdf_mac_addr *bssid);
39 
40 /**
41  * wlan_cfg80211_translate_ml_sta_key - Translate the cfg80211 keys
42  * to internal for ml sta key
43  * @key_index: key index
44  * @key_type: key type
45  * @mac_addr: mac addr
46  * @params: params
47  * @crypto_key: crypto keys
48  *
49  * Return: None
50  */
51 void wlan_cfg80211_translate_ml_sta_key(uint8_t key_index,
52 					enum wlan_crypto_key_type key_type,
53 					const u8 *mac_addr,
54 					struct key_params *params,
55 					struct wlan_crypto_key *crypto_key);
56 /**
57  * wlan_cfg80211_translate_key() - Translate the cfg80211 keys to
58  * internal
59  * @vdev: Pointer to vdev object
60  * @key_index: Key index
61  * @key_type: key type
62  * @mac_addr: mac address
63  * @params: Params
64  * @crypto_key: Crypto keys
65  *
66  * Return: None
67  */
68 void wlan_cfg80211_translate_key(struct wlan_objmgr_vdev *vdev,
69 				 uint8_t key_index,
70 				 enum wlan_crypto_key_type key_type,
71 				 const u8 *mac_addr,
72 				 struct key_params *params,
73 				 struct wlan_crypto_key *crypto_key);
74 
75 /**
76  * wlan_cfg80211_store_link_key() - store link key info
77  * @psoc: psoc handler
78  * @key_index: key index
79  * @key_type: key type
80  * @mac_addr: mac address
81  * @params: params
82  * @link_addr: link address
83  * @link_id: link id
84  *
85  */
86 int wlan_cfg80211_store_link_key(struct wlan_objmgr_psoc *psoc,
87 				 uint8_t key_index,
88 				 enum wlan_crypto_key_type key_type,
89 				 const u8 *mac_addr, struct key_params *params,
90 				 struct qdf_mac_addr *link_addr,
91 				 uint8_t link_id);
92 
93 /**
94  * wlan_cfg80211_store_key() - Store the key
95  * @vdev: VDEV Object pointer
96  * @key_index: Index to be set as the default
97  * @key_type: denotes if the key is pairwise or group key
98  * @mac_addr: BSSID for which the key is to be set
99  * @params: Key params received from the kernel
100  *
101  * Return: Zero for success and negative for failure.
102  */
103 int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
104 			    uint8_t key_index,
105 			    enum wlan_crypto_key_type key_type,
106 			    const u8 *mac_addr, struct key_params *params);
107 
108 /**
109  * wlan_cfg80211_crypto_add_key() - Add key for the specified vdev
110  * @vdev: vdev object
111  * @key_type: denotes if the add key request is for pairwise or group key
112  * @key_index: Index of the key that needs to be added
113  * @sync: flag to indicate whether or not to add key synchronously.
114  *  DO NOT set to true if it's in scheduler context.
115  *
116  * Return: Zero on Success, negative value on failure
117  */
118 int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev,
119 				 enum wlan_crypto_key_type key_type,
120 				 uint8_t key_index, bool sync);
121 #endif
122