EAP-SIM/AKA peer: Support decorated anonymous identity prefix

Support decorated anonymous identity prefix as per RFC 7542,
for SIM-based EAP networks.

Signed-off-by: Hai Shalom <haishalom@google.com>
This commit is contained in:
Hai Shalom 2021-03-11 18:42:10 -08:00 committed by Jouni Malinen
parent 7831b10a89
commit 73d9891bd7

View file

@ -1213,6 +1213,7 @@ void eap_sim_report_notification(void *msg_ctx, int notification, int aka)
int eap_sim_anonymous_username(const u8 *id, size_t id_len)
{
static const char *anonymous_id_prefix = "anonymous@";
const char *decorated;
size_t anonymous_id_len = os_strlen(anonymous_id_prefix);
if (id_len > anonymous_id_len &&
@ -1226,5 +1227,14 @@ int eap_sim_anonymous_username(const u8 *id, size_t id_len)
if (id_len > 1 && id[0] == '@')
return 1; /* '@realm' */
/* RFC 7542 decorated username, for example:
* homerealm.example.org!anonymous@otherrealm.example.net */
decorated = os_strrchr((const char *) id, '!');
if (decorated) {
decorated++;
return eap_sim_anonymous_username((const u8 *) decorated,
os_strlen(decorated));
}
return 0;
}