diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-14 19:34:22 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-14 19:34:22 +0000 |
commit | f0cf5f379a66ff7531d717805e07b593d8addf57 (patch) | |
tree | 0e80812da590dc9d901c4cba6a8ad7db672b4cec | |
parent | 77321bd22e728692518a0bf6b56db854ac8fc9e6 (diff) | |
parent | a7fe56ca95bb38d8a27a9077c5164d4c2da278ad (diff) | |
download | wpa_supplicant_8-f0cf5f379a66ff7531d717805e07b593d8addf57.tar.gz |
Snap for 8721632 from a7fe56ca95bb38d8a27a9077c5164d4c2da278ad to mainline-adservices-release
Change-Id: Id803ffc5b023be52776c594d980b5635d7854dd2
-rw-r--r-- | src/eap_peer/eap_aka.c | 12 | ||||
-rw-r--r-- | src/eap_peer/eap_sim.c | 12 | ||||
-rw-r--r-- | wpa_supplicant/aidl/sta_network.cpp | 39 | ||||
-rw-r--r-- | wpa_supplicant/aidl/sta_network.h | 4 |
4 files changed, 62 insertions, 5 deletions
diff --git a/src/eap_peer/eap_aka.c b/src/eap_peer/eap_aka.c index 8c475f13..ee7010d4 100644 --- a/src/eap_peer/eap_aka.c +++ b/src/eap_peer/eap_aka.c @@ -385,6 +385,7 @@ static int eap_aka_learn_ids(struct eap_sm *sm, struct eap_aka_data *data, size_t identity_len = 0; const u8 *realm = NULL; size_t realm_len = 0; + struct eap_peer_config *config = eap_get_config(sm); wpa_hexdump_ascii(MSG_DEBUG, "EAP-AKA: (encr) AT_NEXT_PSEUDONYM", @@ -400,6 +401,17 @@ static int eap_aka_learn_ids(struct eap_sm *sm, struct eap_aka_data *data, break; } } + // If no realm from the permanent identity, look for the + // realm of the anonymous identity. + if (realm_len == 0 && config && config->anonymous_identity + && config->anonymous_identity_len > 0) { + for (realm = config->anonymous_identity, + realm_len = config->anonymous_identity_len; + realm_len > 0; realm_len--, realm++) { + if (*realm == '@') + break; + } + } data->pseudonym = os_malloc(attr->next_pseudonym_len + realm_len); if (data->pseudonym == NULL) { diff --git a/src/eap_peer/eap_sim.c b/src/eap_peer/eap_sim.c index 09866277..de423e8b 100644 --- a/src/eap_peer/eap_sim.c +++ b/src/eap_peer/eap_sim.c @@ -407,6 +407,7 @@ static int eap_sim_learn_ids(struct eap_sm *sm, struct eap_sim_data *data, size_t identity_len = 0; const u8 *realm = NULL; size_t realm_len = 0; + struct eap_peer_config *config = eap_get_config(sm); wpa_hexdump_ascii(MSG_DEBUG, "EAP-SIM: (encr) AT_NEXT_PSEUDONYM", @@ -422,6 +423,17 @@ static int eap_sim_learn_ids(struct eap_sm *sm, struct eap_sim_data *data, break; } } + // If no realm from the permanent identity, look for the + // realm of the anonymous identity. + if (realm_len == 0 && config && config->anonymous_identity + && config->anonymous_identity_len > 0) { + for (realm = config->anonymous_identity, + realm_len = config->anonymous_identity_len; + realm_len > 0; realm_len--, realm++) { + if (*realm == '@') + break; + } + } data->pseudonym = os_malloc(attr->next_pseudonym_len + realm_len); if (data->pseudonym == NULL) { diff --git a/wpa_supplicant/aidl/sta_network.cpp b/wpa_supplicant/aidl/sta_network.cpp index 88e7b74c..fe4a7604 100644 --- a/wpa_supplicant/aidl/sta_network.cpp +++ b/wpa_supplicant/aidl/sta_network.cpp @@ -1242,11 +1242,24 @@ ndk::ScopedAStatus StaNetwork::setEapAnonymousIdentityInternal( const std::vector<uint8_t> &identity) { struct wpa_ssid *wpa_ssid = retrieveNetworkPtr(); - if (setByteArrayFieldAndResetState( + // If current supplicant pseudonym is the prefix of new pseudonym, + // the credential is not changed, just update the decoration. + // As a result, no need to reset the state. + // The decorated identity will have a postfix like + // @mncXXX.mccYYY.3gppnetwork.org, so the length will be always + // greater than the current one. + bool resetState = wpa_ssid->eap.anonymous_identity == NULL + || wpa_ssid->eap.anonymous_identity_len == 0 + || identity.size() == 0 + || wpa_ssid->eap.anonymous_identity_len >= identity.size() + || os_strncmp((char *) identity.data(), + (char *) wpa_ssid->eap.anonymous_identity, + wpa_ssid->eap.anonymous_identity_len) != 0; + if (setByteArrayField( identity.data(), identity.size(), &(wpa_ssid->eap.anonymous_identity), &(wpa_ssid->eap.anonymous_identity_len), - "eap anonymous_identity")) { + "eap anonymous_identity", resetState)) { return createStatus(SupplicantStatusCode::FAILURE_UNKNOWN); } return ndk::ScopedAStatus::ok(); @@ -2385,9 +2398,9 @@ int StaNetwork::setStringKeyFieldAndResetState( * field in |wpa_ssid| structure instance for this network. * This function frees any existing data in these fields. */ -int StaNetwork::setByteArrayFieldAndResetState( +int StaNetwork::setByteArrayField( const uint8_t *value, const size_t value_len, uint8_t **to_update_field, - size_t *to_update_field_len, const char *hexdump_prefix) + size_t *to_update_field_len, const char *hexdump_prefix, bool resetState) { if (*to_update_field) { os_free(*to_update_field); @@ -2402,11 +2415,27 @@ int StaNetwork::setByteArrayFieldAndResetState( wpa_hexdump_ascii( MSG_MSGDUMP, hexdump_prefix, *to_update_field, *to_update_field_len); - resetInternalStateAfterParamsUpdate(); + + if (resetState) { + resetInternalStateAfterParamsUpdate(); + } return 0; } /** + * Helper function to set value in a string field with a corresponding length + * field in |wpa_ssid| structure instance for this network. + * This function frees any existing data in these fields. + */ +int StaNetwork::setByteArrayFieldAndResetState( + const uint8_t *value, const size_t value_len, uint8_t **to_update_field, + size_t *to_update_field_len, const char *hexdump_prefix) +{ + return setByteArrayField(value, value_len, to_update_field, + to_update_field_len, hexdump_prefix, true); +} + +/** * Helper function to set value in a string key field with a corresponding * length field in |wpa_ssid| structue instance for this network. * This function frees any existing data in these fields. diff --git a/wpa_supplicant/aidl/sta_network.h b/wpa_supplicant/aidl/sta_network.h index 51056690..524f44a4 100644 --- a/wpa_supplicant/aidl/sta_network.h +++ b/wpa_supplicant/aidl/sta_network.h @@ -327,6 +327,10 @@ private: void setFastTransitionKeyMgmt(uint32_t &key_mgmt_mask); void resetFastTransitionKeyMgmt(uint32_t &key_mgmt_mask); ndk::ScopedAStatus setEapErpInternal(bool enable); + int setByteArrayField( + const uint8_t* value, const size_t value_len, + uint8_t** to_update_field, size_t* to_update_field_len, + const char* hexdump_prefix, bool resetState); // Reference to the global wpa_struct. This is assumed to be valid // for the lifetime of the process. |