Commit fb148318 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup

parent 29424d3f
...@@ -65,12 +65,9 @@ using namespace oai::ausf_server::model; ...@@ -65,12 +65,9 @@ using namespace oai::ausf_server::model;
// stored temporarily // stored temporarily
uint8_t XRES_STAR[16]; // store xres* uint8_t XRES_STAR[16]; // store xres*
// uint8_t KAUSF[32];
std::string SUPI_AUSF; // store supi std::string SUPI_AUSF; // store supi
std::string AUTH_TYPE; // store authType std::string AUTH_TYPE; // store authType
std::string SERVING_NN; // store serving network name std::string SERVING_NN; // store serving network name
std::string KAUSF_TMP; // store Kausf(string) std::string KAUSF_TMP; // store Kausf(string)
typedef struct { typedef struct {
...@@ -126,22 +123,18 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -126,22 +123,18 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
return; return;
} }
/*---------------------getting params---------------------------------*/ // getting params
Logger::ausf_server().info( Logger::ausf_server().info(
"Received authCtxId %s", authCtxId.c_str()); // authCtxId "Received authCtxId %s", authCtxId.c_str()); // authCtxId
Logger::ausf_server().info( Logger::ausf_server().info(
"Received res* %s", "Received res* %s", confirmationData.getResStar().c_str());
confirmationData.getResStar()
.c_str()); // res*(const char*) "0ddc2f64bd8dc35906fad44499e18525"
uint8_t resStar[16] = {0}; uint8_t resStar[16] = {0};
conv::hex_str_to_uint8( conv::hex_str_to_uint8(
confirmationData.getResStar().c_str(), confirmationData.getResStar().c_str(),
resStar); // string->uint8, res*(uint8) resStar); // string->uint8, res*(uint8)
/*---------------------认证确认-amf--------------------------------*/
ConfirmationDataResponse confirmResponse; ConfirmationDataResponse confirmResponse;
// 1.验证AV是否过期: 认证成功后,AUSF将存储 KAUSF ?
uint8_t authCtxId_seaf[16]; uint8_t authCtxId_seaf[16];
conv::hex_str_to_uint8( conv::hex_str_to_uint8(
authCtxId.c_str(), authCtxId_seaf); // authCtxId in seaf authCtxId.c_str(), authCtxId_seaf); // authCtxId in seaf
...@@ -157,16 +150,13 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -157,16 +150,13 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
Logger::ausf_server().error( Logger::ausf_server().error(
"Authentication failure by home network with authCtxId %s: AV expired", "Authentication failure by home network with authCtxId %s: AV expired",
authCtxId.c_str()); authCtxId.c_str());
confirmResponse.setAuthResult( confirmResponse.setAuthResult(is_auth_vectors_present);
is_auth_vectors_present); //向SEAF指示,从本地网络角度认证not成功
KAUSF_TMP = "invalid"; 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*...");
// store Kausf // store Kausf
// 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, XRES_STAR, 16); // xres* stored for 5g-aka-confirmation
...@@ -176,8 +166,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -176,8 +166,7 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
"xres in amf: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str()); "xres in amf: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str());
bool authResult = Authentication_5gaka::equal_uint8(xresStar, resStar, 16); bool authResult = Authentication_5gaka::equal_uint8(xresStar, resStar, 16);
confirmResponse.setAuthResult( confirmResponse.setAuthResult(authResult);
authResult); // 3.向SEAF指示,从本地网络角度认证是否成功
if (!authResult) // fail if (!authResult) // fail
{ {
...@@ -227,8 +216,6 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -227,8 +216,6 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
char buf[32]; char buf[32];
strftime(buf, sizeof(buf), "%FT%TZ", gmtime(&rawtime)); strftime(buf, sizeof(buf), "%FT%TZ", gmtime(&rawtime));
confirmResultInfo["timeStamp"] = buf; // timestamp generated confirmResultInfo["timeStamp"] = buf; // timestamp generated
// confirmResultInfo["timeStamp"] = "2020-08-12T17:02:51.128672225+09:00";
// //PARAM
confirmResultInfo["authType"] = AUTH_TYPE; // authType stored in ausf confirmResultInfo["authType"] = AUTH_TYPE; // authType stored in ausf
confirmResultInfo["servingNetworkName"] = confirmResultInfo["servingNetworkName"] =
...@@ -241,8 +228,8 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -241,8 +228,8 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
} }
} }
/*----------------ausf --> seaf-----------*/ // ausf --> seaf
//---forming response // Forming response
nlohmann::json confirmResponse_json; nlohmann::json confirmResponse_json;
to_json(confirmResponse_json, confirmResponse); to_json(confirmResponse_json, confirmResponse);
Logger::ausf_server().debug( Logger::ausf_server().debug(
...@@ -268,7 +255,7 @@ void DefaultApiImpl::ue_authentications_post( ...@@ -268,7 +255,7 @@ void DefaultApiImpl::ue_authentications_post(
Pistache::Http::ResponseWriter& response) { Pistache::Http::ResponseWriter& response) {
Logger::ausf_server().debug("--ue_authentications_post--"); Logger::ausf_server().debug("--ue_authentications_post--");
/*----------------------getting params-------------*/ // Getting params
Logger::ausf_server().info( Logger::ausf_server().info(
"servingNetworkName %s", "servingNetworkName %s",
authenticationInfo.getServingNetworkName().c_str()); authenticationInfo.getServingNetworkName().c_str());
...@@ -279,7 +266,7 @@ void DefaultApiImpl::ue_authentications_post( ...@@ -279,7 +266,7 @@ void DefaultApiImpl::ue_authentications_post(
authenticationInfo.getServingNetworkName(); // serving network name authenticationInfo.getServingNetworkName(); // serving network name
std::string supi = authenticationInfo.getSupiOrSuci(); // supi std::string supi = authenticationInfo.getSupiOrSuci(); // supi
/* -----------5g he av from udm-----------------*/ // 5g he av from udm
// UDM GET interface ----- get authentication related info-------------------- // UDM GET interface ----- get authentication related info--------------------
std::string udm_ip = std::string(inet_ntoa( std::string udm_ip = std::string(inet_ntoa(
...@@ -378,8 +365,8 @@ void DefaultApiImpl::ue_authentications_post( ...@@ -378,8 +365,8 @@ void DefaultApiImpl::ue_authentications_post(
* AV--------------------------*/ * AV--------------------------*/
/* HXRES* <-- XRES* */ /* HXRES* <-- XRES* */
/* KSEAF <-- KAUSF */ /* KSEAF <-- KAUSF */
/* 在5G HE AV中用HXRES*替代XRES*,用 KSEAF 替代KAUSF */ /* 5G HE AV HXRES* XRES*,KSEAF KAUSF */
/* 删除 KSEAF,并向SEAF返回5G SE AV(RAND, AUTN, HXRES*)*/ /* KSEAF,SEAF 5G SE AV(RAND, AUTN, HXRES*)*/
/* A.5, 3gpp ts33.501 */ /* A.5, 3gpp ts33.501 */
Logger::ausf_server().debug("==generating 5g av"); Logger::ausf_server().debug("==generating 5g av");
......
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