1/** \file wepBroadcastKeyDerivation.c 2 * \brief WEP broadcast key derivation implementation. 3 * 4 * \see wepBroadcastKeyDerivation.h 5*/ 6/**************************************************************************** 7**+-----------------------------------------------------------------------+** 8**| |** 9**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |** 10**| All rights reserved. |** 11**| |** 12**| Redistribution and use in source and binary forms, with or without |** 13**| modification, are permitted provided that the following conditions |** 14**| are met: |** 15**| |** 16**| * Redistributions of source code must retain the above copyright |** 17**| notice, this list of conditions and the following disclaimer. |** 18**| * Redistributions in binary form must reproduce the above copyright |** 19**| notice, this list of conditions and the following disclaimer in |** 20**| the documentation and/or other materials provided with the |** 21**| distribution. |** 22**| * Neither the name Texas Instruments nor the names of its |** 23**| contributors may be used to endorse or promote products derived |** 24**| from this software without specific prior written permission. |** 25**| |** 26**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |** 27**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |** 28**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |** 29**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |** 30**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |** 31**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |** 32**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |** 33**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |** 34**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |** 35**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |** 36**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |** 37**| |** 38**+-----------------------------------------------------------------------+** 39****************************************************************************/ 40 41/**************************************************************************** 42 * * 43 * MODULE: WEP broadcast key derivation * 44 * PURPOSE: WEP broadcast key derivation * 45 * * 46 ****************************************************************************/ 47 48#include "osApi.h" 49#include "utils.h" 50#include "report.h" 51#include "rsnApi.h" 52 53#include "keyDerive.h" 54#include "keyDeriveWep.h" 55 56#include "mainKeysSm.h" 57 58/** 59* 60* rsn_wepBroadcastKeyDerivationInit 61* 62* \b Description: 63* 64* WEP broadcast key derivation init function: 65* - Initializes the derive & remove callback functions 66* - Resets the key material in the system control block 67* 68* \b ARGS: 69* 70* None 71* 72* \b RETURNS: 73* 74* OK on success, NOK otherwise. 75*/ 76 77TI_STATUS keyDeriveWep_config(struct _keyDerive_t *pKeyDerive) 78{ 79 pKeyDerive->derive = keyDeriveWep_derive; 80 pKeyDerive->remove = keyDeriveWep_remove; 81 82 return OK; 83} 84 85 86/** 87* 88* wepBroadcastKeyDerivationDerive 89* 90* \b Description: 91* 92* WEP broadcast key derivation function: 93* - Decodes the key material. 94* - Distribute the decoded key material to the driver. 95* 96* \b ARGS: 97* 98* I - p - Pointer to the encoded key material. 99* 100* \b RETURNS: 101* 102* OK on success, NOK otherwise. 103*/ 104 105TI_STATUS keyDeriveWep_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey) 106{ 107 TI_STATUS status; 108 securityKeys_t key; 109 110 if (pEncodedKey==NULL) 111 { 112 return NOK; 113 } 114 115 if ((pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_40) && 116 (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_104) && 117 (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_232)) 118 { 119 WLAN_REPORT_ERROR(pKeyDerive->hReport, RSN_MODULE_LOG, 120 ("DeriveWep_derive: ERROR: it is not WEP key lenghth (len=%d) !!!\n", pEncodedKey->keyLen)); 121 return NOK; 122 } 123 124 key.keyType = WEP_KEY; 125 key.keyIndex = (UINT8)pEncodedKey->keyId; 126 key.encLen = (UINT16)pEncodedKey->keyLen; 127 os_memoryCopy(pKeyDerive->hOs, (void *)key.encKey, pEncodedKey->pData, pEncodedKey->keyLen); 128 129 status = pKeyDerive->pMainKeys->setKey(pKeyDerive->pMainKeys, &key); 130 if (status == OK) 131 { 132 os_memoryCopy(pKeyDerive->hOs, &pKeyDerive->key, pEncodedKey, sizeof(encodedKeyMaterial_t)); 133 } 134 135 return status; 136} 137 138/** 139* 140* wepBroadcastKeyDerivationRemove 141* 142* \b Description: 143* 144* WEP broadcast key removal function: 145* - Remove the key material from the driver. 146* 147* \b ARGS: 148* 149* None. 150* 151* \b RETURNS: 152* 153* OK on success, NOK otherwise. 154*/ 155 156TI_STATUS keyDeriveWep_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey) 157{ 158 TI_STATUS status; 159 securityKeys_t key; 160 161 os_memoryZero(pKeyDerive->hOs, &key, sizeof(securityKeys_t)); 162 key.keyType = WEP_KEY; 163 key.keyIndex = (UINT8)pEncodedKey->keyId; 164 key.encLen = (UINT16)pKeyDerive->key.keyLen; 165 os_memoryCopy(pKeyDerive->hOs, (void *)key.macAddress.addr, pEncodedKey->pData, MAC_ADDR_LEN); 166 167 status = pKeyDerive->pMainKeys->removeKey(pKeyDerive->pMainKeys, &key); 168 if (status == OK) 169 { 170 os_memoryZero(pKeyDerive->hOs, &pKeyDerive->key, sizeof(encodedKeyMaterial_t)); 171 } 172 173 return status; 174} 175 176 177 178TI_STATUS keyDeriveNone_config(struct _keyDerive_t *pKeyDerive) 179{ 180 pKeyDerive->derive = keyDeriveNone_derive; 181 pKeyDerive->remove = keyDeriveNone_remove; 182 183 return OK; 184} 185 186 187TI_STATUS keyDeriveNone_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey) 188{ 189 securityKeys_t key; 190 191 if (pEncodedKey==NULL) 192 { 193 return NOK; 194 } 195 196 if ((pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_40) && 197 (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_104) && 198 (pEncodedKey->keyLen != DERIVE_WEP_KEY_LEN_232)) 199 { 200 return NOK; 201 } 202 203 key.keyType = WEP_KEY; 204 key.keyIndex = (UINT8)pEncodedKey->keyId; 205 key.encLen = (UINT16)pEncodedKey->keyLen; 206 os_memoryCopy(pKeyDerive->hOs, (void *)key.encKey, pEncodedKey->pData, pEncodedKey->keyLen); 207 208 pKeyDerive->pMainKeys->setKey(pKeyDerive->pMainKeys, &key); 209 210 return OK; 211} 212 213 214/** 215* 216* keyDeriveNone_remove 217* 218* \b Description: 219* 220* WEP broadcast key removal function: 221* - Remove the key material from the driver. 222* 223* \b ARGS: 224* 225* None. 226* 227* \b RETURNS: 228* 229* OK on success, NOK otherwise. 230*/ 231 232TI_STATUS keyDeriveNone_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey) 233{ 234 235 return OK; 236} 237 238 239 240 241