Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AUSF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-AUSF
Commits
b608bda7
Commit
b608bda7
authored
Jan 26, 2021
by
HFJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy before error 0127
parent
fd53d21d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
105 deletions
+52
-105
api/DefaultApi.cpp
api/DefaultApi.cpp
+3
-83
impl/DefaultApiImpl.cpp
impl/DefaultApiImpl.cpp
+49
-22
No files found.
api/DefaultApi.cpp
View file @
b608bda7
...
...
@@ -86,39 +86,6 @@ void DefaultApi::eap_auth_method_handler(
}
}
// void DefaultApi::ue_authentications_auth_ctx_id5g_aka_confirmation_put_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// // Getting the path params
// auto authCtxId = request.param(":authCtxId").as<std::string>();
// Logger::ausf_server().info("5gaka confirmation received with authctxID %s",authCtxId.c_str());
// //cout << "5gaka confirmation received with authctxID" << authCtxId.c_str() << endl;
// //cout << request.body().c_str() << endl;
// // Getting the body param
// ConfirmationData confirmationData;
// try {
// nlohmann::json::parse(request.body()).get_to(confirmationData);
// // cout << "json parsed" << endl;
// Logger::ausf_server().debug("json parsed");
// this->ue_authentications_auth_ctx_id5g_aka_confirmation_put(authCtxId, confirmationData, response);
// } catch (nlohmann::detail::exception &e) {
// //send a 400 error
// // cout << "**400 error"<< endl;
// Logger::ausf_server().error("**400 error");
// response.send(Pistache::Http::Code::Bad_Request, e.what());
// return;
// } catch (Pistache::Http::HttpError &e) {
// response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
// return;
// } catch (std::exception &e) {
// //send a 500 error
// // cout << "**500 error"<< endl;
// Logger::ausf_server().error("**500 error");
// response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
// return;
// }
// }
void
DefaultApi
::
rg_authentications_post_handler
(
...
...
@@ -151,9 +118,6 @@ void DefaultApi::ue_authentications_auth_ctx_id5g_aka_confirmation_put_handler(
Pistache
::
Http
::
ResponseWriter
response
)
{
// Getting the path params
auto
authCtxId
=
request
.
param
(
":authCtxId"
).
as
<
std
::
string
>
();
cout
<<
"5gaka confirmation received with authctxID"
<<
authCtxId
.
c_str
()
<<
endl
;
cout
<<
request
.
body
().
c_str
()
<<
endl
;
Logger
::
ausf_server
().
info
(
"5gaka confirmation received with authctxID %s"
,
authCtxId
.
c_str
());
// Getting the body param
...
...
@@ -161,15 +125,12 @@ void DefaultApi::ue_authentications_auth_ctx_id5g_aka_confirmation_put_handler(
ConfirmationData
confirmationData
;
try
{
cout
<<
"--try module"
<<
endl
;
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
confirmationData
);
cout
<<
"json parsed"
<<
endl
;
Logger
::
ausf_server
().
debug
(
"json parsed"
);
this
->
ue_authentications_auth_ctx_id5g_aka_confirmation_put
(
authCtxId
,
confirmationData
,
response
);
}
catch
(
nlohmann
::
detail
::
exception
&
e
)
{
// send a 400 error
cout
<<
"**400 error"
<<
endl
;
Logger
::
ausf_server
().
error
(
"**400 error"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Bad_Request
,
e
.
what
());
return
;
...
...
@@ -178,50 +139,12 @@ void DefaultApi::ue_authentications_auth_ctx_id5g_aka_confirmation_put_handler(
return
;
}
catch
(
std
::
exception
&
e
)
{
// send a 500 error
cout
<<
"**500 error"
<<
endl
;
Logger
::
ausf_server
().
error
(
"**500 error"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Internal_Server_Error
,
e
.
what
());
return
;
}
}
// void DefaultApi::ue_authentications_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// //cout << "------------ue authentications post handler---------"<< endl;
// Logger::ausf_server().info("--ue authentications post handler--");
// // Getting the body param
// AuthenticationInfo authenticationInfo;
// try {
// nlohmann::json::parse(request.body()).get_to(authenticationInfo);
// // cout << "parsed successfully"<< endl;
// Logger::ausf_server().debug("json parsed");
// this->ue_authentications_post(authenticationInfo, response);
// } catch (nlohmann::detail::exception &e) {
// //send a 400 error
// // cout << "**400 error"<< endl;
// Logger::ausf_server().error("**400 error");
// response.send(Pistache::Http::Code::Bad_Request, e.what());
// return;
// } catch (Pistache::Http::HttpError &e) {
// response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
// return;
// } catch (std::exception &e) {
// //send a 500 error
// // cout << "**500 error"<< endl;
// Logger::ausf_server().error("**500 error");
// response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
// return;
// }
// }
// void DefaultApi::default_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
// // cout << "--in default api handler" << endl;
// Logger::ausf_server().info("--in default api handler--");
// response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist-default");
void
DefaultApi
::
ue_authentications_deregister_post_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
)
{
...
...
@@ -250,7 +173,7 @@ void DefaultApi::ue_authentications_deregister_post_handler(
void
DefaultApi
::
ue_authentications_post_handler
(
const
Pistache
::
Rest
::
Request
&
request
,
Pistache
::
Http
::
ResponseWriter
response
)
{
cout
<<
"------------ue authentications post handler---------"
<<
endl
;
//
cout << "------------ue authentications post handler---------" << endl;
Logger
::
ausf_server
().
info
(
"--ue authentications post handler--"
);
// Getting the body param
...
...
@@ -258,14 +181,11 @@ void DefaultApi::ue_authentications_post_handler(
AuthenticationInfo
authenticationInfo
;
try
{
cout
<<
"--try module"
<<
endl
;
nlohmann
::
json
::
parse
(
request
.
body
()).
get_to
(
authenticationInfo
);
cout
<<
"parsed successfully"
<<
endl
;
Logger
::
ausf_server
().
debug
(
"json parsed"
);
this
->
ue_authentications_post
(
authenticationInfo
,
response
);
}
catch
(
nlohmann
::
detail
::
exception
&
e
)
{
// send a 400 error
cout
<<
"**400 error"
<<
endl
;
Logger
::
ausf_server
().
error
(
"**400 error"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Bad_Request
,
e
.
what
());
return
;
...
...
@@ -274,7 +194,6 @@ void DefaultApi::ue_authentications_post_handler(
return
;
}
catch
(
std
::
exception
&
e
)
{
// send a 500 error
cout
<<
"**500 error"
<<
endl
;
Logger
::
ausf_server
().
error
(
"**500 error"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Internal_Server_Error
,
e
.
what
());
return
;
...
...
@@ -283,7 +202,8 @@ void DefaultApi::ue_authentications_post_handler(
void
DefaultApi
::
default_api_default_handler
(
const
Pistache
::
Rest
::
Request
&
,
Pistache
::
Http
::
ResponseWriter
response
)
{
cout
<<
"--in default api handler"
<<
endl
;
Logger
::
ausf_server
().
info
(
"--in default api handler--"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Not_Found
,
"The requested method does not exist-default"
);
}
...
...
impl/DefaultApiImpl.cpp
View file @
b608bda7
...
...
@@ -19,6 +19,8 @@
#include "logger.hpp"
#include <iostream>
#include "sha256.hpp"
using
namespace
std
;
namespace
org
{
...
...
@@ -36,51 +38,44 @@ void DefaultApiImpl::eap_auth_method(const std::string &authCtxId,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
}
void
DefaultApiImpl
::
rg_authentications_post
(
const
RgAuthenticationInfo
&
rgAuthenticationInfo
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
}
void
DefaultApiImpl
::
ue_authentications_auth_ctx_id5g_aka_confirmation_put
(
const
std
::
string
&
authCtxId
,
const
ConfirmationData
&
confirmationData
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
cout
<<
"------------ue_authentications_auth_ctx_id5g_aka_confirmation_put---"
"------"
<<
endl
;
Logger
::
ausf_server
().
debug
(
"--ue_authentications_auth_ctx_id5g_aka_confirmation_put--"
);
Logger
::
ausf_server
().
debug
(
"--ue_authentications_auth_ctx_id5g_aka_confirmation_put--"
);
/
/---------------------getting params---------------------------------
/
*---------------------getting params---------------------------------*/
cout
<<
"handling 5gaka confirmation -- put"
<<
endl
;
cout
<<
"authCtxId"
<<
authCtxId
.
c_str
()
<<
endl
;
// authCtxId
Logger
::
ausf_server
().
info
(
"authCtxId %s"
,
authCtxId
.
c_str
());
cout
<<
"resStar"
<<
confirmationData
.
getResStar
().
c_str
()
<<
endl
;
// resStar
Logger
::
ausf_server
().
info
(
"authCtxId %s"
,
confirmationData
.
getResStar
().
c_str
());
Logger
::
ausf_server
().
info
(
"authCtxId %s"
,
authCtxId
.
c_str
());
// authCtxId
Logger
::
ausf_server
().
info
(
"authCtxId %s"
,
confirmationData
.
getResStar
().
c_str
());
// resStar
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
}
void
DefaultApiImpl
::
ue_authentications_deregister_post
(
const
DeregistrationInfo
&
deregistrationInfo
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
}
void
DefaultApiImpl
::
ue_authentications_post
(
const
AuthenticationInfo
&
authenticationInfo
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
cout
<<
"------------ue_authentications_post---------"
<<
endl
;
Logger
::
ausf_server
().
debug
(
"--ue_authentications_post--"
);
Logger
::
ausf_server
().
debug
(
"--ue_authentications_post--"
);
//----------------------getting params-------------------------------------
cout
<<
"servingNetworkName "
<<
authenticationInfo
.
getServingNetworkName
().
c_str
()
<<
endl
;
// servingNetworkName
/*----------------------getting params-------------*/
Logger
::
ausf_server
().
info
(
"servingNetworkName %s"
,
authenticationInfo
.
getServingNetworkName
().
c_str
());
cout
<<
"supiOrSuci "
<<
authenticationInfo
.
getSupiOrSuci
().
c_str
()
<<
endl
;
// supiOrSuci
Logger
::
ausf_server
().
info
(
"supiOrSuci %s"
,
authenticationInfo
.
getSupiOrSuci
().
c_str
());
//----------------------generating xres*-------------
cout
<<
"--algorithm test"
<<
endl
;
/*----------------------getting xres*-------------*/
Logger
::
ausf_server
().
debug
(
"--algorithm test"
);
uint8_t
opc
[
16
]
=
{
0x00
,
0x01
,
0x02
,
0x03
,
0x04
,
0x05
,
0x06
,
0x07
,
...
...
@@ -122,10 +117,42 @@ void DefaultApiImpl::ue_authentications_post(
print_buffer
(
"amf_n1"
,
"XRES*"
,
output
,
16
);
// cout << "xres* %s" << output << endl;
//----------------------generating 5g av--------------------------
/*----------------------generating 5G AV from 5G HE AV--------------------------*/
/* HXRES* <-- XRES* */
/* KSEAF <-- KAUSF */
/* 在5G HE AV中用HXRES*替代XRES*,用 KSEAF 替代KAUSF */
/* 删除 KSEAF,并向SEAF返回5G SE AV(RAND, AUTN, HXRES*)*/
/* A.5, 3gpp ts33.501 */
Logger
::
ausf_server
().
debug
(
"==generating 5g av"
);
// Logger::ausf_server().debug("Authentication_vectors_generator_in_ausf");
// uint8_t inputString[MAX_5GS_AUTH_VECTORS][40];
// uint8_t *xresStar[MAX_5GS_AUTH_VECTORS];
// uint8_t *rand[MAX_5GS_AUTH_VECTORS];
// for (int i = 0; i < MAX_5GS_AUTH_VECTORS; i++)
// {
// xresStar[i] = nc.get()->_5g_he_av[i].xresStar;
// rand[i] = nc.get()->_5g_he_av[i].rand;
// memcpy(&inputString[i][0], rand[i], 16);
// memcpy(&inputString[i][16], xresStar[i], 16);
// unsigned char sha256Out[Sha256::DIGEST_SIZE];
// sha256((unsigned char *)inputString[i], 32, sha256Out);
// for (int j = 0; j < 16; j++)
// nc.get()->_5g_av[i].hxresStar[j] = (uint8_t)sha256Out[j];
// memcpy(nc.get()->_5g_av[i].rand, nc.get()->_5g_he_av[i].rand, 16);
// memcpy(nc.get()->_5g_av[i].autn, nc.get()->_5g_he_av[i].autn, 16);
// uint8_t kseaf[32];
// Authentication_5gaka::derive_kseaf(nc.get()->serving_network, nc.get()->_5g_he_av[i].kausf, kseaf);
// memcpy(nc.get()->_5g_av[i].kseaf, kseaf, 32);
// //print_buffer("amf_n1", "5G AV: rand", nc.get()->_5g_av[i].rand, 16);
// //print_buffer("amf_n1", "5G AV: autn", nc.get()->_5g_av[i].autn, 16);
// //print_buffer("amf_n1", "5G AV: kseaf", nc.get()->_5g_av[i].kseaf, 32);
// //print_buffer("amf_n1", "5G AV: hxres*", nc.get()->_5g_av[i].hxresStar, 16);
// }
cout
<<
"--handling 5gaka authentication -- post"
<<
endl
;
Logger
::
ausf_server
().
debug
(
"--handling 5gaka authentication -- post"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment