Change in osmo-msc[master]: ran_msg_a.c: use gsm0808_create_cipher2()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Fri Jun 25 08:11:58 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/24763 )

Change subject: ran_msg_a.c: use gsm0808_create_cipher2()
......................................................................

ran_msg_a.c: use gsm0808_create_cipher2()

Use new API in Cipher Mode Command to prepare for A5/4 support.

Depends: Ib3906085e0c6e5a496a9f755f0f786238a86ca34 (libosmocore)
Related: SYS#5324
Change-Id: Ib238d367b8d5d07b6ab4cb2e48fbf4ce22ca4476
---
M TODO-RELEASE
M src/libmsc/ran_msg_a.c
2 files changed, 17 insertions(+), 13 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, approved
  dexter: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/TODO-RELEASE b/TODO-RELEASE
index d0852fc..2297063 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public release: c:r:0.
 #library	what		description / commit summary line
+libosmocore	>1.5.1		A5/4 support requires new API gsm0808_create_cipher2()
diff --git a/src/libmsc/ran_msg_a.c b/src/libmsc/ran_msg_a.c
index 4cce289..61e5024 100644
--- a/src/libmsc/ran_msg_a.c
+++ b/src/libmsc/ran_msg_a.c
@@ -1058,14 +1058,17 @@
 		   gsm0808_encrypt_info_key_fits_osmo_auth_vec_kc);
 static struct msgb *ran_a_make_cipher_mode_command(struct osmo_fsm_inst *fi, const struct ran_cipher_mode_command *cm)
 {
-	struct gsm0808_encrypt_info ei = {};
+	struct gsm0808_cipher_mode_command cmc = {
+		.cipher_response_mode_present = true,
+		.cipher_response_mode = 1, /* 1: include IMEISV (3GPP TS 48.008 3.2.2.34) */
+	};
+	struct gsm0808_encrypt_info *ei = &cmc.ei;
 	char buf[16 * 2 + 1];
-	const uint8_t cipher_response_mode = 1;
 
-	if (make_encrypt_info_perm_algo(fi, &ei, cm->geran.a5_encryption_mask, cm->classmark))
+	if (make_encrypt_info_perm_algo(fi, ei, cm->geran.a5_encryption_mask, cm->classmark))
 		return NULL;
 
-	if (ei.perm_algo_len == 0) {
+	if (ei->perm_algo_len == 0) {
 		LOG_RAN_A_ENC(fi, LOGL_ERROR, "cannot start ciphering, no intersection between MSC-configured"
 			       " and MS-supported A5 algorithms. MSC: 0x%02x  MS: %s\n",
 			       cm->geran.a5_encryption_mask, osmo_gsm48_classmark_a5_name(cm->classmark));
@@ -1076,26 +1079,26 @@
 	 * tokens.  vec->kc was calculated from the GSM algorithm and is not
 	 * necessarily a match for the UMTS AKA tokens. */
 	if (cm->geran.umts_aka)
-		osmo_auth_c3(ei.key, cm->vec->ck, cm->vec->ik);
+		osmo_auth_c3(ei->key, cm->vec->ck, cm->vec->ik);
 	else
-		memcpy(ei.key, cm->vec->kc, sizeof(cm->vec->kc));
-	ei.key_len = sizeof(cm->vec->kc);
+		memcpy(ei->key, cm->vec->kc, sizeof(cm->vec->kc));
+	ei->key_len = sizeof(cm->vec->kc);
 
 	/* Store chosen GERAN key where the caller asked it to be stored.
 	 * alg_id remains unknown until we receive a Cipher Mode Complete from the BSC */
 	if (cm->geran.chosen_key) {
-		if (ei.key_len > sizeof(cm->geran.chosen_key->key)) {
+		if (ei->key_len > sizeof(cm->geran.chosen_key->key)) {
 			LOG_RAN_A_ENC(fi, LOGL_ERROR, "Chosen key is larger than I can store\n");
 			return NULL;
 		}
-		memcpy(cm->geran.chosen_key->key, ei.key, ei.key_len);
-		cm->geran.chosen_key->key_len = ei.key_len;
+		memcpy(cm->geran.chosen_key->key, ei->key, ei->key_len);
+		cm->geran.chosen_key->key_len = ei->key_len;
 	}
 
 	LOG_RAN_A_ENC(fi, LOGL_DEBUG, "Tx BSSMAP CIPHER MODE COMMAND to BSC, %u ciphers (%s) key %s\n",
-		       ei.perm_algo_len, osmo_hexdump_nospc(ei.perm_algo, ei.perm_algo_len),
-		       osmo_hexdump_buf(buf, sizeof(buf), ei.key, ei.key_len, NULL, false));
-	return gsm0808_create_cipher(&ei, cm->geran.retrieve_imeisv ? &cipher_response_mode : NULL);
+		       ei->perm_algo_len, osmo_hexdump_nospc(ei->perm_algo, ei->perm_algo_len),
+		       osmo_hexdump_buf(buf, sizeof(buf), ei->key, ei->key_len, NULL, false));
+	return gsm0808_create_cipher2(&cmc);
 }
 
 struct msgb *ran_a_make_handover_request(struct osmo_fsm_inst *log_fi, const struct ran_handover_request *n)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/24763
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: Ib238d367b8d5d07b6ab4cb2e48fbf4ce22ca4476
Gerrit-Change-Number: 24763
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210625/735b17c4/attachment.htm>


More information about the gerrit-log mailing list