4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name Texas Instruments nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 /** \file wepBroadcastKeyDerivation.c
35 * \brief WEP broadcast key derivation implementation.
37 * \see wepBroadcastKeyDerivation.h
40 /****************************************************************************
42 * MODULE: WEP broadcast key derivation *
43 * PURPOSE: WEP broadcast key derivation *
45 ****************************************************************************/
47 #ifdef XCC_MODULE_INCLUDED
48 #define __FILE_ID__ FILE_ID_30
54 #include "keyDerive.h"
55 #include "keyDeriveCkip.h"
57 #include "mainKeysSm.h"
58 #include "mainSecSm.h"
63 * keyDeriveCkip_config
67 * CKIP key derivation init function:
68 * - Initializes the derive & remove callback functions
69 * - Resets the key material in the system control block
77 * TI_OK on success, TI_NOK otherwise.
80 TI_STATUS keyDeriveCkip_config(struct _keyDerive_t *pKeyDerive)
82 pKeyDerive->derive = keyDeriveCkip_derive;
83 pKeyDerive->remove = keyDeriveCkip_remove;
91 * keyDeriveCkip_derive
95 * CKIP key derivation function:
96 * - Decodes the key material.
97 * - Distribute the decoded key material to the driver.
101 * I - p - Pointer to the encoded key material.
105 * TI_OK on success, TI_NOK otherwise.
108 TI_STATUS keyDeriveCkip_derive(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
112 TI_UINT8 ckipIndex, keyIndex;
113 TI_UINT8 ckipKey[KEY_DERIVE_CKIP_ENC_LEN];
115 key.keyType = KEY_XCC;
116 key.keyIndex = (TI_UINT8)pEncodedKey->keyId;
118 if (pEncodedKey->keyLen != KEY_DERIVE_CKIP_ENC_LEN)
120 if ((pEncodedKey->keyLen != KEY_DERIVE_CKIP_5_LEN) && (pEncodedKey->keyLen != KEY_DERIVE_CKIP_13_LEN))
122 TRACE1(pKeyDerive->hReport, REPORT_SEVERITY_ERROR, "KEY_DERIVE_CKIP: ERROR: wrong key length %d !!!\n", pEncodedKey->keyLen);
127 for (ckipIndex=0; ckipIndex<KEY_DERIVE_CKIP_ENC_LEN; ckipIndex++)
129 ckipKey[ckipIndex]= pEncodedKey->pData[keyIndex];
131 if (keyIndex >= pEncodedKey->keyLen)
135 /*keyIndex = ((keyIndex+1) <pEncodedKey->keyLen) ? keyIndex+1 : 0;*/
140 for (ckipIndex=0; ckipIndex<KEY_DERIVE_CKIP_ENC_LEN; ckipIndex++)
142 ckipKey[ckipIndex]= pEncodedKey->pData[ckipIndex];
146 if (pKeyDerive->pMainKeys->pParent->pParent->pAdmCtrl->encrInSw)
148 key.encLen = KEY_DERIVE_CKIP_ENC_LEN;
152 key.encLen = pEncodedKey->keyLen;
155 /* Copy encryption key - not expand */
156 os_memoryCopy(pKeyDerive->hOs, (void*)key.encKey, ckipKey, key.encLen);
157 /* Copy the MIC keys */
158 os_memoryCopy(pKeyDerive->hOs, (void*)key.micRxKey, ckipKey, KEY_DERIVE_CKIP_ENC_LEN);
159 os_memoryCopy(pKeyDerive->hOs, (void*)key.micTxKey, ckipKey, KEY_DERIVE_CKIP_ENC_LEN);
161 status = pKeyDerive->pMainKeys->setKey(pKeyDerive->pMainKeys, &key);
164 os_memoryCopy(pKeyDerive->hOs, &pKeyDerive->key, pEncodedKey, sizeof(encodedKeyMaterial_t));
172 * wepBroadcastKeyDerivationRemove
176 * WEP broadcast key removal function:
177 * - Remove the key material from the driver.
185 * TI_OK on success, TI_NOK otherwise.
188 TI_STATUS keyDeriveCkip_remove(struct _keyDerive_t *pKeyDerive, encodedKeyMaterial_t *pEncodedKey)
193 os_memoryZero(pKeyDerive->hOs, &key, sizeof(TSecurityKeys));
194 key.keyType = KEY_XCC;
195 key.keyIndex = (TI_UINT8)pEncodedKey->keyId;
196 key.encLen = KEY_DERIVE_CKIP_ENC_LEN;
197 MAC_COPY (key.macAddress, pEncodedKey->pData);
199 status = pKeyDerive->pMainKeys->removeKey(pKeyDerive->pMainKeys, &key);
202 os_memoryZero(pKeyDerive->hOs, &pKeyDerive->key, sizeof(encodedKeyMaterial_t));
208 #endif /* XCC_MODULE_INCLUDED */