blob: c5b30bab509af2af4ed7b47b7f92533fa5be86bc [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 *
30 * This file lim_security_utils.h contains the utility definitions
31 * related to WEP encryption/decryption etc.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38#ifndef __LIM_SECURITY_UTILS_H
39#define __LIM_SECURITY_UTILS_H
40#include "sir_mac_prot_def.h" /* for tSirMacAuthFrameBody */
41
42#define LIM_ENCR_AUTH_BODY_LEN (sizeof(tSirMacAuthFrameBody) + \
43 SIR_MAC_WEP_IV_LENGTH + \
44 SIR_MAC_WEP_ICV_LENGTH)
45struct tLimPreAuthNode;
46
47uint8_t lim_is_auth_algo_supported(tpAniSirGlobal, tAniAuthType, tpPESession);
48
49/* MAC based authentication related functions */
50void lim_init_pre_auth_list(tpAniSirGlobal);
51void lim_delete_pre_auth_list(tpAniSirGlobal);
52struct tLimPreAuthNode *lim_search_pre_auth_list(tpAniSirGlobal, tSirMacAddr);
53void lim_add_pre_auth_node(tpAniSirGlobal, struct tLimPreAuthNode *);
54void lim_delete_pre_auth_node(tpAniSirGlobal, tSirMacAddr);
55void lim_release_pre_auth_node(tpAniSirGlobal pMac, tpLimPreAuthNode pAuthNode);
56void lim_restore_from_auth_state(tpAniSirGlobal,
57 tSirResultCodes, uint16_t, tpPESession);
58uint8_t lim_delete_open_auth_pre_auth_node(tpAniSirGlobal mac_ctx);
59
60/* Encryption/Decryption related functions */
61void lim_compute_crc32(uint8_t *, uint8_t *, uint8_t);
62void lim_rc4(uint8_t *, uint8_t *, uint8_t *, uint32_t, uint16_t);
63void lim_encrypt_auth_frame(tpAniSirGlobal, uint8_t, uint8_t *, uint8_t *,
64 uint8_t *, uint32_t);
65uint8_t lim_decrypt_auth_frame(tpAniSirGlobal, uint8_t *, uint8_t *, uint8_t *,
66 uint32_t, uint16_t);
67
68void lim_send_set_bss_key_req(tpAniSirGlobal, tLimMlmSetKeysReq *, tpPESession);
69void lim_send_set_sta_key_req(tpAniSirGlobal, tLimMlmSetKeysReq *, uint16_t, uint8_t,
70 tpPESession, bool sendRsp);
71void lim_post_sme_set_keys_cnf(tpAniSirGlobal, tLimMlmSetKeysReq *,
72 tLimMlmSetKeysCnf *);
73
74#define PTAPS 0xedb88320
75
76static inline uint32_t lim_crc_update(uint32_t crc, uint8_t x)
77{
78
79 /* Update CRC computation for 8 bits contained in x */
80 /* */
81 uint32_t z;
82 uint32_t fb;
83 int i;
84
85 z = crc ^ x;
86 for (i = 0; i < 8; i++) {
87 fb = z & 1;
88 z >>= 1;
89 if (fb)
90 z ^= PTAPS;
91 }
92 return z;
93}
94
95#endif /* __LIM_SECURITY_UTILS_H */