Beispiel #1
0
static void key_derivation(u8 *inkey, int inkey_len, u8 *text, int text_len, u8 *outkey, int outkey_len, u8 isusk)
{

	KD_hmac_sha256(text, text_len, inkey, inkey_len, outkey, outkey_len);
	/* wpa_hexdump(MSG_DEBUG, "after text", text, text_len); */
	/* iwn_wpa_hexdump(MSG_DEBUG, "inkey", inkey, inkey_len)*/;

	if(isusk)
		mhash_sha256(outkey+outkey_len - CHALLENGE_LEN, CHALLENGE_LEN, outkey+outkey_len - CHALLENGE_LEN);
}
Beispiel #2
0
 int ecc192_verify(const uchar_t *publickey, uint_t publickey_len,
	const uchar_t *data, uint_t data_len, const uchar_t *sign_value, uint_t sign_value_len)
{

	uchar_t digest_data[64]= {0,};
	int digest_len = 0;
	
	digest_len = mhash_sha256(data, data_len, digest_data);

	return ecc192_verify_nss(publickey, publickey_len, digest_data, digest_len, sign_value,sign_value_len);
}
Beispiel #3
0
int ecc192_sign(const uchar_t *privatekey, uint_t privatekey_len,
	const uchar_t *data, uint_t data_len, uchar_t *sign_buffer, uint_t *signature_len)
{

	uchar_t digest_data[64]= {0,};
	int digest_len = 0;
	
	digest_len = mhash_sha256(data, data_len, digest_data);

	return ecc192_sign_nss(privatekey, privatekey_len, digest_data, digest_len, sign_buffer, signature_len);
}
Beispiel #4
0
static int asue_certauthbk_derivation(struct wapi_asue_st *wpa_s)
{
	char input_text[] = "base key expansion for key and additional nonce";
	u8 text[256] = {0,};
	u8 temp_out[48] = {0,};
	u8  ecdhkey[24] = {0,};
	int  ecdhkeyl = sizeof(ecdhkey);
	int ret = -1;

	iwn_wpa_hexdump(MSG_DEBUG, "asue_eck", wpa_s->asue_eck.data,wpa_s->asue_eck.length);
	iwn_wpa_hexdump(MSG_DEBUG, "ae_key_data", wpa_s->ae_key_data.data,wpa_s->ae_key_data.length);

	ret = ecc192_ecdh(wpa_s->asue_eck.data, wpa_s->ae_key_data.data, ecdhkey);

	if (!ret)
	{
		iwn_wpa_printf(MSG_DEBUG, "asue_certauthbk_derivation ECHD fail : in %s:%d", __func__, __LINE__);
		ret = -1;
		return ret;
	}

	iwn_wpa_hexdump(MSG_DEBUG, "ecdhkey", ecdhkey,ecdhkeyl);
		

	memset(text, 0, sizeof(text));
	memcpy(text, wpa_s->Nae, 32);
	memcpy(text + 32, wpa_s->Nasue, 32);
	memcpy(text + 32 + 32, input_text, strlen(input_text));
	KD_hmac_sha256(text, 32+32+strlen(input_text), 
						ecdhkey, 24,
						temp_out, 16 + 32);
	iwn_wpa_hexdump(MSG_DEBUG, "text", text,32+32+strlen(input_text));
	iwn_wpa_hexdump(MSG_DEBUG, "temp_out",temp_out,48);
	
	memcpy(wpa_s->wapi_sm->bksa.bk, temp_out, 16);
	
	memset(text, 0, sizeof(text));
	memcpy(text, wpa_s->bssid, ETH_ALEN);
	memcpy(text + ETH_ALEN, wpa_s->own_addr, ETH_ALEN);
	iwn_wpa_hexdump(MSG_DEBUG, "text1", text,32+32+strlen(input_text));
	
	KD_hmac_sha256(text, 12,
						wpa_s->wapi_sm->bksa.bk, 16, 
						wpa_s->wapi_sm->bksa.bkid, 16);
	
	mhash_sha256(temp_out + 16, 32, wpa_s->ae_auth_flag);
	iwn_wpa_hexdump(MSG_ERROR, "bk", wpa_s->wapi_sm->bksa.bk, 16);
	iwn_wpa_hexdump(MSG_ERROR, "bkid", wpa_s->wapi_sm->bksa.bkid, 16);
	ret = 0;

	return ret;
}