From e400b1161d2a00082dd0b0e543f3bb84a6efefe5 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Fri, 26 Nov 2021 23:57:10 +0100 Subject: [PATCH] ran_msg_iu: do not pass UEA0 to ranap_new_msg_sec_mod_cmd2() On the protocol level, it's impossible to indicate UEA0 together with the other algorithms. The encryption is either a) disabled, so the Encryption Information IE is not present, or b) enabled, so the Encryption Information IE indicates UEA1 and/or UEA2. Because of that, the ranap_new_msg_sec_mod_cmd2() would fail to generate the RANAP PDU if the given bitmask has the UEA0 bit set. Fixes: 505a94a610fc ("Make UTRAN encryption algorithms configurable") Change-Id: I3271d27c09fc8d70a912bce998ceffbce64dd95e --- src/libmsc/ran_msg_iu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libmsc/ran_msg_iu.c b/src/libmsc/ran_msg_iu.c index cf57d350b..b894df2a0 100644 --- a/src/libmsc/ran_msg_iu.c +++ b/src/libmsc/ran_msg_iu.c @@ -377,7 +377,8 @@ static struct msgb *ran_iu_make_security_mode_command(struct osmo_fsm_inst *call { /* TODO: make the choice of available UIA algorithms configurable */ const uint8_t uia_mask = (1 << OSMO_UTRAN_UIA1) | (1 << OSMO_UTRAN_UIA2); - bool use_encryption = cm->utran.uea_encryption_mask > (1 << OSMO_UTRAN_UEA0); + const uint8_t uea_mask = cm->utran.uea_encryption_mask & ~(1 << OSMO_UTRAN_UEA0); + bool use_encryption = uea_mask != 0x00; LOG_RAN_IU_ENC(caller_fi, LOGL_DEBUG, "Tx RANAP SECURITY MODE COMMAND to RNC, IK=%s, CK=%s\n", osmo_hexdump_nospc(cm->vec->ik, 16), @@ -388,7 +389,7 @@ static struct msgb *ran_iu_make_security_mode_command(struct osmo_fsm_inst *call use_encryption ? cm->vec->ck : NULL, RANAP_KeyStatus_new, (uia_mask << 1), /* API treats LSB as UIA0 */ - cm->utran.uea_encryption_mask); + uea_mask); }