1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * mainSecSm.h
3981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
4981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * All rights reserved.
6981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
7981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Redistribution and use in source and binary forms, with or without
8981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * modification, are permitted provided that the following conditions
9981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * are met:
10981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
11981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions of source code must retain the above copyright
12981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer.
13981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions in binary form must reproduce the above copyright
14981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer in
15981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    the documentation and/or other materials provided with the
16981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    distribution.
17981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Neither the name Texas Instruments nor the names of its
18981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    contributors may be used to endorse or promote products derived
19981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    from this software without specific prior written permission.
20981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
21981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
33981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
34981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \file MainSecSm.h
35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \brief RSN main security SM
36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \see MainSecSm.c
38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***************************************************************************/
42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*																		   */
43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*		MODULE:	MainSecSm.h												   */
44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*    PURPOSE:	RSN main security SM									   */
45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*																	 	   */
46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/***************************************************************************/
47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifndef _MAIN_SEC_SM_H
49981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define _MAIN_SEC_SM_H
50981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "paramOut.h"
52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "fsm.h"
53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "rsnApi.h"
54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "rsn.h"
55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "keyTypes.h"
56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Constants */
58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
59981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Enumerations */
60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Typedefs */
62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
63981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef struct _mainSec_t    mainSec_t;
64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
65981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Main Sec SM functions */
66981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmStart_t)(struct _mainSec_t *pMainSec);
67981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmStop_t)(struct _mainSec_t *pMainSec);
68981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmReportAuthStatus_t)(struct _mainSec_t *pMainSec, TI_STATUS authStatus);
69981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmReportKeysStatus_t)(struct _mainSec_t *pMainSec, TI_STATUS keyStatus);
70981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmReportReauthentication_t)(struct _mainSec_t *pMainSec);
71981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmSetSessionKey_t)(struct _mainSec_t *pMainSec, TI_UINT8* pKey, TI_UINT8 keyLen);
72981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmGetSessionKey_t)(struct _mainSec_t *pMainSec, TI_UINT8* pKey, TI_UINT32* pKeyLen);
73981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmSetKey_t)(struct _mainSec_t *pMainSec, TSecurityKeys *pKey);
74981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmRemoveKey_t)(struct _mainSec_t *pMainSec, TSecurityKeys *pKey);
75981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmSetDefaultKeyId_t)(struct _mainSec_t *pMainSec, TI_UINT8 keyId);
76981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSmEapolRecv_t)(struct _mainSec_t *pMainSec, TI_UINT8 *pPacket);
77981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSm_getAuthIdentity_t)(struct _mainSec_t *pMainSec, authIdentity_t *authIdentity);
78981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSm_getAuthState_t)(struct _mainSec_t *pMainSec, TIWLN_SECURITY_STATE *secState);
79981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef TI_STATUS (*mainSecSm_reportAuthFailure_t)(struct _mainSec_t *pMainSec, EAuthStatus authStatus);
80981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
81981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Structures */
82981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
83981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef struct
84981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TRsnPaeConfig   		*pPaeConfig;
86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT32				heldPeriod;
87981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT32				startPeriod;
88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT32				authPeriod;
89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT32				maxStart;
90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT8				*pUserId;
91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT8				idLen;
92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT8				*pUserPasswd;
93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_UINT8				pwdLen;
94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} mainSecInitData_t;
95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef struct
97981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_STATUS		status;
99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} mainSecData_t;
100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstruct _mainSec_t
102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
103653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt	TI_UINT8                            currentState;
104653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    TI_UINT32				            startCount;
105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	fsm_stateMachine_t	                *pMainSecSm;
106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_BOOL				                PrivacyOptionImplemented;
107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecData_t						data;
108653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt	TI_UINT8							sessionKey[SESSION_KEY_LEN];
109653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt	TI_UINT8							sessionKeyLen;
110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    struct _rsn_t                      	*pParent;
112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_HANDLE			                hReport;
113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	TI_HANDLE			                hOs;
114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    struct _mainKeys_t                  *pMainKeys;
116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    struct _keyParser_t                 *pKeyParser;
117653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    struct externalSec_t                *pExternalSec;
118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSmStart_t                    start;
119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSmStop_t                     stop;
120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSmReportAuthStatus_t         reportAuthStatus;
121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSmReportKeysStatus_t       	reportKeysStatus;
122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSmReportReauthentication_t   reportReAuthenticate;
123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	mainSecSmSetSessionKey_t			setSessionKey;
124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	mainSecSmGetSessionKey_t			getSessionKey;
125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	mainSecSmSetKey_t					setKey;
126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	mainSecSmRemoveKey_t				removeKey;
127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	mainSecSmSetDefaultKeyId_t			setDefaultKeyId;
128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSm_getAuthIdentity_t  		getAuthIdentity;
129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSm_getAuthIdentity_t  		setAuthIdentity;
130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt	mainSecSm_getAuthState_t 			getAuthState;
131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mainSecSm_reportAuthFailure_t       reportAuthFailure;
132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt};
134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* External data definitions */
136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* External functions definitions */
138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Function prototypes */
140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtmainSec_t* mainSec_create(TI_HANDLE hOs);
142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS mainSec_unload(mainSec_t *pMainSec);
144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS mainSec_config (mainSec_t *pMainSec,
146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          mainSecInitData_t *pInitData,
147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          void *pParent,
148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE hReport,
149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE hOs,
150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE hCtrlData,
151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE hEvHandler,
152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE hConn,
153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE hTimer);
154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
157