Small bug fixes, debug print. MAC f1_star does not work

master
David Rupprecht 7 years ago
parent 244b68e76b
commit 52e7082aee

@ -109,7 +109,7 @@ private:
bool set_auth_algo(std::string auth_algo);
bool read_db_file(std::string db_file);
bool write_db_file(std::string db_file);
bool get_ue_ctx(uint64_t imsi, hss_ue_ctx_t *ue_ctx);
bool get_ue_ctx(uint64_t imsi, hss_ue_ctx_t **ue_ctx);
std::string hex_string(uint8_t *hex, int size);

@ -256,6 +256,7 @@ hss::resync_sqn(uint64_t imsi, uint8_t *auts)
ret = resync_sqn_milenage(imsi, auts);
break;
}
increment_sqn(imsi);
return ret;
}
@ -312,19 +313,21 @@ hss::resync_sqn_milenage(uint64_t imsi, uint8_t *auts)
}
m_hss_log->debug_hex(sqn_ms, 6, "SQN MS : ");
m_hss_log->debug_hex(amf, 2, "AMF : ");
uint8_t mac_s_tmp[8];
security_milenage_f1_star(k, op, 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;
@ -544,7 +547,7 @@ void
hss::increment_sqn(uint64_t imsi)
{
hss_ue_ctx_t *ue_ctx = NULL;
bool ret = get_ue_ctx(imsi, ue_ctx);
bool ret = get_ue_ctx(imsi, &ue_ctx);
if(ret == false)
{
return;
@ -560,7 +563,7 @@ hss::increment_sqn(uint64_t imsi)
sqn++;
m_hss_log->debug("Incremented IMSI: %015lu SQN: %d", imsi, sqn);
m_hss_log->debug("Incremented SQN (IMSI: %015lu) SQN: %d\n", imsi, sqn);
for(int i = 0; i < 6; i++){
ue_ctx->sqn[i] = p[5-i];
@ -571,7 +574,7 @@ void
hss::set_sqn(uint64_t imsi, uint8_t *sqn)
{
hss_ue_ctx_t *ue_ctx = NULL;
bool ret = get_ue_ctx(imsi, ue_ctx);
bool ret = get_ue_ctx(imsi, &ue_ctx);
if(ret == false)
{
return;
@ -583,7 +586,7 @@ void
hss::set_last_rand(uint64_t imsi, uint8_t *rand)
{
hss_ue_ctx_t *ue_ctx = NULL;
bool ret = get_ue_ctx(imsi, ue_ctx);
bool ret = get_ue_ctx(imsi, &ue_ctx);
if(ret == false)
{
return;
@ -596,7 +599,7 @@ void
hss::get_last_rand(uint64_t imsi, uint8_t *rand)
{
hss_ue_ctx_t *ue_ctx = NULL;
bool ret = get_ue_ctx(imsi, ue_ctx);
bool ret = get_ue_ctx(imsi, &ue_ctx);
if(ret == false)
{
return;
@ -614,7 +617,7 @@ hss::gen_rand(uint8_t rand_[16])
return;
}
bool hss::get_ue_ctx(uint64_t imsi, hss_ue_ctx_t *ue_ctx)
bool hss::get_ue_ctx(uint64_t imsi, hss_ue_ctx_t **ue_ctx)
{
std::map<uint64_t,hss_ue_ctx_t*>::iterator ue_ctx_it = m_imsi_to_ue_ctx.find(imsi);
if(ue_ctx_it == m_imsi_to_ue_ctx.end())
@ -623,7 +626,7 @@ bool hss::get_ue_ctx(uint64_t imsi, hss_ue_ctx_t *ue_ctx)
return false;
}
ue_ctx = ue_ctx_it->second;
*ue_ctx = ue_ctx_it->second;
return true;
}

Loading…
Cancel
Save