def test_m5g_kausf_vector(self): """Can we compute the vector that OAI generates?""" self.rand = (b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b' b'\x0c\r\x0e\x0f') # Inputs extracted from OAI logs key = b'F[\\\xe8\xb1\x99\xb4\x9f\xaa_\n.\xe28\xa6\xbc' sqn = 20672 op = 16 * b'\x11' amf = b'\x80\x00' serving_network = "5G:mnc456.mcc222.3gppnetwork.org" snni = serving_network.encode('utf-8') # Outputs extracted from OAI logs op_c = b'\xc4\xd5\xe49\x91\xb0\xc5Q\xaf\xf8\xb9%<\x131\xab' autn = b'\xba\xb4\x99\xbe\xd2"\x80\x00\xfa)\x93+?1\xde\x05' kausf = (b'\xed\x08\xc3Z\x0b\x93\x88\xdfr\x9a\x9a6\x80e\xd91' b'\x9a\x12\x14\x95g\x9c1\xe6\xcd\x14(\xd0W$\x10\xac') crypto = Milenage(amf) self.assertEqual(crypto.generate_opc(key, op), op_c) fiveg_ran_auth_vectors = \ crypto.generate_m5gran_vector(key, op_c, sqn, snni) self.assertEqual(self.rand, fiveg_ran_auth_vectors.rand) self.assertEqual(autn, fiveg_ran_auth_vectors.autn) ck = Milenage.f3(key, self.rand, op_c) ik = Milenage.f4(key, self.rand, op_c) kausf_ = crypto.generate_m5g_kausf(ck + ik, snni, autn) self.assertEqual(kausf, kausf_)
def test_f4(self): """ Tests that the f4 function works as expected. This is a test set 1 from 3GPP 35.207 6.3 """ # Fake the random self.rand = b'#U<\xbe\x967\xa8\x9d!\x8a\xe6M\xaeG\xbf5' # Inputs k = b'\x46\x5b\x5c\xe8\xb1\x99\xb4\x9f\xaa\x5f\x0a\x2e\xe2\x38\xa6\xbc' op = b'\xcd\xc2\x02\xd5\x12> \xf6+mgj\xc7,\xb3\x18' # Outputs opc = b'\xcdc\xcbq\x95J\x9fNH\xa5\x99N7\xa0+\xaf' f4 = b'\xf7\x69\xbc\xd7\x51\x04\x46\x04\x12\x76\x72\x71\x1c\x6d\x34\x41' self.assertEqual(Milenage.generate_opc(k, op), opc) ik = Milenage.f4(k, self.rand, opc) self.assertEqual(ik, f4)