1 /** \file unicastKeyNone.c 2 * \brief station unicast key None implementation 3 * 4 * \see unicastKeyNone.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 None * 44 * PURPOSE: station unicast key None implementation * 45 * * 46 ****************************************************************************/ 47 48 #include "osApi.h" 49 #include "utils.h" 50 #include "report.h" 51 #include "rsnApi.h" 52 53 #include "unicastKeyNone.h" 54 #include "mainKeysSm.h" 55 56 57 TI_STATUS unicastKeyNone_start(struct _unicastKey_t *pUnicastKey); 58 TI_STATUS unicastKeyNone_distribute(struct _unicastKey_t *pUnicastKey, encodedKeyMaterial_t *pEncodedKeyMaterial); 59 60 61 62 /** 63 * 64 * Function - Config KEY Parser module. 65 * 66 * \b Description: 67 * 68 * Called by RSN Manager. 69 * Registers the function 'rsn_UnicastKeyRecv()' at the distributor to receive KEY frames upon receiving a KEY_RECV event. 70 * 71 * \b ARGS: 72 * 73 * 74 * \b RETURNS: 75 * 76 * TI_STATUS - 0 on success, any other value on failure. 77 * 78 */ 79 80 TI_STATUS unicastKeyNone_config(struct _unicastKey_t *pUnicastKey) 81 { 82 83 pUnicastKey->start = unicastKeyNone_start; 84 pUnicastKey->stop = unicastKeySmNop; 85 pUnicastKey->recvFailure = unicastKeySmNop; 86 pUnicastKey->recvSuccess = unicastKeyNone_distribute; 87 88 pUnicastKey->currentState = 0; 89 90 91 return OK; 92 } 93 94 /** 95 * 96 * unicastKeyNone_start 97 * 98 * \b Description: 99 * 100 * report the main key SM of unicast complete, whithout wating for keys. 101 * 102 * \b ARGS: 103 * 104 * I - pUnicastKey - context \n 105 * 106 * \b RETURNS: 107 * 108 * OK on success, NOK otherwise. 109 */ 110 TI_STATUS unicastKeyNone_start(struct _unicastKey_t *pUnicastKey) 111 { 112 TI_STATUS status=NOK; 113 114 if (pUnicastKey->pParent->reportUcastStatus!=NULL) 115 { 116 status = pUnicastKey->pParent->reportUcastStatus(pUnicastKey->pParent, OK); 117 } 118 119 return status; 120 } 121 122 /** 123 * 124 * unicastKeyNone_distribute 125 * 126 * \b Description: 127 * 128 * Distribute unicast key material to the driver and report the main key SM on unicast complete. 129 * 130 * \b ARGS: 131 * 132 * I - pData - Encoded key material \n 133 * 134 * \b RETURNS: 135 * 136 * OK on success, NOK otherwise. 137 */ 138 TI_STATUS unicastKeyNone_distribute(struct _unicastKey_t *pUnicastKey, encodedKeyMaterial_t *pEncodedKeyMaterial) 139 { 140 TI_STATUS status=NOK; 141 142 if ((pUnicastKey==NULL) || (pEncodedKeyMaterial==NULL)) 143 { 144 return NOK; 145 } 146 147 if (pUnicastKey->pKeyDerive->derive!=NULL) 148 { 149 status = pUnicastKey->pKeyDerive->derive(pUnicastKey->pKeyDerive, 150 pEncodedKeyMaterial); 151 } 152 if (status != OK) 153 { 154 return NOK; 155 } 156 157 if (pUnicastKey->pParent->setDefaultKeyId!=NULL) 158 { 159 status = pUnicastKey->pParent->setDefaultKeyId(pUnicastKey->pParent, 160 (UINT8)pEncodedKeyMaterial->keyId); 161 } 162 if (status != OK) 163 { 164 return status; 165 } 166 167 if (pUnicastKey->pParent->reportUcastStatus!=NULL) 168 { 169 status = pUnicastKey->pParent->reportUcastStatus(pUnicastKey->pParent, OK); 170 } 171 172 return status; 173 } 174