aboutsummaryrefslogtreecommitdiffstats
path: root/src/eap_server/eap_psk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eap_server/eap_psk.c')
-rw-r--r--src/eap_server/eap_psk.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/eap_server/eap_psk.c b/src/eap_server/eap_psk.c
index 4183980..f7b0d48 100644
--- a/src/eap_server/eap_psk.c
+++ b/src/eap_server/eap_psk.c
@@ -53,8 +53,8 @@ static void * eap_psk_init(struct eap_sm *sm)
static void eap_psk_reset(struct eap_sm *sm, void *priv)
{
struct eap_psk_data *data = priv;
- free(data->id_p);
- free(data);
+ os_free(data->id_p);
+ os_free(data);
}
@@ -74,7 +74,7 @@ static u8 * eap_psk_build_1(struct eap_sm *sm, struct eap_psk_data *data,
data->rand_s, EAP_PSK_RAND_LEN);
*reqDataLen = sizeof(*req) + data->id_s_len;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-PSK: Failed to allocate memory "
"request");
@@ -87,8 +87,8 @@ static u8 * eap_psk_build_1(struct eap_sm *sm, struct eap_psk_data *data,
req->length = host_to_be16(*reqDataLen);
req->type = EAP_TYPE_PSK;
req->flags = EAP_PSK_FLAGS_SET_T(0); /* T=0 */
- memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
- memcpy((u8 *) (req + 1), data->id_s, data->id_s_len);
+ os_memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
+ os_memcpy((u8 *) (req + 1), data->id_s, data->id_s_len);
return (u8 *) req;
}
@@ -104,7 +104,7 @@ static u8 * eap_psk_build_3(struct eap_sm *sm, struct eap_psk_data *data,
wpa_printf(MSG_DEBUG, "EAP-PSK: PSK-3 (sending)");
*reqDataLen = sizeof(*req) + 4 + 16 + 1;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-PSK: Failed to allocate memory "
"request");
@@ -117,20 +117,20 @@ static u8 * eap_psk_build_3(struct eap_sm *sm, struct eap_psk_data *data,
req->length = host_to_be16(*reqDataLen);
req->type = EAP_TYPE_PSK;
req->flags = EAP_PSK_FLAGS_SET_T(2); /* T=2 */
- memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
+ os_memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
/* MAC_S = OMAC1-AES-128(AK, ID_S||RAND_P) */
buflen = data->id_s_len + EAP_PSK_RAND_LEN;
- buf = malloc(buflen);
+ buf = os_malloc(buflen);
if (buf == NULL) {
- free(req);
+ os_free(req);
data->state = FAILURE;
return NULL;
}
- memcpy(buf, data->id_s, data->id_s_len);
- memcpy(buf + data->id_s_len, data->rand_p, EAP_PSK_RAND_LEN);
+ os_memcpy(buf, data->id_s, data->id_s_len);
+ os_memcpy(buf + data->id_s_len, data->rand_p, EAP_PSK_RAND_LEN);
omac1_aes_128(data->ak, buf, buflen, req->mac_s);
- free(buf);
+ os_free(buf);
eap_psk_derive_keys(data->kdk, data->rand_p, data->tek, data->msk,
data->emsk);
@@ -138,10 +138,10 @@ static u8 * eap_psk_build_3(struct eap_sm *sm, struct eap_psk_data *data,
wpa_hexdump_key(MSG_DEBUG, "EAP-PSK: MSK", data->msk, EAP_MSK_LEN);
wpa_hexdump_key(MSG_DEBUG, "EAP-PSK: EMSK", data->emsk, EAP_EMSK_LEN);
- memset(nonce, 0, sizeof(nonce));
+ os_memset(nonce, 0, sizeof(nonce));
pchannel = (u8 *) (req + 1);
- memcpy(pchannel, nonce + 12, 4);
- memset(pchannel + 4, 0, 16); /* Tag */
+ os_memcpy(pchannel, nonce + 12, 4);
+ os_memset(pchannel + 4, 0, 16); /* Tag */
pchannel[4 + 16] = EAP_PSK_R_FLAG_DONE_SUCCESS << 6;
wpa_hexdump(MSG_DEBUG, "EAP-PSK: PCHANNEL (plaintext)",
pchannel, 4 + 16 + 1);
@@ -233,14 +233,14 @@ static void eap_psk_process_2(struct eap_sm *sm,
pos = (u8 *) (resp + 1);
left = len - sizeof(*resp);
- free(data->id_p);
- data->id_p = malloc(left);
+ os_free(data->id_p);
+ data->id_p = os_malloc(left);
if (data->id_p == NULL) {
wpa_printf(MSG_INFO, "EAP-PSK: Failed to allocate memory for "
"ID_P");
return;
}
- memcpy(data->id_p, pos, left);
+ os_memcpy(data->id_p, pos, left);
data->id_p_len = left;
wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-PSK: ID_P",
data->id_p, data->id_p_len);
@@ -286,26 +286,26 @@ static void eap_psk_process_2(struct eap_sm *sm,
wpa_hexdump(MSG_MSGDUMP, "EAP-PSK: RAND_P (client rand)",
resp->rand_p, EAP_PSK_RAND_LEN);
- memcpy(data->rand_p, resp->rand_p, EAP_PSK_RAND_LEN);
+ os_memcpy(data->rand_p, resp->rand_p, EAP_PSK_RAND_LEN);
/* MAC_P = OMAC1-AES-128(AK, ID_P||ID_S||RAND_S||RAND_P) */
buflen = data->id_p_len + data->id_s_len + 2 * EAP_PSK_RAND_LEN;
- buf = malloc(buflen);
+ buf = os_malloc(buflen);
if (buf == NULL) {
data->state = FAILURE;
return;
}
- memcpy(buf, data->id_p, data->id_p_len);
+ os_memcpy(buf, data->id_p, data->id_p_len);
pos = buf + data->id_p_len;
- memcpy(pos, data->id_s, data->id_s_len);
+ os_memcpy(pos, data->id_s, data->id_s_len);
pos += data->id_s_len;
- memcpy(pos, data->rand_s, EAP_PSK_RAND_LEN);
+ os_memcpy(pos, data->rand_s, EAP_PSK_RAND_LEN);
pos += EAP_PSK_RAND_LEN;
- memcpy(pos, data->rand_p, EAP_PSK_RAND_LEN);
+ os_memcpy(pos, data->rand_p, EAP_PSK_RAND_LEN);
omac1_aes_128(data->ak, buf, buflen, mac);
- free(buf);
+ os_free(buf);
wpa_hexdump(MSG_DEBUG, "EAP-PSK: MAC_P", resp->mac_p, EAP_PSK_MAC_LEN);
- if (memcmp(mac, resp->mac_p, EAP_PSK_MAC_LEN) != 0) {
+ if (os_memcmp(mac, resp->mac_p, EAP_PSK_MAC_LEN) != 0) {
wpa_printf(MSG_INFO, "EAP-PSK: Invalid MAC_P");
wpa_hexdump(MSG_MSGDUMP, "EAP-PSK: Expected MAC_P",
mac, EAP_PSK_MAC_LEN);
@@ -348,23 +348,23 @@ static void eap_psk_process_4(struct eap_sm *sm,
return;
}
- memset(nonce, 0, 12);
- memcpy(nonce + 12, pos, 4);
+ os_memset(nonce, 0, 12);
+ os_memcpy(nonce + 12, pos, 4);
pos += 4;
left -= 4;
tag = pos;
pos += 16;
left -= 16;
- decrypted = malloc(left);
+ decrypted = os_malloc(left);
if (decrypted == NULL)
return;
- memcpy(decrypted, pos, left);
+ os_memcpy(decrypted, pos, left);
if (aes_128_eax_decrypt(data->tek, nonce, sizeof(nonce),
respData, 22, decrypted, left, tag)) {
wpa_printf(MSG_WARNING, "EAP-PSK: PCHANNEL decryption failed");
- free(decrypted);
+ os_free(decrypted);
data->state = FAILURE;
return;
}
@@ -386,7 +386,7 @@ static void eap_psk_process_4(struct eap_sm *sm,
data->state = FAILURE;
break;
}
- free(decrypted);
+ os_free(decrypted);
}
@@ -431,10 +431,10 @@ static u8 * eap_psk_getKey(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_MSK_LEN);
+ key = os_malloc(EAP_MSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->msk, EAP_MSK_LEN);
+ os_memcpy(key, data->msk, EAP_MSK_LEN);
*len = EAP_MSK_LEN;
return key;
@@ -449,10 +449,10 @@ static u8 * eap_psk_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_EMSK_LEN);
+ key = os_malloc(EAP_EMSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->emsk, EAP_EMSK_LEN);
+ os_memcpy(key, data->emsk, EAP_EMSK_LEN);
*len = EAP_EMSK_LEN;
return key;