diff --git a/lib/test/common/test_f12345.cc b/lib/test/common/test_f12345.cc index 1c5375c43..e75d80bd7 100644 --- a/lib/test/common/test_f12345.cc +++ b/lib/test/common/test_f12345.cc @@ -63,9 +63,19 @@ void test_set_2() uint8_t op[] = {0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6, 0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18}; // f1 - uint8_t mac_o[8]; + uint8_t opc_o[16]; + err_lte = liblte_compute_opc(k,op,opc_o); + assert(err_lte == LIBLTE_SUCCESS); + + arrprint(opc_o, sizeof(opc_o)); + + uint8_t opc_a[] = {0xcd, 0x63, 0xcb, 0x71, 0x95, 0x4a, 0x9f, 0x4e, 0x48, 0xa5, 0x99, 0x4e, 0x37, 0xa0, 0x2b, 0xaf}; + err_cmp = arrcmp(opc_o,opc_a,sizeof(opc_o)); + assert(err_cmp == 0); + + uint8_t mac_o[8]; err_lte = liblte_security_milenage_f1(k, - op, + opc_o, rand, sqn, amf, @@ -84,7 +94,7 @@ void test_set_2() uint8_t mac_so[8]; err_lte = liblte_security_milenage_f1_star(k, - op, + opc_o, rand, sqn, amf, @@ -93,9 +103,9 @@ void test_set_2() assert(err_lte == LIBLTE_SUCCESS); uint8_t mac_s[] = {0x01, 0xcf, 0xaf, 0x9e, 0xc4, 0xe8, 0x71, 0xe9}; - + arrprint(mac_so, sizeof(mac_so)); - + err_cmp = arrcmp(mac_so, mac_s, sizeof(mac_s)); assert(err_cmp == 0); @@ -106,7 +116,7 @@ void test_set_2() uint8_t ak_o[6]; err_lte = liblte_security_milenage_f2345(k, - op, + opc_o, rand, res_o, ck_o, @@ -126,7 +136,7 @@ void test_set_2() err_cmp = arrcmp(res_o, res, sizeof(res)); assert(err_cmp == 0); - // CK + // CK arrprint(ck_o, sizeof(ck_o)); err_cmp = arrcmp(ck_o, ck, sizeof(ck)); @@ -142,10 +152,10 @@ void test_set_2() err_cmp = arrcmp(ak_o, ak, sizeof(ak)); assert(err_cmp == 0); - // f star + // f star uint8_t ak_star_o[6]; - - err_lte = liblte_security_milenage_f5_star(k, op, rand, ak_star_o); + + err_lte = liblte_security_milenage_f5_star(k, opc_o, rand, ak_star_o); assert(err_lte == LIBLTE_SUCCESS); arrprint(ak_star_o, sizeof(ak_star_o)); @@ -160,8 +170,9 @@ void test_set_2() */ int main(int argc, char * argv[]) { - /* + test_set_2(); + /* test_set_3(); test_set_4(); test_set_5(); diff --git a/srsepc/hdr/hss/hss.h b/srsepc/hdr/hss/hss.h index 26bbe8aa6..c81ec6296 100644 --- a/srsepc/hdr/hss/hss.h +++ b/srsepc/hdr/hss/hss.h @@ -91,7 +91,7 @@ private: void gen_rand(uint8_t rand_[16]); - bool get_k_amf_op_sqn(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op, uint8_t *sqn); + bool get_k_amf_opc_sqn(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op, uint8_t *sqn); bool gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uint8_t *rand, uint8_t *xres); bool gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uint8_t *rand, uint8_t *xres); diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index eaf206f5c..fa4c89bd9 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -180,7 +180,6 @@ hss::read_db_file(std::string db_filename) m_hss_log->error("Neither OP nor OPc configured.\n"); return false; } - get_uint_vec_from_hex_str(split[4],ue_ctx->op,16); get_uint_vec_from_hex_str(split[5],ue_ctx->amf,2); get_uint_vec_from_hex_str(split[6],ue_ctx->sqn,6); @@ -321,10 +320,10 @@ hss::resync_sqn_milenage(uint64_t imsi, uint8_t *auts) uint8_t k[16]; uint8_t amf[2]; - uint8_t op[16]; + uint8_t opc[16]; uint8_t sqn[6]; - if(!get_k_amf_op_sqn(imsi, k, amf, op, sqn)) + if(!get_k_amf_opc_sqn(imsi, k, amf, opc, sqn)) { return false; } @@ -340,13 +339,13 @@ hss::resync_sqn_milenage(uint64_t imsi, uint8_t *auts) } m_hss_log->debug_hex(k, 16, "User Key : "); - m_hss_log->debug_hex(op, 16, "User OP : "); + m_hss_log->debug_hex(opc, 16, "User OPc : "); m_hss_log->debug_hex(last_rand, 16, "User Last Rand : "); m_hss_log->debug_hex(auts, 16, "AUTS : "); m_hss_log->debug_hex(sqn_ms_xor_ak, 6, "SQN xor AK : "); m_hss_log->debug_hex(mac_s, 8, "MAC : "); - security_milenage_f5_star(k, op, last_rand, ak); + security_milenage_f5_star(k, opc, last_rand, ak); m_hss_log->debug_hex(ak, 6, "Resynch AK : "); uint8_t sqn_ms[6]; @@ -359,17 +358,10 @@ hss::resync_sqn_milenage(uint64_t imsi, uint8_t *auts) uint8_t mac_s_tmp[8]; - security_milenage_f1_star(k, op, last_rand, sqn_ms, amf, mac_s_tmp); + security_milenage_f1_star(k, opc, last_rand, sqn_ms, amf, mac_s_tmp); m_hss_log->debug_hex(mac_s_tmp, 8, "MAC calc : "); - /* - for(int i=0; i<8; i++){ - if(!(mac_s_tmp[i] == mac_s[i])){ - m_hss_log->error("Calculated MAC does not match sent MAC\n"); - return false; - } - } - */ + set_sqn(imsi, sqn_ms); return true; @@ -380,7 +372,7 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn { uint8_t k[16]; uint8_t amf[2]; - uint8_t op[16]; + uint8_t opc[16]; uint8_t sqn[6]; uint8_t ck[16]; @@ -389,14 +381,14 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn uint8_t mac[8]; - if(!get_k_amf_op_sqn(imsi, k, amf, op, sqn)) + if(!get_k_amf_opc_sqn(imsi, k, amf, opc, sqn)) { return false; } gen_rand(rand); security_milenage_f2345( k, - op, + opc, rand, xres, ck, @@ -404,7 +396,7 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn ak); m_hss_log->debug_hex(k, 16, "User Key : "); - m_hss_log->debug_hex(op, 16, "User OP : "); + m_hss_log->debug_hex(opc, 16, "User OPc : "); m_hss_log->debug_hex(rand, 16, "User Rand : "); m_hss_log->debug_hex(xres, 8, "User XRES: "); m_hss_log->debug_hex(ck, 16, "User CK: "); @@ -412,7 +404,7 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn m_hss_log->debug_hex(ak, 6, "User AK: "); security_milenage_f1( k, - op, + opc, rand, sqn, amf, @@ -459,7 +451,7 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin { uint8_t k[16]; uint8_t amf[2]; - uint8_t op[16]; + uint8_t opc[16]; uint8_t sqn[6]; uint8_t xdout[16]; @@ -472,7 +464,7 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin int i = 0; - if(!get_k_amf_op_sqn(imsi, k, amf, op, sqn)) + if(!get_k_amf_opc_sqn(imsi, k, amf, opc, sqn)) { return false; } @@ -493,7 +485,7 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin } m_hss_log->debug_hex(k, 16, "User Key : "); - m_hss_log->debug_hex(op, 16, "User OP : "); + m_hss_log->debug_hex(opc, 16, "User OPc : "); m_hss_log->debug_hex(rand, 16, "User Rand : "); m_hss_log->debug_hex(xres, 8, "User XRES: "); m_hss_log->debug_hex(ck, 16, "User CK: "); @@ -565,7 +557,7 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin bool -hss::get_k_amf_op_sqn(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op, uint8_t *sqn) +hss::get_k_amf_opc_sqn(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *opc, uint8_t *sqn) { std::map::iterator ue_ctx_it = m_imsi_to_ue_ctx.find(imsi); @@ -579,7 +571,7 @@ hss::get_k_amf_op_sqn(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op, uint m_hss_log->info("Found User %015lu\n",imsi); memcpy(k, ue_ctx->key, 16); memcpy(amf, ue_ctx->amf, 2); - memcpy(op, ue_ctx->op, 16); + memcpy(opc, ue_ctx->opc, 16); memcpy(sqn, ue_ctx->sqn, 6); return true; diff --git a/srsue/src/main.cc b/srsue/src/main.cc index eb9bd673b..ccf7ae88d 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -381,7 +381,6 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { } } - cout << vm.count("usim.op") <