From fd97caadb372b53681e89933b8e3501aec431475 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 19 Jun 2018 18:17:11 +0100 Subject: [PATCH] Revert "Merge branch 'op_vs_opc' into next" This reverts commit be2276b8da5670544824eb6905da2d721cedaa8a, reversing changes made to 4d3fd342f73c9f8847594c035142a189c5c2fb8e. --- lib/src/common/liblte_security.cc | 43 +++++-------------------------- srsepc/src/hss/hss.cc | 24 ++++++++++++----- 2 files changed, 25 insertions(+), 42 deletions(-) diff --git a/lib/src/common/liblte_security.cc b/lib/src/common/liblte_security.cc index 020f019c9..1cf83e5b3 100644 --- a/lib/src/common/liblte_security.cc +++ b/lib/src/common/liblte_security.cc @@ -37,7 +37,7 @@ #include "srslte/common/liblte_security.h" #include "srslte/common/liblte_ssl.h" #include "math.h" -#include + /******************************************************************************* DEFINES *******************************************************************************/ @@ -1124,15 +1124,7 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1(uint8 *k, rijndael_key_schedule(k, &round_keys); // Compute OPc - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); - - //compute_OPc(&round_keys, op, op_c); + compute_OPc(&round_keys, op, op_c); // Compute temp for(i=0; i<16; i++) @@ -1215,16 +1207,8 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f1_star(uint8 *k, // Initialize the round keys rijndael_key_schedule(k, &round_keys); - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); - // Compute OPc - //compute_OPc(&round_keys, op, op_c); + compute_OPc(&round_keys, op, op_c); // Compute temp for(i=0; i<16; i++) @@ -1309,14 +1293,8 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f2345(uint8 *k, rijndael_key_schedule(k, &round_keys); // Compute OPc - //compute_OPc(&round_keys, op, op_c); - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); + compute_OPc(&round_keys, op, op_c); + // Compute temp for(i=0; i<16; i++) { @@ -1420,15 +1398,8 @@ LIBLTE_ERROR_ENUM liblte_security_milenage_f5_star(uint8 *k, rijndael_key_schedule(k, &round_keys); // Compute OPc - //compute_OPc(&round_keys, op, op_c); - printf("OPc 0x: "); - for(i=0;i<16;i++) - { - op_c[i] = op[i]; - printf("%02x", op_c[i]); - } - printf("\n"); - + compute_OPc(&round_keys, op, op_c); + // Compute temp for(i=0; i<16; i++) { diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index cb15cebf0..9a8db0e3a 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -354,7 +354,7 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn return false; } gen_rand(rand); - + security_milenage_f2345( k, op, rand, @@ -498,7 +498,7 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin mcc, mnc, k_asme); - + m_hss_log->debug("User MCC : %x MNC : %x \n", mcc, mnc); m_hss_log->debug_hex(k_asme, 32, "User k_asme : "); @@ -545,7 +545,7 @@ hss::get_k_amf_op_sqn(uint64_t imsi, uint8_t *k, uint8_t *amf, uint8_t *op, uint return true; } -void +void hss::increment_sqn(uint64_t imsi) { hss_ue_ctx_t *ue_ctx = NULL; @@ -562,9 +562,9 @@ hss::increment_sqn(uint64_t imsi) for(int i = 0; i < 6; i++) { p[5-i] = (uint8_t) ((ue_ctx->sqn[i])); } - + sqn++; - + m_hss_log->debug("Incremented SQN (IMSI: %" PRIu64 ") SQN: %" PRIu64 "\n", imsi, sqn); for(int i = 0; i < 6; i++){ @@ -627,7 +627,7 @@ bool hss::get_ue_ctx(uint64_t imsi, hss_ue_ctx_t **ue_ctx) m_hss_log->info("User not found. IMSI: %015lu\n",imsi); return false; } - + *ue_ctx = ue_ctx_it->second; return true; } @@ -660,6 +660,7 @@ hss::get_uint_vec_from_hex_str(const std::string &key_str, uint8_t *key, uint le return; } + std::string hss::hex_string(uint8_t *hex, int size) { @@ -671,4 +672,15 @@ hss::hex_string(uint8_t *hex, int size) } return ss.str(); } + /* +uint64_t +string_to_imsi() +{ + uint64_t imsi = 0; + for(int i=0;i<=14;i++){ + imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i); + } + return imsi; +} + */ } //namespace srsepc