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