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
54e7660f
Commit
54e7660f
authored
Mar 14, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix naked ptr for NAS security context
parent
f4b85dff
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
145 additions
and
122 deletions
+145
-122
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+130
-108
src/amf-app/amf_n1.hpp
src/amf-app/amf_n1.hpp
+6
-6
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+7
-5
src/contexts/nas_context.cpp
src/contexts/nas_context.cpp
+1
-2
src/contexts/nas_context.hpp
src/contexts/nas_context.hpp
+1
-1
No files found.
src/amf-app/amf_n1.cpp
View file @
54e7660f
This diff is collapsed.
Click to expand it.
src/amf-app/amf_n1.hpp
View file @
54e7660f
...
...
@@ -366,7 +366,7 @@ class amf_n1 {
/*
* Encode the NAS message with corresponding integrity and ciphered algorithms
* @param [nas_secu_ctx
*
] nsc: NAS Security context
* @param [nas_secu_ctx
&
] nsc: NAS Security context
* @param [bool] is_secu_ctx_new: indicate the status of the security context
* (new/old)
* @param [uint8_t] security_header_type: Security Header Type
...
...
@@ -377,13 +377,13 @@ class amf_n1 {
* @return void
*/
void
encode_nas_message_protected
(
nas_secu_ctx
*
nsc
,
bool
is_secu_ctx_new
,
uint8_t
security_header_type
,
nas_secu_ctx
&
nsc
,
bool
is_secu_ctx_new
,
uint8_t
security_header_type
,
uint8_t
direction
,
uint8_t
*
input_nas_buf
,
int
input_nas_len
,
bstring
&
encrypted_nas
);
/*
* Encrypt with integrity algorithm
* @param [nas_secu_ctx
*
] nsc: NAS Security context
* @param [nas_secu_ctx
&
] nsc: NAS Security context
* @param [uint8_t] direction: Direction
* @param [uint8_t*] input_nas_buf: Buffer of the input NAS
* @param [int] input_nas_les: Length of the buffer
...
...
@@ -391,19 +391,19 @@ class amf_n1 {
* @return true if MAC can be calculated successfully, otherwise return false
*/
bool
nas_message_integrity_protected
(
nas_secu_ctx
*
nsc
,
uint8_t
direction
,
uint8_t
*
input_nas
,
nas_secu_ctx
&
nsc
,
uint8_t
direction
,
uint8_t
*
input_nas
,
int
input_nas_len
,
uint32_t
&
mac
);
/*
* Cipher NAS message with the corresponding ciphered algorithm
* @param [nas_secu_ctx
*
] nsc: NAS Security context
* @param [nas_secu_ctx
&
] nsc: NAS Security context
* @param [uint8_t] direction: Direction
* @param [bstring] input_nas: Input NAS message
* @param [bstring&] output_nas: Output NAS message
* @return true if message is successfully ciphered, otherwise return false
*/
bool
nas_message_cipher_protected
(
nas_secu_ctx
*
nsc
,
uint8_t
direction
,
bstring
input_nas
,
nas_secu_ctx
&
nsc
,
uint8_t
direction
,
bstring
input_nas
,
bstring
&
output_nas
);
// NOTE: All the MySQL-related functions are currently implemented in
...
...
src/amf-app/amf_n2.cpp
View file @
54e7660f
...
...
@@ -1581,16 +1581,18 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
return
false
;
}
nas_secu_ctx
*
secu
=
nc
->
security_ctx
;
if
(
!
secu
)
{
if
(
!
nc
->
security_ctx
.
has_value
())
{
Logger
::
amf_n2
().
error
(
"No Security Context found"
);
return
false
;
}
uint8_t
*
kamf
=
nc
->
kamf
[
secu
->
vector_pointer
];
nas_secu_ctx
security_ctx
=
nc
->
security_ctx
.
value
();
uint8_t
*
kamf
=
nc
->
kamf
[
security_ctx
.
vector_pointer
];
uint8_t
kgnb
[
32
];
uint32_t
ulcount
=
secu
->
ul_count
.
seq_num
|
(
secu
->
ul_count
.
overflow
<<
8
);
uint32_t
ulcount
=
security_ctx
.
ul_count
.
seq_num
|
(
security_ctx
.
ul_count
.
overflow
<<
8
);
Logger
::
amf_n2
().
debug
(
"Handover Required, Uplink count (%d)"
,
secu
->
ul_count
.
seq_num
);
"Handover Required, Uplink count (%d)"
,
secu
rity_ctx
.
ul_count
.
seq_num
);
uint8_t
knh
[
32
];
Authentication_5gaka
::
handover_ncc_derive_knh
(
ulcount
,
0x01
,
kamf
,
kgnb
,
knh
,
unc
->
ncc
);
...
...
src/contexts/nas_context.cpp
View file @
54e7660f
...
...
@@ -24,7 +24,6 @@
//------------------------------------------------------------------------------
nas_context
::
nas_context
()
:
_vector
(),
_5g_he_av
(),
_5g_av
(),
kamf
(),
_5gmm_capability
()
{
security_ctx
=
nullptr
;
is_imsi_present
=
false
;
is_stacs_available
=
false
;
is_auth_vectors_present
=
false
;
...
...
@@ -44,7 +43,7 @@ nas_context::nas_context()
is_common_procedure_for_identification_running
=
false
;
is_common_procedure_for_security_mode_control_running
=
false
;
is_common_procedure_for_nas_transport_running
=
false
;
security_ctx
=
nullptr
;
security_ctx
=
std
::
nullopt
;
is_current_security_available
=
false
;
registration_attempt_counter
=
0
;
is_imsi_present
=
false
;
...
...
src/contexts/nas_context.hpp
View file @
54e7660f
...
...
@@ -117,7 +117,7 @@ class nas_context {
_5G_AV_t
_5g_av
[
MAX_5GS_AUTH_VECTORS
];
// generated by AUSF
std
::
string
href
;
uint8_t
kamf
[
MAX_5GS_AUTH_VECTORS
][
32
];
nas_secu_ctx
*
security_ctx
;
// TODO: avoid using naked ptr
std
::
optional
<
nas_secu_ctx
>
security_ctx
;
bool
is_current_security_available
;
int
registration_attempt_counter
;
// used to limit the subsequently reject
// registration
...
...
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