Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
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
lizhongxiao
OpenXG-RAN
Commits
f8219745
Commit
f8219745
authored
Jul 14, 2023
by
Anatolii Pankevych
Committed by
Jerome Peraldi
Aug 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugz #125253: add AS Data Plane security: TC 7.1.3.2.x and 7.1.3.3.x
parent
542bcfb4
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
378 additions
and
202 deletions
+378
-202
ci-scripts/conf_files/3GPP_System_Simulator/SS_proxy_gnb.band78_1CC.sa.fr1.106PRB.usrpn310.conf
...lator/SS_proxy_gnb.band78_1CC.sa.fr1.106PRB.usrpn310.conf
+2
-1
ci-scripts/conf_files/3GPP_System_Simulator/SS_proxy_nr-ue.nfapi.conf
...onf_files/3GPP_System_Simulator/SS_proxy_nr-ue.nfapi.conf
+1
-3
common/ran_context.h
common/ran_context.h
+14
-0
openair2/COMMON/rrc_messages_types.h
openair2/COMMON/rrc_messages_types.h
+2
-0
openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c
openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c
+13
-7
openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h
openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h
+1
-1
openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
+96
-24
openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
+9
-6
openair2/RRC/NR/rrc_gNB.c
openair2/RRC/NR/rrc_gNB.c
+23
-14
openair2/RRC/NR_UE/rrc_UE.c
openair2/RRC/NR_UE/rrc_UE.c
+2
-2
openair3/NAS/NR_UE/nr_nas_msg_sim.c
openair3/NAS/NR_UE/nr_nas_msg_sim.c
+42
-48
openair3/SS/ss_gNB_drb_task.c
openair3/SS/ss_gNB_drb_task.c
+156
-91
openair3/SS/ss_gNB_srb_task.c
openair3/SS/ss_gNB_srb_task.c
+2
-2
openair3/SS/ss_gNB_sys_task.c
openair3/SS/ss_gNB_sys_task.c
+15
-3
No files found.
ci-scripts/conf_files/3GPP_System_Simulator/SS_proxy_gnb.band78_1CC.sa.fr1.106PRB.usrpn310.conf
View file @
f8219745
...
...
@@ -260,6 +260,7 @@ security = {
# rlc_log_level ="info";
# pdcp_log_level ="info";
# rrc_log_level ="info";
# ngap_log_level ="debug";
# nr_rrc_log_level ="info";
# ngap_log_level ="debug";
};
ci-scripts/conf_files/3GPP_System_Simulator/SS_proxy_nr-ue.nfapi.conf
View file @
f8219745
...
...
@@ -5,9 +5,7 @@ log_config = {
mac_log_level
=
"error"
;
nr_mac_log_level
=
"error"
;
rlc_log_level
=
"info"
;
nr_rlc_log_level
=
"info"
;
pdcp_log_level
=
"debug"
;
nr_pdcp_log_level
=
"debug"
;
pdcp_log_level
=
"info"
;
rrc_log_level
=
"info"
;
nr_rrc_log_level
=
"info"
;
};
...
...
common/ran_context.h
View file @
f8219745
...
...
@@ -39,6 +39,18 @@
#include "radio/SS/ss_config.h"
#include "RRC/NR/nr_rrc_defs.h"
// Used for loopback message routing in DRB-specific TC's
typedef
enum
{
DRB_MacPdu
=
0
,
DRB_RlcPdu
,
DRB_RlcSdu
,
DRB_PdcpPdu
,
DRB_PdcpSdu
,
DRB_SdapPdu
,
DRB_SdapSdu
,
DRB_data_type_qty
}
nr_drb_data_t
;
// forward declarations to avoid including the full typess ***eNB;
struct
PHY_VARS_gNB_s
;
struct
PHY_VARS_eNB_NB_IoT_s
;
...
...
@@ -133,6 +145,8 @@ typedef struct {
struct
ss_config_s
ss
;
// Variable to store Transaction ID for SS in case of RRCReconfiguration
long
rrc_Transaction_Identifier
;
// Loopback mode can operate on either sdap, pdcp or rlc
nr_drb_data_t
nr_drb_data_type
;
RBConfig
RB_Config
[
MAX_NUM_CCs
][
MAX_RBS
];
NRRBConfig
NR_RB_Config
[
MAX_NUM_CCs
][
MAX_NR_RBS
];
}
RAN_CONTEXT_t
;
...
...
openair2/COMMON/rrc_messages_types.h
View file @
f8219745
...
...
@@ -153,6 +153,8 @@ typedef struct SecurityActTimeList_s {
typedef
struct
AS_IntegrityInfo_s
{
e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm
integrity_algorithm
;
uint8_t
*
kRRCint
;
bool
isUPIntegrityInfoPresent
;
uint8_t
*
kUPint
;
SecurityActTimeList
ActTimeList
;
}
AS_IntegrityInfo
;
...
...
openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c
View file @
f8219745
...
...
@@ -31,6 +31,8 @@
#include "nr_pdcp_integrity_nia1.h"
#include "nr_pdcp_sdu.h"
#include "MAC/mac.h" // for DCCH
#include "LOG/log.h"
// 2DO: REMOVE, FOR DEBUG PURPOSES ONLY
#include "nr_pdcp_security.h"
...
...
@@ -93,7 +95,6 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
entity
->
stats
.
rxpdu_dd_pkts
++
;
entity
->
stats
.
rxpdu_dd_bytes
+=
size
;
return
;
}
...
...
@@ -116,7 +117,8 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
if
(
entity
->
has_ciphering
)
{
if
(
entity
->
has_ciphering
==
NR_PDCP_ENTITY_CIPHERING_SMC
)
{
// 3GPP TS 33.501 6.7.4, Security Mode Command is on SRB1
if
(
entity
->
type
==
NR_PDCP_SRB
&&
entity
->
rb_id
==
DCCH
&&
entity
->
has_ciphering
==
NR_PDCP_ENTITY_CIPHERING_SMC
)
{
LOG_I
(
PDCP
,
"%s: Skip deciphering during Security Mode Command
\n
"
,
__FUNCTION__
);
}
else
{
LOG_I
(
PDCP
,
"%s: Deciphering...
\n
"
,
__FUNCTION__
);
...
...
@@ -206,7 +208,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity,
FNOUT
;
}
// RRC to PDCP
// RRC
/SDAP
to PDCP
static
void
nr_pdcp_entity_recv_sdu
(
nr_pdcp_entity_t
*
entity
,
char
*
buffer
,
int
size
,
int
sdu_id
)
{
...
...
@@ -256,7 +258,8 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity,
LOG_I
(
PDCP
,
"Entity security status (%d): ciphering %d, integrity check %d
\n
"
,
entity
->
has_ciphering
,
entity
->
has_ciphering
?
entity
->
ciphering_algorithm
:-
1
,
entity
->
has_integrity
?
entity
->
integrity_algorithm
:-
1
);
if
(
entity
->
has_integrity
){
if
(
entity
->
has_integrity
)
{
uint8_t
integrity
[
4
]
=
{
0
};
LOG_I
(
PDCP
,
"%s: Integrity protection...
\n
"
,
__FUNCTION__
);
LOG_MSG
(
buf
,
header_size
+
size
,
"rbid=%d cnt=%d dir=%d, buffer(%d): "
,
entity
->
rb_id
,
count
,
entity
->
is_gnb
?
1
:
0
,
header_size
+
size
);
...
...
@@ -270,13 +273,14 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity,
memcpy
((
unsigned
char
*
)
buf
+
header_size
+
size
,
integrity
,
4
);
}
else
if
(
integrity_size
==
4
)
{
// set MAC-I to 0 for SRBs with integrity not active
// set MAC-I to 0 for SRBs with integrity not active
memset
(
buf
+
header_size
+
size
,
0
,
4
);
}
if
(
entity
->
has_ciphering
)
{
if
(
entity
->
has_ciphering
==
NR_PDCP_ENTITY_CIPHERING_SMC
)
{
// 3GPP TS 33.501 6.7.4, Security Mode Command is on SRB1
if
(
entity
->
type
==
NR_PDCP_SRB
&&
entity
->
rb_id
==
DCCH
&&
entity
->
has_ciphering
==
NR_PDCP_ENTITY_CIPHERING_SMC
)
{
/* 3GPP TS 33.501, 6.7.4: RRC DL ciphering @gNB shall start after sending the AS security mode command message */
LOG_I
(
PDCP
,
"%s: Skip ciphering during Security Mode Command
\n
"
,
__FUNCTION__
);
if
(
!
entity
->
is_gnb
&&
count
>
0
)
{
...
...
@@ -376,7 +380,9 @@ static void nr_pdcp_entity_set_security(nr_pdcp_entity_t *entity,
}
if
(
ciphering_algorithm
!=
0
&&
ciphering_algorithm
!=
-
1
)
{
entity
->
has_ciphering
=
entity
->
has_ciphering
==
NR_PDCP_ENTITY_CIPHERING_ON
?
NR_PDCP_ENTITY_CIPHERING_ON
:
NR_PDCP_ENTITY_CIPHERING_SMC
;
if
(
entity
->
type
==
NR_PDCP_SRB
&&
entity
->
rb_id
==
DCCH
&&
entity
->
has_ciphering
==
NR_PDCP_ENTITY_CIPHERING_OFF
)
{
entity
->
has_ciphering
=
NR_PDCP_ENTITY_CIPHERING_SMC
;
}
LOG_I
(
PDCP
,
"%s: entity->has_ciphering %d
\n
"
,
__FUNCTION__
,
entity
->
has_ciphering
);
if
(
entity
->
free_security
!=
NULL
)
{
entity
->
free_security
(
entity
->
security_context
);
...
...
openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h
View file @
f8219745
...
...
@@ -36,7 +36,7 @@ typedef enum {
}
nr_pdcp_entity_type_t
;
/**
* 3GPP TS 33.501
* 3GPP TS 33.501
6.7.4
* RRC downlink ciphering (encryption) at the gNB shall start after sending the AS security mode command message.
* RRC uplink deciphering (decryption) at the gNB shall start after receiving and successful verification of the AS security mode complete message.
*
...
...
openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c
View file @
f8219745
This diff is collapsed.
Click to expand it.
openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c
View file @
f8219745
...
...
@@ -158,8 +158,10 @@ void mac_rlc_data_ind (
T
(
T_ENB_RLC_MAC_UL
,
T_INT
(
module_idP
),
T_INT
(
rntiP
),
T_INT
(
channel_idP
),
T_INT
(
tb_sizeP
));
LOG_UDUMPMSG
(
RLC
,
buffer_pP
,
tb_sizeP
,
LOG_DUMP_CHAR
,
"%s: "
,
__FUNCTION__
);
if
(
RC
.
ss
.
mode
>=
SS_SOFTMODEM
)
{
if
((
tb_sizeP
!=
0
)
&&
(
true
==
enb_flagP
)
&&
(
channel_idP
>=
4
))
{
if
((
tb_sizeP
!=
0
)
&&
(
true
==
enb_flagP
)
&&
(
channel_idP
>=
4
)
&&
(
RC
.
nr_drb_data_type
==
DRB_RlcPdu
)
)
{
int
drb_id
=
channel_idP
-
3
;
int
result
;
LOG_A
(
RLC
,
"Sending packet to SS, Calling SS_DRB_PDU_IND ue %x drb id %d size %u
\n
"
,
rntiP
,
drb_id
,
tb_sizeP
);
...
...
@@ -179,11 +181,11 @@ void mac_rlc_data_ind (
}
}
RC
.
nr_drb_data_type
=
DRB_data_type_qty
;
return
;
}
}
// Trace UL RLC PDU Here
nr_rlc_pkt_info_t
rlc_pkt
;
rlc_pkt
.
direction
=
DIRECTION_UPLINK
;
rlc_pkt
.
ueid
=
rntiP
;
...
...
@@ -239,7 +241,6 @@ tbs_size_t mac_rlc_data_req(
nr_rlc_entity_t
*
rb
;
int
maxsize
;
// Trace UL RLC PDU Here
nr_rlc_pkt_info_t
rlc_pkt
;
rlc_pkt
.
direction
=
DIRECTION_DOWNLINK
;
rlc_pkt
.
ueid
=
rntiP
;
...
...
@@ -630,6 +631,8 @@ rb_found:
is_enb
=
nr_rlc_manager_get_enb_flag
(
nr_rlc_ue_manager
);
ctx
.
enb_flag
=
is_enb
;
LOG_UDUMPMSG
(
RLC
,
buf
,
size
,
LOG_DUMP_CHAR
,
"%s: "
,
__FUNCTION__
);
if
(
is_enb
)
{
T
(
T_ENB_RLC_UL
,
T_INT
(
0
/*ctxt_pP->module_id*/
),
...
...
@@ -681,7 +684,7 @@ rb_found:
exit
(
1
);
}
memcpy
(
memblock
->
data
,
buf
,
size
);
LOG_
D
(
PDCP
,
"Calling PDCP layer from RLC in %s
\n
"
,
__FUNCTION__
);
LOG_
I
(
RLC
,
"Calling PDCP layer from RLC in %s
\n
"
,
__FUNCTION__
);
if
(
!
pdcp_data_ind
(
&
ctx
,
is_srb
,
0
,
rb_id
,
size
,
memblock
,
NULL
,
NULL
))
{
LOG_E
(
RLC
,
"%s:%d:%s: ERROR: pdcp_data_ind failed
\n
"
,
__FILE__
,
__LINE__
,
__FUNCTION__
);
/* what to do in case of failure? for the moment: nothing */
...
...
@@ -722,7 +725,7 @@ static void successful_delivery(void *_ue, nr_rlc_entity_t *entity, int sdu_id)
exit
(
1
);
rb_found:
LOG_
D
(
RLC
,
"sdu %d was successfully delivered on %s %d
\n
"
,
LOG_
I
(
RLC
,
"sdu %d was successfully delivered on %s %d
\n
"
,
sdu_id
,
is_srb
?
"SRB"
:
"DRB"
,
rb_id
);
...
...
@@ -820,7 +823,7 @@ void *rlc_enb_task(void *arg)
if
(
RC
.
ss
.
mode
>=
SS_SOFTMODEM
)
{
protocol_ctxt_t
ctxt
;
instance_t
instance
=
ITTI_MSG_DESTINATION_INSTANCE
(
received_msg
);
LOG_
D
(
RLC
,
"RLC received SS_DRB_PDU_REQ DRB_ID:%d SDU_SIZE:%d
\n
"
,
LOG_
I
(
RLC
,
"RLC received SS_DRB_PDU_REQ DRB_ID:%d SDU_SIZE:%d
\n
"
,
SS_DRB_PDU_REQ
(
received_msg
).
drb_id
,
SS_DRB_PDU_REQ
(
received_msg
).
sdu_size
);
PROTOCOL_CTXT_SET_BY_INSTANCE
(
&
ctxt
,
instance
,
...
...
openair2/RRC/NR/rrc_gNB.c
View file @
f8219745
...
...
@@ -122,11 +122,13 @@ mui_t rrc_gNB_mui = 0;
uint8_t
first_rrcreconfiguration
=
0
;
// temp static storage
for AS Security settings to be applied
for SRB1 and SRB2
// temp static storage
of AS Security settings
for SRB1 and SRB2
static
e_NR_IntegrityProtAlgorithm
_int_algo
=
0
;
static
NR_CipheringAlgorithm_t
_cip_algo
=
0
;
static
uint8_t
_nr_cp_int_key
[
16
]
=
{
0
};
static
uint8_t
_nr_cp_cip_key
[
16
]
=
{
0
};
static
uint8_t
_nr_control_plane_int_key
[
16
]
=
{
0
};
static
uint8_t
_nr_control_plane_cip_key
[
16
]
=
{
0
};
static
uint8_t
_nr_data_plane_int_key
[
16
]
=
{
0
};
static
uint8_t
_nr_data_plane_cip_key
[
16
]
=
{
0
};
///---------------------------------------------------------------------------------------------------------------///
///---------------------------------------------------------------------------------------------------------------///
...
...
@@ -917,10 +919,9 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co
size
,
buffer
,
PDCP_TRANSMISSION_MODE_CONTROL
);
}
// rrc_pdcp_config_asn1_req
break
;
}
break
;
case
ngran_gNB_DU
:
// nothing to do for DU
...
...
@@ -1646,9 +1647,13 @@ rrc_gNB_process_RRCReconfigurationComplete(
kRRCenc
=
(
uint8_t
*
)
malloc
(
16
);
kRRCint
=
(
uint8_t
*
)
malloc
(
16
);
AssertFatal
(
kRRCint
&&
kRRCenc
,
"malloc failed"
);
memcpy
(
kRRCenc
,
_nr_cp_cip_key
,
16
);
memcpy
(
kRRCint
,
_nr_cp_int_key
,
16
);
kUPint
=
(
uint8_t
*
)
malloc
(
16
);
kUPenc
=
(
uint8_t
*
)
malloc
(
16
);
AssertFatal
(
kRRCint
&&
kRRCenc
&&
kUPint
&&
kUPenc
,
"malloc failed
\n
"
);
memcpy
(
kRRCenc
,
_nr_control_plane_cip_key
,
16
);
memcpy
(
kRRCint
,
_nr_control_plane_int_key
,
16
);
memcpy
(
kUPint
,
_nr_data_plane_int_key
,
16
);
memcpy
(
kUPenc
,
_nr_data_plane_int_key
,
16
);
LOG_D
(
NR_RRC
,
"Configuring PDCP DRBs/SRBs for UE %04x
\n
"
,
ue_context_pP
->
ue_context
.
rnti
);
...
...
@@ -1674,7 +1679,7 @@ rrc_gNB_process_RRCReconfigurationComplete(
ctxt_pP
->
rntiMaybeUEid
,
reestablish_ue_id
,
DRB_configList
,
(
ue_context_pP
->
ue_context
.
integrity_algorithm
<<
4
)
|
ue_context_pP
->
ue_context
.
ciphering_algorithm
,
(
_int_algo
<<
4
)
|
_cip_algo
,
kUPenc
,
kUPint
,
get_softmodem_params
()
->
sa
?
ue_context_pP
->
ue_context
.
masterCellGroup
->
rlc_BearerToAddModList
:
NULL
);
...
...
@@ -4678,15 +4683,19 @@ void *rrc_gnb_task(void *args_p) {
msg_p
->
ittiMsgHeader
.
lte_time
.
frame
,
msg_p
->
ittiMsgHeader
.
lte_time
.
slot
);
if
(
_int_algo
>
0
)
{
memcpy
(
&
(
_nr_cp_int_key
[
0
]),
&
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kRRCint
[
0
]),
16
);
memcpy
(
&
(
_nr_control_plane_int_key
[
0
]),
&
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kRRCint
[
0
]),
16
);
memcpy
(
&
(
_nr_data_plane_int_key
[
0
]),
&
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kUPint
[
0
]),
16
);
}
else
{
memset
(
&
(
_nr_cp_int_key
[
0
]),
0
,
16
);
memset
(
&
(
_nr_control_plane_int_key
[
0
]),
0
,
16
);
memset
(
&
(
_nr_data_plane_int_key
[
0
]),
0
,
16
);
}
if
(
_cip_algo
>
0
)
{
memcpy
(
&
(
_nr_cp_cip_key
[
0
]),
&
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Ciphering
.
kRRCenc
[
0
]),
16
);
memcpy
(
&
(
_nr_control_plane_cip_key
[
0
]),
&
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Ciphering
.
kRRCenc
[
0
]),
16
);
memcpy
(
&
(
_nr_data_plane_cip_key
[
0
]),
&
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Ciphering
.
kUPenc
[
0
]),
16
);
}
else
{
memset
(
&
(
_nr_cp_cip_key
[
0
]),
0
,
16
);
memset
(
&
(
_nr_control_plane_cip_key
[
0
]),
0
,
16
);
memset
(
&
(
_nr_data_plane_cip_key
[
0
]),
0
,
16
);
}
int
unused
=
0
;
...
...
openair2/RRC/NR_UE/rrc_UE.c
View file @
f8219745
...
...
@@ -1784,8 +1784,8 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
if
(
LOG_DEBUGFLAG
(
DEBUG_ASN1
)
)
{
xer_fprint
(
stdout
,
&
asn_DEF_NR_UL_DCCH_Message
,
(
void
*
)
&
ul_dcch_msg
);
}
log_dump
(
MAC
,
buffer
,
16
,
LOG_DUMP_CHAR
,
"securityModeComplete payload: "
);
LOG_
D
(
NR_RRC
,
"securityModeComplete Encoded %zd bits (%zd bytes)
\n
"
,
enc_rval
.
encoded
,
(
enc_rval
.
encoded
+
7
)
/
8
);
log_dump
(
NR_RRC
,
buffer
,
(
enc_rval
.
encoded
+
7
)
/
8
,
LOG_DUMP_CHAR
,
"securityModeComplete payload: "
);
LOG_
I
(
NR_RRC
,
"securityModeComplete Encoded %zd bits (%zd bytes)
\n
"
,
enc_rval
.
encoded
,
(
enc_rval
.
encoded
+
7
)
/
8
);
for
(
i
=
0
;
i
<
(
enc_rval
.
encoded
+
7
)
/
8
;
i
++
)
{
LOG_I
(
NR_RRC
,
"%02x."
,
buffer
[
i
]);
...
...
openair3/NAS/NR_UE/nr_nas_msg_sim.c
View file @
f8219745
...
...
@@ -1311,11 +1311,14 @@ static void generateCloseUeTestLoopComplete(int Mod_id, as_nas_info_t *initialNa
}
static
void
generateOpenUeTestLoopComplete
(
int
Mod_id
,
as_nas_info_t
*
initialNasMsg
)
{
LOG_FUNC_IN
;
int
size
=
sizeof
(
mm_msg_header_t
);
fgs_nas_message_t
nas_msg
=
{
0
};
int
security_header_len
=
0
;
int
msg_len
=
0
;
MM_msg
*
mm_msg
;
nas_msg
.
header
.
protocol_discriminator
=
FGS_MOBILITY_MANAGEMENT_MESSAGE
;
nas_msg
.
header
.
security_header_type
=
INTEGRITY_PROTECTED_AND_CIPHERED
;
size
+=
7
;
...
...
@@ -1335,36 +1338,33 @@ static void generateOpenUeTestLoopComplete(int Mod_id, as_nas_info_t *initialNas
// encode the message
initialNasMsg
->
data
=
(
Byte_t
*
)
malloc
(
size
*
sizeof
(
Byte_t
));
int
security_header_len
=
nas_protected_security_header_encode
((
char
*
)(
initialNasMsg
->
data
),
&
(
nas_msg
.
header
),
size
);
initialNasMsg
->
length
=
security_header_len
+
m
m_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
+
security_header_len
),
size
-
security_header_len
)
;
security_header_len
=
nas_protected_security_header_encode
((
char
*
)(
initialNasMsg
->
data
),
&
(
nas_msg
.
header
),
size
);
msg_len
=
mm_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
+
security_header_len
),
size
-
security_header_len
);
initialNasMsg
->
length
=
security_header_len
+
m
sg_len
;
LOG_T
(
NAS
,
"header len %d, msg len %d, todal: %d
\n
"
,
security_header_len
,
msg_len
,
initialNasMsg
->
length
);
printf
(
"Before Security: "
);
for
(
int
i
=
0
;
i
<
initialNasMsg
->
length
;
++
i
)
printf
(
"%02x"
,
(
initialNasMsg
->
data
)[
i
]);
printf
(
"
\n
"
);
_ul_nas_count
=
256
;
/* HACK: Only to match expected TTCN value in TC 7.1.3.x*/
// Ciphering
_encrypt_nas_msg
(
Mod_id
,
_ul_nas_count
,
initialNasMsg
->
data
+
security_header_len
,
msg_len
);
/* Workaround fix of bypassing security for the TTCN */
#if 0
nas_stream_cipher_t stream_cipher;
stream_cipher.key = ue_security_key[Mod_id]->knas_int;
stream_cipher.key_length = 16;
stream_cipher.count = 0;
stream_cipher.bearer = 1;
stream_cipher.direction = 0;
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6);
/* length in bits */
stream_cipher.blength = (initialNasMsg->length - 6) << 3;
// only for Type of integrity protection algorithm: 128-5G-IA2 (2)
nas_stream_encrypt_eia2(
&stream_cipher,
mac);
#endif
for
(
int
i
=
0
;
i
<
4
;
i
++
){
initialNasMsg
->
data
[
2
+
i
]
=
0
;
//mac[i];/* Workaround fix of bypassing security for the TTCN */
// Integrity
_calculate_nas_maci
(
Mod_id
,
SECU_DIRECTION_UPLINK
,
_ul_nas_count
,
initialNasMsg
->
data
+
security_header_len
-
1
,
msg_len
+
1
,
mac
);
printf
(
"xmac %02x%02x%02x%02x
\n
"
,
mac
[
0
],
mac
[
1
],
mac
[
2
],
mac
[
3
]);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
initialNasMsg
->
data
[
2
+
i
]
=
mac
[
i
];
}
printf
(
"After Security: "
);
for
(
int
i
=
0
;
i
<
initialNasMsg
->
length
;
++
i
)
printf
(
"%02x"
,
(
initialNasMsg
->
data
)[
i
]);
printf
(
"
\n
"
);
LOG_FUNC_OUT
;
}
static
void
generateDeactivateTestModeComplete
(
int
Mod_id
,
as_nas_info_t
*
initialNasMsg
)
{
LOG_FUNC_IN
;
int
size
=
sizeof
(
mm_msg_header_t
);
fgs_nas_message_t
nas_msg
=
{
0
};
int
security_header_len
=
0
;
int
msg_len
=
0
;
MM_msg
*
mm_msg
;
nas_msg
.
header
.
protocol_discriminator
=
FGS_MOBILITY_MANAGEMENT_MESSAGE
;
...
...
@@ -1386,34 +1386,25 @@ static void generateDeactivateTestModeComplete(int Mod_id, as_nas_info_t *initia
// encode the message
initialNasMsg
->
data
=
(
Byte_t
*
)
malloc
(
size
*
sizeof
(
Byte_t
));
int
security_header_len
=
nas_protected_security_header_encode
((
char
*
)(
initialNasMsg
->
data
),
&
(
nas_msg
.
header
),
size
);
initialNasMsg
->
length
=
security_header_len
+
mm_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
+
security_header_len
),
size
-
security_header_len
);
#if 0
nas_stream_cipher_t stream_cipher;
stream_cipher.key = ue_security_key[Mod_id]->knas_int;
stream_cipher.key_length = 16;
stream_cipher.count = 0;
stream_cipher.bearer = 1;
stream_cipher.direction = 0;
stream_cipher.message = (unsigned char *)(initialNasMsg->data + 6);
/* length in bits */
stream_cipher.blength = (initialNasMsg->length - 6) << 3;
security_header_len
=
nas_protected_security_header_encode
((
char
*
)(
initialNasMsg
->
data
),
&
(
nas_msg
.
header
),
size
);
msg_len
=
mm_msg_encode
(
mm_msg
,
(
uint8_t
*
)(
initialNasMsg
->
data
+
security_header_len
),
size
-
security_header_len
);
initialNasMsg
->
length
=
security_header_len
+
msg_len
;
LOG_T
(
NAS
,
"header len %d, msg len %d, todal: %d
\n
"
,
security_header_len
,
msg_len
,
initialNasMsg
->
length
);
/* Workaround fix of bypassing security for the TTCN */
printf
(
"Before Security: "
);
for
(
int
i
=
0
;
i
<
initialNasMsg
->
length
;
++
i
)
printf
(
"%02x"
,
(
initialNasMsg
->
data
)[
i
]);
printf
(
"
\n
"
);
_ul_nas_count
=
256
;
/* HACK: Only to match expected TTCN value in TC 7.1.3.x*/
// Ciphering
_encrypt_nas_msg
(
Mod_id
,
_ul_nas_count
,
initialNasMsg
->
data
+
security_header_len
,
msg_len
);
// only for Type of integrity protection algorithm: 128-5G-IA2 (2)
uint8_t mac[4];
nas_stream_encrypt_eia2(
&stream_cipher,
mac);
printf("xmac %02x%02x%02x%02x\n", mac[0], mac[1], mac[2], mac[3]);
#endif
// Integrity
_calculate_nas_maci
(
Mod_id
,
SECU_DIRECTION_UPLINK
,
_ul_nas_count
,
initialNasMsg
->
data
+
security_header_len
-
1
,
msg_len
+
1
,
mac
);
for
(
int
i
=
0
;
i
<
4
;
i
++
){
initialNasMsg
->
data
[
2
+
i
]
=
0
;
//mac[i];/* Workaround fix of bypassing security for the TTCN */
printf
(
"xmac %02x%02x%02x%02x
\n
"
,
mac
[
0
],
mac
[
1
],
mac
[
2
],
mac
[
3
]);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
initialNasMsg
->
data
[
2
+
i
]
=
mac
[
i
];
}
printf
(
"After Security: "
);
for
(
int
i
=
0
;
i
<
initialNasMsg
->
length
;
++
i
)
printf
(
"%02x"
,
(
initialNasMsg
->
data
)[
i
]);
printf
(
"
\n
"
);
LOG_FUNC_OUT
;
}
void
generateServiceRequestInner
(
as_nas_info_t
*
initialNasMsg
,
int
Mod_id
)
{
...
...
@@ -1654,9 +1645,12 @@ void *nas_nrue_task(void *args_p)
pdu_buffer_len
=
NAS_DOWNLINK_DATA_IND
(
msg_p
).
nasMsg
.
length
;
LOG_I
(
NAS
,
"NAS_DOWNLINK_DATA_IND msg: "
);
// TODOAGP replace
for
(
int
i
=
0
;
i
<
pdu_buffer_len
;
i
++
)
{
LOG_I
(
NAS
,
"%02x"
,
pdu_buffer
[
i
]);
// LOG_I(NAS, "%02x", pdu_buffer[i]);
printf
(
"%02x"
,
pdu_buffer
[
i
]);
}
printf
(
"
\n
"
);
if
(
_security_set
)
{
_dl_nas_count
++
;
...
...
openair3/SS/ss_gNB_drb_task.c
View file @
f8219745
This diff is collapsed.
Click to expand it.
openair3/SS/ss_gNB_srb_task.c
View file @
f8219745
...
...
@@ -283,7 +283,7 @@ static void ss_task_handle_rrc_pdu_req(struct NR_RRC_PDU_REQ *req)
}
LOG_A
(
GNB_APP
,
"[SS_SRB][NR_RRC_PDU_REQ] sending to TASK_RRC_GNB: {srb: %d, ch: %s, qty: %d }"
,
LOG_A
(
GNB_APP
,
"[SS_SRB][NR_RRC_PDU_REQ] sending to TASK_RRC_GNB: {srb: %d, ch: %s, qty: %d }
\n
"
,
SS_NRRRC_PDU_REQ
(
message_p
).
srb_id
,
req
->
RrcPdu
.
d
==
NR_RRC_MSG_Request_Type_Ccch
?
"CCCH"
:
"DCCH"
,
SS_NRRRC_PDU_REQ
(
message_p
).
sdu_size
);
...
...
@@ -294,7 +294,7 @@ static void ss_task_handle_rrc_pdu_req(struct NR_RRC_PDU_REQ *req)
LOG_A
(
GNB_APP
,
"[SS_SRB] Error in itti_send_msg_to_task"
);
}
LOG_A
(
GNB_APP
,
"Send res: %d"
,
send_res
);
LOG_A
(
GNB_APP
,
"Send res: %d
\n
"
,
send_res
);
}
}
...
...
openair3/SS/ss_gNB_sys_task.c
View file @
f8219745
...
...
@@ -262,7 +262,7 @@ static void sys_handle_nr_as_security_req(struct NR_AS_Security_Type *ASSecurity
MessageDef
*
msg_p
=
itti_alloc_new_message
(
TASK_SYS_GNB
,
INSTANCE_DEFAULT
,
RRC_AS_SECURITY_CONFIG_REQ
);
if
(
msg_p
)
{
LOG_
E
(
GNB_APP
,
"[SYS-GNB] AS Security Request Received
\n
"
);
LOG_
I
(
GNB_APP
,
"[SYS-GNB] AS Security Request Received
\n
"
);
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
rnti
=
SS_context
.
ss_rnti_g
;
switch
(
ASSecurity
->
d
)
{
...
...
@@ -275,9 +275,21 @@ static void sys_handle_nr_as_security_req(struct NR_AS_Security_Type *ASSecurity
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kRRCint
=
CALLOC
(
1
,
16
);
memset
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kRRCint
,
0
,
16
);
bits_copy_from_array
((
char
*
)
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kRRCint
,
0
,
(
const
char
*
)
ASSecurity
->
v
.
StartRestart
.
Integrity
.
v
.
KRRCint
,
128
);
LOG_
E
(
GNB_APP
,
"[SYS-GNB] kRRCint:
\n
"
);
LOG_
I
(
GNB_APP
,
"[SYS-GNB] kRRCint:
\n
"
);
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
LOG_E
(
GNB_APP
,
"%02x
\n
"
,
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kRRCint
[
i
]);
LOG_I
(
GNB_APP
,
"%02x
\n
"
,
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kRRCint
[
i
]);
}
if
(
ASSecurity
->
v
.
StartRestart
.
Integrity
.
v
.
KUPint
.
d
==
true
)
{
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
isUPIntegrityInfoPresent
=
true
;
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kUPint
=
CALLOC
(
1
,
16
);
memset
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kUPint
,
0
,
16
);
bits_copy_from_array
(
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kUPint
,
0
,
ASSecurity
->
v
.
StartRestart
.
Integrity
.
v
.
KUPint
.
v
,
128
);
LOG_I
(
GNB_APP
,
"[SYS-GNB] kUPint:
\n
"
);
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
LOG_I
(
GNB_APP
,
"%02x
\n
"
,
RRC_AS_SECURITY_CONFIG_REQ
(
msg_p
).
Integrity
.
kUPint
[
i
]);
}
}
if
(
ASSecurity
->
v
.
StartRestart
.
Integrity
.
v
.
ActTimeList
.
d
==
true
)
...
...
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