1 /* 2 * Copyright (c) 2017-2019 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 * wlan_crypto_set_vdev_param - called by ucfg to set crypto param 28 * @vdev: vdev 29 * @param: param to be set. 30 * @value: value 31 * 32 * This function gets called from ucfg to set param 33 * 34 * Return: QDF_STATUS_SUCCESS - in case of success 35 */ 36 QDF_STATUS wlan_crypto_set_vdev_param(struct wlan_objmgr_vdev *vdev, 37 wlan_crypto_param_type param, 38 uint32_t value); 39 40 /** 41 * wlan_crypto_set_peer_param - called by ucfg to set crypto param 42 * 43 * @peer: peer 44 * @param: param to be set. 45 * @value: value 46 * 47 * This function gets called from ucfg to set param 48 * 49 * Return: QDF_STATUS_SUCCESS - in case of success 50 */ 51 QDF_STATUS wlan_crypto_set_peer_param(struct wlan_objmgr_peer *peer, 52 wlan_crypto_param_type param, 53 uint32_t value); 54 55 /** 56 * wlan_crypto_get_param - called by ucfg to get crypto param 57 * @vdev: vdev 58 * @param: param to be get. 59 * 60 * This function gets called from ucfg to get param 61 * 62 * Return: value or -1 for failure 63 */ 64 int32_t wlan_crypto_get_param(struct wlan_objmgr_vdev *vdev, 65 wlan_crypto_param_type param); 66 /** 67 * wlan_crypto_get_peer_param - called by ucfg to get crypto peer param 68 * @peer: peer 69 * @param: param to be get. 70 * 71 * This function gets called from ucfg to get peer param 72 * 73 * Return: value or -1 for failure 74 */ 75 int32_t wlan_crypto_get_peer_param(struct wlan_objmgr_peer *peer, 76 wlan_crypto_param_type param); 77 78 /** 79 * wlan_crypto_is_htallowed - called by ucfg to check if HT rates is allowed 80 * @vdev: Vdev 81 * @peer: Peer 82 * 83 * This function is called to check if HT rates is allowed 84 * 85 * Return: 0 for not allowed and +ve for allowed 86 */ 87 uint8_t wlan_crypto_is_htallowed(struct wlan_objmgr_vdev *vdev, 88 struct wlan_objmgr_peer *peer); 89 /** 90 * wlan_crypto_setkey - called by ucfg to setkey 91 * @vdev: vdev 92 * @req_key: req_key with cipher type, key macaddress 93 * 94 * This function gets called from ucfg to sey key 95 * 96 * Return: QDF_STATUS_SUCCESS - in case of success 97 */ 98 QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev, 99 struct wlan_crypto_req_key *req_key); 100 101 /** 102 * wlan_crypto_getkey - called by ucfg to get key 103 * @vdev: vdev 104 * @req_key: key value will be copied in this req_key 105 * @mac_address: mac address of the peer for unicast key 106 * or broadcast address if group key is requested. 107 * 108 * This function gets called from ucfg to get key 109 * 110 * Return: QDF_STATUS_SUCCESS - in case of success 111 */ 112 QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev, 113 struct wlan_crypto_req_key *req_key, 114 uint8_t *mac_addr); 115 116 /** 117 * wlan_crypto_delkey - called by ucfg to delete key 118 * @vdev: vdev 119 * @mac_address: mac address of the peer for unicast key 120 * or broadcast address if group key is deleted. 121 * @key_idx: key index to be deleted 122 * 123 * This function gets called from ucfg to delete key 124 * 125 * Return: QDF_STATUS_SUCCESS - in case of success 126 */ 127 QDF_STATUS wlan_crypto_delkey(struct wlan_objmgr_vdev *vdev, 128 uint8_t *macaddr, 129 uint8_t key_idx); 130 131 /** 132 * wlan_crypto_default_key - called by ucfg to set default tx key 133 * @vdev: vdev 134 * @mac_address: mac address of the peer for unicast key 135 * or broadcast address if group key need to made default. 136 * @key_idx: key index to be made as default key 137 * @unicast: is key was unicast or group key. 138 * 139 * This function gets called from ucfg to set default key 140 * 141 * Return: QDF_STATUS_SUCCESS - in case of success 142 */ 143 QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev, 144 uint8_t *macaddr, 145 uint8_t key_idx, 146 bool unicast); 147 148 /** 149 * wlan_crypto_encap - called by mgmt for encap the frame based on cipher 150 * @vdev: vdev 151 * @wbuf: wbuf 152 * @macaddr: macaddr 153 * @encapdone: is encapdone already or not. 154 * 155 * This function gets called from mgmt txrx to encap frame. 156 * 157 * Return: QDF_STATUS_SUCCESS - in case of success 158 */ 159 QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev, 160 qdf_nbuf_t wbuf, 161 uint8_t *macaddr, 162 uint8_t encapdone); 163 164 /** 165 * wlan_crypto_decap - called by mgmt for decap the frame based on cipher 166 * @vdev: vdev 167 * @wbuf: wbuf 168 * @macaddr: macaddr 169 * @tid: tid of the packet. 170 * 171 * This function gets called from mgmt txrx to decap frame. 172 * 173 * Return: QDF_STATUS_SUCCESS - in case of success 174 */ 175 QDF_STATUS wlan_crypto_decap(struct wlan_objmgr_vdev *vdev, 176 qdf_nbuf_t wbuf, 177 uint8_t *macaddr, 178 uint8_t tid); 179 180 /** 181 * wlan_crypto_enmic - called by mgmt for adding mic in frame based on cipher 182 * @vdev: vdev 183 * @wbuf: wbuf 184 * @macaddr: macaddr 185 * @encapdone: is encapdone already or not. 186 * 187 * This function gets called from mgmt txrx to adding mic to the frame. 188 * 189 * Return: QDF_STATUS_SUCCESS - in case of success 190 */ 191 QDF_STATUS wlan_crypto_enmic(struct wlan_objmgr_vdev *vdev, 192 qdf_nbuf_t wbuf, 193 uint8_t *macaddr, 194 uint8_t encapdone); 195 196 /** 197 * wlan_crypto_demic - called by mgmt for remove and check mic for 198 * the frame based on cipher 199 * @vdev: vdev 200 * @wbuf: wbuf 201 * @macaddr: macaddr 202 * @tid: tid of the frame 203 * @keyid: keyid in the received frame 204 * 205 * This function gets called from mgmt txrx to decap frame. 206 * 207 * Return: QDF_STATUS_SUCCESS - in case of success 208 */ 209 QDF_STATUS wlan_crypto_demic(struct wlan_objmgr_vdev *vdev, 210 qdf_nbuf_t wbuf, 211 uint8_t *macaddr, 212 uint8_t tid, 213 uint8_t keyid); 214 215 /** 216 * wlan_crypto_vdev_is_pmf_enabled - called to check is pmf enabled in vdev 217 * @vdev: vdev 218 * 219 * This function gets called to check is pmf enabled or not in vdev. 220 * 221 * Return: true or false 222 */ 223 bool wlan_crypto_vdev_is_pmf_enabled(struct wlan_objmgr_vdev *vdev); 224 225 /** 226 * wlan_crypto_is_pmf_enabled - called by mgmt txrx to check is pmf enabled 227 * @vdev: vdev 228 * @peer: peer 229 * 230 * This function gets called by mgmt txrx to check is pmf enabled or not. 231 * 232 * Return: true or false 233 */ 234 bool wlan_crypto_is_pmf_enabled(struct wlan_objmgr_vdev *vdev, 235 struct wlan_objmgr_peer *peer); 236 237 /** 238 * wlan_crypto_add_mmie - called by mgmt txrx to add mmie in frame 239 * @vdev: vdev 240 * @frm: frame starting pointer 241 * @len: length of the frame 242 * 243 * This function gets called by mgmt txrx to add mmie in frame 244 * 245 * Return: end of frame or NULL in case failure 246 */ 247 uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev, 248 uint8_t *frm, 249 uint32_t len); 250 251 /** 252 * wlan_crypto_is_mmie_valid - called by mgmt txrx to check mmie of the frame 253 * @vdev: vdev 254 * @frm: frame starting pointer 255 * @efrm: end of frame pointer 256 * 257 * This function gets called by mgmt txrx to check mmie of the frame 258 * 259 * Return: true or false 260 */ 261 bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev, 262 uint8_t *frm, 263 uint8_t *efrm); 264 265 /** 266 * wlan_crypto_wpaie_check - called by mlme to check the wpaie 267 * @crypto params: crypto params 268 * @iebuf: ie buffer 269 * 270 * This function gets called by mlme to check the contents of wpa is 271 * matching with given crypto params 272 * 273 * Return: QDF_STATUS_SUCCESS - in case of success 274 */ 275 QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *, uint8_t *frm); 276 277 /** 278 * wlan_crypto_rsnie_check - called by mlme to check the rsnie 279 * @crypto params: crypto params 280 * @iebuf: ie buffer 281 * 282 * This function gets called by mlme to check the contents of rsn is 283 * matching with given crypto params 284 * 285 * Return: QDF_STATUS_SUCCESS - in case of success 286 */ 287 QDF_STATUS wlan_crypto_rsnie_check(struct wlan_crypto_params *, uint8_t *frm); 288 /** 289 * wlan_crypto_build_wpaie - called by mlme to build wpaie 290 * @vdev: vdev 291 * @iebuf: ie buffer 292 * 293 * This function gets called by mlme to build wpaie from given vdev 294 * 295 * Return: end of buffer 296 */ 297 uint8_t *wlan_crypto_build_wpaie(struct wlan_objmgr_vdev *vdev, 298 uint8_t *iebuf); 299 /** 300 * wlan_crypto_build_rsnie - called by mlme to build rsnie 301 * @vdev: vdev 302 * @iebuf: ie buffer 303 * @bssid: bssid mac address to add pmkid in rsnie 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 struct qdf_mac_addr *bssid); 312 313 /** 314 * wlan_crypto_wapiie_check - called by mlme to check the wapiie 315 * @crypto params: crypto params 316 * @iebuf: ie buffer 317 * 318 * This function gets called by mlme to check the contents of wapi is 319 * matching with given crypto params 320 * 321 * Return: QDF_STATUS_SUCCESS - in case of success 322 */ 323 QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params, 324 uint8_t *frm); 325 326 /** 327 * wlan_crypto_build_wapiie - called by mlme to build wapi ie 328 * @vdev: vdev 329 * @iebuf: ie buffer 330 * 331 * This function gets called by mlme to build wapi ie from given vdev 332 * 333 * Return: end of buffer 334 */ 335 uint8_t *wlan_crypto_build_wapiie(struct wlan_objmgr_vdev *vdev, 336 uint8_t *iebuf); 337 /** 338 * wlan_crypto_rsn_info - check is given params matching with vdev params. 339 * @vdev: vdev 340 * @crypto params: crypto params 341 * 342 * This function gets called by mlme to check is given params matching with 343 * vdev params. 344 * 345 * Return: true success or false for failure. 346 */ 347 bool wlan_crypto_rsn_info(struct wlan_objmgr_vdev *vdev, 348 struct wlan_crypto_params *crypto_params); 349 /** 350 * wlan_crypto_pn_check - called by data patch for PN check 351 * @vdev: vdev 352 * @wbuf: wbuf 353 * 354 * This function gets called by data patch for PN check 355 * 356 * Return: QDF_STATUS 357 */ 358 QDF_STATUS wlan_crypto_pn_check(struct wlan_objmgr_vdev *vdev, 359 qdf_nbuf_t wbuf); 360 /** 361 * wlan_crypto_vdev_get_crypto_params - called by mlme to get crypto params 362 * @vdev:vdev 363 * 364 * This function gets called by mlme to get crypto params 365 * 366 * Return: wlan_crypto_params or NULL in case of failure 367 */ 368 struct wlan_crypto_params *wlan_crypto_vdev_get_crypto_params( 369 struct wlan_objmgr_vdev *vdev); 370 /** 371 * wlan_crypto_peer_get_crypto_params - called by mlme to get crypto params 372 * @peer:peer 373 * 374 * This function gets called by mlme to get crypto params 375 * 376 * Return: wlan_crypto_params or NULL in case of failure 377 */ 378 struct wlan_crypto_params *wlan_crypto_peer_get_crypto_params( 379 struct wlan_objmgr_peer *peer); 380 381 /** 382 * wlan_crypto_set_peer_wep_keys - set wep keys into peer entries 383 * @vdev:vdev 384 * @peer:peer 385 * 386 * This function gets called by mlme, when auth frame is received. 387 * this helps in setting wep keys into peer data structure. 388 * 389 * Return: QDF_STATUS 390 */ 391 QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev, 392 struct wlan_objmgr_peer *peer); 393 394 /** 395 * wlan_crypto_register_crypto_rx_ops - set crypto_rx_ops 396 * @crypto_rx_ops: crypto_rx_ops 397 * 398 * This function gets called by object manger to register crypto rx ops. 399 * 400 * Return: QDF_STATUS 401 */ 402 QDF_STATUS wlan_crypto_register_crypto_rx_ops( 403 struct wlan_lmac_if_crypto_rx_ops *crypto_rx_ops); 404 405 /** 406 * wlan_crypto_get_crypto_rx_ops - get crypto_rx_ops from psoc 407 * @psoc: psoc 408 * 409 * This function gets called by umac to get the crypto_rx_ops 410 * 411 * Return: crypto_rx_ops 412 */ 413 struct wlan_lmac_if_crypto_rx_ops *wlan_crypto_get_crypto_rx_ops( 414 struct wlan_objmgr_psoc *psoc); 415 /** 416 * wlan_crypto_vdev_has_auth_mode - check authmode for vdev 417 * @vdev: vdev 418 * @authvalue: authvalue to be checked 419 * 420 * This function check is authvalue passed is set in vdev or not 421 * 422 * Return: true or false 423 */ 424 bool wlan_crypto_vdev_has_auth_mode(struct wlan_objmgr_vdev *vdev, 425 wlan_crypto_auth_mode authmode); 426 427 /** 428 * wlan_crypto_peer_has_auth_mode - check authmode for peer 429 * @peer: peer 430 * @authvalue: authvalue to be checked 431 * 432 * This function check is authvalue passed is set in peer or not 433 * 434 * Return: true or false 435 */ 436 bool wlan_crypto_peer_has_auth_mode(struct wlan_objmgr_peer *peer, 437 wlan_crypto_auth_mode authvalue); 438 439 /** 440 * wlan_crypto_vdev_has_ucastcipher - check ucastcipher for vdev 441 * @vdev: vdev 442 * @ucastcipher: ucastcipher to be checked 443 * 444 * This function check is ucastcipher passed is set in vdev or not 445 * 446 * Return: true or false 447 */ 448 bool wlan_crypto_vdev_has_ucastcipher(struct wlan_objmgr_vdev *vdev, 449 wlan_crypto_cipher_type ucastcipher); 450 451 /** 452 * wlan_crypto_peer_has_ucastcipher - check ucastcipher for peer 453 * @peer: peer 454 * @ucastcipher: ucastcipher to be checked 455 * 456 * This function check is ucastcipher passed is set in peer or not 457 * 458 * Return: true or false 459 */ 460 bool wlan_crypto_peer_has_ucastcipher(struct wlan_objmgr_peer *peer, 461 wlan_crypto_cipher_type ucastcipher); 462 463 464 /** 465 * wlan_crypto_vdev_has_mcastcipher - check mcastcipher for vdev 466 * @vdev: vdev 467 * @mcastcipher: mcastcipher to be checked 468 * 469 * This function check is mcastcipher passed is set in vdev or not 470 * 471 * Return: true or false 472 */ 473 bool wlan_crypto_vdev_has_mcastcipher(struct wlan_objmgr_vdev *vdev, 474 wlan_crypto_cipher_type mcastcipher); 475 476 /** 477 * wlan_crypto_peer_has_mcastcipher - check mcastcipher for peer 478 * @peer: peer 479 * @mcastcipher: mcastcipher to be checked 480 * 481 * This function check is mcastcipher passed is set in peer or not 482 * 483 * Return: true or false 484 */ 485 bool wlan_crypto_peer_has_mcastcipher(struct wlan_objmgr_peer *peer, 486 wlan_crypto_cipher_type mcastcipher); 487 488 /** 489 * wlan_crypto_get_keytype - get keytype 490 * @key: key 491 * 492 * This function gets keytype from key 493 * 494 * Return: keytype 495 */ 496 wlan_crypto_cipher_type wlan_crypto_get_key_type( 497 struct wlan_crypto_key *key); 498 499 /** 500 * wlan_crypto_vdev_getkey - get key from vdev 501 * @vdev: vdev 502 * @keyix: keyix 503 * 504 * This function gets key from vdev 505 * 506 * Return: key or NULL 507 */ 508 struct wlan_crypto_key *wlan_crypto_vdev_getkey(struct wlan_objmgr_vdev *vdev, 509 uint16_t keyix); 510 /** 511 * wlan_crypto_peer_getkey - get key from peer 512 * @peer: peer 513 * @keyix: keyix 514 * 515 * This function gets key from peer 516 * 517 * Return: key or NULL 518 */ 519 struct wlan_crypto_key *wlan_crypto_peer_getkey(struct wlan_objmgr_peer *peer, 520 uint16_t keyix); 521 /** 522 * wlan_crypto_get_peer_fils_aead - Get peer fils aead set flag 523 * @peer: Peer object 524 * 525 * This function returns the peer fils aead set flag value. 526 * 527 * Return: 1 for enabled, 0 for disabled 528 */ 529 uint8_t wlan_crypto_get_peer_fils_aead(struct wlan_objmgr_peer *peer); 530 531 /** 532 * wlan_crypto_set_peer_fils_aead - Set peer fils aead set flag 533 * @peer: Peer object 534 * @value: Value to set the flag 535 * 536 * This function set the peer fils aead set flag once FILS AUTH received. 537 * 538 * Return: None 539 */ 540 void wlan_crypto_set_peer_fils_aead( 541 struct wlan_objmgr_peer *peer, uint8_t value); 542 543 /** 544 * wlan_crypto_get_key_header - get header length 545 * @key: key 546 * 547 * This function gets header length based on keytype 548 * 549 * Return: header length 550 */ 551 uint8_t wlan_crypto_get_key_header(struct wlan_crypto_key *key); 552 553 /** 554 * wlan_crypto_get_key_trailer - get cipher trailer length 555 * @key: key 556 * 557 * This function gets cipher trailer length based on keytype 558 * 559 * Return: cipher trailer length 560 */ 561 uint8_t wlan_crypto_get_key_trailer(struct wlan_crypto_key *key); 562 563 /** 564 * wlan_crypto_get_key_miclen - get cipher miclen length 565 * @key: key 566 * 567 * This function gets cipher miclen length based on keytype 568 * 569 * Return: cipher miclen length 570 */ 571 uint8_t wlan_crypto_get_key_miclen(struct wlan_crypto_key *key); 572 573 /** 574 * wlan_crypto_get_keyid - get keyid from frame 575 * @data: frame 576 * @hdrlen: 802.11 header length 577 * 578 * This function parse frame and returns keyid 579 * 580 * Return: keyid 581 */ 582 uint16_t wlan_crypto_get_keyid(uint8_t *data, int hdrlen); 583 584 /** 585 * wlan_crypto_restore_keys - restore crypto keys in hw keycache 586 * @vdev: vdev 587 * 588 * This function restores keys in hw keycache 589 * 590 * Return: void 591 */ 592 void wlan_crypto_restore_keys(struct wlan_objmgr_vdev *vdev); 593 594 /** 595 * wlan_crypto_check_open_none - called by ucfg to check for open security 596 * @psoc: psoc pointer 597 * @vdev_id: vdev id 598 * 599 * This function gets called from ucfg to check open security. 600 * 601 * Return: true or false 602 */ 603 bool wlan_crypto_check_open_none(struct wlan_objmgr_psoc *psoc, 604 uint8_t vedv_id); 605 606 /** 607 * wlan_crypto_check_wep - called by ucfg to check for WEP security 608 * @psoc: psoc pointer 609 * @vdev_id: vdev id 610 * 611 * This function gets called from ucfg to check WEP security. 612 * 613 * Return: true or false 614 */ 615 bool wlan_crypto_check_wep(struct wlan_objmgr_psoc *psoc, uint8_t vedv_id); 616 617 /** 618 * wlan_crypto_check_rsn_match - called by ucfg to check for RSN match 619 * @psoc: psoc pointer 620 * @vdev_id: vdev id 621 * @ie_ptr: pointer to IEs 622 * @ie_len: IE length 623 * 624 * This function gets called from ucfg to check RSN match. 625 * 626 * Return: true or false 627 */ 628 bool wlan_crypto_check_rsn_match(struct wlan_objmgr_psoc *psoc, 629 uint8_t vedv_id, uint8_t *ie_ptr, 630 uint16_t ie_len); 631 632 /** 633 * wlan_crypto_check_rsn_match - called by ucfg to check for WPA match 634 * @psoc: psoc pointer 635 * @vdev_id: vdev id 636 * @ie_ptr: pointer to IEs 637 * @ie_len: IE length 638 * 639 * This function gets called from ucfg to check WPA match. 640 * 641 * Return: true or false 642 */ 643 bool wlan_crypto_check_wpa_match(struct wlan_objmgr_psoc *psoc, 644 uint8_t vedv_id, uint8_t *ie_ptr, 645 uint16_t ie_len); 646 647 /** 648 * wlan_set_vdev_crypto_prarams_from_ie - Sets vdev crypto params from IE info 649 * @vdev: vdev pointer 650 * @ie_ptr: pointer to IE 651 * @ie_len: IE length 652 * 653 * This function gets called from ucfg to set crypto params from IE data. 654 * 655 * Return: QDF_STATUS_SUCCESS or error code 656 */ 657 QDF_STATUS wlan_set_vdev_crypto_prarams_from_ie(struct wlan_objmgr_vdev *vdev, 658 uint8_t *ie_ptr, 659 uint16_t ie_len); 660 #ifdef WLAN_CRYPTO_GCM_OS_DERIVATIVE 661 static inline int wlan_crypto_aes_gmac(const uint8_t *key, size_t key_len, 662 const uint8_t *iv, size_t iv_len, 663 const uint8_t *aad, size_t aad_len, 664 uint8_t *tag) 665 { 666 return 0; 667 } 668 #endif 669 #ifdef WLAN_CRYPTO_OMAC1_OS_DERIVATIVE 670 static inline int omac1_aes_128(const uint8_t *key, const uint8_t *data, 671 size_t data_len, uint8_t *mac) 672 { 673 return 0; 674 } 675 676 static inline int omac1_aes_256(const uint8_t *key, const uint8_t *data, 677 size_t data_len, uint8_t *mac) 678 { 679 return 0; 680 } 681 #endif 682 683 /** 684 * ucfg_crypto_set_key_req() - Set key request to UCFG 685 * @vdev: vdev object 686 * @req: key request information 687 * @pairwise: indicates the type of key to be set, unicast or group key 688 * 689 * Return: None 690 */ 691 QDF_STATUS ucfg_crypto_set_key_req(struct wlan_objmgr_vdev *vdev, 692 struct wlan_crypto_key *req, bool pairwise); 693 694 /** 695 * wlan_crypto_get_default_key_idx() - Get the default key index 696 * @vdev: vdev object 697 * @igtk: denotes if the request is for igtk key type or not 698 * 699 * Return: Index of the requested key 700 */ 701 int8_t wlan_crypto_get_default_key_idx(struct wlan_objmgr_vdev *vdev, 702 bool igtk); 703 704 /** 705 * wlan_crypto_get_cipher() - Get the cipher type for the vdev 706 * @vdev: vdev object 707 * @pairwise: denotes if the request is for pairwise cipher or not 708 * @key_index: Index of the key whose cipher type has to be returned 709 * 710 * Return: enum wlan_crypto_cipher_type 711 */ 712 enum wlan_crypto_cipher_type 713 wlan_crypto_get_cipher(struct wlan_objmgr_vdev *vdev, 714 bool pairwise, uint8_t key_index); 715 716 #ifdef CRYPTO_SET_KEY_CONVERGED 717 /** 718 * wlan_crypto_update_set_key_peer() - Update the peer for set key 719 * @vdev: vdev object 720 * @pairwise: denotes if the request is for pairwise cipher or not 721 * @key_index: Index of the key whose peer has to be set 722 * @peer_mac: MAC address of the peer 723 * 724 * Return: None 725 */ 726 void wlan_crypto_update_set_key_peer(struct wlan_objmgr_vdev *vdev, 727 bool pairwise, uint8_t key_index, 728 struct qdf_mac_addr *peer_mac); 729 730 /** 731 * wlan_crypto_validate_key_params() - validates key parameters 732 * @cipher: cipher type 733 * @key_index: the index of the key 734 * @key_len: key length 735 * @seq_len: sequence counter length 736 * 737 * Return: QDF_STATUS 738 */ 739 QDF_STATUS wlan_crypto_validate_key_params(enum wlan_crypto_cipher_type cipher, 740 uint8_t key_index, uint8_t key_len, 741 uint8_t seq_len); 742 743 /** 744 * wlan_crypto_save_key() - Allocate memory for storing key 745 * @vdev: vdev object 746 * @key_index: the index of the key that needs to be allocated 747 * @crypto_key: Pointer to crypto key 748 * 749 * Return: QDF_STATUS 750 */ 751 QDF_STATUS wlan_crypto_save_key(struct wlan_objmgr_vdev *vdev, 752 uint8_t key_index, 753 struct wlan_crypto_key *crypto_key); 754 755 /** 756 * wlan_crypto_get_key() - Get the stored key information 757 * @vdev: vdev object 758 * @key_index: the index of the key that needs to be retrieved 759 * 760 * Return: Key material 761 */ 762 struct wlan_crypto_key *wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev, 763 uint8_t key_index); 764 765 /** 766 * wlan_crypto_set_key_req() - Set key request 767 * @vdev: vdev object 768 * @req: key request information 769 * @pairwise: indicates the type of key to be set, unicast or group key 770 * 771 * Return: QDF status 772 */ 773 QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev, 774 struct wlan_crypto_key *req, bool pairwise); 775 #else 776 static inline void wlan_crypto_update_set_key_peer( 777 struct wlan_objmgr_vdev *vdev, 778 bool pairwise, 779 uint8_t key_index, 780 struct qdf_mac_addr *peer_mac) 781 { 782 } 783 784 static inline QDF_STATUS 785 wlan_crypto_save_key(struct wlan_objmgr_vdev *vdev, uint8_t key_index, 786 struct wlan_crypto_key *crypto_key) 787 { 788 return QDF_STATUS_SUCCESS; 789 } 790 791 static inline struct wlan_crypto_key * 792 wlan_crypto_get_key(struct wlan_objmgr_vdev *vdev, uint8_t key_index) 793 { 794 return NULL; 795 } 796 797 static inline QDF_STATUS wlan_crypto_set_key_req(struct wlan_objmgr_vdev *vdev, 798 struct wlan_crypto_key *req, 799 bool pairwise) 800 { 801 return QDF_STATUS_SUCCESS; 802 } 803 #endif /* CRYPTO_SET_KEY_CONVERGED */ 804 /** 805 * wlan_crypto_pmksa_flush - called to flush saved pmksa 806 * @crypto_params: crypto_params 807 * 808 * This function flush saved pmksa from crypto params. 809 * 810 * Return: QDF_STATUS_SUCCESS - in case of success 811 */ 812 QDF_STATUS wlan_crypto_pmksa_flush(struct wlan_crypto_params *crypto_params); 813 814 /** 815 * wlan_crypto_set_vdev_param - called by ucfg to set crypto param 816 * @vdev: vdev 817 * @pmksa: pmksa to be set/del. 818 * @set: set(set=1) or del(set=0) pmksa from the list. 819 * 820 * This function gets called from ucfg to set or del pmksa. 821 * when given pmksa is NULL and set is 0, it is for flush all entries. 822 * 823 * Return: QDF_STATUS_SUCCESS - in case of success 824 */ 825 QDF_STATUS wlan_crypto_set_del_pmksa(struct wlan_objmgr_vdev *vdev, 826 struct wlan_crypto_pmksa *pmksa, 827 bool set); 828 829 #endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */ 830