Commit 24b835f4 authored by Niuhaiwen's avatar Niuhaiwen

support multiple UEs' authentication

parent a635a7ad
...@@ -59,10 +59,11 @@ typedef struct { ...@@ -59,10 +59,11 @@ typedef struct {
uint8_t autn[16]; uint8_t autn[16];
uint8_t hxresStar[16]; uint8_t hxresStar[16];
uint8_t kseaf[32]; uint8_t kseaf[32];
uint8_t XRES_STAR[16]; //store xres*
} AUSF_AV_s; } AUSF_AV_s;
AUSF_AV_s ausf_av_s; AUSF_AV_s ausf_av_s;
vector<AUSF_AV_s> all_AVs;
DefaultApiImpl::DefaultApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr) DefaultApiImpl::DefaultApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr)
: DefaultApi(rtr) {} : DefaultApi(rtr) {}
...@@ -114,15 +115,29 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -114,15 +115,29 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
uint8_t authCtxId_seaf[16]; uint8_t authCtxId_seaf[16];
conv::hex_str_to_uint8(authCtxId.c_str(), authCtxId_seaf); //authCtxId in seaf conv::hex_str_to_uint8(authCtxId.c_str(), authCtxId_seaf); //authCtxId in seaf
Logger::ausf_server().debug("authCtxId in ausf: %s", (conv::uint8_to_hex_string(ausf_av_s.autn, 16)).c_str()); int ausf_av_index = 0;
for(int i=0;i<all_AVs.size();i++){
bool is_auth_vectors_present = Authentication_5gaka::equal_uint8(ausf_av_s.autn,authCtxId_seaf,16); Logger::ausf_server().debug("authCtxId in ausf: %s", (conv::uint8_to_hex_string(all_AVs[i].autn, 16)).c_str());
if(!is_auth_vectors_present) //AV expired if(Authentication_5gaka::equal_uint8(all_AVs[i].autn,authCtxId_seaf,16)){
{ ausf_av_index = i;
break;
}
}
if(ausf_av_index == all_AVs.size()){
Logger::ausf_server().error("Authentication failure by home network with authCtxId %s: AV expired",authCtxId.c_str()); Logger::ausf_server().error("Authentication failure by home network with authCtxId %s: AV expired",authCtxId.c_str());
confirmResponse.setAuthResult(is_auth_vectors_present); //向SEAF指示,从本地网络角度认证not成功 confirmResponse.setAuthResult(false); //向SEAF指示,从本地网络角度认证not成功
KAUSF_TMP = "invalid"; KAUSF_TMP = "invalid";
} }
//Logger::ausf_server().debug("authCtxId in ausf: %s", (conv::uint8_to_hex_string(ausf_av_s.autn, 16)).c_str());
//bool is_auth_vectors_present = Authentication_5gaka::equal_uint8(ausf_av_s.autn,authCtxId_seaf,16);
//if(!is_auth_vectors_present) //AV expired
//{
// Logger::ausf_server().error("Authentication failure by home network with authCtxId %s: AV expired",authCtxId.c_str());
// confirmResponse.setAuthResult(is_auth_vectors_present); //向SEAF指示,从本地网络角度认证not成功
// KAUSF_TMP = "invalid";
//}
else //AV valid else //AV valid
{ {
Logger::ausf_server().info("AV is up to date, handling received res*..."); Logger::ausf_server().info("AV is up to date, handling received res*...");
...@@ -132,7 +147,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -132,7 +147,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
//2.将接收到的RES*与存储的XRES*进行比较:RES*与XRES*相等,AUSF将从家庭网络角度认为认证成功 //2.将接收到的RES*与存储的XRES*进行比较:RES*与XRES*相等,AUSF将从家庭网络角度认为认证成功
//get stored xres* ----- //get stored xres* -----
uint8_t xresStar[16] = {0}; uint8_t xresStar[16] = {0};
memcpy(xresStar,XRES_STAR,16); //xres* stored for 5g-aka-confirmation memcpy(xresStar,all_AVs[ausf_av_index].XRES_STAR,16); //xres* stored for 5g-aka-confirmation
Logger::ausf_server().debug("xres* in ausf: %s", (conv::uint8_to_hex_string(xresStar, 16)).c_str()); Logger::ausf_server().debug("xres* in ausf: %s", (conv::uint8_to_hex_string(xresStar, 16)).c_str());
Logger::ausf_server().debug("xres in amf: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str()); Logger::ausf_server().debug("xres in amf: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str());
...@@ -149,7 +164,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -149,7 +164,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
//4.send KSEAF to SEAF //4.send KSEAF to SEAF
string kseaf_s; string kseaf_s;
kseaf_s = conv::uint8_to_hex_string(ausf_av_s.kseaf, 32); // convert uint8_t to string kseaf_s = conv::uint8_to_hex_string(all_AVs[ausf_av_index].kseaf, 32); // convert uint8_t to string
confirmResponse.setKseaf(kseaf_s); confirmResponse.setKseaf(kseaf_s);
//5.send supi when supi_ausf exists //5.send supi when supi_ausf exists
...@@ -342,7 +357,8 @@ void DefaultApiImpl::ue_authentications_post( ...@@ -342,7 +357,8 @@ void DefaultApiImpl::ue_authentications_post(
memcpy(ausf_av_s.autn,autn_ausf,16); memcpy(ausf_av_s.autn,autn_ausf,16);
memcpy(ausf_av_s.hxresStar,hxresStar,16); memcpy(ausf_av_s.hxresStar,hxresStar,16);
memcpy(ausf_av_s.kseaf,kseaf,32); memcpy(ausf_av_s.kseaf,kseaf,32);
memcpy(XRES_STAR,xresStar,16); //store xres* in ausf memcpy(ausf_av_s.XRES_STAR,xresStar,16); //store xres* in ausf
all_AVs.push_back(ausf_av_s);
SUPI_AUSF = authenticationInfo.getSupiOrSuci(); //store supi in ausf SUPI_AUSF = authenticationInfo.getSupiOrSuci(); //store supi in ausf
SERVING_NN = snn; //store snn in ausf SERVING_NN = snn; //store snn in ausf
AUTH_TYPE = authType_udm; //store authType in ausf AUTH_TYPE = authType_udm; //store authType in ausf
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment