Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
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-AMF
Commits
57928508
Commit
57928508
authored
Feb 08, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup for Authentication Request/Reject/Failure
parent
7a295360
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
26 deletions
+41
-26
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+3
-3
src/nas/common/3gpp_24.501.hpp
src/nas/common/3gpp_24.501.hpp
+1
-1
src/nas/msgs/AuthenticationFailure.cpp
src/nas/msgs/AuthenticationFailure.cpp
+11
-6
src/nas/msgs/AuthenticationFailure.hpp
src/nas/msgs/AuthenticationFailure.hpp
+1
-1
src/nas/msgs/AuthenticationReject.cpp
src/nas/msgs/AuthenticationReject.cpp
+2
-1
src/nas/msgs/AuthenticationRequest.cpp
src/nas/msgs/AuthenticationRequest.cpp
+10
-10
src/nas/msgs/AuthenticationRequest.hpp
src/nas/msgs/AuthenticationRequest.hpp
+13
-4
No files found.
src/amf-app/amf_n1.cpp
View file @
57928508
...
@@ -2156,7 +2156,7 @@ bool amf_n1::start_authentication_procedure(
...
@@ -2156,7 +2156,7 @@ bool amf_n1::start_authentication_procedure(
abba
[
1
]
=
0x00
;
abba
[
1
]
=
0x00
;
auth_request
->
SetAbba
(
2
,
abba
);
auth_request
->
SetAbba
(
2
,
abba
);
// uint8_t* rand = nc->_5g_av[vindex].rand;
// uint8_t* rand = nc->_5g_av[vindex].rand;
auth_request
->
setAuthentication_Parameter_RAND
(
nc
->
_5g_av
[
vindex
].
rand
);
auth_request
->
SetAuthenticationParameterRand
(
nc
->
_5g_av
[
vindex
].
rand
);
Logger
::
amf_n1
().
debug
(
"Sending Authentication Request with RAND"
);
Logger
::
amf_n1
().
debug
(
"Sending Authentication Request with RAND"
);
printf
(
"0x"
);
printf
(
"0x"
);
for
(
int
i
=
0
;
i
<
kAuthenticationParameterRandValueLength
;
i
++
)
for
(
int
i
=
0
;
i
<
kAuthenticationParameterRandValueLength
;
i
++
)
...
@@ -2164,7 +2164,7 @@ bool amf_n1::start_authentication_procedure(
...
@@ -2164,7 +2164,7 @@ bool amf_n1::start_authentication_procedure(
printf
(
"
\n
"
);
printf
(
"
\n
"
);
uint8_t
*
autn
=
nc
->
_5g_av
[
vindex
].
autn
;
uint8_t
*
autn
=
nc
->
_5g_av
[
vindex
].
autn
;
if
(
autn
)
auth_request
->
setAuthentication_Parameter_AUTN
(
autn
);
if
(
autn
)
auth_request
->
SetAuthenticationParameterAutn
(
autn
);
uint8_t
buffer
[
1024
]
=
{
0
};
uint8_t
buffer
[
1024
]
=
{
0
};
int
encoded_size
=
auth_request
->
Encode
(
buffer
,
1024
);
int
encoded_size
=
auth_request
->
Encode
(
buffer
,
1024
);
if
(
!
encoded_size
)
{
if
(
!
encoded_size
)
{
...
@@ -2319,7 +2319,7 @@ void amf_n1::authentication_failure_handle(
...
@@ -2319,7 +2319,7 @@ void amf_n1::authentication_failure_handle(
auto
auth_failure
=
std
::
make_unique
<
AuthenticationFailure
>
();
auto
auth_failure
=
std
::
make_unique
<
AuthenticationFailure
>
();
auth_failure
->
Decode
((
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
auth_failure
->
Decode
((
uint8_t
*
)
bdata
(
plain_msg
),
blength
(
plain_msg
));
uint8_t
mm_cause
=
auth_failure
->
Get5
GM
mCause
();
uint8_t
mm_cause
=
auth_failure
->
Get5
gm
mCause
();
if
(
mm_cause
==
-
1
)
{
if
(
mm_cause
==
-
1
)
{
Logger
::
amf_n1
().
error
(
"Missing mandatory IE 5G_MM_CAUSE"
);
Logger
::
amf_n1
().
error
(
"Missing mandatory IE 5G_MM_CAUSE"
);
send_registration_reject_msg
(
send_registration_reject_msg
(
...
...
src/nas/common/3gpp_24.501.hpp
View file @
57928508
...
@@ -150,7 +150,7 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = {
...
@@ -150,7 +150,7 @@ static const std::vector<std::string> nas_ciphering_algorithm_list_e2str = {
/************************** cause value for 5g mobility management(Annex A)
/************************** cause value for 5g mobility management(Annex A)
* ********************************/
* ********************************/
#define _5GMM_CAUSE_ILLEGAL_UE 3
#define _5GMM_CAUSE_ILLEGAL_UE 3
#define _5GMM_CAUSE_SYNCH_FAILURE 0b00010101
#define _5GMM_CAUSE_SYNCH_FAILURE 0b00010101
// 21
#define _5GMM_CAUSE_IMPLICITLY_DE_REGISTERED 10
#define _5GMM_CAUSE_IMPLICITLY_DE_REGISTERED 10
#define _5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED 9
#define _5GMM_CAUSE_UE_IDENTITY_CANNOT_BE_DERIVED 9
#define _5GMM_CAUSE_NGKSI_ALREADY_IN_USE 0b01000111 // 71
#define _5GMM_CAUSE_NGKSI_ALREADY_IN_USE 0b01000111 // 71
...
...
src/nas/msgs/AuthenticationFailure.cpp
View file @
57928508
...
@@ -46,7 +46,7 @@ void AuthenticationFailure::Set5gmmCause(uint8_t value) {
...
@@ -46,7 +46,7 @@ void AuthenticationFailure::Set5gmmCause(uint8_t value) {
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
uint8_t
AuthenticationFailure
::
Get5
GMmCause
()
{
uint8_t
AuthenticationFailure
::
Get5
gmmCause
()
const
{
return
ie_5gmm_cause
.
GetValue
();
return
ie_5gmm_cause
.
GetValue
();
}
}
...
@@ -101,11 +101,11 @@ int AuthenticationFailure::Encode(uint8_t* buf, int len) {
...
@@ -101,11 +101,11 @@ int AuthenticationFailure::Encode(uint8_t* buf, int len) {
encoded_size
+=
encoded_ie_size
;
encoded_size
+=
encoded_ie_size
;
int
size
=
ie_5gmm_cause
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
int
size
=
ie_5gmm_cause
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
!=
KEncodeDecodeError
)
{
if
(
size
!=
KEncodeDecodeError
)
{
encoded_size
+=
size
;
encoded_size
+=
size
;
}
else
{
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding ie_5gmm_cause error"
);
Logger
::
nas_mm
().
error
(
"Encoding %s error"
,
_5gmmCause
::
GetIeName
().
c_str
());
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
}
...
@@ -120,7 +120,8 @@ int AuthenticationFailure::Encode(uint8_t* buf, int len) {
...
@@ -120,7 +120,8 @@ int AuthenticationFailure::Encode(uint8_t* buf, int len) {
encoded_size
+=
size
;
encoded_size
+=
size
;
}
else
{
}
else
{
Logger
::
nas_mm
().
error
(
Logger
::
nas_mm
().
error
(
"Encoding ie_authentication_failure_parameter error"
);
"Encoding %s error"
,
AuthenticationFailureParameter
::
GetIeName
().
c_str
());
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
}
}
}
...
@@ -148,8 +149,11 @@ int AuthenticationFailure::Decode(uint8_t* buf, int len) {
...
@@ -148,8 +149,11 @@ int AuthenticationFailure::Decode(uint8_t* buf, int len) {
// 5GMM Cause
// 5GMM Cause
if
((
decoded_result
=
ie_5gmm_cause
.
Decode
(
if
((
decoded_result
=
ie_5gmm_cause
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
))
==
buf
+
decoded_size
,
len
-
decoded_size
,
false
))
==
KEncodeDecodeError
)
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Decoding %s error"
,
_5gmmCause
::
GetIeName
().
c_str
());
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
decoded_size
+=
decoded_result
;
decoded_size
+=
decoded_result
;
Logger
::
nas_mm
().
debug
(
"Decoded_size (%d)"
,
decoded_size
);
Logger
::
nas_mm
().
debug
(
"Decoded_size (%d)"
,
decoded_size
);
...
@@ -161,7 +165,8 @@ int AuthenticationFailure::Decode(uint8_t* buf, int len) {
...
@@ -161,7 +165,8 @@ int AuthenticationFailure::Decode(uint8_t* buf, int len) {
Logger
::
nas_mm
().
debug
(
"IEI 0x%x"
,
octet
);
Logger
::
nas_mm
().
debug
(
"IEI 0x%x"
,
octet
);
switch
(
octet
)
{
switch
(
octet
)
{
case
kIeiAuthenticationFailureParameter
:
{
case
kIeiAuthenticationFailureParameter
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI (0x30)"
);
Logger
::
nas_mm
().
debug
(
"Decoding IEI 0x%x"
,
kIeiAuthenticationFailureParameter
);
AuthenticationFailureParameter
ie_authentication_failure_parameter_tmp
=
AuthenticationFailureParameter
ie_authentication_failure_parameter_tmp
=
{};
{};
if
((
decoded_result
=
ie_authentication_failure_parameter_tmp
.
Decode
(
if
((
decoded_result
=
ie_authentication_failure_parameter_tmp
.
Decode
(
...
...
src/nas/msgs/AuthenticationFailure.hpp
View file @
57928508
...
@@ -37,7 +37,7 @@ class AuthenticationFailure : public NasMmPlainHeader {
...
@@ -37,7 +37,7 @@ class AuthenticationFailure : public NasMmPlainHeader {
void
SetHeader
(
uint8_t
security_header_type
);
void
SetHeader
(
uint8_t
security_header_type
);
void
Set5gmmCause
(
uint8_t
value
);
void
Set5gmmCause
(
uint8_t
value
);
uint8_t
Get5
GMmCause
()
;
uint8_t
Get5
gmmCause
()
const
;
// void SetAuthenticationFailureParameter(const uint8_t
// void SetAuthenticationFailureParameter(const uint8_t
// (&value)[kAuthenticationFailureParameterContentLength]); bool
// (&value)[kAuthenticationFailureParameterContentLength]); bool
...
...
src/nas/msgs/AuthenticationReject.cpp
View file @
57928508
...
@@ -68,7 +68,8 @@ int AuthenticationReject::Encode(uint8_t* buf, int len) {
...
@@ -68,7 +68,8 @@ int AuthenticationReject::Encode(uint8_t* buf, int len) {
if
(
size
!=
KEncodeDecodeError
)
{
if
(
size
!=
KEncodeDecodeError
)
{
encoded_size
+=
size
;
encoded_size
+=
size
;
}
else
{
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding ie_eap_message error"
);
Logger
::
nas_mm
().
error
(
"Encoding %s error"
,
EapMessage
::
GetIeName
().
c_str
());
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
}
}
}
...
...
src/nas/msgs/AuthenticationRequest.cpp
View file @
57928508
...
@@ -44,9 +44,9 @@ void AuthenticationRequest::SetHeader(uint8_t security_header_type) {
...
@@ -44,9 +44,9 @@ void AuthenticationRequest::SetHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
AuthenticationRequest
::
SetNgKsi
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
void
AuthenticationRequest
::
SetNgKsi
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ng
KSI
.
Set
(
false
);
// 4 lower bits
ie_ng
_ksi
.
Set
(
false
);
// 4 lower bits
ie_ng
KSI
.
SetNasKeyIdentifier
(
key_set_id
);
ie_ng
_ksi
.
SetNasKeyIdentifier
(
key_set_id
);
ie_ng
KSI
.
SetTypeOfSecurityContext
(
tsc
);
ie_ng
_ksi
.
SetTypeOfSecurityContext
(
tsc
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -55,7 +55,7 @@ void AuthenticationRequest::SetAbba(uint8_t length, uint8_t* value) {
...
@@ -55,7 +55,7 @@ void AuthenticationRequest::SetAbba(uint8_t length, uint8_t* value) {
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
AuthenticationRequest
::
setAuthentication_Parameter_RAND
(
void
AuthenticationRequest
::
SetAuthenticationParameterRand
(
uint8_t
value
[
kAuthenticationParameterRandValueLength
])
{
uint8_t
value
[
kAuthenticationParameterRandValueLength
])
{
ie_authentication_parameter_rand
=
ie_authentication_parameter_rand
=
std
::
make_optional
<
Authentication_Parameter_RAND
>
(
std
::
make_optional
<
Authentication_Parameter_RAND
>
(
...
@@ -63,7 +63,7 @@ void AuthenticationRequest::setAuthentication_Parameter_RAND(
...
@@ -63,7 +63,7 @@ void AuthenticationRequest::setAuthentication_Parameter_RAND(
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
AuthenticationRequest
::
setAuthentication_Parameter_AUTN
(
void
AuthenticationRequest
::
SetAuthenticationParameterAutn
(
uint8_t
value
[
kAuthenticationParameterAutnValueLength
])
{
uint8_t
value
[
kAuthenticationParameterAutnValueLength
])
{
ie_authentication_parameter_autn
=
ie_authentication_parameter_autn
=
std
::
make_optional
<
Authentication_Parameter_AUTN
>
(
std
::
make_optional
<
Authentication_Parameter_AUTN
>
(
...
@@ -71,7 +71,7 @@ void AuthenticationRequest::setAuthentication_Parameter_AUTN(
...
@@ -71,7 +71,7 @@ void AuthenticationRequest::setAuthentication_Parameter_AUTN(
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void
AuthenticationRequest
::
SetEapMessage
(
bstring
eap
)
{
void
AuthenticationRequest
::
SetEapMessage
(
const
bstring
&
eap
)
{
ie_eap_message
=
std
::
make_optional
<
EapMessage
>
(
kIeiEapMessage
,
eap
);
ie_eap_message
=
std
::
make_optional
<
EapMessage
>
(
kIeiEapMessage
,
eap
);
}
}
...
@@ -89,7 +89,7 @@ int AuthenticationRequest::Encode(uint8_t* buf, int len) {
...
@@ -89,7 +89,7 @@ int AuthenticationRequest::Encode(uint8_t* buf, int len) {
}
}
encoded_size
+=
encoded_ie_size
;
encoded_size
+=
encoded_ie_size
;
int
size
=
ie_ng
KSI
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
int
size
=
ie_ng
_ksi
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
!=
KEncodeDecodeError
)
{
if
(
size
!=
KEncodeDecodeError
)
{
encoded_size
+=
size
;
encoded_size
+=
size
;
}
else
{
}
else
{
...
@@ -98,7 +98,7 @@ int AuthenticationRequest::Encode(uint8_t* buf, int len) {
...
@@ -98,7 +98,7 @@ int AuthenticationRequest::Encode(uint8_t* buf, int len) {
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
}
// Spare half octet
// Spare half octet
encoded_size
++
;
// 1/2 octet + 1/2 octet from ie_ng
KSI
encoded_size
++
;
// 1/2 octet + 1/2 octet from ie_ng
_ksi
// ABBA
// ABBA
size
=
ie_abba
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
size
=
ie_abba
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
...
@@ -181,7 +181,7 @@ int AuthenticationRequest::Decode(uint8_t* buf, int len) {
...
@@ -181,7 +181,7 @@ int AuthenticationRequest::Decode(uint8_t* buf, int len) {
decoded_size
+=
decoded_result
;
decoded_size
+=
decoded_result
;
// NgKSI
// NgKSI
decoded_result
=
ie_ng
KSI
.
Decode
(
decoded_result
=
ie_ng
_ksi
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
// length 1/2, low position
false
);
// length 1/2, low position
if
(
decoded_result
==
KEncodeDecodeError
)
{
if
(
decoded_result
==
KEncodeDecodeError
)
{
...
@@ -190,7 +190,7 @@ int AuthenticationRequest::Decode(uint8_t* buf, int len) {
...
@@ -190,7 +190,7 @@ int AuthenticationRequest::Decode(uint8_t* buf, int len) {
return
KEncodeDecodeError
;
return
KEncodeDecodeError
;
}
}
decoded_size
+=
decoded_result
;
decoded_size
+=
decoded_result
;
decoded_size
++
;
// 1/2 octet from ie_ng
KSI
, 1/2 from Spare half octet
decoded_size
++
;
// 1/2 octet from ie_ng
_ksi
, 1/2 from Spare half octet
// ABBA
// ABBA
decoded_result
=
decoded_result
=
...
...
src/nas/msgs/AuthenticationRequest.hpp
View file @
57928508
...
@@ -37,15 +37,24 @@ class AuthenticationRequest : public NasMmPlainHeader {
...
@@ -37,15 +37,24 @@ class AuthenticationRequest : public NasMmPlainHeader {
void
SetHeader
(
uint8_t
security_header_type
);
void
SetHeader
(
uint8_t
security_header_type
);
void
SetNgKsi
(
uint8_t
tsc
,
uint8_t
key_set_id
);
void
SetNgKsi
(
uint8_t
tsc
,
uint8_t
key_set_id
);
void
SetEapMessage
(
bstring
eap
);
// TODO: Get
void
SetEapMessage
(
const
bstring
&
eap
);
// TODO: Get
void
SetAbba
(
uint8_t
length
,
uint8_t
*
value
);
void
SetAbba
(
uint8_t
length
,
uint8_t
*
value
);
void
setAuthentication_Parameter_RAND
(
// TODO: Get
void
SetAuthenticationParameterRand
(
uint8_t
value
[
kAuthenticationParameterRandValueLength
]);
uint8_t
value
[
kAuthenticationParameterRandValueLength
]);
void
setAuthentication_Parameter_AUTN
(
// TODO: Get
void
SetAuthenticationParameterAutn
(
uint8_t
value
[
kAuthenticationParameterAutnValueLength
]);
uint8_t
value
[
kAuthenticationParameterAutnValueLength
]);
// TODO: Get
public:
public:
NasKeySetIdentifier
ie_ng
KSI
;
// Mandatory
NasKeySetIdentifier
ie_ng
_ksi
;
// Mandatory
// Spare half octet (will be processed together with NgKSI)
// Spare half octet (will be processed together with NgKSI)
ABBA
ie_abba
;
// Mandatory
ABBA
ie_abba
;
// Mandatory
...
...
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