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.orgVadim Yanitskiy has submitted this change and it was merged.
Change subject: libmsc: add support for both comp128v2 and comp128v3
......................................................................
libmsc: add support for both comp128v2 and comp128v3
This change adds support for both comp128v2 and comp128v3 GSM
A3/A8 algorithms. Since they already implemented in libosmocore,
the corresponding it's API is used.
Change-Id: Ic761be0220397d100c9e6345d4d01af4889dc7c1
---
M openbsc/include/openbsc/gsm_data.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
5 files changed, 53 insertions(+), 5 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 57fa301..39c7458 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -54,6 +54,8 @@
AUTH_ALGO_NONE,
AUTH_ALGO_XOR,
AUTH_ALGO_COMP128v1,
+ AUTH_ALGO_COMP128v2,
+ AUTH_ALGO_COMP128v3,
};
struct gsm_auth_info {
diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c
index 19def1e..8c8af11 100644
--- a/openbsc/src/libmsc/auth.c
+++ b/openbsc/src/libmsc/auth.c
@@ -25,6 +25,7 @@
#include <openbsc/auth.h>
#include <openbsc/gsm_data.h>
+#include <osmocom/gsm/comp128v23.h>
#include <osmocom/gsm/comp128.h>
#include <osmocom/core/utils.h>
@@ -62,7 +63,8 @@
}
static int
-_use_comp128_v1(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple)
+_use_comp128(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple,
+ enum gsm_auth_algo algo)
{
if (ainfo->a3a8_ki_len != A38_COMP128_KEY_LEN) {
LOGP(DMM, LOGL_ERROR, "Invalid COMP128v1 key (len=%d) %s\n",
@@ -71,7 +73,23 @@
return -1;
}
- comp128(ainfo->a3a8_ki, atuple->vec.rand, atuple->vec.sres, atuple->vec.kc);
+ switch (algo) {
+ case AUTH_ALGO_COMP128v1:
+ comp128(ainfo->a3a8_ki, atuple->vec.rand,
+ atuple->vec.sres, atuple->vec.kc);
+ break;
+ case AUTH_ALGO_COMP128v2:
+ comp128v2(ainfo->a3a8_ki, atuple->vec.rand,
+ atuple->vec.sres, atuple->vec.kc);
+ break;
+ case AUTH_ALGO_COMP128v3:
+ comp128v3(ainfo->a3a8_ki, atuple->vec.rand,
+ atuple->vec.sres, atuple->vec.kc);
+ break;
+ default:
+ /* Unsupported version */
+ return -ENOTSUP;
+ }
return 0;
}
@@ -139,7 +157,9 @@
break;
case AUTH_ALGO_COMP128v1:
- if (_use_comp128_v1(&ainfo, atuple))
+ case AUTH_ALGO_COMP128v2:
+ case AUTH_ALGO_COMP128v3:
+ if (_use_comp128(&ainfo, atuple, ainfo.auth_algo))
return AUTH_NOT_AVAIL;
break;
diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c
index c99dde4..8e4e8b6 100644
--- a/openbsc/src/libmsc/ctrl_commands.c
+++ b/openbsc/src/libmsc/ctrl_commands.c
@@ -41,6 +41,10 @@
return true;
if (strcasecmp(alg, "comp128v1") == 0)
return true;
+ if (strcasecmp(alg, "comp128v2") == 0)
+ return true;
+ if (strcasecmp(alg, "comp128v3") == 0)
+ return true;
return false;
}
@@ -118,6 +122,10 @@
ainfo.auth_algo = AUTH_ALGO_XOR;
else if (strcasecmp(alg, "comp128v1") == 0)
ainfo.auth_algo = AUTH_ALGO_COMP128v1;
+ else if (strcasecmp(alg, "comp128v2") == 0)
+ ainfo.auth_algo = AUTH_ALGO_COMP128v2;
+ else if (strcasecmp(alg, "comp128v3") == 0)
+ ainfo.auth_algo = AUTH_ALGO_COMP128v3;
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 b88c139..a97e1ec 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -775,11 +775,13 @@
return CMD_SUCCESS;
}
-#define A3A8_ALG_TYPES "(none|xor|comp128v1)"
+#define A3A8_ALG_TYPES "(none|xor|comp128v1|comp128v2|comp128v3)"
#define A3A8_ALG_HELP \
"Use No A3A8 algorithm\n" \
"Use XOR algorithm\n" \
- "Use COMP128v1 algorithm\n"
+ "Use COMP128v1 algorithm\n" \
+ "Use COMP128v2 algorithm\n" \
+ "Use COMP128v3 algorithm\n"
DEFUN(ena_subscr_a3a8,
ena_subscr_a3a8_cmd,
@@ -811,6 +813,12 @@
} else if (!strcasecmp(alg_str, "comp128v1")) {
ainfo.auth_algo = AUTH_ALGO_COMP128v1;
minlen = maxlen = A38_COMP128_KEY_LEN;
+ } else if (!strcasecmp(alg_str, "comp128v2")) {
+ ainfo.auth_algo = AUTH_ALGO_COMP128v2;
+ minlen = maxlen = A38_COMP128_KEY_LEN;
+ } else if (!strcasecmp(alg_str, "comp128v3")) {
+ ainfo.auth_algo = AUTH_ALGO_COMP128v3;
+ minlen = maxlen = A38_COMP128_KEY_LEN;
} else {
/* Unknown method */
subscr_put(subscr);
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index fb69027..b63dd27 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -496,6 +496,16 @@
self.assertEquals(r['var'], 'subscriber-modify-v1')
self.assertEquals(r['value'], 'OK')
+ r = self.do_set('subscriber-modify-v1', '2620345,445566,comp128v2,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,comp128v3,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/5765
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic761be0220397d100c9e6345d4d01af4889dc7c1
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Alexander Chemeris <Alexander.Chemeris at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>