[PATCH] openbsc[master]: libmsc/auth.c: add Milenage algorithm support

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/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Tue Mar 20 10:57:41 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/7399

to look at the new patch set (#2).

libmsc/auth.c: add Milenage algorithm support

Despite the current Milenage implementation in libosmogsm
does support 2G authentication, it has been disabled.
Let's enable it in order to support SIM cards
with Milenage algorithm set for 2G mode.

Change-Id: I519e6bb4eb37a5ac70556d580a18fcae62730a76
---
M openbsc/include/openbsc/gsm_data.h
M openbsc/include/openbsc/gsm_data_shared.h
M openbsc/src/libmsc/auth.c
M openbsc/src/libmsc/ctrl_commands.c
M openbsc/src/libmsc/vty_interface_layer3.c
M openbsc/tests/ctrl_test_runner.py
6 files changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/99/7399/2

diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index b823acc..9ed56e6 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -57,6 +57,7 @@
 	AUTH_ALGO_COMP128v1,
 	AUTH_ALGO_COMP128v2,
 	AUTH_ALGO_COMP128v3,
+	AUTH_ALGO_MILENAGE,
 };
 
 struct gsm_auth_info {
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index ddd5991..209fb1c 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -135,6 +135,7 @@
 #define A38_XOR_MIN_KEY_LEN	12
 #define A38_XOR_MAX_KEY_LEN	16
 #define A38_COMP128_KEY_LEN	16
+#define A38_MILENAGE_KEY_LEN	16
 #define RSL_ENC_ALG_A5(x)	(x+1)
 #define MAX_EARFCN_LIST 32
 
diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c
index 059d7b3..645349f 100644
--- a/openbsc/src/libmsc/auth.c
+++ b/openbsc/src/libmsc/auth.c
@@ -106,6 +106,9 @@
 	case AUTH_ALGO_XOR:
 		aud2g.algo = OSMO_AUTH_ALG_XOR;
 		break;
+	case AUTH_ALGO_MILENAGE:
+		aud2g.algo = OSMO_AUTH_ALG_MILENAGE;
+		break;
 	case AUTH_ALGO_COMP128v1:
 		aud2g.algo = OSMO_AUTH_ALG_COMP128v1;
 		break;
diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c
index 8e4e8b6..924dbb5 100644
--- a/openbsc/src/libmsc/ctrl_commands.c
+++ b/openbsc/src/libmsc/ctrl_commands.c
@@ -45,6 +45,8 @@
 		return true;
 	if (strcasecmp(alg, "comp128v3") == 0)
 		return true;
+	if (strcasecmp(alg, "milenage") == 0)
+		return true;
 	return false;
 }
 
@@ -126,6 +128,8 @@
 				ainfo.auth_algo = AUTH_ALGO_COMP128v2;
 			else if (strcasecmp(alg, "comp128v3") == 0)
 				ainfo.auth_algo = AUTH_ALGO_COMP128v3;
+			else if (strcasecmp(alg, "milenage") == 0)
+				ainfo.auth_algo = AUTH_ALGO_MILENAGE;
 
 			rc = osmo_hexparse(ki, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki));
 			if (rc < 0) {
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index a97e1ec..4c2549d 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -775,10 +775,11 @@
 	return CMD_SUCCESS;
 }
 
-#define A3A8_ALG_TYPES "(none|xor|comp128v1|comp128v2|comp128v3)"
+#define A3A8_ALG_TYPES "(none|xor|milenage|comp128v1|comp128v2|comp128v3)"
 #define A3A8_ALG_HELP 			\
 	"Use No A3A8 algorithm\n"	\
 	"Use XOR algorithm\n"		\
+	"Use Milenage algorithm\n"  \
 	"Use COMP128v1 algorithm\n" \
 	"Use COMP128v2 algorithm\n" \
 	"Use COMP128v3 algorithm\n"
@@ -810,6 +811,9 @@
 		ainfo.auth_algo = AUTH_ALGO_XOR;
 		minlen = A38_XOR_MIN_KEY_LEN;
 		maxlen = A38_XOR_MAX_KEY_LEN;
+	} else if (!strcasecmp(alg_str, "milenage")) {
+		ainfo.auth_algo = AUTH_ALGO_MILENAGE;
+		minlen = maxlen = A38_MILENAGE_KEY_LEN;
 	} else if (!strcasecmp(alg_str, "comp128v1")) {
 		ainfo.auth_algo = AUTH_ALGO_COMP128v1;
 		minlen = maxlen = A38_COMP128_KEY_LEN;
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index b63dd27..c4f67ef 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -506,6 +506,11 @@
         self.assertEquals(r['var'], 'subscriber-modify-v1')
         self.assertEquals(r['value'], 'OK')
 
+        r = self.do_set('subscriber-modify-v1', '2620345,445566,milenage,00112233445566778899AABBCCDDEEFF')
+        self.assertEquals(r['mtype'], 'SET_REPLY')
+        self.assertEquals(r['var'], 'subscriber-modify-v1')
+        self.assertEquals(r['value'], 'OK')
+
         r = self.do_set('subscriber-modify-v1', '2620345,445566,none')
         self.assertEquals(r['mtype'], 'SET_REPLY')
         self.assertEquals(r['var'], 'subscriber-modify-v1')

-- 
To view, visit https://gerrit.osmocom.org/7399
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I519e6bb4eb37a5ac70556d580a18fcae62730a76
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list