1 /*
2 * broadcastKeyNone.c
3 *
4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
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
16 * distribution.
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.
20 *
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.
32 */
33
34 /** \file broadcastKeyNone.c
35 * \brief broadcast key None implementation
36 *
37 * \see broadcastKeyNone.h
38 */
39
40 /****************************************************************************
41 * *
42 * MODULE: None station broadcast key SM *
43 * PURPOSE: None station broadcast key SM implementation *
44 * *
45 ****************************************************************************/
46
47 #define __FILE_ID__ FILE_ID_23
48 #include "osApi.h"
49 #include "report.h"
50 #include "rsnApi.h"
51
52 #include "keyDerive.h"
53
54 #include "broadcastKeyNone.h"
55 #include "mainKeysSm.h"
56
57
58
59 TI_STATUS broadcastKeyNone_distribute(struct _broadcastKey_t *pBroadcastKey, encodedKeyMaterial_t *pEncodedKeyMaterial);
60 TI_STATUS broadcastKeyNone_start(struct _broadcastKey_t *pBroadcastKey);
61
62
63
64 /**
65 *
66 * Function - Init KEY Parser module.
67 *
68 * \b Description:
69 *
70 * Called by RSN Manager.
71 * Registers the function 'rsn_BroadcastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event.
72 *
73 * \b ARGS:
74 *
75 *
76 * \b RETURNS:
77 *
78 * TI_STATUS - 0 on success, any other value on failure.
79 *
80 */
81
broadcastKeyNone_config(struct _broadcastKey_t * pBroadcastKey)82 TI_STATUS broadcastKeyNone_config(struct _broadcastKey_t *pBroadcastKey)
83 {
84
85 pBroadcastKey->start = broadcastKeyNone_start;
86 pBroadcastKey->stop = broadcastKeySmNop;
87 pBroadcastKey->recvFailure = broadcastKeySmNop;
88 pBroadcastKey->recvSuccess = broadcastKeyNone_distribute;
89
90 pBroadcastKey->currentState = 0;
91
92 return TI_OK;
93 }
94
95
96 /**
97 *
98 * broadcastKeyNone_start
99 *
100 * \b Description:
101 *
102 * report the main key SM of broadcast complete, whithout wating for keys.
103 *
104 * \b ARGS:
105 *
106 * I - pBroadcastKey - context \n
107 *
108 * \b RETURNS:
109 *
110 * TI_OK on success, TI_NOK otherwise.
111 */
broadcastKeyNone_start(struct _broadcastKey_t * pBroadcastKey)112 TI_STATUS broadcastKeyNone_start(struct _broadcastKey_t *pBroadcastKey)
113 {
114 TI_STATUS status=TI_NOK;
115
116 if (pBroadcastKey->pParent->reportBcastStatus!=NULL)
117 {
118 status = pBroadcastKey->pParent->reportBcastStatus(pBroadcastKey->pParent, TI_OK);
119 }
120
121 return status;
122 }
123
124 /**
125 *
126 * broadcastKeyNone_distribute
127 *
128 * \b Description:
129 *
130 * Distribute broadcast key material to the driver and report the main key SM on broadcast complete.
131 *
132 * \b ARGS:
133 *
134 * I - pData - Encoded key material \n
135 *
136 * \b RETURNS:
137 *
138 * TI_OK on success, TI_NOK otherwise.
139 */
broadcastKeyNone_distribute(struct _broadcastKey_t * pBroadcastKey,encodedKeyMaterial_t * pEncodedKeyMaterial)140 TI_STATUS broadcastKeyNone_distribute(struct _broadcastKey_t *pBroadcastKey, encodedKeyMaterial_t *pEncodedKeyMaterial)
141 {
142 TI_STATUS status=TI_NOK;
143
144 if (pBroadcastKey->pKeyDerive->derive!=NULL)
145 {
146 status = pBroadcastKey->pKeyDerive->derive(pBroadcastKey->pKeyDerive,
147 pEncodedKeyMaterial);
148 }
149 if (status != TI_OK)
150 {
151 return TI_NOK;
152 }
153
154 if (pBroadcastKey->pParent->reportBcastStatus!=NULL)
155 {
156 status = pBroadcastKey->pParent->reportBcastStatus(pBroadcastKey->pParent, TI_OK);
157 }
158
159 return status;
160 }
161
162