Commit f528f60f authored by aligungr's avatar aligungr

Protection of initial NAS messages

parent 6ad594ac
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#include <ue/nas/sm/sm.hpp> #include <ue/nas/sm/sm.hpp>
#include <ue/rrc/task.hpp> #include <ue/rrc/task.hpp>
// See https://github.com/aligungr/UERANSIM/issues/316 for details about this behaviour.
#define NAS_CONTAINER_NOT_CIPHERED 1
namespace nr::ue namespace nr::ue
{ {
...@@ -125,9 +128,14 @@ void NasMm::sendNasMessage(const nas::PlainMmMessage &msg) ...@@ -125,9 +128,14 @@ void NasMm::sendNasMessage(const nas::PlainMmMessage &msg)
{ {
if (HasNonCleartext(msg)) if (HasNonCleartext(msg))
{ {
auto originalSecured = nas_enc::Encrypt(*m_usim->m_currentNsCtx, msg, false);
OctetString originalPdu; OctetString originalPdu;
#if NAS_CONTAINER_NOT_CIPHERED
nas::EncodeNasMessage(msg, originalPdu);
#else
auto originalSecured = nas_enc::Encrypt(*m_usim->m_currentNsCtx, msg, false);
nas::EncodeNasMessage(*originalSecured, originalPdu); nas::EncodeNasMessage(*originalSecured, originalPdu);
#endif
auto copy = nas::utils::DeepCopyMsg(msg); auto copy = nas::utils::DeepCopyMsg(msg);
RemoveCleartextIEs((nas::PlainMmMessage &)*copy, std::move(originalPdu)); RemoveCleartextIEs((nas::PlainMmMessage &)*copy, std::move(originalPdu));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment