pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43213?usp=email )
Change subject: mme: Fix NG NAS ul_count not incremented ......................................................................
mme: Fix NG NAS ul_count not incremented
Since open5gs.git b9823196b5de3394b7a144569f186d7d62fad6f9, open5gs properly validates received seq_nr (ul_count) of integrity protected 4G NAS message to make sure it increases with each new UL message, in order to protect against accepting replayed messages.
This made the mme testsuite fail since our S1AP/4G-NAS emulation was not properly increasing ul_count when sending new messages, but always using ul_count=0.
Change-Id: Idace7ad5c832cbfa48696de69e604eb4bd411980 --- M library/LTE_CryptoFunctions.ttcn 1 file changed, 9 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/13/43213/1
diff --git a/library/LTE_CryptoFunctions.ttcn b/library/LTE_CryptoFunctions.ttcn index 882861b..954e085 100644 --- a/library/LTE_CryptoFunctions.ttcn +++ b/library/LTE_CryptoFunctions.ttcn @@ -247,13 +247,16 @@ { var BIT4 sec_hdr_t; var PDU_NAS_EPS nas_out; - - if (nus.use_enc == false and nus.use_int == false) { - return nas_in; - } + var OCT1 seq_nr;
if (nus.new_ctx) { nus.tx_count := 0; + } else { + nus.tx_count := nus.tx_count + 1; + } + + if (nus.use_enc == false and nus.use_int == false) { + return nas_in; }
var octetstring nas_enc := enc_PDU_NAS_EPS(nas_in); @@ -262,11 +265,12 @@ f_tx_is_downlink(nus), nas_enc); }
+ seq_nr := int2oct(nus.tx_count mod 256, 1); sec_hdr_t := f_nas_determine_sec_hdr_t(nus.use_enc, nus.use_int, nus.new_ctx); nas_out := valueof(ts_NAS_EMM_SecurityProtected(sec_hdr_t, nus.tx_count, nas_enc)); if (nus.use_int) { var OCT4 mac := f_nas_mac_calc(nus.alg_int, nus.k_nas_int, nus.tx_count, 0, - f_tx_is_downlink(nus), '00'O & nas_enc); + f_tx_is_downlink(nus), seq_nr & nas_enc); nas_out.ePS_messages.ePS_MobilityManagement.pDU_NAS_EPS_SecurityProtectedNASMessage.messageAuthenticationCode := mac; } return nas_out;