laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/33089 )

 (

4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: libosmogsm: Ensure MILENAGE + XOR-3G K length is 128 bit
......................................................................

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
---
M src/gsm/auth_milenage.c
M src/gsm/auth_xor.c
2 files changed, 33 insertions(+), 4 deletions(-)

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




diff --git a/src/gsm/auth_milenage.c b/src/gsm/auth_milenage.c
index 84780c6..9e94293 100644
--- a/src/gsm/auth_milenage.c
+++ b/src/gsm/auth_milenage.c
@@ -19,6 +19,7 @@
  *
  */

+#include <errno.h>
 #include <osmocom/crypt/auth.h>
 #include <osmocom/core/bits.h>
 #include "milenage/common.h"
@@ -57,6 +58,11 @@

        OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE);

+       if (aud->u.umts.k_len != 16)
+               return -EINVAL;
+       if (aud->u.umts.opc_len != 16)
+               return -EINVAL;
+
        opc = gen_opc_if_needed(aud, gen_opc);
        if (!opc)
                return -1;
@@ -154,6 +160,11 @@

        OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_MILENAGE);

+       if (aud->u.umts.k_len != 16)
+               return -EINVAL;
+       if (aud->u.umts.opc_len != 16)
+               return -EINVAL;
+
        opc = gen_opc_if_needed(aud, gen_opc);

        rc = milenage_auts(opc, aud->u.umts.k, rand_auts, auts, sqn_out);
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] */

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iae8b93cf059abda087101cdd01bbcf92d355753b
Gerrit-Change-Number: 33089
Gerrit-PatchSet: 6
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to