summaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-01-12 03:13:33 +0600
committerVadim Yanitskiy <axilirator@gmail.com>2018-01-12 03:13:33 +0600
commit82cfa3945c35be251dff168260d30756bc3d60db (patch)
tree5ce43fc3a2ac8486f20787232f96ccdca8734ae5 /openbsc/src/libmsc
parente44a5687c4728a3ef1f730ec7349cef135cf174a (diff)
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
Diffstat (limited to 'openbsc/src/libmsc')
-rw-r--r--openbsc/src/libmsc/auth.c26
-rw-r--r--openbsc/src/libmsc/ctrl_commands.c8
-rw-r--r--openbsc/src/libmsc/vty_interface_layer3.c12
3 files changed, 41 insertions, 5 deletions
diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c
index 19def1ec1..8c8af11c6 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 @@ _use_xor(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple)
}
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 @@ _use_comp128_v1(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple)
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 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple,
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 c99dde44c..8e4e8b634 100644
--- a/openbsc/src/libmsc/ctrl_commands.c
+++ b/openbsc/src/libmsc/ctrl_commands.c
@@ -41,6 +41,10 @@ static bool alg_supported(const char *alg)
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 @@ static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data)
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 b88c139b0..a97e1ece4 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -775,11 +775,13 @@ DEFUN(ena_subscr_handover,
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 @@ DEFUN(ena_subscr_a3a8,
} 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);