<p>Max has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12381">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Use define for key buffers<br><br>Add corresponding spec. references and comments where appropriate.<br><br>Change-Id: If5e2aad86eaecd8eada667b3488ba415d81c6312<br>---<br>M include/osmocom/crypt/auth.h<br>M src/gsm/auth_core.c<br>M tests/auth/milenage_test.c<br>3 files changed, 9 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/81/12381/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h</span><br><span>index e544126..c653b61 100644</span><br><span>--- a/include/osmocom/crypt/auth.h</span><br><span>+++ b/include/osmocom/crypt/auth.h</span><br><span>@@ -42,7 +42,7 @@</span><br><span>   union {</span><br><span>              struct {</span><br><span>                     uint8_t opc[16]; /*!< operator invariant value */</span><br><span style="color: hsl(0, 100%, 40%);">-                    uint8_t k[16];  /*!< secret key of the subscriber */</span><br><span style="color: hsl(120, 100%, 40%);">+                       uint8_t k[OSMO_A5_MAX_KEY_LEN_BYTES];   /*!< secret key of the subscriber */</span><br><span>                      uint8_t amf[2];</span><br><span>                      uint64_t sqn;   /*!< sequence number (in: prev sqn; out: used sqn) */</span><br><span>                     int opc_is_op;  /*!< is the OPC field OPC (0) or OP (1) ? */</span><br><span>@@ -60,8 +60,8 @@</span><br><span> struct osmo_auth_vector {</span><br><span>     uint8_t rand[16];       /*!< random challenge */</span><br><span>  uint8_t autn[16];       /*!< authentication nonce */</span><br><span style="color: hsl(0, 100%, 40%);">- uint8_t ck[16];         /*!< ciphering key */</span><br><span style="color: hsl(0, 100%, 40%);">-        uint8_t ik[16];         /*!< integrity key */</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t ck[OSMO_A5_MAX_KEY_LEN_BYTES];          /*!< ciphering key */</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t ik[OSMO_A5_MAX_KEY_LEN_BYTES];          /*!< integrity key */</span><br><span>     uint8_t res[16];        /*!< authentication result */</span><br><span>     uint8_t res_len;        /*!< length (in bytes) of res */</span><br><span>  uint8_t kc[8];          /*!< Kc for GSM encryption (A5) */</span><br><span>diff --git a/src/gsm/auth_core.c b/src/gsm/auth_core.c</span><br><span>index f171ed4..9e750a0 100644</span><br><span>--- a/src/gsm/auth_core.c</span><br><span>+++ b/src/gsm/auth_core.c</span><br><span>@@ -98,7 +98,7 @@</span><br><span>   return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* C5 function to derive UMTS IK from GSM Kc */</span><br><span style="color: hsl(120, 100%, 40%);">+/* 3GPP TS 33.102 §6.8.2.3 C5 function to derive UMTS IK from GSM Kc */</span><br><span> static inline void c5_function(uint8_t *ik, const uint8_t *kc)</span><br><span> {</span><br><span>   unsigned int i;</span><br><span>@@ -110,7 +110,7 @@</span><br><span>                ik[i] = ik[i-12];</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* C4 function to derive UMTS CK from GSM Kc */</span><br><span style="color: hsl(120, 100%, 40%);">+/* 3GPP TS 33.102 §6.8.2.3 C4 function to derive UMTS CK from GSM Kc */</span><br><span> void osmo_c4(uint8_t *ck, const uint8_t *kc)</span><br><span> {</span><br><span>     memcpy(ck, kc, 8);</span><br><span>diff --git a/tests/auth/milenage_test.c b/tests/auth/milenage_test.c</span><br><span>index 2bd3cf2..8b058e5 100644</span><br><span>--- a/tests/auth/milenage_test.c</span><br><span>+++ b/tests/auth/milenage_test.c</span><br><span>@@ -23,7 +23,10 @@</span><br><span> </span><br><span>     if (vec->auth_types & OSMO_AUTH_TYPE_GSM) {</span><br><span>           printf("SRES:\t%s\n", osmo_hexdump(vec->sres, sizeof(vec->sres)));</span><br><span style="color: hsl(0, 100%, 40%);">-              printf("Kc:\t%s\n", osmo_hexdump(vec->kc, sizeof(vec->kc)));</span><br><span style="color: hsl(120, 100%, 40%);">+          /* According to 3GPP TS 55.205 Sec. 4 the GSM-MILENAGE output is limited to 64 bits.</span><br><span style="color: hsl(120, 100%, 40%);">+             According to 3GPP TS 33.102 Annex. B5 in UMTS security context Kc can be 128 bits.</span><br><span style="color: hsl(120, 100%, 40%);">+            Here we test the former, so make sure we only print interesting Kc bits. */</span><br><span style="color: hsl(120, 100%, 40%);">+                printf("Kc:\t%s\n", osmo_hexdump(vec->kc, OSMO_A5_MAX_KEY_LEN_BYTES/2));</span><br><span>        }</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12381">change 12381</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12381"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If5e2aad86eaecd8eada667b3488ba415d81c6312 </div>
<div style="display:none"> Gerrit-Change-Number: 12381 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>