From 73d9891bd7222de9a0841d8c1a5d58c54a4327c1 Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Thu, 11 Mar 2021 18:42:10 -0800 Subject: [PATCH] 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 --- src/eap_common/eap_sim_common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/eap_common/eap_sim_common.c b/src/eap_common/eap_sim_common.c index 4a9324406..7f82fdd2e 100644 --- a/src/eap_common/eap_sim_common.c +++ b/src/eap_common/eap_sim_common.c @@ -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; } -- 2.47.2