1 /* 2 * Copyright (c) 2017-2020 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 #include <qdf_crypto.h> 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_vdev_is_pmf_required - called to check is pmf required in vdev 228 * @vdev: vdev 229 * 230 * This function gets called to check is pmf required or not in vdev. 231 * 232 * Return: true or false 233 */ 234 bool wlan_crypto_vdev_is_pmf_required(struct wlan_objmgr_vdev *vdev); 235 236 /** 237 * wlan_crypto_is_pmf_enabled - called by mgmt txrx to check is pmf enabled 238 * @vdev: vdev 239 * @peer: peer 240 * 241 * This function gets called by mgmt txrx to check is pmf enabled or not. 242 * 243 * Return: true or false 244 */ 245 bool wlan_crypto_is_pmf_enabled(struct wlan_objmgr_vdev *vdev, 246 struct wlan_objmgr_peer *peer); 247 248 /** 249 * wlan_crypto_is_key_valid - called by mgmt txrx to check if key is valid 250 * @vdev: vdev 251 * @peer: peer 252 * @keyidx : key index 253 * 254 * This function gets called by mgmt txrx to check if key is valid 255 * 256 * Return: true or false 257 */ 258 bool wlan_crypto_is_key_valid(struct wlan_objmgr_vdev *vdev, 259 struct wlan_objmgr_peer *peer, 260 uint16_t keyidx); 261 262 /** 263 * wlan_crypto_add_mmie - called by mgmt txrx to add mmie in frame 264 * @vdev: vdev 265 * @frm: frame starting pointer 266 * @len: length of the frame 267 * 268 * This function gets called by mgmt txrx to add mmie in frame 269 * 270 * Return: end of frame or NULL in case failure 271 */ 272 uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev, 273 uint8_t *frm, 274 uint32_t len); 275 276 /** 277 * wlan_crypto_is_mmie_valid - called by mgmt txrx to check mmie of the frame 278 * @vdev: vdev 279 * @frm: frame starting pointer 280 * @efrm: end of frame pointer 281 * 282 * This function gets called by mgmt txrx to check mmie of the frame 283 * 284 * Return: true or false 285 */ 286 bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev, 287 uint8_t *frm, 288 uint8_t *efrm); 289 290 /** 291 * wlan_crypto_wpaie_check - called by mlme to check the wpaie 292 * @crypto params: crypto params 293 * @iebuf: ie buffer 294 * 295 * This function gets called by mlme to check the contents of wpa is 296 * matching with given crypto params 297 * 298 * Return: QDF_STATUS_SUCCESS - in case of success 299 */ 300 QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *, uint8_t *frm); 301 302 /** 303 * wlan_crypto_rsnie_check - called by mlme to check the rsnie 304 * @crypto params: crypto params 305 * @iebuf: ie buffer 306 * 307 * This function gets called by mlme to check the contents of rsn is 308 * matching with given crypto params 309 * 310 * Return: QDF_STATUS_SUCCESS - in case of success 311 */ 312 QDF_STATUS wlan_crypto_rsnie_check(struct wlan_crypto_params *, uint8_t *frm); 313 /** 314 * wlan_crypto_build_wpaie - called by mlme to build wpaie 315 * @vdev: vdev 316 * @iebuf: ie buffer 317 * 318 * This function gets called by mlme to build wpaie from given vdev 319 * 320 * Return: end of buffer 321 */ 322 uint8_t *wlan_crypto_build_wpaie(struct wlan_objmgr_vdev *vdev, 323 uint8_t *iebuf); 324 325 /** 326 * wlan_crypto_build_rsnie_with_pmksa() - called by mlme to build rsnie 327 * @vdev: vdev 328 * @iebuf: ie buffer 329 * @pmksa: pmksa struct 330 * 331 * This function gets called by mlme to build rsnie from given vdev 332 * 333 * Return: end of buffer 334 */ 335 uint8_t *wlan_crypto_build_rsnie_with_pmksa(struct wlan_objmgr_vdev *vdev, 336 uint8_t *iebuf, 337 struct wlan_crypto_pmksa *pmksa); 338 339 /** 340 * wlan_crypto_build_rsnie - called by mlme to build rsnie 341 * @vdev: vdev 342 * @iebuf: ie buffer 343 * @bssid: bssid mac address to add pmkid in rsnie 344 * 345 * This function gets called by mlme to build rsnie from given vdev 346 * 347 * Return: end of buffer 348 */ 349 uint8_t *wlan_crypto_build_rsnie(struct wlan_objmgr_vdev *vdev, 350 uint8_t *iebuf, 351 struct qdf_mac_addr *bssid); 352 353 /** 354 * wlan_crypto_wapiie_check - called by mlme to check the wapiie 355 * @crypto params: crypto params 356 * @iebuf: ie buffer 357 * 358 * This function gets called by mlme to check the contents of wapi is 359 * matching with given crypto params 360 * 361 * Return: QDF_STATUS_SUCCESS - in case of success 362 */ 363 QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params, 364 uint8_t *frm); 365 366 /** 367 * wlan_crypto_build_wapiie - called by mlme to build wapi ie 368 * @vdev: vdev 369 * @iebuf: ie buffer 370 * 371 * This function gets called by mlme to build wapi ie from given vdev 372 * 373 * Return: end of buffer 374 */ 375 uint8_t *wlan_crypto_build_wapiie(struct wlan_objmgr_vdev *vdev, 376 uint8_t *iebuf); 377 /** 378 * wlan_crypto_rsn_info - check is given params matching with vdev params. 379 * @vdev: vdev 380 * @crypto params: crypto params 381 * 382 * This function gets called by mlme to check is given params matching with 383 * vdev params. 384 * 385 * Return: true success or false for failure. 386 */ 387 bool wlan_crypto_rsn_info(struct wlan_objmgr_vdev *vdev, 388 struct wlan_crypto_params *crypto_params); 389 /** 390 * wlan_crypto_pn_check - called by data patch for PN check 391 * @vdev: vdev 392 * @wbuf: wbuf 393 * 394 * This function gets called by data patch for PN check 395 * 396 * Return: QDF_STATUS 397 */ 398 QDF_STATUS wlan_crypto_pn_check(struct wlan_objmgr_vdev *vdev, 399 qdf_nbuf_t wbuf); 400 /** 401 * wlan_crypto_vdev_get_crypto_params - called by mlme to get crypto params 402 * @vdev:vdev 403 * 404 * This function gets called by mlme to get crypto params 405 * 406 * Return: wlan_crypto_params or NULL in case of failure 407 */ 408 struct wlan_crypto_params *wlan_crypto_vdev_get_crypto_params( 409 struct wlan_objmgr_vdev *vdev); 410 /** 411 * wlan_crypto_peer_get_crypto_params - called by mlme to get crypto params 412 * @peer:peer 413 * 414 * This function gets called by mlme to get crypto params 415 * 416 * Return: wlan_crypto_params or NULL in case of failure 417 */ 418 struct wlan_crypto_params *wlan_crypto_peer_get_crypto_params( 419 struct wlan_objmgr_peer *peer); 420 421 /** 422 * wlan_crypto_set_peer_wep_keys - set wep keys into peer entries 423 * @vdev:vdev 424 * @peer:peer 425 * 426 * This function gets called by mlme, when auth frame is received. 427 * this helps in setting wep keys into peer data structure. 428 * 429 * Return: QDF_STATUS 430 */ 431 QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev, 432 struct wlan_objmgr_peer *peer); 433 434 /** 435 * wlan_crypto_register_crypto_rx_ops - set crypto_rx_ops 436 * @crypto_rx_ops: crypto_rx_ops 437 * 438 * This function gets called by object manger to register crypto rx ops. 439 * 440 * Return: QDF_STATUS 441 */ 442 QDF_STATUS wlan_crypto_register_crypto_rx_ops( 443 struct wlan_lmac_if_crypto_rx_ops *crypto_rx_ops); 444 445 /** 446 * wlan_crypto_get_crypto_rx_ops - get crypto_rx_ops from psoc 447 * @psoc: psoc 448 * 449 * This function gets called by umac to get the crypto_rx_ops 450 * 451 * Return: crypto_rx_ops 452 */ 453 struct wlan_lmac_if_crypto_rx_ops *wlan_crypto_get_crypto_rx_ops( 454 struct wlan_objmgr_psoc *psoc); 455 /** 456 * wlan_crypto_vdev_has_auth_mode - check authmode for vdev 457 * @vdev: vdev 458 * @authvalue: authvalue to be checked 459 * 460 * This function check is authvalue passed is set in vdev or not 461 * 462 * Return: true or false 463 */ 464 bool wlan_crypto_vdev_has_auth_mode(struct wlan_objmgr_vdev *vdev, 465 wlan_crypto_auth_mode authmode); 466 467 /** 468 * wlan_crypto_peer_has_auth_mode - check authmode for peer 469 * @peer: peer 470 * @authvalue: authvalue to be checked 471 * 472 * This function check is authvalue passed is set in peer or not 473 * 474 * Return: true or false 475 */ 476 bool wlan_crypto_peer_has_auth_mode(struct wlan_objmgr_peer *peer, 477 wlan_crypto_auth_mode authvalue); 478 479 /** 480 * wlan_crypto_vdev_has_ucastcipher - check ucastcipher for vdev 481 * @vdev: vdev 482 * @ucastcipher: ucastcipher to be checked 483 * 484 * This function check is ucastcipher passed is set in vdev or not 485 * 486 * Return: true or false 487 */ 488 bool wlan_crypto_vdev_has_ucastcipher(struct wlan_objmgr_vdev *vdev, 489 wlan_crypto_cipher_type ucastcipher); 490 491 /** 492 * wlan_crypto_peer_has_ucastcipher - check ucastcipher for peer 493 * @peer: peer 494 * @ucastcipher: ucastcipher to be checked 495 * 496 * This function check is ucastcipher passed is set in peer or not 497 * 498 * Return: true or false 499 */ 500 bool wlan_crypto_peer_has_ucastcipher(struct wlan_objmgr_peer *peer, 501 wlan_crypto_cipher_type ucastcipher); 502 503 504 /** 505 * wlan_crypto_vdev_has_mcastcipher - check mcastcipher for vdev 506 * @vdev: vdev 507 * @mcastcipher: mcastcipher to be checked 508 * 509 * This function check is mcastcipher passed is set in vdev or not 510 * 511 * Return: true or false 512 */ 513 bool wlan_crypto_vdev_has_mcastcipher(struct wlan_objmgr_vdev *vdev, 514 wlan_crypto_cipher_type mcastcipher); 515 516 /** 517 * wlan_crypto_peer_has_mcastcipher - check mcastcipher for peer 518 * @peer: peer 519 * @mcastcipher: mcastcipher to be checked 520 * 521 * This function check is mcastcipher passed is set in peer or not 522 * 523 * Return: true or false 524 */ 525 bool wlan_crypto_peer_has_mcastcipher(struct wlan_objmgr_peer *peer, 526 wlan_crypto_cipher_type mcastcipher); 527 528 /** 529 * wlan_crypto_vdev_has_mgmtcipher - check mgmtcipher for vdev 530 * @vdev: vdev 531 * @mgmtcipher: mgmtcipher to be checked 532 * 533 * This function checks any one of mgmtciphers are supported by vdev or not. 534 * 535 * Return: true or false 536 */ 537 bool wlan_crypto_vdev_has_mgmtcipher(struct wlan_objmgr_vdev *vdev, 538 uint32_t mgmtcipher); 539 540 /** 541 * wlan_crypto_peer_has_mgmtcipher - check mgmtcipher for peer 542 * @peer: peer 543 * @mgmtcipher: mgmtcipher to be checked 544 * 545 * This function checks any one of mgmtciphers are supported by peer or not. 546 * 547 * Return: true or false 548 */ 549 bool wlan_crypto_peer_has_mgmtcipher(struct wlan_objmgr_peer *peer, 550 uint32_t mgmtcipher); 551 552 /** 553 * wlan_crypto_get_keytype - get keytype 554 * @key: key 555 * 556 * This function gets keytype from key 557 * 558 * Return: keytype 559 */ 560 wlan_crypto_cipher_type wlan_crypto_get_key_type( 561 struct wlan_crypto_key *key); 562 563 /** 564 * wlan_crypto_vdev_getkey - get key from vdev 565 * @vdev: vdev 566 * @keyix: keyix 567 * 568 * This function gets key from vdev 569 * 570 * Return: key or NULL 571 */ 572 struct wlan_crypto_key *wlan_crypto_vdev_getkey(struct wlan_objmgr_vdev *vdev, 573 uint16_t keyix); 574 /** 575 * wlan_crypto_peer_getkey - get key from peer 576 * @peer: peer 577 * @keyix: keyix 578 * 579 * This function gets key from peer 580 * 581 * Return: key or NULL 582 */ 583 struct wlan_crypto_key *wlan_crypto_peer_getkey(struct wlan_objmgr_peer *peer, 584 uint16_t keyix); 585 /** 586 * wlan_crypto_get_peer_fils_aead - Get peer fils aead set flag 587 * @peer: Peer object 588 * 589 * This function returns the peer fils aead set flag value. 590 * 591 * Return: 1 for enabled, 0 for disabled 592 */ 593 uint8_t wlan_crypto_get_peer_fils_aead(struct wlan_objmgr_peer *peer); 594 595 /** 596 * wlan_crypto_set_peer_fils_aead - Set peer fils aead set flag 597 * @peer: Peer object 598 * @value: Value to set the flag 599 * 600 * This function set the peer fils aead set flag once FILS AUTH received. 601 * 602 * Return: None 603 */ 604 void wlan_crypto_set_peer_fils_aead( 605 struct wlan_objmgr_peer *peer, uint8_t value); 606 607 /** 608 * wlan_crypto_get_key_header - get header length 609 * @key: key 610 * 611 * This function gets header length based on keytype 612 * 613 * Return: header length 614 */ 615 uint8_t wlan_crypto_get_key_header(struct wlan_crypto_key *key); 616 617 /** 618 * wlan_crypto_get_key_trailer - get cipher trailer length 619 * @key: key 620 * 621 * This function gets cipher trailer length based on keytype 622 * 623 * Return: cipher trailer length 624 */ 625 uint8_t wlan_crypto_get_key_trailer(struct wlan_crypto_key *key); 626 627 /** 628 * wlan_crypto_get_key_miclen - get cipher miclen length 629 * @key: key 630 * 631 * This function gets cipher miclen length based on keytype 632 * 633 * Return: cipher miclen length 634 */ 635 uint8_t wlan_crypto_get_key_miclen(struct wlan_crypto_key *key); 636 637 /** 638 * wlan_crypto_get_keyid - get keyid from frame 639 * @data: frame 640 * @hdrlen: 802.11 header length 641 * 642 * This function parse frame and returns keyid 643 * 644 * Return: keyid 645 */ 646 uint16_t wlan_crypto_get_keyid(uint8_t *data, int hdrlen); 647 648 /** 649 * wlan_crypto_restore_keys - restore crypto keys in hw keycache 650 * @vdev: vdev 651 * 652 * This function restores keys in hw keycache 653 * 654 * Return: void 655 */ 656 void wlan_crypto_restore_keys(struct wlan_objmgr_vdev *vdev); 657 658 /** 659 * wlan_crypto_check_open_none - called by ucfg to check for open security 660 * @psoc: psoc pointer 661 * @vdev_id: vdev id 662 * 663 * This function gets called from ucfg to check open security. 664 * 665 * Return: true or false 666 */ 667 bool wlan_crypto_check_open_none(struct wlan_objmgr_psoc *psoc, 668 uint8_t vedv_id); 669 670 /** 671 * wlan_crypto_check_wep - called by ucfg to check for WEP security 672 * @psoc: psoc pointer 673 * @vdev_id: vdev id 674 * 675 * This function gets called from ucfg to check WEP security. 676 * 677 * Return: true or false 678 */ 679 bool wlan_crypto_check_wep(struct wlan_objmgr_psoc *psoc, uint8_t vedv_id); 680 681 /** 682 * wlan_crypto_check_rsn_match - called by ucfg to check for RSN match 683 * @psoc: psoc pointer 684 * @vdev_id: vdev id 685 * @ie_ptr: pointer to IEs 686 * @ie_len: IE length 687 * @peer_crypto_params: return peer crypto parameters 688 * 689 * This function gets called from ucfg to check RSN match. 690 * 691 * Return: true or false 692 */ 693 bool wlan_crypto_check_rsn_match(struct wlan_objmgr_psoc *psoc, 694 uint8_t vedv_id, uint8_t *ie_ptr, 695 uint16_t ie_len, struct wlan_crypto_params * 696 peer_crypto_params); 697 698 /** 699 * wlan_crypto_check_rsn_match - called by ucfg to check for WPA match 700 * @psoc: psoc pointer 701 * @vdev_id: vdev id 702 * @ie_ptr: pointer to IEs 703 * @ie_len: IE length 704 * @peer_crypto_params: return peer crypto parameters 705 * 706 * This function gets called from ucfg to check WPA match. 707 * 708 * Return: true or false 709 */ 710 bool wlan_crypto_check_wpa_match(struct wlan_objmgr_psoc *psoc, 711 uint8_t vedv_id, uint8_t *ie_ptr, 712 uint16_t ie_len, struct wlan_crypto_params * 713 peer_crypto_params); 714 715 /** 716 * wlan_set_vdev_crypto_prarams_from_ie - Sets vdev crypto params from IE info 717 * @vdev: vdev pointer 718 * @ie_ptr: pointer to IE 719 * @ie_len: IE length 720 * 721 * This function gets called from ucfg to set crypto params from IE data. 722 * 723 * Return: QDF_STATUS_SUCCESS or error code 724 */ 725 QDF_STATUS wlan_set_vdev_crypto_prarams_from_ie(struct wlan_objmgr_vdev *vdev, 726 uint8_t *ie_ptr, 727 uint16_t ie_len); 728 #ifdef WLAN_CRYPTO_GCM_OS_DERIVATIVE 729 static inline int wlan_crypto_aes_gmac(const uint8_t *key, size_t key_len, 730 uint8_t *iv, size_t iv_len, 731 const uint8_t *aad, size_t aad_len, 732 uint8_t *tag) 733 { 734 return qdf_crypto_aes_gmac(key, key_len, iv, aad, 735 aad + AAD_LEN, 736 aad_len - AAD_LEN - 737 IEEE80211_MMIE_GMAC_MICLEN, 738 tag); 739 } 740 #endif 741 #ifdef WLAN_CRYPTO_OMAC1_OS_DERIVATIVE 742 static inline int omac1_aes_128(const uint8_t *key, const uint8_t *data, 743 size_t data_len, uint8_t *mac) 744 { 745 return qdf_crypto_aes_128_cmac(key, data, data_len, mac); 746 } 747 748 static inline int omac1_aes_256(const uint8_t *key, const uint8_t *data, 749 size_t data_len, uint8_t *mac) 750 { 751 return 0; 752 } 753 #endif 754 755 /** 756 * ucfg_crypto_set_key_req() - Set key request to UCFG 757 * @vdev: vdev object 758 * @req: key request information 759 * @key_type: indicates the type of key to be set, unicast or group key 760 * 761 * Return: None 762 */ 763 QDF_STATUS ucfg_crypto_set_key_req(struct wlan_objmgr_vdev *vdev, 764 struct wlan_crypto_key *req, 765 enum wlan_crypto_key_type key_type); 766 767 /** 768 * wlan_crypto_get_default_key_idx() - Get the default key index 769 * @vdev: vdev object 770 * @igtk: denotes if the request is for igtk key type or not 771 * 772 * Return: Index of the requested key 773 */ 774 int8_t wlan_crypto_get_default_key_idx(struct wlan_objmgr_vdev *vdev, 775 bool igtk); 776 777 /** 778 * wlan_crypto_get_cipher() - Get the cipher type for the vdev 779 * @vdev: vdev object 780 * @pairwise: denotes if the request is for pairwise cipher or not 781 * @key_index: Index of the key whose cipher type has to be returned 782 * 783 * Return: enum wlan_crypto_cipher_type 784 */ 785 enum wlan_crypto_cipher_type 786 wlan_crypto_get_cipher(struct wlan_objmgr_vdev *vdev, 787 bool pairwise, uint8_t key_index); 788 789 #ifdef CRYPTO_SET_KEY_CONVERGED 790 /** 791 * wlan_crypto_update_set_key_peer() - Update the peer for set key 792 * @vdev: vdev object 793 * @pairwise: denotes if the request is for pairwise cipher or not 794 * @key_index: Index of the key whose peer has to be set 795 * @peer_mac: MAC address of the peer 796 * 797 * Return: None 798 */ 799 void wlan_crypto_update_set_key_peer(struct wlan_objmgr_vdev *vdev, 800 bool pairwise, uint8_t key_index, 801 struct qdf_mac_addr *peer_mac); 802 803 /** 804 * wlan_crypto_validate_key_params() - validates key parameters 805 * @cipher: cipher type 806 * @key_index: the index of the key 807 * @key_len: key length 808 * @seq_len: sequence counter length 809 * 810 * Return: QDF_STATUS 811 */ 812 QDF_STATUS wlan_crypto_validate_key_params(enum wlan_crypto_cipher_type cipher, 813 uint8_t key_index, uint8_t key_len, 814 uint8_t seq_len); 815 816 /** 817 * wlan_crypto_save_key() - Allocate memory for storing key 818 * @vdev: vdev object 819 * @key_index: the index of the key that needs to be allocated 820 * @crypto_key: Pointer to crypto key 821 * 822 * Return: QDF_STATUS 823 */ 824 QDF_STATUS wlan_crypto_save_key(struct wlan_objmgr_vdev *vdev, 825 uint8_t key_index, 826 struct wlan_crypto_key *crypto_key); 827 828 /** 829 * wlan_crypto_get_key() - Get the stored key information 830 * @vdev: vdev object 831 * @key_index: the index of the key that needs to be retrieved 832 * 833 * Return: Key material 834 */ 835 struct wlan_crypto_key *wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev, 836 uint8_t key_index); 837 838 /** 839 * wlan_crypto_set_key_req() - Set key request 840 * @vdev: vdev object 841 * @req: key request information 842 * @key_type: indicates the type of key to be set, unicast or group key 843 * 844 * Return: QDF status 845 */ 846 QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev, 847 struct wlan_crypto_key *req, 848 enum wlan_crypto_key_type key_type); 849 #else 850 static inline void wlan_crypto_update_set_key_peer( 851 struct wlan_objmgr_vdev *vdev, 852 bool pairwise, 853 uint8_t key_index, 854 struct qdf_mac_addr *peer_mac) 855 { 856 } 857 858 static inline QDF_STATUS 859 wlan_crypto_save_key(struct wlan_objmgr_vdev *vdev, uint8_t key_index, 860 struct wlan_crypto_key *crypto_key) 861 { 862 return QDF_STATUS_SUCCESS; 863 } 864 865 static inline struct wlan_crypto_key * 866 wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev, uint8_t key_index) 867 { 868 return NULL; 869 } 870 871 static inline 872 QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev, 873 struct wlan_crypto_key *req, 874 enum wlan_crypto_key_type key_type) 875 { 876 return QDF_STATUS_SUCCESS; 877 } 878 #endif /* CRYPTO_SET_KEY_CONVERGED */ 879 880 /** 881 * wlan_crypto_get_peer_pmksa() - called to get pmksa based on pmksa parameter 882 * @vdev: vdev 883 * @pmksa: bssid 884 * 885 * This function is to get pmksa based on pmksa parameter 886 * 887 * Return: wlan_crypto_pmksa when match found else NULL. 888 */ 889 struct wlan_crypto_pmksa * 890 wlan_crypto_get_peer_pmksa(struct wlan_objmgr_vdev *vdev, 891 struct wlan_crypto_pmksa *pmksa); 892 893 /** 894 * wlan_crypto_get_pmksa - called to get pmksa of bssid passed. 895 * @vdev: vdev 896 * @bssid: bssid 897 * 898 * This function gets called from to get pmksa for the bssid. 899 * 900 * Return: wlan_crypto_pmksa when match found else NULL. 901 */ 902 struct wlan_crypto_pmksa * 903 wlan_crypto_get_pmksa(struct wlan_objmgr_vdev *vdev, 904 struct qdf_mac_addr *bssid); 905 906 /** 907 * wlan_crypto_get_fils_pmksa - Get the PMKSA for FILS 908 * SSID, if the SSID and cache id matches 909 * @vdev: Pointer with VDEV object 910 * @cache_id: Cache id 911 * @ssid: Pointer to ssid 912 * @ssid_len: SSID length 913 * 914 * Return: PMKSA entry if the cache id and SSID matches 915 */ 916 struct wlan_crypto_pmksa * 917 wlan_crypto_get_fils_pmksa(struct wlan_objmgr_vdev *vdev, 918 uint8_t *cache_id, uint8_t *ssid, 919 uint8_t ssid_len); 920 921 /** 922 * wlan_crypto_pmksa_flush - called to flush saved pmksa 923 * @crypto_params: crypto_params 924 * 925 * This function flush saved pmksa from crypto params. 926 * 927 * Return: QDF_STATUS_SUCCESS - in case of success 928 */ 929 QDF_STATUS wlan_crypto_pmksa_flush(struct wlan_crypto_params *crypto_params); 930 931 /** 932 * wlan_crypto_set_vdev_param - called by ucfg to set crypto param 933 * @vdev: vdev 934 * @pmksa: pmksa to be set/del. 935 * @set: set(set=1) or del(set=0) pmksa from the list. 936 * 937 * This function gets called from ucfg to set or del pmksa. 938 * when given pmksa is NULL and set is 0, it is for flush all entries. 939 * 940 * Return: QDF_STATUS_SUCCESS - in case of success 941 */ 942 QDF_STATUS wlan_crypto_set_del_pmksa(struct wlan_objmgr_vdev *vdev, 943 struct wlan_crypto_pmksa *pmksa, 944 bool set); 945 946 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) 947 /** 948 * wlan_crypto_selective_clear_sae_single_pmk_entries - Clear the PMK entries 949 * for BSS which have the single PMK flag set other than the current connected 950 * AP 951 * @vdev: Vdev 952 * @conn_bssid: Connected bssid 953 */ 954 void 955 wlan_crypto_selective_clear_sae_single_pmk_entries( 956 struct wlan_objmgr_vdev *vdev, struct qdf_mac_addr *conn_bssid); 957 958 /** 959 * wlan_crypto_set_sae_single_pmk_bss_cap - Set the peer SAE sinlge pmk 960 * feature supported status 961 * @vdev: Vdev 962 * @bssid: BSSID for which the flag is to be set 963 * @single_pmk_capable_bss: Flag to indicate Sae single pmk supported BSSID or 964 * not 965 */ 966 void wlan_crypto_set_sae_single_pmk_bss_cap(struct wlan_objmgr_vdev *vdev, 967 struct qdf_mac_addr *bssid, 968 bool single_pmk_capable_bss); 969 #else 970 static inline void 971 wlan_crypto_selective_clear_sae_single_pmk_entries( 972 struct wlan_objmgr_vdev *vdev, struct qdf_mac_addr *conn_bssid) 973 { 974 } 975 976 static inline 977 void wlan_crypto_set_sae_single_pmk_bss_cap(struct wlan_objmgr_vdev *vdev, 978 struct qdf_mac_addr *bssid, 979 bool single_pmk_capable_bss) 980 { 981 } 982 #endif 983 984 #ifdef WLAN_FEATURE_FILS_SK 985 /** 986 * lim_create_fils_rik()- This API create rik using rrk coming from 987 * supplicant. 988 * @rrk: input rrk 989 * @rrk_len: rrk length 990 * @rik: Created rik 991 * @rik_len: rik length to be filled 992 * 993 * rIK = KDF (K, S), where 994 * K = rRK and 995 * S = rIK Label + "\0" + cryptosuite + length 996 * The rIK Label is the 8-bit ASCII string: 997 * Re-authentication Integrity Key@ietf.org 998 * 999 * Return: QDF_STATUS 1000 */ 1001 QDF_STATUS wlan_crypto_create_fils_rik(uint8_t *rrk, uint8_t rrk_len, 1002 uint8_t *rik, uint32_t *rik_len); 1003 #endif /* WLAN_FEATURE_FILS_SK */ 1004 #endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */ 1005