aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2021-06-15 01:10:39 +0200
committerlaforge <laforge@osmocom.org>2021-06-22 05:56:09 +0000
commit68536ccf8b5d7ca6e29792c370bf5a6b275d9cf7 (patch)
treec6db2dab25da36507889d551d1405e9eaa5fcf72
parent5ec7b65eed04bd1b26d92dc184ace1f1687410b6 (diff)
support A5/4 in inter-BSC Handover
inter-BSC into this BSC: from BSSMAP Handover Request, parse and store Kc128. All else is already implemented: depending on the chosen encryption algorithm, Kc128 will end up in the Channel Activation. inter-BSC out of this BSC: nothing is needed to support A5/4, the BSSMAP Handover Required message does not contain any encryption related information. The MSC already knows the chosen algorithm. Related: SYS#5324 Change-Id: I7e9590e8c96aa50086148863ad9a2741b978e614
-rw-r--r--include/osmocom/bsc/gsm_data.h2
-rw-r--r--src/osmo-bsc/handover_fsm.c22
2 files changed, 21 insertions, 3 deletions
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 1755b92d7..c5d2b8612 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -241,6 +241,8 @@ struct handover_in_req {
struct gsm0808_channel_type ct;
struct gsm0808_speech_codec_list scl;
struct gsm0808_encrypt_info ei;
+ bool kc128_present;
+ uint8_t kc128[16];
struct gsm_classmark classmark;
/* chosen_encr_alg reflects the encoded value as in RSL_ENC_ALG_A5(a5_numer):
* chosen_encr_alg == 1 means A5/0 i.e. no encryption, chosen_encr_alg == 4 means A5/3.
diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c
index cae5167b4..5f4b8928a 100644
--- a/src/osmo-bsc/handover_fsm.c
+++ b/src/osmo-bsc/handover_fsm.c
@@ -454,6 +454,7 @@ static bool parse_ho_request(struct gsm_subscriber_connection *conn, const struc
int payload_length;
bool aoip = gscon_is_aoip(conn);
bool sccplite = gscon_is_sccplite(conn);
+ bool has_a54 = false;
if ((aoip && sccplite) || !(aoip || sccplite)) {
LOG_HO(conn, LOGL_ERROR, "Received BSSMAP Handover Request, but conn is not"
@@ -485,6 +486,15 @@ static bool parse_ho_request(struct gsm_subscriber_connection *conn, const struc
return false;
}
+ if ((e = TLVP_GET(tp, GSM0808_IE_KC_128))) {
+ if (e->len != 16) {
+ LOG_HO(conn, LOGL_ERROR, "Invalid length in Kc128 IE: %u bytes (expected 16)\n", e->len);
+ return false;
+ }
+ memcpy(req->kc128, e->val, 16);
+ req->kc128_present = true;
+ }
+
if ((e = TLVP_GET(tp, GSM0808_IE_CLASSMARK_INFORMATION_TYPE_1))) {
if (e->len != sizeof(req->classmark.classmark1)) {
LOG_HO(conn, LOGL_ERROR, "Classmark Information 1 has wrong size\n");
@@ -513,9 +523,10 @@ static bool parse_ho_request(struct gsm_subscriber_connection *conn, const struc
req->chosen_encr_alg);
}
- LOG_HO(conn, LOGL_DEBUG, "Handover Request encryption info: chosen=A5/%u key=%s\n",
- (req->chosen_encr_alg ? : 1) - 1, req->ei.key_len?
- osmo_hexdump_nospc(req->ei.key, req->ei.key_len) : "none");
+ LOG_HO(conn, LOGL_DEBUG, "Handover Request encryption info: chosen=A5/%u key=%s kc128=%s\n",
+ (req->chosen_encr_alg ? : 1) - 1,
+ req->ei.key_len ? osmo_hexdump_nospc(req->ei.key, req->ei.key_len) : "none",
+ has_a54 ? osmo_hexdump_nospc(req->kc128, 16) : "none");
if (TLVP_PRESENT(tp, GSM0808_IE_AOIP_TRASP_ADDR)) {
int rc;
@@ -720,6 +731,11 @@ void handover_start_inter_bsc_in(struct gsm_subscriber_connection *conn,
info.encr.key_len = req->ei.key_len;
}
+ if (req->kc128_present) {
+ memcpy(info.encr.kc128, req->kc128, 16);
+ info.encr.kc128_present = true;
+ }
+
if (req->last_eutran_plmn_valid) {
conn->fast_return.allowed = ho->new_bts->srvcc_fast_return_allowed;
conn->fast_return.last_eutran_plmn_valid = true;