static int gotoStateKeyUpdate(tAuthRsnFsm *fsm) { fsm->currentState = KEY_UPDATE; if( VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes(fsm->cryptHandle, fsm->aNonce, ANI_EAPOL_KEY_RSN_NONCE_SIZE) ) ) { // Replay counter will be automatically updated when we create a // new packet checkTransition(fsm, NULL); // UCT return ANI_OK; } return ANI_ERROR; }
/** * aniSsmReplayCtrCreate * * Creates a replay counter and initializes it for first time * use. The initialization can be done randomly or with a passed in * value like 0. In case this is going to be used on the RX side, it * doesn't matter what the initialization is and can be optimized to * a fixed value so as to avoid the overhead of obtaining a random * value. * * @param ctrPtr a pointer that will be set to the newly allocated * counter if the operation succeeds * @param size the number of bytes that are desired in the counter * @param initValue if this is negative and size is greater than 4, * the initialization is done randomly. Otherwise, these bytes are * copied into the least significant four or less octets of the * counter, depending on the size of the counter. i.e., if the counter * is only 2B, then the least significant 2B of initValue will be * copied over. * * @return ANI_OK if the operation succeeds */ int aniSsmReplayCtrCreate(v_U32_t cryptHandle, tAniSsmReplayCtr **ctrPtr, v_U8_t size, int initValue) { tAniSsmReplayCtr *ctr; ctr = vos_mem_malloc( sizeof(tAniSsmReplayCtr) ); if( NULL == ctr ) { return ANI_E_MALLOC_FAILED; } ctr->buf = vos_mem_malloc( size ); if (ctr->buf == NULL) { VOS_ASSERT( 0 ); vos_mem_free(ctr); return ANI_E_MALLOC_FAILED; } ctr->size = size; // We cannot randomly generate the most significant bytes if the // total number of bytes is not greater than 4 (sizeof ANI_U32). if (initValue < 0 && ctr->size <= 4) initValue = 0; // If initValue is negative, initialize the ctr randomly, else // initialize it to what the user specified. if (initValue < 0) { if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes(cryptHandle, ctr->buf, ctr->size) ) ) { return ANI_ERROR; } } else { ctr->currentValue = initValue - 1; } *ctrPtr = ctr; return ANI_OK; }
static int gotoStateAuthentication2(tAuthRsnFsm *fsm) { fsm->currentState = AUTHENTICATION_2; if( !VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( fsm->cryptHandle, fsm->aNonce, ANI_EAPOL_KEY_RSN_NONCE_SIZE ) ) ) { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "gotoStateAuthentication2 fail to get random number. Disconnect\n" ); bapAuthDisconnect( fsm->ctx ); return ANI_ERROR; } fsm->numTries = 0; checkTransition(fsm, NULL); // UCT rule return ANI_OK; }
static int gotoStateAuthentication(tSuppRsnFsm *fsm) { fsm->currentState = AUTHENTICATION; if( VOS_IS_STATUS_SUCCESS( vos_rand_get_bytes( fsm->cryptHandle, fsm->sNonce, ANI_EAPOL_KEY_RSN_NONCE_SIZE ) ) ) { zeroOutPtk(fsm); // TODO: Zero out all GTK's fsm->authReq = eANI_BOOLEAN_FALSE; /////getPmk(fsm->suppCtx); } else { VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR, "Supp fail to random number\n" ); return ANI_ERROR; } return ANI_OK; }