utran: use new UTRAN encryption enum
Depends: libosmocore.git I4b9baff2c2fbd0e339fc769cc69cce58d3a72cdf
Change-Id: If6978d7ed1a78facc2591cfc30fda2721629bffa
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index fc1b2e2..075ef0f 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -51,6 +51,7 @@
#include <osmocom/core/fsm.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/crypt/auth.h>
+#include <osmocom/crypt/utran_cipher.h>
#include <osmocom/msc/msub.h>
#include <osmocom/msc/msc_roles.h>
@@ -414,7 +415,7 @@
net->vlr, msc_a, vlr_lu_type, tmsi, imsi,
&old_lai, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
- is_utran ? net->uea_encryption_mask > 0x01 : net->a5_encryption_mask > 0x01,
+ is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
lu->key_seq,
osmo_gsm48_classmark1_is_r99(&lu->classmark1),
is_utran,
@@ -805,7 +806,7 @@
req->cm_service_type,
&mi, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
- is_utran ? net->uea_encryption_mask > 0x01 : net->a5_encryption_mask > 0x01,
+ is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
req->cipher_key_seq,
osmo_gsm48_classmark2_is_r99(cm2, cm2_len),
is_utran);
@@ -931,7 +932,7 @@
VLR_PR_ARQ_T_CM_RE_ESTABLISH_REQ, 0,
&mi, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
- is_utran ? net->uea_encryption_mask > 0x01 : net->a5_encryption_mask > 0x01,
+ is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
req->cipher_key_seq,
osmo_gsm48_classmark2_is_r99(cm2, cm2_len),
is_utran);
@@ -1293,7 +1294,7 @@
net->vlr, msc_a,
VLR_PR_ARQ_T_PAGING_RESP, 0, &mi, &msc_a->via_cell.lai,
is_utran || net->authentication_required,
- is_utran ? net->uea_encryption_mask > 0x01 : net->a5_encryption_mask > 0x01,
+ is_utran ? net->uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) : net->a5_encryption_mask > 0x01,
pr->key_seq,
osmo_gsm48_classmark2_is_r99(cm2, classmark2_len),
is_utran);
diff --git a/src/libmsc/msc_net_init.c b/src/libmsc/msc_net_init.c
index d53156b..af23fe5 100644
--- a/src/libmsc/msc_net_init.c
+++ b/src/libmsc/msc_net_init.c
@@ -24,6 +24,7 @@
#include "config.h"
#include <osmocom/core/tdef.h>
+#include <osmocom/crypt/utran_cipher.h>
#include <osmocom/msc/gsm_data.h>
#include <osmocom/msc/vlr.h>
@@ -68,7 +69,7 @@
/* Permit a compile-time default of A5/3 and A5/1 */
net->a5_encryption_mask = (1 << 3) | (1 << 1);
/* Permit a compile-time default of UEA2 and UEA1 */
- net->uea_encryption_mask = (1 << 2) | (1 << 1);
+ net->uea_encryption_mask = (1 << OSMO_UTRAN_UEA2) | (1 << OSMO_UTRAN_UEA1);
net->mncc_guard_timeout = 180;
net->ncss_guard_timeout = 30;
diff --git a/src/libmsc/ran_msg_iu.c b/src/libmsc/ran_msg_iu.c
index 81147cf..8ffdd93 100644
--- a/src/libmsc/ran_msg_iu.c
+++ b/src/libmsc/ran_msg_iu.c
@@ -27,6 +27,7 @@
#include <osmocom/core/prim.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/crypt/auth.h>
+#include <osmocom/crypt/utran_cipher.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/ranap/ranap_common_cn.h>
@@ -377,10 +378,10 @@
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),
- cm->utran.uea_encryption_mask > 0x01 ? osmo_hexdump_nospc(cm->vec->ck, 16) : "NONE");
+ cm->utran.uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) ? osmo_hexdump_nospc(cm->vec->ck, 16) : "NONE");
/* TODO: Do we need to check if the UE supports all of the algorithms and build an intersection like
* in the case of A5? */
- return ranap_new_msg_sec_mod_cmd2(cm->vec->ik, cm->utran.uea_encryption_mask > 0x01 ? cm->vec->ck : NULL,
+ return ranap_new_msg_sec_mod_cmd2(cm->vec->ik, cm->utran.uea_encryption_mask > (1 << OSMO_UTRAN_UEA0) ? cm->vec->ck : NULL,
RANAP_KeyStatus_new, 0x06, cm->utran.uea_encryption_mask);
}