pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/35508?usp=email )
Change subject: LTE_CryptoFunctions: Fix rx_count increment ......................................................................
LTE_CryptoFunctions: Fix rx_count increment
The previous logic was wrong, since it was increasing the rx_count at the time where the msg is received and before checking it. Instead, it should be increased after having validated and accepted it. This fixes the case where rx_count will have to be reset (to zero) when doing mobility GERAN->EUTRAN.
Change-Id: I712d95f7784a6a9855fe36300b0ebfcd4c6ef377 --- M mme/LTE_CryptoFunctions.ttcn 1 file changed, 19 insertions(+), 2 deletions(-)
Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved
diff --git a/mme/LTE_CryptoFunctions.ttcn b/mme/LTE_CryptoFunctions.ttcn index 340b784..18a3755 100644 --- a/mme/LTE_CryptoFunctions.ttcn +++ b/mme/LTE_CryptoFunctions.ttcn @@ -176,20 +176,21 @@ if (not f_nas_check_ip(nus, secp_nas)) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "f_nas_check_ip() failed"); } + nus.rx_count := nus.rx_count + 1; return dec_PDU_NAS_EPS(secp_nas.nAS_Message); } case ('0001'B) { /* IP only */ - nus.rx_count := nus.rx_count + 1; if (not f_nas_check_ip(nus, secp_nas)) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "f_nas_check_ip() failed"); } + nus.rx_count := nus.rx_count + 1; return dec_PDU_NAS_EPS(secp_nas.nAS_Message); } case ('0010'B) { /* IP + ciphered */ - nus.rx_count := nus.rx_count + 1; if (not f_nas_check_ip(nus, secp_nas)) { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "f_nas_check_ip() failed"); } + nus.rx_count := nus.rx_count + 1; f_nas_encrypt(nus.alg_enc, nus.k_nas_enc, nus.rx_count, 0, f_rx_is_downlink(nus), secp_nas.nAS_Message); return dec_PDU_NAS_EPS(secp_nas.nAS_Message); @@ -201,6 +202,7 @@ } f_nas_encrypt(nus.alg_enc, nus.k_nas_enc, nus.rx_count, 0, f_rx_is_downlink(nus), secp_nas.nAS_Message); + nus.rx_count := nus.rx_count + 1; return dec_PDU_NAS_EPS(secp_nas.nAS_Message); } //case ('0101'B) { /* IP + partially ciphered */ }