Fixed MAC failure due to wrong size and xor debug prints

This commit is contained in:
David Rupprecht 2018-01-22 14:35:38 +01:00
parent 6fbe26d653
commit 9f4e8c0632
2 changed files with 19 additions and 7 deletions

View File

@ -250,7 +250,7 @@ hss::gen_auth_info_answer_milenage(uint64_t imsi, uint8_t *k_asme, uint8_t *autn
k_asme);
m_hss_log->debug("User MCC : %x MNC : %x \n", mcc, mnc);
m_hss_log->debug_hex(k_asme, 16, "User k_asme : ");
m_hss_log->debug_hex(k_asme, 32, "User k_asme : ");
//Generate AUTN (autn = sqn ^ ak |+| amf |+| mac)
for(int i=0;i<6;i++ )
@ -310,6 +310,14 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin
ak[i] = xdout[i+3];
}
m_hss_log->debug_hex(k, 16, "User Key : ");
m_hss_log->debug_hex(op, 16, "User OP : ");
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: ");
m_hss_log->debug_hex(ik, 16, "User IK: ");
m_hss_log->debug_hex(ak, 6, "User AK: ");
// Generate cdout
for(i=0; i<6; i++) {
cdout[i] = sqn[i];
@ -323,6 +331,9 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin
mac[i] = xdout[i] ^ cdout[i];
}
m_hss_log->debug_hex(sqn, 6, "User SQN : ");
m_hss_log->debug_hex(mac, 8, "User MAC : ");
//Generate AUTN (autn = sqn ^ ak |+| amf |+| mac)
for(int i=0;i<6;i++ )
{
@ -345,6 +356,9 @@ 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 : ");
//Generate AUTN (autn = sqn ^ ak |+| amf |+| mac)
for(int i=0;i<6;i++ )
@ -360,9 +374,7 @@ hss::gen_auth_info_answer_xor(uint64_t imsi, uint8_t *k_asme, uint8_t *autn, uin
autn[8+i]=mac[i];
}
m_hss_log->debug_hex(sqn, 6, "User SQN : ");
m_hss_log->debug_hex(autn, 8, "User AUTN: ");
m_hss_log->debug_hex(xres, 8, "User XRES: ");
return true;
}

View File

@ -241,7 +241,7 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
{
uint8_t k_asme[32];
uint8_t autn[16];
uint8_t rand[6];
uint8_t rand[16];
uint8_t xres[8];
ue_ctx_t ue_ctx;
@ -317,7 +317,7 @@ s1ap_nas_transport::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
m_s1ap->add_new_ue_ctx(ue_ctx);
//Pack NAS Authentication Request in Downlink NAS Transport msg
pack_authentication_request(reply_buffer, ue_ctx.enb_ue_s1ap_id, ue_ctx.mme_ue_s1ap_id, autn, rand);
//Send reply to eNB
*reply_flag = true;
m_s1ap_log->info("Downlink NAS: Sending Athentication Request\n");
@ -584,7 +584,7 @@ bool
s1ap_nas_transport::handle_identity_response(srslte::byte_buffer_t *nas_msg, ue_ctx_t* ue_ctx, srslte::byte_buffer_t *reply_msg, bool *reply_flag)
{
uint8_t autn[16];
uint8_t rand[6];
uint8_t rand[16];
uint8_t xres[8];
LIBLTE_MME_ID_RESPONSE_MSG_STRUCT id_resp;
@ -609,7 +609,7 @@ s1ap_nas_transport::handle_identity_response(srslte::byte_buffer_t *nas_msg, ue_
m_s1ap_log->info("User not found. IMSI %015lu\n",imsi);
return false;
}
//Pack NAS Authentication Request in Downlink NAS Transport msg
pack_authentication_request(reply_msg, ue_ctx->enb_ue_s1ap_id, ue_ctx->mme_ue_s1ap_id, autn, rand);