aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/msc/a_iface.h2
-rw-r--r--src/libmsc/a_iface.c32
-rw-r--r--src/libmsc/gsm_04_08.c14
3 files changed, 20 insertions, 28 deletions
diff --git a/include/osmocom/msc/a_iface.h b/include/osmocom/msc/a_iface.h
index f0da248b7..30a10af2e 100644
--- a/include/osmocom/msc/a_iface.h
+++ b/include/osmocom/msc/a_iface.h
@@ -57,7 +57,7 @@ int a_iface_tx_dtap(struct msgb *msg);
/* Send Cipher mode command via A-interface */
int a_iface_tx_cipher_mode(const struct gsm_subscriber_connection *conn,
- int cipher, const uint8_t *key, int len, int include_imeisv);
+ struct gsm0808_encrypt_info *ei, int include_imeisv);
/* Page a subscriber via A-interface */
int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac);
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index e264aeeba..9083f0e37 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -165,38 +165,20 @@ int a_iface_tx_dtap(struct msgb *msg)
/* Send Cipher mode command via A-interface */
int a_iface_tx_cipher_mode(const struct gsm_subscriber_connection *conn,
- int cipher, const uint8_t *key, int len, int include_imeisv)
+ struct gsm0808_encrypt_info *ei, int include_imeisv)
{
/* TODO generalize for A- and Iu interfaces, don't name after 08.08 */
struct msgb *msg_resp;
- struct gsm0808_encrypt_info ei;
-
- OSMO_ASSERT(conn);
-
- LOGP(DMSC, LOGL_DEBUG, "(subscr %s, conn_id %d) Cipher Mode Command to BSC,"
- " cipher=%d key=%s\n",
- vlr_subscr_name(conn->vsub), conn->a.conn_id, cipher, osmo_hexdump_nospc(key, len));
uint8_t crm = 0x01;
- uint8_t *crm_ptr = NULL;
- /* Setup encryption information */
- if (len > ENCRY_INFO_KEY_MAXLEN || !key) {
- LOGP(DMSC, LOGL_ERROR,
- "Cipher mode command message could not be generated due to invalid key! (conn_id=%i)\n",
- conn->a.conn_id);
- return -EINVAL;
- } else {
- memcpy(&ei.key, key, len);
- ei.key_len = len;
- }
-
- if (include_imeisv)
- crm_ptr = &crm;
+ OSMO_ASSERT(conn);
- ei.perm_algo[0] = vlr_ciph_to_gsm0808_alg_id(cipher);
- ei.perm_algo_len = 1;
+ LOGP(DMSC, LOGL_DEBUG, "(subscr %s, conn_id %d) Cipher Mode Command to BSC, %u ciphers (%s)",
+ vlr_subscr_name(conn->vsub), conn->a.conn_id, ei->perm_algo_len,
+ osmo_hexdump_nospc(ei->perm_algo, ei->perm_algo_len));
+ LOGPC(DMSC, LOGL_DEBUG, " key %s\n", osmo_hexdump_nospc(ei->key, ei->key_len));
- msg_resp = gsm0808_create_cipher(&ei, crm_ptr);
+ msg_resp = gsm0808_create_cipher(ei, include_imeisv ? &crm : NULL);
LOGP(DMSC, LOGL_DEBUG, "N-DATA.req(%u, %s)\n", conn->a.conn_id, osmo_hexdump(msg_resp->data, msg_resp->len));
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp);
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index d71b48bd8..f2cb9caf3 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -3410,8 +3410,18 @@ static int msc_vlr_set_ciph_mode(void *msc_conn_ref,
case RAN_GERAN_A:
DEBUGP(DMM, "-> CIPHER MODE COMMAND %s\n",
vlr_subscr_name(conn->vsub));
- return a_iface_tx_cipher_mode(conn, ciph, tuple->vec.kc, 8,
- retrieve_imeisv);
+ {
+ struct gsm0808_encrypt_info ei;
+
+ ei.perm_algo[0] = vlr_ciph_to_gsm0808_alg_id(ciph);
+ ei.perm_algo_len = 1;
+
+ OSMO_ASSERT(sizeof(ei.key) >= sizeof(tuple->vec.kc));
+ memcpy(ei.key, tuple->vec.kc, sizeof(tuple->vec.kc));
+ ei.key_len = sizeof(tuple->vec.kc);
+
+ return a_iface_tx_cipher_mode(conn, &ei, retrieve_imeisv);
+ }
case RAN_UTRAN_IU:
#ifdef BUILD_IU
DEBUGP(DMM, "-> SECURITY MODE CONTROL %s\n",