3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 12:52:49 +01:00

sae: fix endianness issues

Replaced all calls of l_get_u16 with l_get_le16. This fixes
failures on big-endian hardware.
This commit is contained in:
James Prestwood 2018-08-23 09:25:10 -07:00 committed by Denis Kenzior
parent 99253a8689
commit 9c71d56444

View File

@ -404,13 +404,13 @@ old_commit:
ecc_native2be(element.y); ecc_native2be(element.y);
/* transaction */ /* transaction */
l_put_u16(1, ptr); l_put_le16(1, ptr);
ptr += 2; ptr += 2;
/* status success */ /* status success */
l_put_u16(0, ptr); l_put_le16(0, ptr);
ptr += 2; ptr += 2;
/* group */ /* group */
l_put_u16(19, ptr); l_put_le16(19, ptr);
ptr += 2; ptr += 2;
if (sm->token) { if (sm->token) {
@ -461,11 +461,11 @@ static void sae_send_confirm(struct sae_sm *sm)
ecc_be2native(sm->p_element.x); ecc_be2native(sm->p_element.x);
ecc_be2native(sm->p_element.y); ecc_be2native(sm->p_element.y);
l_put_u16(2, ptr); l_put_le16(2, ptr);
ptr += 2; ptr += 2;
l_put_u16(0, ptr); l_put_le16(0, ptr);
ptr += 2; ptr += 2;
l_put_u16(sm->sc, ptr); l_put_le16(sm->sc, ptr);
ptr += 2; ptr += 2;
memcpy(ptr, confirm, 32); memcpy(ptr, confirm, 32);
ptr += 32; ptr += 32;
@ -498,7 +498,7 @@ static void sae_process_commit(struct sae_sm *sm, const uint8_t *from,
goto reject; goto reject;
} }
group = l_get_u16(ptr); group = l_get_le16(ptr);
ptr += 2; ptr += 2;
if (group != 19) { if (group != 19) {
@ -590,7 +590,7 @@ reject:
static bool sae_verify_confirm(struct sae_sm *sm, const uint8_t *frame) static bool sae_verify_confirm(struct sae_sm *sm, const uint8_t *frame)
{ {
uint8_t check[32]; uint8_t check[32];
uint16_t rc = l_get_u16(frame); uint16_t rc = l_get_le16(frame);
ecc_native2be(sm->scalar); ecc_native2be(sm->scalar);
ecc_native2be(sm->element.x); ecc_native2be(sm->element.x);
@ -744,7 +744,7 @@ static bool sae_verify_nothing(struct sae_sm *sm, uint16_t transaction,
} }
/* reject with unsupported group */ /* reject with unsupported group */
if (l_get_u16(frame) != 19) { if (l_get_le16(frame) != 19) {
sae_reject_authentication(sm, sae_reject_authentication(sm,
MMPDU_REASON_CODE_UNSUPP_FINITE_CYCLIC_GROUP); MMPDU_REASON_CODE_UNSUPP_FINITE_CYCLIC_GROUP);
return false; return false;
@ -789,11 +789,11 @@ static bool sae_verify_committed(struct sae_sm *sm, uint16_t transaction,
return false; return false;
case MMPDU_REASON_CODE_UNSUPP_FINITE_CYCLIC_GROUP: case MMPDU_REASON_CODE_UNSUPP_FINITE_CYCLIC_GROUP:
l_error("AP requested unsupported FCC group %d", l_error("AP requested unsupported FCC group %d",
l_get_u16(frame)); l_get_le16(frame));
goto reject_unsupp_group; goto reject_unsupp_group;
case 0: case 0:
if (l_get_u16(frame) != 19) { if (l_get_le16(frame) != 19) {
if (sm->sync > SAE_SYNC_MAX) { if (sm->sync > SAE_SYNC_MAX) {
sae_authentication_failed(sm, sae_authentication_failed(sm,
MMPDU_REASON_CODE_UNSPECIFIED); MMPDU_REASON_CODE_UNSPECIFIED);
@ -847,7 +847,7 @@ static bool sae_verify_confirmed(struct sae_sm *sm, uint16_t trans,
} }
/* frame shall be silently discarded */ /* frame shall be silently discarded */
if (l_get_u16(frame) != 19) if (l_get_le16(frame) != 19)
return false; return false;
/* /*
@ -883,7 +883,7 @@ static bool sae_verify_accepted(struct sae_sm *sm, uint16_t trans,
return false; return false;
} }
sc = l_get_u16(frame); sc = l_get_le16(frame);
/* /*
* ... the value of send-confirm shall be checked. If the value is not * ... the value of send-confirm shall be checked. If the value is not
@ -952,9 +952,9 @@ void sae_rx_packet(struct sae_sm *sm, const uint8_t *from, const uint8_t *frame,
goto reject; goto reject;
} }
transaction = l_get_u16(ptr); transaction = l_get_le16(ptr);
ptr += 2; ptr += 2;
status = l_get_u16(ptr); status = l_get_le16(ptr);
ptr += 2; ptr += 2;
/* AP rejected authentication */ /* AP rejected authentication */