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
e8f7150e
Commit
e8f7150e
authored
Jan 03, 2023
by
Tien Thinh NGUYEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update NasKeySetIdentifier
parent
df2aabcf
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
139 additions
and
76 deletions
+139
-76
src/nas/ies/5GSMobileIdentity.cpp
src/nas/ies/5GSMobileIdentity.cpp
+23
-3
src/nas/ies/5GSMobileIdentity.hpp
src/nas/ies/5GSMobileIdentity.hpp
+7
-1
src/nas/ies/NasKeySetIdentifier.cpp
src/nas/ies/NasKeySetIdentifier.cpp
+35
-20
src/nas/ies/NasKeySetIdentifier.hpp
src/nas/ies/NasKeySetIdentifier.hpp
+23
-10
src/nas/msgs/AuthenticationRequest.cpp
src/nas/msgs/AuthenticationRequest.cpp
+9
-6
src/nas/msgs/AuthenticationResult.cpp
src/nas/msgs/AuthenticationResult.cpp
+9
-8
src/nas/msgs/DeregistrationRequest.cpp
src/nas/msgs/DeregistrationRequest.cpp
+8
-5
src/nas/msgs/RegistrationRequest.cpp
src/nas/msgs/RegistrationRequest.cpp
+11
-10
src/nas/msgs/SecurityModeCommand.cpp
src/nas/msgs/SecurityModeCommand.cpp
+7
-7
src/nas/msgs/ServiceRequest.cpp
src/nas/msgs/ServiceRequest.cpp
+7
-6
No files found.
src/nas/ies/5GSMobileIdentity.cpp
View file @
e8f7150e
...
...
@@ -283,7 +283,7 @@ int _5GSMobileIdentity::suci_encode2buffer(uint8_t* buf, int len) {
if
(
!
supi_format_imsi
.
has_value
())
return
KEncodeDecodeError
;
if
(
len
<
length
)
{
Logger
::
nas_mm
().
debug
(
"
e
rror: len is less than %d"
,
length
);
Logger
::
nas_mm
().
debug
(
"
E
rror: len is less than %d"
,
length
);
return
KEncodeDecodeError
;
}
...
...
@@ -317,6 +317,26 @@ int _5GSMobileIdentity::suci_encode2buffer(uint8_t* buf, int len) {
buf
+
encoded_size
,
supi_format_imsi
.
value
().
homeNetworkPKI
,
encoded_size
);
// MSIN
std
::
string
msin
=
{};
uint8_t
digit_low
=
0
;
uint8_t
digit_high
=
0
;
for
(
int
i
=
0
;
i
<
supi_format_imsi
.
value
().
msin
.
length
()
/
2
;
i
++
)
{
conv
::
string_to_int8
(
supi_format_imsi
.
value
().
msin
.
substr
(
i
,
1
),
digit_low
);
conv
::
string_to_int8
(
supi_format_imsi
.
value
().
msin
.
substr
(
i
+
1
,
1
),
digit_high
);
uint8_t
octet
=
(
0xf0
&
(
digit_high
<<
4
))
|
(
digit_low
&
0x0f
);
ENCODE_U8
(
buf
+
encoded_size
,
octet
,
encoded_size
);
}
if
(
supi_format_imsi
.
value
().
msin
.
length
()
%
2
!=
0
)
{
conv
::
string_to_int8
(
supi_format_imsi
.
value
().
msin
.
substr
(
supi_format_imsi
.
value
().
msin
.
length
()
-
1
,
1
),
digit_low
);
uint8_t
octet
=
0xf0
|
(
digit_low
&
0x0f
);
ENCODE_U8
(
buf
+
encoded_size
,
octet
,
encoded_size
);
}
// Encode Length
int
encoded_len_ie
=
0
;
if
(
!
iei
)
{
...
...
@@ -708,8 +728,8 @@ int _5GSMobileIdentity::_5g_guti_decodefrombuffer(uint8_t* buf, int len) {
tmp
.
amf_set_id
=
octet
<<
2
;
// 8 most significant bits
DECODE_U8
(
buf
+
decoded_size
,
octet
,
decoded_size
);
tmp
.
amf_set_id
|=
((
octet
&
0xc0
)
>>
6
);
// 2 most significant bits of this octet
// as 2 lest significant bits of AMF Set ID
((
octet
&
0xc0
)
>>
6
);
// 2 most significant bits of this octet
// as 2 lest significant bits of AMF Set ID
tmp
.
amf_pointer
=
octet
&
0x3f
;
// 6 lest significant bits
// TMSI, 4 octets
...
...
src/nas/ies/5GSMobileIdentity.hpp
View file @
e8f7150e
...
...
@@ -53,7 +53,12 @@ typedef struct IMEI_or_IMEISV_s {
std
::
string
identity
;
// "46011000001"
}
IMEI_IMEISV_t
;
// SUCI and SUPI format IMSI
// TODO:
// 5GS mobile identity information element for type of identity "SUCI" and SUPI
// format "IMSI"
// SUCI and SUPI format IMSI and
// Protection scheme Id "Null scheme"
typedef
struct
SUCI_imsi_s
{
uint8_t
supi_format
:
3
;
std
::
string
mcc
;
...
...
@@ -65,6 +70,7 @@ typedef struct SUCI_imsi_s {
}
SUCI_imsi_t
;
// SUPI format "IMSI"
// TODO: SUCI and SUPI format "Network specific identifier"
// 5G-S-TMSI
typedef
struct
_5G_S_TMSI_s
{
uint16_t
amf_set_id
;
...
...
src/nas/ies/NasKeySetIdentifier.cpp
View file @
e8f7150e
...
...
@@ -28,30 +28,52 @@
using
namespace
nas
;
//------------------------------------------------------------------------------
NasKeySetIdentifier
::
NasKeySetIdentifier
()
{}
NasKeySetIdentifier
::
NasKeySetIdentifier
()
:
Type1NasIe
(),
tsc_
(
false
),
key_id_
()
{}
//------------------------------------------------------------------------------
NasKeySetIdentifier
::
NasKeySetIdentifier
(
const
uint8_t
&
iei
,
const
uint8_t
&
tsc
,
const
uint8_t
&
key_id
)
{
iei_
=
iei
;
const
uint8_t
&
iei
,
const
bool
&
tsc
,
const
uint8_t
&
key_id
)
:
Type1NasIe
(
iei
)
{
tsc_
=
0x01
&
tsc
;
key_id_
=
0x07
&
key_id
;
SetValue
();
SetIeName
(
kNasKeySetIdentifierName
);
}
//------------------------------------------------------------------------------
NasKeySetIdentifier
::
NasKeySetIdentifier
(
const
uint8_t
&
tsc
,
const
uint8_t
&
key_id
)
{
iei_
=
0
;
NasKeySetIdentifier
::
NasKeySetIdentifier
(
const
bool
&
tsc
,
const
uint8_t
&
key_id
)
:
Type1NasIe
(
false
)
{
tsc_
=
0x01
&
tsc
;
key_id_
=
0x07
&
key_id
;
SetValue
();
SetIeName
(
kNasKeySetIdentifierName
);
}
//------------------------------------------------------------------------------
NasKeySetIdentifier
::~
NasKeySetIdentifier
(){};
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
Set
(
const
bool
&
high_pos
)
{
Type1NasIe
::
Set
(
high_pos
);
}
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
SetValue
()
{
if
(
tsc_
)
value_
=
0b1000
|
(
0x07
&
key_id_
);
else
value_
=
0x07
&
key_id_
;
}
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
GetValue
()
{
tsc_
=
(
0b1000
&
value_
)
>>
3
;
key_id_
=
value_
&
0b00000111
;
}
/*
//------------------------------------------------------------------------------
int NasKeySetIdentifier::encode2Buffer(uint8_t* buf, const int& len) {
Logger
::
nas_mm
().
debug
(
"Encoding NasKeySetIdentifier IE
(IEI 0x%x)"
,
iei_
);
Logger::nas_mm().debug("Encoding NasKeySetIdentifier IE
"
);
if (len < kType1IeSize) {
Logger::nas_mm().error(
"Buffer length is less than the minimum length of this IE (%d octet)",
...
...
@@ -61,14 +83,6 @@ int NasKeySetIdentifier::encode2Buffer(uint8_t* buf, const int& len) {
uint8_t octet = 0;
uint32_t encoded_size = 0;
if
(
!
(
iei_
&
0x0f
))
{
octet
=
(
0x0f
)
&
((
tsc_
<<
3
)
|
key_id_
);
ENCODE_U8
(
buf
,
octet
,
encoded_size
);
}
else
{
octet
=
(
iei_
<<
4
)
|
(
tsc_
<<
3
)
|
key_id_
;
ENCODE_U8
(
buf
,
octet
,
encoded_size
);
}
Logger::nas_mm().debug(
"Encoded NasKeySetIdentifier IE (TSC 0x%x, Key_id 0x%x)", tsc_, key_id_);
return encoded_size;
...
...
@@ -90,9 +104,9 @@ int NasKeySetIdentifier::decodeFromBuffer(
DECODE_U8(buf, octet, decoded_size);
if (is_option) {
iei_
=
(
octet
&
0xf0
)
>>
4
;
//
iei_ = (octet & 0xf0) >> 4;
} else {
iei_
=
0
;
//
iei_ = 0;
}
if (!is_high) {
...
...
@@ -110,10 +124,11 @@ int NasKeySetIdentifier::decodeFromBuffer(
else
return 0; // 1/2 octet
}
*/
//------------------------------------------------------------------------------
void
NasKeySetIdentifier
::
setTypeOfSecurityContext
(
const
uint8_t
&
type
)
{
tsc_
=
0x01
&
type
;
void
NasKeySetIdentifier
::
setTypeOfSecurityContext
(
const
bool
&
type
)
{
tsc_
=
type
;
}
//------------------------------------------------------------------------------
...
...
@@ -122,7 +137,7 @@ void NasKeySetIdentifier::setNasKeyIdentifier(const uint8_t& id) {
}
//------------------------------------------------------------------------------
uint8_t
NasKeySetIdentifier
::
getTypeOfSecurityContext
()
const
{
bool
NasKeySetIdentifier
::
getTypeOfSecurityContext
()
const
{
return
tsc_
;
}
...
...
src/nas/ies/NasKeySetIdentifier.hpp
View file @
e8f7150e
...
...
@@ -22,30 +22,43 @@
#ifndef _NAS_KEY_SET_IDENTIFIER_H
#define _NAS_KEY_SET_IDENTIFIER_H
#include "Type1NasIe.hpp"
#include <stdint.h>
constexpr
auto
kNasKeySetIdentifierName
=
"NAS Key Set Identifier"
;
namespace
nas
{
class
NasKeySetIdentifier
{
class
NasKeySetIdentifier
:
public
Type1NasIe
{
public:
NasKeySetIdentifier
();
NasKeySetIdentifier
(
const
uint8_t
&
iei
,
const
uint8_t
&
tsc
,
const
uint8_t
&
key_id
);
NasKeySetIdentifier
(
const
uint8_t
&
tsc
,
const
uint8_t
&
key_id
);
const
uint8_t
&
iei
,
const
bool
&
tsc
,
const
uint8_t
&
key_id
);
NasKeySetIdentifier
(
const
bool
&
tsc
,
const
uint8_t
&
key_id
);
// Default: low position
~
NasKeySetIdentifier
();
int
encode2Buffer
(
uint8_t
*
buf
,
const
int
&
len
);
int
decodeFromBuffer
(
uint8_t
*
buf
,
const
int
&
len
,
bool
is_option
,
bool
is_high
);
void
Set
(
const
bool
&
high_pos
);
// void Set(const bool& tsc, const uint8_t& key_id);
// void Set(const bool& tsc, const uint8_t& key_id, const uint8_t& iei);
void
Get
(
bool
&
tsc
,
uint8_t
&
key_id
);
// int encode2Buffer(uint8_t* buf, const int& len);
// int decodeFromBuffer(
// uint8_t* buf, const int& len, bool is_option, bool is_high);
void
setTypeOfSecurityContext
(
const
bool
&
type
);
bool
getTypeOfSecurityContext
()
const
;
void
setTypeOfSecurityContext
(
const
uint8_t
&
type
);
void
setNasKeyIdentifier
(
const
uint8_t
&
id
);
uint8_t
getTypeOfSecurityContext
()
const
;
uint8_t
getNasKeyIdentifier
()
const
;
private:
uint8_t
iei_
;
uint8_t
tsc_
;
void
SetValue
()
override
;
void
GetValue
()
override
;
// uint8_t iei_;
bool
tsc_
;
uint8_t
key_id_
;
};
...
...
src/nas/msgs/AuthenticationRequest.cpp
View file @
e8f7150e
...
...
@@ -55,7 +55,7 @@ void AuthenticationRequest::setHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
void
AuthenticationRequest
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
=
new
NasKeySetIdentifier
(
0x00
,
tsc
,
key_set_id
);
ie_ngKSI
=
new
NasKeySetIdentifier
(
tsc
,
key_set_id
);
}
//------------------------------------------------------------------------------
...
...
@@ -93,13 +93,15 @@ int AuthenticationRequest::encode2Buffer(uint8_t* buf, int len) {
if
(
!
ie_ngKSI
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_ngKSI is not available"
);
}
else
{
int
size
=
ie_ngKSI
->
encode2Buffer
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
!=
-
1
)
{
int
size
=
ie_ngKSI
->
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
);
if
(
size
!=
KEncodeDecodeError
)
{
encoded_size
+=
size
;
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding ie_ngKSI error"
);
return
0
;
}
// Spare half octet
encoded_size
++
;
// 1/2 octet + 1/2 octet from ie_ngKSI
}
if
(
!
ie_abba
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_abba is not available"
);
...
...
@@ -166,9 +168,10 @@ int AuthenticationRequest::decodeFromBuffer(
int
decoded_size
=
3
;
plain_header
=
header
;
ie_ngKSI
=
new
NasKeySetIdentifier
();
decoded_size
+=
ie_ngKSI
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
decoded_size
++
;
decoded_size
+=
ie_ngKSI
->
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
// length 1/2, low position
decoded_size
++
;
// 1/2 octet from ie_ngKSI, 1/2 from Spare half octet
ie_abba
=
new
ABBA
();
decoded_size
+=
ie_abba
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
...
...
src/nas/msgs/AuthenticationResult.cpp
View file @
e8f7150e
...
...
@@ -53,7 +53,7 @@ void AuthenticationResult::setHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
void
AuthenticationResult
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
=
new
NasKeySetIdentifier
(
0x00
,
tsc
,
key_set_id
);
ie_ngKSI
=
new
NasKeySetIdentifier
(
tsc
,
key_set_id
);
}
//------------------------------------------------------------------------------
...
...
@@ -79,13 +79,13 @@ int AuthenticationResult::encode2Buffer(uint8_t* buf, int len) {
if
(
!
ie_ngKSI
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_ngKSI is not available"
);
}
else
{
if
(
int
size
=
ie_ngKSI
->
encode2Buffer
(
buf
+
encoded_size
,
len
-
encoded_size
))
{
encoded_size
+=
size
;
}
else
{
if
(
int
size
=
ie_ngKSI
->
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
)
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encoding ie_ngKSI error"
);
return
0
;
}
// Spare half octet
encoded_size
++
;
// 1/2 octet + 1/2 octet from ie_ngKSI
}
if
(
!
ie_eap_message
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_eap_message is not available"
);
...
...
@@ -121,9 +121,10 @@ int AuthenticationResult::decodeFromBuffer(
int
decoded_size
=
3
;
plain_header
=
header
;
ie_ngKSI
=
new
NasKeySetIdentifier
();
decoded_size
+=
ie_ngKSI
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
decoded_size
++
;
decoded_size
+=
ie_ngKSI
->
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
// length 1/2, low position
decoded_size
++
;
// 1/2 octet from ie_ngKSI, 1/2 from Spare half octet
ie_eap_message
=
new
EAP_Message
();
decoded_size
+=
ie_eap_message
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
...
...
src/nas/msgs/DeregistrationRequest.cpp
View file @
e8f7150e
...
...
@@ -70,6 +70,7 @@ void DeregistrationRequest::setDeregistrationType(
//------------------------------------------------------------------------------
void
DeregistrationRequest
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
=
new
NasKeySetIdentifier
(
tsc
,
key_set_id
);
ie_ngKSI
->
Set
(
true
);
// high position
}
//------------------------------------------------------------------------------
...
...
@@ -187,8 +188,9 @@ int DeregistrationRequest::encode2Buffer(uint8_t* buf, int len) {
encoded_size
+=
3
;
if
(
!
(
ie_deregistrationtype
->
encode2Buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)))
{
if
(
!
(
ie_ngKSI
->
encode2Buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)))
{
encoded_size
+=
1
;
if
(
ie_ngKSI
->
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
)
!=
KEncodeDecodeError
)
{
encoded_size
+=
1
;
// 1/2 octet for Deregistration Request, 1/2 for ngKSI
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_ngKSI error"
);
return
0
;
...
...
@@ -220,9 +222,10 @@ int DeregistrationRequest::decodeFromBuffer(
decoded_size
+=
ie_deregistrationtype
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
);
ie_ngKSI
=
new
NasKeySetIdentifier
();
decoded_size
+=
ie_ngKSI
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
true
);
decoded_size
++
;
decoded_size
+=
ie_ngKSI
->
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
,
false
);
// High position, 1/2 octet
decoded_size
++
;
// 1/2 octet for Deregistration type, 1/2 for ngKSI
ie_5gs_mobility_id
=
new
_5GSMobileIdentity
();
decoded_size
+=
ie_5gs_mobility_id
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
...
...
src/nas/msgs/RegistrationRequest.cpp
View file @
e8f7150e
...
...
@@ -77,6 +77,7 @@ bool RegistrationRequest::get5GSRegistrationType(
//------------------------------------------------------------------------------
void
RegistrationRequest
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
.
Set
(
true
);
// high pos
ie_ngKSI
.
setNasKeyIdentifier
(
key_set_id
);
ie_ngKSI
.
setTypeOfSecurityContext
(
tsc
);
}
...
...
@@ -172,8 +173,8 @@ void RegistrationRequest::set5G_S_TMSI() {}
//------------------------------------------------------------------------------
void
RegistrationRequest
::
setNonCurrentNativeNasKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_non_current_native_nas_ksi
=
std
::
make_optional
<
NasKeySetIdentifier
>
(
0xC
,
tsc
,
key_set_id
);
ie_non_current_native_nas_ksi
=
std
::
make_optional
<
NasKeySetIdentifier
>
(
0xC
,
tsc
,
key_set_id
);
// TODO: remove hardcoded value
}
//------------------------------------------------------------------------------
...
...
@@ -555,7 +556,7 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) {
return
KEncodeDecodeError
;
}
// ngKSI
if
((
encoded_ie_size
=
ie_ngKSI
.
encode2Buffer
(
if
((
encoded_ie_size
=
ie_ngKSI
.
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encoding IE ie_ngKSI error"
);
return
KEncodeDecodeError
;
...
...
@@ -576,7 +577,7 @@ int RegistrationRequest::encode2Buffer(uint8_t* buf, int len) {
Logger
::
nas_mm
().
warn
(
"IE Non-current native NAS key set identifier is not available"
);
}
else
{
if
((
encoded_ie_size
=
ie_non_current_native_nas_ksi
.
value
().
encode2Buffer
(
if
((
encoded_ie_size
=
ie_non_current_native_nas_ksi
.
value
().
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
))
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encoding IE Non-current native NAS key set identifier error"
);
...
...
@@ -844,9 +845,10 @@ int RegistrationRequest::decodeFromBuffer(uint8_t* buf, int len) {
// ie_5gsregistrationtype = new _5GSRegistrationType();
decoded_size
+=
ie_5gsregistrationtype
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
decoded_size
+=
ie_ngKSI
.
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
true
);
decoded_size
++
;
decoded_size
+=
ie_ngKSI
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
,
false
);
// high, 1/2 octet
decoded_size
++
;
// 1/2 octet for ie_5gsregistrationtype, 1/2 octet for
// ie_ngKSI
decoded_size
+=
ie_5gs_mobile_identity
.
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
uint8_t
octet
=
*
(
buf
+
decoded_size
);
...
...
@@ -856,9 +858,8 @@ int RegistrationRequest::decodeFromBuffer(uint8_t* buf, int len) {
case
0xC
:
{
Logger
::
nas_mm
().
debug
(
"Decoding IEI(0xC)"
);
NasKeySetIdentifier
ie_non_current_native_nas_ksi_tmp
=
{};
if
((
decoded_result
=
ie_non_current_native_nas_ksi_tmp
.
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
true
,
false
))
<=
0
)
if
((
decoded_result
=
ie_non_current_native_nas_ksi_tmp
.
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
true
))
<=
0
)
return
decoded_result
;
ie_non_current_native_nas_ksi
=
std
::
optional
<
NasKeySetIdentifier
>
(
ie_non_current_native_nas_ksi_tmp
);
...
...
src/nas/msgs/SecurityModeCommand.cpp
View file @
e8f7150e
...
...
@@ -66,7 +66,7 @@ void SecurityModeCommand::setNAS_Security_Algorithms(
//------------------------------------------------------------------------------
void
SecurityModeCommand
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
=
new
NasKeySetIdentifier
(
0x00
,
tsc
,
key_set_id
);
ie_ngKSI
=
new
NasKeySetIdentifier
(
tsc
,
key_set_id
);
}
//------------------------------------------------------------------------------
...
...
@@ -144,13 +144,12 @@ int SecurityModeCommand::encode2Buffer(uint8_t* buf, int len) {
if
(
!
ie_ngKSI
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_ngKSI is not available"
);
}
else
{
if
(
int
size
=
ie_ngKSI
->
encode2Buffer
(
buf
+
encoded_size
,
len
-
encoded_size
))
{
encoded_size
+=
size
;
}
else
{
if
(
int
size
=
ie_ngKSI
->
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
)
==
KEncodeDecodeError
)
{
Logger
::
nas_mm
().
error
(
"Encoding ie_ngKSI error"
);
return
0
;
}
encoded_size
++
;
// 1/2 octet for ngKSI, 1/2 for Spare half octet
}
if
(
!
ie_ue_security_capability
)
{
Logger
::
nas_mm
().
warn
(
"IE ie_ue_security_capability is not available"
);
...
...
@@ -246,8 +245,9 @@ int SecurityModeCommand::decodeFromBuffer(
decoded_size
+=
ie_selected_nas_security_algorithms
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
ie_ngKSI
=
new
NasKeySetIdentifier
();
decoded_size
+=
ie_ngKSI
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
decoded_size
+=
ie_ngKSI
->
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
decoded_size
++
;
// 1/2 octet for ngKSI, 1/2 for Spare half octet
ie_ue_security_capability
=
new
UESecurityCapability
();
decoded_size
+=
ie_ue_security_capability
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
);
...
...
src/nas/msgs/ServiceRequest.cpp
View file @
e8f7150e
...
...
@@ -57,7 +57,7 @@ void ServiceRequest::setHeader(uint8_t security_header_type) {
//------------------------------------------------------------------------------
void
ServiceRequest
::
setngKSI
(
uint8_t
tsc
,
uint8_t
key_set_id
)
{
ie_ngKSI
=
new
NasKeySetIdentifier
(
0x00
,
tsc
,
key_set_id
);
ie_ngKSI
=
new
NasKeySetIdentifier
(
tsc
,
key_set_id
);
}
//------------------------------------------------------------------------------
...
...
@@ -114,10 +114,11 @@ int ServiceRequest::encode2Buffer(uint8_t* buf, int len) {
}
if
(
!
(
plain_header
->
encode2Buffer
(
buf
,
len
)))
return
0
;
encoded_size
+=
3
;
if
(
ie_ngKSI
->
encode2Buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)
!=
-
1
)
{
if
(
ie_ngKSI
->
Encode
(
buf
+
encoded_size
,
len
-
encoded_size
)
!=
KEncodeDecodeError
)
{
if
(
ie_service_type
->
encode2Buffer
(
buf
+
encoded_size
,
len
-
encoded_size
)
!=
-
1
)
{
encoded_size
++
;
encoded_size
++
;
// 1/2 octet for ngKSI, 1/2 for Service Type
}
else
{
Logger
::
nas_mm
().
error
(
"Encoding ie_service_type error"
);
return
0
;
...
...
@@ -193,12 +194,12 @@ int ServiceRequest::decodeFromBuffer(
int
decoded_size
=
3
;
plain_header
=
header
;
ie_ngKSI
=
new
NasKeySetIdentifier
();
decoded_size
+=
ie_ngKSI
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
decoded_size
+=
ie_ngKSI
->
Decode
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
false
);
ie_service_type
=
new
ServiceType
();
decoded_size
+=
ie_service_type
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
false
,
true
);
decoded_size
++
;
decoded_size
++
;
// 1/2 octet for ngKSI, 1/2 for Service Type
ie_5g_s_tmsi
=
new
_5GSMobileIdentity
();
decoded_size
+=
ie_5g_s_tmsi
->
decodeFromBuffer
(
buf
+
decoded_size
,
len
-
decoded_size
,
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