From ccd2ee83e4623567cbdfcf1e085dc61d518ebafd Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Mon, 24 Jan 2022 15:54:39 +0100
Subject: [PATCH] nr ue: fix security setting of DRB

Maybe this fix won't work for non-openair gNB. We use the same keys and
algorithms as for SRBs, which is what openair gNB does.

(I hope I'm right there.)

To be changed if needed.
---
 openair2/RRC/NR_UE/rrc_UE.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index bc209afd0..f910ff68d 100644
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -2180,7 +2180,8 @@ nr_rrc_ue_establish_srb2(
                                     NULL,
                                     radioBearerConfig->drb_ToAddModList,
                                     NULL,
-                                    0,
+                                    NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm
+                                      | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4),
                                     NULL,
                                     NULL,
                                     kUPenc,
-- 
2.26.2