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
3cce2ae2
Commit
3cce2ae2
authored
Jan 28, 2021
by
HFJ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
algorithm done
parent
e053ef56
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
34 deletions
+82
-34
5gaka/authentication_algorithms_with_5gaka.hpp
5gaka/authentication_algorithms_with_5gaka.hpp
+1
-1
impl/DefaultApiImpl.cpp
impl/DefaultApiImpl.cpp
+81
-33
No files found.
5gaka/authentication_algorithms_with_5gaka.hpp
View file @
3cce2ae2
...
...
@@ -41,7 +41,7 @@ typedef struct {
uint8_t
kausf
[
32
];
}
_5G_HE_AV_t
;
// clause 6.3.6.2.5, ts33.501
typedef
struct
{
typedef
struct
_5G_AV_s
{
uint8_t
avType
;
uint8_t
rand
[
16
];
uint8_t
hxres
[
16
];
...
...
impl/DefaultApiImpl.cpp
View file @
3cce2ae2
...
...
@@ -40,6 +40,15 @@ using namespace org::openapitools::server::model;
uint8_t
XRES_STAR
[
16
];
//store xres*
uint8_t
KSEAF
[
32
];
typedef
struct
{
uint8_t
rand
[
16
];
uint8_t
autn
[
16
];
uint8_t
hxresStar
[
16
];
uint8_t
kseaf
[
32
];
}
AUSF_AV_s
;
AUSF_AV_s
ausf_av_s
;
DefaultApiImpl
::
DefaultApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
)
:
DefaultApi
(
rtr
)
{}
...
...
@@ -70,52 +79,75 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
conv
::
hex_str_to_uint8
(
confirmationData
.
getResStar
().
c_str
(),
resStar
);
//string->uint8, res*(uint8)
cout
<<
"
\n
res*"
<<
endl
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x "
,
resStar
[
i
]);
cout
<<
endl
;
/*---------------------认证确认-amf--------------------------------*/
ConfirmationDataResponse
confirmResponse
;
//1.验证AV是否过期: 认证成功后,AUSF将存储 KAUSF ?
bool
is_auth_vectors_present
=
true
;
//2.将接收到的RES*与存储的XRES*进行比较:RES*与XRES*相等,AUSF将从家庭网络角度认为认证成功
//get stored xres* -----
uint8_t
xresStar
[
16
]
=
{
0
};
memcpy
(
xresStar
,
XRES_STAR
,
16
);
//xres* stored for 5g-aka-confirmation
cout
<<
"
\n
xres*"
<<
endl
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x "
,
xresStar
[
i
]);
cout
<<
endl
;
cout
<<
"
\n
string xres*"
<<
endl
;
cout
<<
conv
::
uint8_to_hex_string
(
xresStar
,
16
);
cout
<<
endl
;
//res* verification
bool
authResult
=
true
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
if
(
xresStar
[
i
]
!=
resStar
[
i
])
authResult
=
false
;
}
confirmResponse
.
setAuthResult
(
authResult
);
//av up to date?
if
(
!
authResult
)
//fail
if
(
!
is_auth_vectors_present
)
//AV expired
{
Logger
::
ausf_server
().
error
(
"Authentication failure with authCtxId %s: res* != xres*"
,
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指示,从本地网络角度认证否成功
}
else
//
success
else
//
AV valid
{
Logger
::
ausf_server
().
info
(
"Authentication successful by home network!"
);
// confirmResponse.setKseaf();
Logger
::
ausf_server
().
info
(
"AV is up to date, handling received res*..."
);
//2.将接收到的RES*与存储的XRES*进行比较:RES*与XRES*相等,AUSF将从家庭网络角度认为认证成功
//get stored xres* -----
uint8_t
xresStar
[
16
]
=
{
0
};
memcpy
(
xresStar
,
XRES_STAR
,
16
);
//xres* stored for 5g-aka-confirmation
cout
<<
"
\n
xres*"
<<
endl
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x "
,
xresStar
[
i
]);
cout
<<
endl
;
}
cout
<<
"
\n
string xres*"
<<
endl
;
cout
<<
conv
::
uint8_to_hex_string
(
xresStar
,
16
);
cout
<<
endl
;
//3.向SEAF指示,从本地网络角度认证是否成功
//4.将KSEAF 发送给SEAF
//res* verification
bool
authResult
=
true
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
if
(
xresStar
[
i
]
!=
resStar
[
i
])
authResult
=
false
;
}
confirmResponse
.
setAuthResult
(
authResult
);
//3.向SEAF指示,从本地网络角度认证是否成功
if
(
!
authResult
)
//fail
{
Logger
::
ausf_server
().
error
(
"Authentication failure by home network with authCtxId %s: res* != xres*"
,
authCtxId
.
c_str
());
}
else
//success
{
Logger
::
ausf_server
().
info
(
"Authentication successful by home network!"
);
//4.send KSEAF to SEAF
string
kseaf_s
;
kseaf_s
=
conv
::
uint8_to_hex_string
(
ausf_av_s
.
kseaf
,
32
);
// convert uint8_t to string
confirmResponse
.
setKseaf
(
kseaf_s
);
//supi ignored
}
}
cout
<<
"kseafIsSet"
<<
confirmResponse
.
kseafIsSet
()
<<
endl
;
cout
<<
"supiIsSet "
<<
confirmResponse
.
supiIsSet
()
<<
endl
;
/*----------------ausf --> seaf-----------*/
//---forming response
nlohmann
::
json
confirmResponse_json
;
to_json
(
confirmResponse_json
,
confirmResponse
);
cout
<<
confirmResponse_json
<<
endl
;
Logger
::
ausf_server
().
info
(
"Send 5g-aka-confirmation response to SEAF"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Do some magic
\n
"
);
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
confirmResponse_json
.
dump
()
);
}
void
DefaultApiImpl
::
ue_authentications_deregister_post
(
...
...
@@ -131,8 +163,8 @@ void DefaultApiImpl::ue_authentications_post(
Logger
::
ausf_server
().
debug
(
"--ue_authentications_post--"
);
/*----------------------getting params-------------*/
Logger
::
ausf_server
().
info
(
"servingNetworkName %s"
,
authenticationInfo
.
getServingNetworkName
());
Logger
::
ausf_server
().
info
(
"supiOrSuci %s"
,
authenticationInfo
.
getSupiOrSuci
());
Logger
::
ausf_server
().
info
(
"servingNetworkName %s"
,
authenticationInfo
.
getServingNetworkName
()
.
c_str
()
);
Logger
::
ausf_server
().
info
(
"supiOrSuci %s"
,
authenticationInfo
.
getSupiOrSuci
()
.
c_str
()
);
//std::string snn = "5G:mnc001.mcc460.3gppnetwork.org";
std
::
string
snn
=
authenticationInfo
.
getServingNetworkName
();
//std::string imsi = "imsi-460010123456789";
...
...
@@ -253,6 +285,21 @@ void DefaultApiImpl::ue_authentications_post(
for
(
int
i
=
0
;
i
<
32
;
i
++
)
printf
(
"%x "
,
kseaf
[
i
]);
cout
<<
endl
;
//store 5g av in ausf
memcpy
(
ausf_av_s
.
rand
,
rand_ausf
,
16
);
memcpy
(
ausf_av_s
.
autn
,
autn_ausf
,
16
);
memcpy
(
ausf_av_s
.
hxresStar
,
hxresStar
,
16
);
memcpy
(
ausf_av_s
.
kseaf
,
kseaf
,
32
);
cout
<<
"
\n
ausf_av_s.rand"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x "
,
ausf_av_s
.
rand
[
i
]);
cout
<<
"
\n
ausf_av_s.autn"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x "
,
ausf_av_s
.
autn
[
i
]);
cout
<<
"
\n
ausf_av_s.hxresStar"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
printf
(
"%x "
,
ausf_av_s
.
hxresStar
[
i
]);
cout
<<
"
\n
ausf_av_s.kseaf"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
32
;
i
++
)
printf
(
"%x "
,
ausf_av_s
.
kseaf
[
i
]);
cout
<<
endl
;
...
...
@@ -273,10 +320,11 @@ void DefaultApiImpl::ue_authentications_post(
AuthResponse
.
setAutn
(
autn_s
);
AuthResponse
.
setHxresStar
(
hxresStar_s
);
nlohmann
::
json
AuthResponse_json
;
to_json
(
AuthResponse_json
,
AuthResponse
);
cout
<<
AuthResponse_json
;
cout
<<
AuthResponse_json
<<
endl
;
Logger
::
ausf_server
().
info
(
"Send response to SEAF"
);
...
...
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