Ciphering EMM information message. Chainging detach_request security header in the UE to integrity and ciphered to avoid malformed message.

master
Pedro Alvarez 6 years ago
parent b5d5f9f91c
commit b675e1fcc9

@ -1321,7 +1321,7 @@ nas::pack_emm_information(srslte::byte_buffer_t *nas_buffer)
emm_info.utc_and_local_time_zone_present = false; emm_info.utc_and_local_time_zone_present = false;
emm_info.net_dst_present = false; emm_info.net_dst_present = false;
uint8_t sec_hdr_type =2; uint8_t sec_hdr_type =LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED;
m_sec_ctx.dl_nas_count++; m_sec_ctx.dl_nas_count++;
LIBLTE_ERROR_ENUM err = liblte_mme_pack_emm_information_msg(&emm_info, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer); LIBLTE_ERROR_ENUM err = liblte_mme_pack_emm_information_msg(&emm_info, sec_hdr_type, m_sec_ctx.dl_nas_count, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
if (err != LIBLTE_SUCCESS) { if (err != LIBLTE_SUCCESS) {
@ -1330,6 +1330,10 @@ nas::pack_emm_information(srslte::byte_buffer_t *nas_buffer)
return false; return false;
} }
// Encrypt NAS message
cipher_encrypt(nas_buffer);
// Integrity protect NAS message
uint8_t mac[4]; uint8_t mac[4];
integrity_generate(nas_buffer,mac); integrity_generate(nas_buffer,mac);
memcpy(&nas_buffer->msg[1],mac,4); memcpy(&nas_buffer->msg[1],mac,4);

@ -1351,7 +1351,7 @@ void nas::send_detach_request(bool switch_off)
detach_request.nas_ksi.nas_ksi = ctxt.ksi; detach_request.nas_ksi.nas_ksi = ctxt.ksi;
nas_log->info("Requesting Detach with GUTI\n"); nas_log->info("Requesting Detach with GUTI\n");
liblte_mme_pack_detach_request_msg(&detach_request, liblte_mme_pack_detach_request_msg(&detach_request,
LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY, LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED,
ctxt.tx_count, ctxt.tx_count,
(LIBLTE_BYTE_MSG_STRUCT *) pdu); (LIBLTE_BYTE_MSG_STRUCT *) pdu);

Loading…
Cancel
Save