1/** \file keyDeriveSM.c
2 * \brief station unicast key SM implementation
3 *
4 * \see keyDeriveSM.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:	station unicast key SM		                                *
44 *   PURPOSE:   station unicast key SM implementation						*
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#include "keyDeriveTkip.h"
56#include "keyDeriveAes.h"
57#ifdef EXC_MODULE_INCLUDED
58#include "keyDeriveCkip.h"
59#endif
60
61/**
62*
63* Function  - Init KEY Parser module.
64*
65* \b Description:
66*
67* Called by RSN Manager.
68* Registers the function 'rsn_KeyDeriveRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
69*
70* \b ARGS:
71*
72*
73* \b RETURNS:
74*
75*  TI_STATUS - 0 on success, any other value on failure.
76*
77*/
78
79keyDerive_t* keyDerive_create(TI_HANDLE hOs)
80{
81	keyDerive_t 		*pKeyDerive;
82
83	/* allocate key parser context memory */
84	pKeyDerive = (keyDerive_t*)os_memoryAlloc(hOs, sizeof(keyDerive_t));
85	if (pKeyDerive == NULL)
86	{
87		return NULL;
88	}
89
90	os_memoryZero(hOs, pKeyDerive, sizeof(keyDerive_t));
91
92	pKeyDerive->hOs = hOs;
93
94	return pKeyDerive;
95}
96
97/**
98*
99* Function  - Init KEY Parser module.
100*
101* \b Description:
102*
103* Called by RSN Manager.
104* Registers the function 'rsn_KeyDeriveRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
105*
106* \b ARGS:
107*
108*
109* \b RETURNS:
110*
111*  TI_STATUS - 0 on success, any other value on failure.
112*
113*/
114
115TI_STATUS keyDerive_unload(struct _keyDerive_t *pKeyDerive)
116{
117	/* free key parser context memory */
118	os_memoryFree(pKeyDerive->hOs, pKeyDerive, sizeof(keyDerive_t));
119
120	return OK;
121}
122
123/**
124*
125* Function  - Init KEY Parser module.
126*
127* \b Description:
128*
129* Called by RSN Manager.
130* Registers the function 'rsn_KeyDeriveRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
131*
132* \b ARGS:
133*
134*
135* \b RETURNS:
136*
137*  TI_STATUS - 0 on success, any other value on failure.
138*
139*/
140
141TI_STATUS keyDerive_config(struct _keyDerive_t *pKeyDerive,
142						cipherSuite_e cipher,
143						struct _mainKeys_t *pMainKeys,
144						TI_HANDLE hReport,
145						TI_HANDLE hOs)
146{
147
148	TI_STATUS		status = NOK;
149
150	pKeyDerive->hReport = hReport;
151	pKeyDerive->hOs = hOs;
152	pKeyDerive->pMainKeys = pMainKeys;
153
154    switch (cipher)
155	{
156    case RSN_CIPHER_NONE:
157		status = keyDeriveNone_config(pKeyDerive);
158        break;
159	case RSN_CIPHER_WEP:
160    case RSN_CIPHER_WEP104:
161		status = keyDeriveWep_config(pKeyDerive);
162		break;
163	case RSN_CIPHER_TKIP:
164		status = keyDeriveTkip_config(pKeyDerive);
165		break;
166#ifdef EXC_MODULE_INCLUDED
167	case RSN_CIPHER_CKIP:
168  	status = keyDeriveCkip_config(pKeyDerive);
169		break;
170#endif
171
172	case RSN_CIPHER_AES_CCMP:
173		status = keyDeriveAes_config(pKeyDerive);
174		break;
175	default:
176		return NOK;
177	}
178
179	return status;
180}
181
182
183
184