1 /* 2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: Public APIs for crypto service 21 */ 22 #ifndef _WLAN_CRYPTO_GLOBAL_API_H_ 23 #define _WLAN_CRYPTO_GLOBAL_API_H_ 24 25 #include "wlan_crypto_global_def.h" 26 27 /** 28 * wlan_crypto_set_vdev_param - called by ucfg to set crypto param 29 * @vdev: vdev 30 * @param: param to be set. 31 * @value: value 32 * 33 * This function gets called from ucfg to set param 34 * 35 * Return: QDF_STATUS_SUCCESS - in case of success 36 */ 37 QDF_STATUS wlan_crypto_set_vdev_param(struct wlan_objmgr_vdev *vdev, 38 wlan_crypto_param_type param, 39 uint32_t value); 40 41 /** 42 * wlan_crypto_set_peer_param - called by ucfg to set crypto param 43 * 44 * @peer: peer 45 * @param: param to be set. 46 * @value: value 47 * 48 * This function gets called from ucfg to set param 49 * 50 * Return: QDF_STATUS_SUCCESS - in case of success 51 */ 52 QDF_STATUS wlan_crypto_set_peer_param(struct wlan_objmgr_peer *peer, 53 wlan_crypto_param_type param, 54 uint32_t value); 55 56 /** 57 * wlan_crypto_get_param - called by ucfg to get crypto param 58 * @vdev: vdev 59 * @param: param to be get. 60 * 61 * This function gets called from ucfg to get param 62 * 63 * Return: value or -1 for failure 64 */ 65 int32_t wlan_crypto_get_param(struct wlan_objmgr_vdev *vdev, 66 wlan_crypto_param_type param); 67 /** 68 * wlan_crypto_get_peer_param - called by ucfg to get crypto peer param 69 * @peer: peer 70 * @param: param to be get. 71 * 72 * This function gets called from ucfg to get peer param 73 * 74 * Return: value or -1 for failure 75 */ 76 int32_t wlan_crypto_get_peer_param(struct wlan_objmgr_peer *peer, 77 wlan_crypto_param_type param); 78 79 /** 80 * wlan_crypto_is_htallowed - called by ucfg to check if HT rates is allowed 81 * @vdev: Vdev 82 * @peer: Peer 83 * 84 * This function is called to check if HT rates is allowed 85 * 86 * Return: 0 for not allowed and +ve for allowed 87 */ 88 uint8_t wlan_crypto_is_htallowed(struct wlan_objmgr_vdev *vdev, 89 struct wlan_objmgr_peer *peer); 90 /** 91 * wlan_crypto_setkey - called by ucfg to setkey 92 * @vdev: vdev 93 * @req_key: req_key with cipher type, key macaddress 94 * 95 * This function gets called from ucfg to sey key 96 * 97 * Return: QDF_STATUS_SUCCESS - in case of success 98 */ 99 QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev, 100 struct wlan_crypto_req_key *req_key); 101 102 /** 103 * wlan_crypto_getkey - called by ucfg to get key 104 * @vdev: vdev 105 * @req_key: key value will be copied in this req_key 106 * @mac_address: mac address of the peer for unicast key 107 * or broadcast address if group key is requested. 108 * 109 * This function gets called from ucfg to get key 110 * 111 * Return: QDF_STATUS_SUCCESS - in case of success 112 */ 113 QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev, 114 struct wlan_crypto_req_key *req_key, 115 uint8_t *mac_addr); 116 117 /** 118 * wlan_crypto_delkey - called by ucfg to delete key 119 * @vdev: vdev 120 * @mac_address: mac address of the peer for unicast key 121 * or broadcast address if group key is deleted. 122 * @key_idx: key index to be deleted 123 * 124 * This function gets called from ucfg to delete key 125 * 126 * Return: QDF_STATUS_SUCCESS - in case of success 127 */ 128 QDF_STATUS wlan_crypto_delkey(struct wlan_objmgr_vdev *vdev, 129 uint8_t *macaddr, 130 uint8_t key_idx); 131 132 /** 133 * wlan_crypto_default_key - called by ucfg to set default tx key 134 * @vdev: vdev 135 * @mac_address: mac address of the peer for unicast key 136 * or broadcast address if group key need to made default. 137 * @key_idx: key index to be made as default key 138 * @unicast: is key was unicast or group key. 139 * 140 * This function gets called from ucfg to set default key 141 * 142 * Return: QDF_STATUS_SUCCESS - in case of success 143 */ 144 QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev, 145 uint8_t *macaddr, 146 uint8_t key_idx, 147 bool unicast); 148 149 /** 150 * wlan_crypto_encap - called by mgmt for encap the frame based on cipher 151 * @vdev: vdev 152 * @wbuf: wbuf 153 * @macaddr: macaddr 154 * @encapdone: is encapdone already or not. 155 * 156 * This function gets called from mgmt txrx to encap frame. 157 * 158 * Return: QDF_STATUS_SUCCESS - in case of success 159 */ 160 QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev, 161 qdf_nbuf_t wbuf, 162 uint8_t *macaddr, 163 uint8_t encapdone); 164 165 /** 166 * wlan_crypto_decap - called by mgmt for decap the frame based on cipher 167 * @vdev: vdev 168 * @wbuf: wbuf 169 * @macaddr: macaddr 170 * @tid: tid of the packet. 171 * 172 * This function gets called from mgmt txrx to decap frame. 173 * 174 * Return: QDF_STATUS_SUCCESS - in case of success 175 */ 176 QDF_STATUS wlan_crypto_decap(struct wlan_objmgr_vdev *vdev, 177 qdf_nbuf_t wbuf, 178 uint8_t *macaddr, 179 uint8_t tid); 180 181 /** 182 * wlan_crypto_enmic - called by mgmt for adding mic in frame based on cipher 183 * @vdev: vdev 184 * @wbuf: wbuf 185 * @macaddr: macaddr 186 * @encapdone: is encapdone already or not. 187 * 188 * This function gets called from mgmt txrx to adding mic to the frame. 189 * 190 * Return: QDF_STATUS_SUCCESS - in case of success 191 */ 192 QDF_STATUS wlan_crypto_enmic(struct wlan_objmgr_vdev *vdev, 193 qdf_nbuf_t wbuf, 194 uint8_t *macaddr, 195 uint8_t encapdone); 196 197 /** 198 * wlan_crypto_demic - called by mgmt for remove and check mic for 199 * the frame based on cipher 200 * @vdev: vdev 201 * @wbuf: wbuf 202 * @macaddr: macaddr 203 * @tid: tid of the frame 204 * @keyid: keyid in the received frame 205 * 206 * This function gets called from mgmt txrx to decap frame. 207 * 208 * Return: QDF_STATUS_SUCCESS - in case of success 209 */ 210 QDF_STATUS wlan_crypto_demic(struct wlan_objmgr_vdev *vdev, 211 qdf_nbuf_t wbuf, 212 uint8_t *macaddr, 213 uint8_t tid, 214 uint8_t keyid); 215 216 /** 217 * wlan_crypto_vdev_is_pmf_enabled - called to check is pmf enabled in vdev 218 * @vdev: vdev 219 * 220 * This function gets called to check is pmf enabled or not in vdev. 221 * 222 * Return: true or false 223 */ 224 bool wlan_crypto_vdev_is_pmf_enabled(struct wlan_objmgr_vdev *vdev); 225 226 /** 227 * wlan_crypto_is_pmf_enabled - called by mgmt txrx to check is pmf enabled 228 * @vdev: vdev 229 * @peer: peer 230 * 231 * This function gets called by mgmt txrx to check is pmf enabled or not. 232 * 233 * Return: true or false 234 */ 235 bool wlan_crypto_is_pmf_enabled(struct wlan_objmgr_vdev *vdev, 236 struct wlan_objmgr_peer *peer); 237 238 /** 239 * wlan_crypto_add_mmie - called by mgmt txrx to add mmie in frame 240 * @vdev: vdev 241 * @frm: frame starting pointer 242 * @len: length of the frame 243 * 244 * This function gets called by mgmt txrx to add mmie in frame 245 * 246 * Return: end of frame or NULL in case failure 247 */ 248 uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev, 249 uint8_t *frm, 250 uint32_t len); 251 252 /** 253 * wlan_crypto_is_mmie_valid - called by mgmt txrx to check mmie of the frame 254 * @vdev: vdev 255 * @frm: frame starting pointer 256 * @efrm: end of frame pointer 257 * 258 * This function gets called by mgmt txrx to check mmie of the frame 259 * 260 * Return: true or false 261 */ 262 bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev, 263 uint8_t *frm, 264 uint8_t *efrm); 265 266 /** 267 * wlan_crypto_wpaie_check - called by mlme to check the wpaie 268 * @crypto params: crypto params 269 * @iebuf: ie buffer 270 * 271 * This function gets called by mlme to check the contents of wpa is 272 * matching with given crypto params 273 * 274 * Return: QDF_STATUS_SUCCESS - in case of success 275 */ 276 QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *, uint8_t *frm); 277 278 /** 279 * wlan_crypto_rsnie_check - called by mlme to check the rsnie 280 * @crypto params: crypto params 281 * @iebuf: ie buffer 282 * 283 * This function gets called by mlme to check the contents of rsn is 284 * matching with given crypto params 285 * 286 * Return: QDF_STATUS_SUCCESS - in case of success 287 */ 288 QDF_STATUS wlan_crypto_rsnie_check(struct wlan_crypto_params *, uint8_t *frm); 289 /** 290 * wlan_crypto_build_wpaie - called by mlme to build wpaie 291 * @vdev: vdev 292 * @iebuf: ie buffer 293 * 294 * This function gets called by mlme to build wpaie from given vdev 295 * 296 * Return: end of buffer 297 */ 298 uint8_t *wlan_crypto_build_wpaie(struct wlan_objmgr_vdev *vdev, 299 uint8_t *iebuf); 300 /** 301 * wlan_crypto_build_rsnie - called by mlme to build rsnie 302 * @vdev: vdev 303 * @iebuf: ie buffer 304 * 305 * This function gets called by mlme to build rsnie from given vdev 306 * 307 * Return: end of buffer 308 */ 309 uint8_t *wlan_crypto_build_rsnie(struct wlan_objmgr_vdev *vdev, 310 uint8_t *iebuf); 311 312 /** 313 * wlan_crypto_wapiie_check - called by mlme to check the wapiie 314 * @crypto params: crypto params 315 * @iebuf: ie buffer 316 * 317 * This function gets called by mlme to check the contents of wapi is 318 * matching with given crypto params 319 * 320 * Return: QDF_STATUS_SUCCESS - in case of success 321 */ 322 QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params, 323 uint8_t *frm); 324 325 /** 326 * wlan_crypto_build_wapiie - called by mlme to build wapi ie 327 * @vdev: vdev 328 * @iebuf: ie buffer 329 * 330 * This function gets called by mlme to build wapi ie from given vdev 331 * 332 * Return: end of buffer 333 */ 334 uint8_t *wlan_crypto_build_wapiie(struct wlan_objmgr_vdev *vdev, 335 uint8_t *iebuf); 336 /** 337 * wlan_crypto_rsn_info - check is given params matching with vdev params. 338 * @vdev: vdev 339 * @crypto params: crypto params 340 * 341 * This function gets called by mlme to check is given params matching with 342 * vdev params. 343 * 344 * Return: true success or false for failure. 345 */ 346 bool wlan_crypto_rsn_info(struct wlan_objmgr_vdev *vdev, 347 struct wlan_crypto_params *crypto_params); 348 /** 349 * wlan_crypto_pn_check - called by data patch for PN check 350 * @vdev: vdev 351 * @wbuf: wbuf 352 * 353 * This function gets called by data patch for PN check 354 * 355 * Return: QDF_STATUS 356 */ 357 QDF_STATUS wlan_crypto_pn_check(struct wlan_objmgr_vdev *vdev, 358 qdf_nbuf_t wbuf); 359 /** 360 * wlan_crypto_vdev_get_crypto_params - called by mlme to get crypto params 361 * @vdev:vdev 362 * 363 * This function gets called by mlme to get crypto params 364 * 365 * Return: wlan_crypto_params or NULL in case of failure 366 */ 367 struct wlan_crypto_params *wlan_crypto_vdev_get_crypto_params( 368 struct wlan_objmgr_vdev *vdev); 369 /** 370 * wlan_crypto_peer_get_crypto_params - called by mlme to get crypto params 371 * @peer:peer 372 * 373 * This function gets called by mlme to get crypto params 374 * 375 * Return: wlan_crypto_params or NULL in case of failure 376 */ 377 struct wlan_crypto_params *wlan_crypto_peer_get_crypto_params( 378 struct wlan_objmgr_peer *peer); 379 380 /** 381 * wlan_crypto_set_peer_wep_keys - set wep keys into peer entries 382 * @vdev:vdev 383 * @peer:peer 384 * 385 * This function gets called by mlme, when auth frame is received. 386 * this helps in setting wep keys into peer data structure. 387 * 388 * Return: QDF_STATUS 389 */ 390 QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev, 391 struct wlan_objmgr_peer *peer); 392 393 /** 394 * wlan_crypto_register_crypto_rx_ops - set crypto_rx_ops 395 * @crypto_rx_ops: crypto_rx_ops 396 * 397 * This function gets called by object manger to register crypto rx ops. 398 * 399 * Return: QDF_STATUS 400 */ 401 QDF_STATUS wlan_crypto_register_crypto_rx_ops( 402 struct wlan_lmac_if_crypto_rx_ops *crypto_rx_ops); 403 404 /** 405 * wlan_crypto_get_crypto_rx_ops - get crypto_rx_ops from psoc 406 * @psoc: psoc 407 * 408 * This function gets called by umac to get the crypto_rx_ops 409 * 410 * Return: crypto_rx_ops 411 */ 412 struct wlan_lmac_if_crypto_rx_ops *wlan_crypto_get_crypto_rx_ops( 413 struct wlan_objmgr_psoc *psoc); 414 /** 415 * wlan_crypto_vdev_has_auth_mode - check authmode for vdev 416 * @vdev: vdev 417 * @authvalue: authvalue to be checked 418 * 419 * This function check is authvalue passed is set in vdev or not 420 * 421 * Return: true or false 422 */ 423 bool wlan_crypto_vdev_has_auth_mode(struct wlan_objmgr_vdev *vdev, 424 wlan_crypto_auth_mode authmode); 425 426 /** 427 * wlan_crypto_peer_has_auth_mode - check authmode for peer 428 * @peer: peer 429 * @authvalue: authvalue to be checked 430 * 431 * This function check is authvalue passed is set in peer or not 432 * 433 * Return: true or false 434 */ 435 bool wlan_crypto_peer_has_auth_mode(struct wlan_objmgr_peer *peer, 436 wlan_crypto_auth_mode authvalue); 437 438 /** 439 * wlan_crypto_vdev_has_ucastcipher - check ucastcipher for vdev 440 * @vdev: vdev 441 * @ucastcipher: ucastcipher to be checked 442 * 443 * This function check is ucastcipher passed is set in vdev or not 444 * 445 * Return: true or false 446 */ 447 bool wlan_crypto_vdev_has_ucastcipher(struct wlan_objmgr_vdev *vdev, 448 wlan_crypto_cipher_type ucastcipher); 449 450 /** 451 * wlan_crypto_peer_has_ucastcipher - check ucastcipher for peer 452 * @peer: peer 453 * @ucastcipher: ucastcipher to be checked 454 * 455 * This function check is ucastcipher passed is set in peer or not 456 * 457 * Return: true or false 458 */ 459 bool wlan_crypto_peer_has_ucastcipher(struct wlan_objmgr_peer *peer, 460 wlan_crypto_cipher_type ucastcipher); 461 462 463 /** 464 * wlan_crypto_vdev_has_mcastcipher - check mcastcipher for vdev 465 * @vdev: vdev 466 * @mcastcipher: mcastcipher to be checked 467 * 468 * This function check is mcastcipher passed is set in vdev or not 469 * 470 * Return: true or false 471 */ 472 bool wlan_crypto_vdev_has_mcastcipher(struct wlan_objmgr_vdev *vdev, 473 wlan_crypto_cipher_type mcastcipher); 474 475 /** 476 * wlan_crypto_peer_has_mcastcipher - check mcastcipher for peer 477 * @peer: peer 478 * @mcastcipher: mcastcipher to be checked 479 * 480 * This function check is mcastcipher passed is set in peer or not 481 * 482 * Return: true or false 483 */ 484 bool wlan_crypto_peer_has_mcastcipher(struct wlan_objmgr_peer *peer, 485 wlan_crypto_cipher_type mcastcipher); 486 487 /** 488 * wlan_crypto_get_keytype - get keytype 489 * @key: key 490 * 491 * This function gets keytype from key 492 * 493 * Return: keytype 494 */ 495 wlan_crypto_cipher_type wlan_crypto_get_key_type( 496 struct wlan_crypto_key *key); 497 498 /** 499 * wlan_crypto_vdev_getkey - get key from vdev 500 * @vdev: vdev 501 * @keyix: keyix 502 * 503 * This function gets key from vdev 504 * 505 * Return: key or NULL 506 */ 507 struct wlan_crypto_key *wlan_crypto_vdev_getkey(struct wlan_objmgr_vdev *vdev, 508 uint16_t keyix); 509 /** 510 * wlan_crypto_peer_getkey - get key from peer 511 * @peer: peer 512 * @keyix: keyix 513 * 514 * This function gets key from peer 515 * 516 * Return: key or NULL 517 */ 518 struct wlan_crypto_key *wlan_crypto_peer_getkey(struct wlan_objmgr_peer *peer, 519 uint16_t keyix); 520 /** 521 * wlan_crypto_get_peer_fils_aead - Get peer fils aead set flag 522 * @peer: Peer object 523 * 524 * This function returns the peer fils aead set flag value. 525 * 526 * Return: 1 for enabled, 0 for disabled 527 */ 528 uint8_t wlan_crypto_get_peer_fils_aead(struct wlan_objmgr_peer *peer); 529 530 /** 531 * wlan_crypto_set_peer_fils_aead - Set peer fils aead set flag 532 * @peer: Peer object 533 * @value: Value to set the flag 534 * 535 * This function set the peer fils aead set flag once FILS AUTH received. 536 * 537 * Return: None 538 */ 539 void wlan_crypto_set_peer_fils_aead( 540 struct wlan_objmgr_peer *peer, uint8_t value); 541 542 /** 543 * wlan_crypto_get_key_header - get header length 544 * @key: key 545 * 546 * This function gets header length based on keytype 547 * 548 * Return: header length 549 */ 550 uint8_t wlan_crypto_get_key_header(struct wlan_crypto_key *key); 551 552 /** 553 * wlan_crypto_get_key_trailer - get cipher trailer length 554 * @key: key 555 * 556 * This function gets cipher trailer length based on keytype 557 * 558 * Return: cipher trailer length 559 */ 560 uint8_t wlan_crypto_get_key_trailer(struct wlan_crypto_key *key); 561 562 /** 563 * wlan_crypto_get_key_miclen - get cipher miclen length 564 * @key: key 565 * 566 * This function gets cipher miclen length based on keytype 567 * 568 * Return: cipher miclen length 569 */ 570 uint8_t wlan_crypto_get_key_miclen(struct wlan_crypto_key *key); 571 572 /** 573 * wlan_crypto_get_keyid - get keyid from frame 574 * @data: frame 575 * @hdrlen: 802.11 header length 576 * 577 * This function parse frame and returns keyid 578 * 579 * Return: keyid 580 */ 581 uint16_t wlan_crypto_get_keyid(uint8_t *data, int hdrlen); 582 583 /** 584 * wlan_crypto_restore_keys - restore crypto keys in hw keycache 585 * @vdev: vdev 586 * 587 * This function restores keys in hw keycache 588 * 589 * Return: void 590 */ 591 void wlan_crypto_restore_keys(struct wlan_objmgr_vdev *vdev); 592 #endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */ 593