/* Guess the values for sigma_i ivlen - how long was the iv (is used differently in original klein attack) iv - IV which was used for this packet keystream - keystream recovered result - buffer for the values of sigma_i kb - how many keybytes should be guessed  */
static void guesskeybytes(int ivlen, uint8_t *iv, uint8_t *keystream, uint8_t *result, int kb)
/* Guess the values for sigma_i ivlen - how long was the iv (is used differently in original klein attack) iv - IV which was used for this packet keystream - keystream recovered result - buffer for the values of sigma_i kb - how many keybytes should be guessed  */
static void guesskeybytes(int ivlen, uint8_t *iv, uint8_t *keystream, uint8_t *result, int kb)
{
		j += state[i] + iv[i];
		tmp = state[i];
		state[i] = state[j];
		state[j] = tmp;
	}
	for (i = 0; i < kb; i++) {
		tmp = jj - keystream[jj-1];
		ii = 0;
		while(tmp != state[ii]) {
			ii++;
		}
		s += state[jj];
		ii -= (j+s);
		result[i] = ii;
		jj++;
	}
	return;
}