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
2542778d
Commit
2542778d
authored
Jan 13, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup
parent
e925211a
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
60 additions
and
79 deletions
+60
-79
src/nas/common/NasIeHeader.hpp
src/nas/common/NasIeHeader.hpp
+1
-1
src/nas/ies/NasKeySetIdentifier.cpp
src/nas/ies/NasKeySetIdentifier.cpp
+4
-4
src/nas/ies/NasKeySetIdentifier.hpp
src/nas/ies/NasKeySetIdentifier.hpp
+4
-6
src/nas/ies/NasSecurityAlgorithms.cpp
src/nas/ies/NasSecurityAlgorithms.cpp
+14
-23
src/nas/ies/NasSecurityAlgorithms.hpp
src/nas/ies/NasSecurityAlgorithms.hpp
+6
-7
src/nas/ies/Type1NasIe.hpp
src/nas/ies/Type1NasIe.hpp
+1
-0
src/nas/ies/Type4NasIe.cpp
src/nas/ies/Type4NasIe.cpp
+0
-4
src/nas/ies/Type4NasIe.hpp
src/nas/ies/Type4NasIe.hpp
+1
-0
src/nas/ies/UESecurityCapability.cpp
src/nas/ies/UESecurityCapability.cpp
+0
-4
src/nas/ies/UESecurityCapability.hpp
src/nas/ies/UESecurityCapability.hpp
+0
-2
src/nas/msgs/AuthenticationRequest.cpp
src/nas/msgs/AuthenticationRequest.cpp
+2
-2
src/nas/msgs/DeregistrationRequest.cpp
src/nas/msgs/DeregistrationRequest.cpp
+2
-2
src/nas/msgs/RegistrationRequest.cpp
src/nas/msgs/RegistrationRequest.cpp
+5
-5
src/nas/msgs/SecurityModeCommand.cpp
src/nas/msgs/SecurityModeCommand.cpp
+4
-12
src/nas/msgs/SecurityModeCommand.hpp
src/nas/msgs/SecurityModeCommand.hpp
+14
-5
src/nas/msgs/ServiceRequest.cpp
src/nas/msgs/ServiceRequest.cpp
+2
-2
No files found.
src/nas/common/NasIeHeader.hpp
View file @
2542778d
...
...
@@ -47,7 +47,7 @@
#include "LADN_Indication.hpp"
#include "MA_PDU_Session_Information.hpp"
#include "NasMessageContainer.hpp"
#include "N
AS_Security_
Algorithms.hpp"
#include "N
asSecurity
Algorithms.hpp"
#include "NSSAI.hpp"
#include "NssaiInclusionMode.hpp"
#include "NasKeySetIdentifier.hpp"
...
...
src/nas/ies/NasKeySetIdentifier.cpp
View file @
2542778d
...
...
@@ -129,23 +129,23 @@ int NasKeySetIdentifier::Decode(
*/
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
s
etTypeOfSecurityContext
(
const
bool
&
type
)
{
void
NasKeySetIdentifier
::
S
etTypeOfSecurityContext
(
const
bool
&
type
)
{
tsc_
=
type
;
SetValue
();
// Update value
}
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
s
etNasKeyIdentifier
(
const
uint8_t
&
id
)
{
void
NasKeySetIdentifier
::
S
etNasKeyIdentifier
(
const
uint8_t
&
id
)
{
key_id_
=
0x07
&
id
;
SetValue
();
// Update value
}
//------------------------------------------------------------------------------
bool
NasKeySetIdentifier
::
g
etTypeOfSecurityContext
()
const
{
bool
NasKeySetIdentifier
::
G
etTypeOfSecurityContext
()
const
{
return
tsc_
;
}
//------------------------------------------------------------------------------
uint8_t
NasKeySetIdentifier
::
g
etNasKeyIdentifier
()
const
{
uint8_t
NasKeySetIdentifier
::
G
etNasKeyIdentifier
()
const
{
return
key_id_
;
}
src/nas/ies/NasKeySetIdentifier.hpp
View file @
2542778d
...
...
@@ -23,7 +23,6 @@
#define _NAS_KEY_SET_IDENTIFIER_H
#include "Type1NasIe.hpp"
#include <stdint.h>
constexpr
auto
kNasKeySetIdentifierName
=
"NAS Key Set Identifier"
;
namespace
nas
{
...
...
@@ -43,17 +42,16 @@ class NasKeySetIdentifier : public Type1NasIe {
// void Set(const bool& tsc, const uint8_t& key_id, const uint8_t& iei);
void
Get
(
bool
&
tsc
,
uint8_t
&
key_id
);
void
s
etTypeOfSecurityContext
(
const
bool
&
type
);
bool
g
etTypeOfSecurityContext
()
const
;
void
S
etTypeOfSecurityContext
(
const
bool
&
type
);
bool
G
etTypeOfSecurityContext
()
const
;
void
s
etNasKeyIdentifier
(
const
uint8_t
&
id
);
uint8_t
g
etNasKeyIdentifier
()
const
;
void
S
etNasKeyIdentifier
(
const
uint8_t
&
id
);
uint8_t
G
etNasKeyIdentifier
()
const
;
private:
void
SetValue
()
override
;
void
GetValue
()
override
;
// uint8_t iei_;
bool
tsc_
;
uint8_t
key_id_
;
};
...
...
src/nas/ies/N
AS_Security_
Algorithms.cpp
→
src/nas/ies/N
asSecurity
Algorithms.cpp
View file @
2542778d
...
...
@@ -19,23 +19,14 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "NAS_Security_Algorithms.hpp"
#include <iostream>
#include "NasSecurityAlgorithms.hpp"
#include "logger.hpp"
using
namespace
nas
;
using
namespace
std
;
//------------------------------------------------------------------------------
N
AS_Security_Algorithms
::
NAS_Security_
Algorithms
()
N
asSecurityAlgorithms
::
NasSecurity
Algorithms
()
:
Type3NasIe
(),
type_of_ciphering_algorithm_
(),
type_of_integrity_protection_algorithm_
()
{
...
...
@@ -43,7 +34,7 @@ NAS_Security_Algorithms::NAS_Security_Algorithms()
}
//------------------------------------------------------------------------------
N
AS_Security_Algorithms
::
NAS_Security_
Algorithms
(
uint8_t
iei
)
N
asSecurityAlgorithms
::
NasSecurity
Algorithms
(
uint8_t
iei
)
:
Type3NasIe
(
iei
),
type_of_ciphering_algorithm_
(),
type_of_integrity_protection_algorithm_
()
{
...
...
@@ -51,10 +42,10 @@ NAS_Security_Algorithms::NAS_Security_Algorithms(uint8_t iei)
}
//------------------------------------------------------------------------------
N
AS_Security_Algorithms
::~
NAS_Security_
Algorithms
()
{}
N
asSecurityAlgorithms
::~
NasSecurity
Algorithms
()
{}
//------------------------------------------------------------------------------
N
AS_Security_Algorithms
::
NAS_Security_
Algorithms
(
N
asSecurityAlgorithms
::
NasSecurity
Algorithms
(
uint8_t
ciphering
,
uint8_t
integrity_protection
)
:
Type3NasIe
()
{
type_of_ciphering_algorithm_
=
ciphering
&
0x0f
;
...
...
@@ -63,41 +54,41 @@ NAS_Security_Algorithms::NAS_Security_Algorithms(
}
//------------------------------------------------------------------------------
void
N
AS_Security_
Algorithms
::
SetTypeOfCipheringAlgorithm
(
uint8_t
value
)
{
void
N
asSecurity
Algorithms
::
SetTypeOfCipheringAlgorithm
(
uint8_t
value
)
{
type_of_ciphering_algorithm_
=
value
&
0x0f
;
}
//------------------------------------------------------------------------------
void
N
AS_Security_
Algorithms
::
SetTypeOfIntegrityProtectionAlgorithm
(
void
N
asSecurity
Algorithms
::
SetTypeOfIntegrityProtectionAlgorithm
(
uint8_t
value
)
{
type_of_integrity_protection_algorithm_
=
value
&
0x0f
;
}
//------------------------------------------------------------------------------
uint8_t
N
AS_Security_
Algorithms
::
GetTypeOfCipheringAlgorithm
()
const
{
uint8_t
N
asSecurity
Algorithms
::
GetTypeOfCipheringAlgorithm
()
const
{
return
type_of_ciphering_algorithm_
;
}
//------------------------------------------------------------------------------
uint8_t
N
AS_Security_
Algorithms
::
GetTypeOfIntegrityProtectionAlgorithm
()
const
{
uint8_t
N
asSecurity
Algorithms
::
GetTypeOfIntegrityProtectionAlgorithm
()
const
{
return
type_of_integrity_protection_algorithm_
;
}
//------------------------------------------------------------------------------
void
N
AS_Security_
Algorithms
::
Set
(
void
N
asSecurity
Algorithms
::
Set
(
uint8_t
ciphering
,
uint8_t
integrity_protection
)
{
type_of_ciphering_algorithm_
=
ciphering
&
0x0f
;
type_of_integrity_protection_algorithm_
=
integrity_protection
&
0x0f
;
}
//------------------------------------------------------------------------------
void
N
AS_Security_
Algorithms
::
Get
(
void
N
asSecurity
Algorithms
::
Get
(
uint8_t
&
ciphering
,
uint8_t
&
integrity_protection
)
const
{
ciphering
=
type_of_ciphering_algorithm_
;
integrity_protection
=
type_of_integrity_protection_algorithm_
;
}
//------------------------------------------------------------------------------
int
N
AS_Security_
Algorithms
::
Encode
(
uint8_t
*
buf
,
int
len
)
{
int
N
asSecurity
Algorithms
::
Encode
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Encoding %s"
,
GetIeName
().
c_str
());
if
(
len
<
kNasSecurityAlgorithmsLength
)
{
...
...
@@ -123,7 +114,7 @@ int NAS_Security_Algorithms::Encode(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int
N
AS_Security_
Algorithms
::
Decode
(
uint8_t
*
buf
,
int
len
,
bool
is_iei
)
{
int
N
asSecurity
Algorithms
::
Decode
(
uint8_t
*
buf
,
int
len
,
bool
is_iei
)
{
Logger
::
nas_mm
().
debug
(
"Decoding %s"
,
GetIeName
().
c_str
());
if
(
len
<
kNasSecurityAlgorithmsLength
)
{
...
...
src/nas/ies/N
AS_Security_
Algorithms.hpp
→
src/nas/ies/N
asSecurity
Algorithms.hpp
View file @
2542778d
...
...
@@ -23,21 +23,20 @@
#define _NAS_SECURITY_ALGORITHS_H
#include "Type3NasIe.hpp"
#include <stdint.h>
constexpr
uint8_t
kNasSecurityAlgorithmsLength
=
2
;
constexpr
auto
kNasSecurityAlgorithmsIeName
=
"NAS Security Algorithms"
;
namespace
nas
{
class
N
AS_Security_
Algorithms
:
public
Type3NasIe
{
class
N
asSecurity
Algorithms
:
public
Type3NasIe
{
public:
N
AS_Security_
Algorithms
();
N
AS_Security_
Algorithms
(
uint8_t
iei
);
N
AS_Security_
Algorithms
(
uint8_t
ciphering
,
uint8_t
integrity_protection
);
N
AS_Security_
Algorithms
(
N
asSecurity
Algorithms
();
N
asSecurity
Algorithms
(
uint8_t
iei
);
N
asSecurity
Algorithms
(
uint8_t
ciphering
,
uint8_t
integrity_protection
);
N
asSecurity
Algorithms
(
uint8_t
iei
,
uint8_t
ciphering
,
uint8_t
integrity_protection
);
~
N
AS_Security_
Algorithms
();
~
N
asSecurity
Algorithms
();
void
SetTypeOfCipheringAlgorithm
(
uint8_t
value
);
uint8_t
GetTypeOfCipheringAlgorithm
()
const
;
...
...
src/nas/ies/Type1NasIe.hpp
View file @
2542778d
...
...
@@ -21,6 +21,7 @@
#ifndef _TYPE1_NAS_IE_H_
#define _TYPE1_NAS_IE_H_
#include "NasIe.hpp"
constexpr
uint8_t
kType1NasIeLength
=
1
;
...
...
src/nas/ies/Type4NasIe.cpp
View file @
2542778d
...
...
@@ -21,10 +21,6 @@
#include "Type4NasIe.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
#include "logger.hpp"
using
namespace
nas
;
//------------------------------------------------------------------------------
Type4NasIe
::
Type4NasIe
()
:
NasIe
()
{
...
...
src/nas/ies/Type4NasIe.hpp
View file @
2542778d
...
...
@@ -21,6 +21,7 @@
#ifndef _TYPE4_NAS_IE_H_
#define _TYPE4_NAS_IE_H_
#include "NasIe.hpp"
namespace
nas
{
...
...
src/nas/ies/UESecurityCapability.cpp
View file @
2542778d
...
...
@@ -21,10 +21,6 @@
#include "UESecurityCapability.hpp"
#include "logger.hpp"
#include "3gpp_24.501.hpp"
#include "common_defs.h"
using
namespace
nas
;
//------------------------------------------------------------------------------
...
...
src/nas/ies/UESecurityCapability.hpp
View file @
2542778d
...
...
@@ -24,8 +24,6 @@
#include "Type4NasIe.hpp"
#include <stdint.h>
constexpr
uint8_t
kUeSecurityCapabilityMinimumLength
=
4
;
constexpr
uint8_t
kUeSecurityCapabilityMaximumLength
=
10
;
constexpr
auto
kUeSecurityCapabilityIeName
=
"UE Security Capability"
;
...
...
src/nas/msgs/AuthenticationRequest.cpp
View file @
2542778d
...
...
@@ -45,8 +45,8 @@ void AuthenticationRequest::setHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
void
AuthenticationRequest
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
.
Set
(
false
);
// 4 lower bits
ie_ngKSI
.
s
etNasKeyIdentifier
(
key_set_id
);
ie_ngKSI
.
s
etTypeOfSecurityContext
(
tsc
);
ie_ngKSI
.
S
etNasKeyIdentifier
(
key_set_id
);
ie_ngKSI
.
S
etTypeOfSecurityContext
(
tsc
);
}
//------------------------------------------------------------------------------
...
...
src/nas/msgs/DeregistrationRequest.cpp
View file @
2542778d
...
...
@@ -87,8 +87,8 @@ void DeregistrationRequest::getDeregistrationType(
//------------------------------------------------------------------------------
bool
DeregistrationRequest
::
getngKSI
(
uint8_t
&
ng_ksi
)
{
if
(
ie_ngKSI
)
{
ng_ksi
=
(
ie_ngKSI
->
g
etTypeOfSecurityContext
())
|
ie_ngKSI
->
g
etNasKeyIdentifier
();
ng_ksi
=
(
ie_ngKSI
->
G
etTypeOfSecurityContext
())
|
ie_ngKSI
->
G
etNasKeyIdentifier
();
return
true
;
}
else
{
// ng_ksi = 0;
...
...
src/nas/msgs/RegistrationRequest.cpp
View file @
2542778d
...
...
@@ -78,14 +78,14 @@ bool RegistrationRequest::get5gsRegistrationType(
//------------------------------------------------------------------------------
void
RegistrationRequest
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
.
Set
(
true
);
// high pos
ie_ngKSI
.
s
etNasKeyIdentifier
(
key_set_id
);
ie_ngKSI
.
s
etTypeOfSecurityContext
(
tsc
);
ie_ngKSI
.
S
etNasKeyIdentifier
(
key_set_id
);
ie_ngKSI
.
S
etTypeOfSecurityContext
(
tsc
);
}
//------------------------------------------------------------------------------
bool
RegistrationRequest
::
getngKSI
(
uint8_t
&
ng_ksi
)
{
ng_ksi
=
(
ie_ngKSI
.
getTypeOfSecurityContext
())
|
ie_ngKSI
.
g
etNasKeyIdentifier
();
(
ie_ngKSI
.
GetTypeOfSecurityContext
())
|
ie_ngKSI
.
G
etNasKeyIdentifier
();
return
true
;
}
...
...
@@ -181,8 +181,8 @@ void RegistrationRequest::setNonCurrentNativeNasKSI(
bool
RegistrationRequest
::
getNonCurrentNativeNasKSI
(
uint8_t
&
value
)
const
{
if
(
ie_non_current_native_nas_ksi
.
has_value
())
{
value
|=
(
ie_non_current_native_nas_ksi
.
value
().
g
etTypeOfSecurityContext
())
|
(
ie_non_current_native_nas_ksi
.
value
().
g
etNasKeyIdentifier
());
(
ie_non_current_native_nas_ksi
.
value
().
G
etTypeOfSecurityContext
())
|
(
ie_non_current_native_nas_ksi
.
value
().
G
etNasKeyIdentifier
());
return
true
;
}
else
{
return
false
;
...
...
src/nas/msgs/SecurityModeCommand.cpp
View file @
2542778d
...
...
@@ -19,13 +19,6 @@
* contact@openairinterface.org
*/
/*! \file
\brief
\author Keliang DU, BUPT
\date 2020
\email: contact@openairinterface.org
*/
#include "SecurityModeCommand.hpp"
#include "3gpp_24.501.hpp"
...
...
@@ -60,8 +53,8 @@ void SecurityModeCommand::setNAS_Security_Algorithms(
//------------------------------------------------------------------------------
void
SecurityModeCommand
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
.
s
etTypeOfSecurityContext
(
tsc
);
ie_ngKSI
.
s
etNasKeyIdentifier
(
key_set_id
);
ie_ngKSI
.
S
etTypeOfSecurityContext
(
tsc
);
ie_ngKSI
.
S
etNasKeyIdentifier
(
key_set_id
);
}
//------------------------------------------------------------------------------
...
...
@@ -238,8 +231,7 @@ int SecurityModeCommand::Encode(uint8_t* buf, int len) {
}
//------------------------------------------------------------------------------
int
SecurityModeCommand
::
Decode
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
)
{
int
SecurityModeCommand
::
Decode
(
uint8_t
*
buf
,
int
len
)
{
Logger
::
nas_mm
().
debug
(
"Decoding SecurityModeCommand message"
);
int
decoded_size
=
0
;
int
decoded_result
=
0
;
...
...
@@ -360,5 +352,5 @@ int SecurityModeCommand::Decode(
}
Logger
::
nas_mm
().
debug
(
"Decoded SecurityModeCommand message len (%d)"
,
decoded_size
);
return
1
;
return
decoded_size
;
}
src/nas/msgs/SecurityModeCommand.hpp
View file @
2542778d
...
...
@@ -34,33 +34,42 @@ class SecurityModeCommand : public NasMmPlainHeader {
void
setHeader
(
uint8_t
security_header_type
);
int
Encode
(
uint8_t
*
buf
,
int
len
);
int
Decode
(
NasMmPlainHeader
*
header
,
uint8_t
*
buf
,
int
len
);
int
Decode
(
uint8_t
*
buf
,
int
len
);
void
setNAS_Security_Algorithms
(
uint8_t
ciphering
,
uint8_t
integrity
);
// TODO: Get
void
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
);
// TODO: Get
void
setUE_Security_Capability
(
uint8_t
g_EASel
,
uint8_t
g_IASel
);
// TODO: Get
void
setUE_Security_Capability
(
uint8_t
g_EASel
,
uint8_t
g_IASel
,
uint8_t
eea
,
uint8_t
eia
);
// TODO: Get
void
setIMEISV_Request
(
uint8_t
value
);
// TODO: Get
void
setEPS_NAS_Security_Algorithms
(
uint8_t
ciphering
,
uint8_t
integrity
);
// TODO: Get
void
setAdditional_5G_Security_Information
(
bool
rinmr
,
bool
hdp
);
// TODO: Get
void
SetEapMessage
(
bstring
eap
);
// TODO: Get
void
setABBA
(
uint8_t
length
,
uint8_t
*
value
);
// TODO: Get
void
setS1_UE_Security_Capability
(
uint8_t
g_EEASel
,
uint8_t
g_EIASel
);
// TODO: Get
public:
N
AS_Security_
Algorithms
ie_selected_nas_security_algorithms
;
// Mandatory
NasKeySetIdentifier
ie_ngKSI
;
// Mandatory
UESecurityCapability
ie_ue_security_capability
;
// Mandatory
N
asSecurity
Algorithms
ie_selected_nas_security_algorithms
;
// Mandatory
NasKeySetIdentifier
ie_ngKSI
;
// Mandatory
UESecurityCapability
ie_ue_security_capability
;
// Mandatory
std
::
optional
<
IMEISV_Request
>
ie_imeisv_request
;
// Optional
std
::
optional
<
EPS_NAS_Security_Algorithms
>
...
...
src/nas/msgs/ServiceRequest.cpp
View file @
2542778d
...
...
@@ -249,8 +249,8 @@ int ServiceRequest::Decode(NasMmPlainHeader* header, uint8_t* buf, int len) {
//------------------------------------------------------------------------------
bool
ServiceRequest
::
getngKSI
(
uint8_t
&
ng_ksi
)
{
if
(
ie_ngKSI
)
{
ng_ksi
=
(
ie_ngKSI
->
g
etTypeOfSecurityContext
())
|
ie_ngKSI
->
g
etNasKeyIdentifier
();
ng_ksi
=
(
ie_ngKSI
->
G
etTypeOfSecurityContext
())
|
ie_ngKSI
->
G
etNasKeyIdentifier
();
return
true
;
}
else
{
return
false
;
...
...
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