libosmogsm: Ensure MILENAGE + XOR-3G K length is 128 bit
Since Change-Id Ie775fedba4a3fa12314c0f7c8a369662ef6a40df we are
supporting K-lengths != 128 bit. However, our existing MILENAGE
and XOR-3G algorithms only support that key length, so let's add
some explicit checks for that.
Change-Id: Iae8b93cf059abda087101cdd01bbcf92d355753b
diff --git a/src/gsm/auth_xor.c b/src/gsm/auth_xor.c
index c94b02f..a506a03 100644
--- a/src/gsm/auth_xor.c
+++ b/src/gsm/auth_xor.c
@@ -55,9 +55,11 @@
/* Step 1: xdout = (ki or k) ^ rand */
if (aud->type == OSMO_AUTH_TYPE_GSM)
xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout));
- else if (aud->type == OSMO_AUTH_TYPE_UMTS)
+ else if (aud->type == OSMO_AUTH_TYPE_UMTS) {
+ if (aud->u.umts.k_len != 16)
+ return -EINVAL;
xor(xdout, aud->u.umts.k, _rand, sizeof(xdout));
- else
+ } else
return -ENOTSUP;
/**
@@ -141,9 +143,11 @@
/* Step 1: xdout = (ki or k) ^ rand */
if (aud->type == OSMO_AUTH_TYPE_GSM)
xor(xdout, aud->u.gsm.ki, _rand, sizeof(xdout));
- else if (aud->type == OSMO_AUTH_TYPE_UMTS)
+ else if (aud->type == OSMO_AUTH_TYPE_UMTS) {
+ if (aud->u.umts.k_len != 16)
+ return -EINVAL;
xor(xdout, aud->u.umts.k, _rand, sizeof(xdout));
- else
+ } else
return -ENOTSUP;
/* Step 2: ak = xdout[2-8] */