Apply security to Deregistration Request (UE Originating)

master
Bedran Karakoc 3 years ago committed by Bedran Karakoc
parent f1385640c4
commit 4e60475200

@ -622,6 +622,8 @@ int nas_5g::send_deregistration_request_ue_originating(bool switch_off)
nas_5gs_msg nas_msg; nas_5gs_msg nas_msg;
deregistration_request_ue_originating_t& deregistration_request = nas_msg.set_deregistration_request_ue_originating(); deregistration_request_ue_originating_t& deregistration_request = nas_msg.set_deregistration_request_ue_originating();
nas_msg.hdr.security_header_type = nas_5gs_hdr::security_header_type_opts::integrity_protected_and_ciphered;
nas_msg.hdr.sequence_number = ctxt_base.tx_count;
// Note 5.5.2.2.2 : AMF does not send a Deregistration Accept NAS message if De-registration type IE indicates "switch // Note 5.5.2.2.2 : AMF does not send a Deregistration Accept NAS message if De-registration type IE indicates "switch
// off" // off"
@ -655,10 +657,17 @@ int nas_5g::send_deregistration_request_ue_originating(bool switch_off)
} }
logger.info("Sending Deregistration Request (UE Originating)"); logger.info("Sending Deregistration Request (UE Originating)");
rrc_nr->write_sdu(std::move(pdu)); cipher_encrypt(pdu.get());
integrity_generate(&ctxt_base.k_nas_int[16],
ctxt_base.tx_count,
SECURITY_DIRECTION_UPLINK,
&pdu->msg[SEQ_5G_OFFSET],
pdu->N_bytes - SEQ_5G_OFFSET,
&pdu->msg[MAC_5G_OFFSET]);
rrc_nr->write_sdu(std::move(pdu));
ctxt_base.tx_count++;
reset_pdu_sessions(); reset_pdu_sessions();
// TODO: Delete / Reset context (ctxt & ctxt_5g) // TODO: Delete / Reset context (ctxt & ctxt_5g)
return SRSASN_SUCCESS; return SRSASN_SUCCESS;

Loading…
Cancel
Save