laforge submitted this change.

View Change


Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved
LTE_CryptoFunctions.ttcn: Increment nus.rx_count on each pkt read

Before this patch, the rx_count field was never set to anything other
than zero.

There's still a problem with counter not being incremented when a
S1AP_IntialCtxSetupReq message containing a NAS_PDU is received. This
will be fixed ina follow-up patch.

Change-Id: I1ee25fd8fde6fbce95444ee4b73918ce1f61b427
---
M mme/LTE_CryptoFunctions.ttcn
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/mme/LTE_CryptoFunctions.ttcn b/mme/LTE_CryptoFunctions.ttcn
index 9923541..340b784 100644
--- a/mme/LTE_CryptoFunctions.ttcn
+++ b/mme/LTE_CryptoFunctions.ttcn
@@ -143,6 +143,12 @@
var octetstring data_with_seq := int2oct(secp_nas.sequenceNumber, 1) & secp_nas.nAS_Message;
var OCT4 exp_mac := f_nas_mac_calc(nus.alg_int, nus.k_nas_int, nus.rx_count, 0,
f_rx_is_downlink(nus), data_with_seq);
+
+ if (nus.rx_count != secp_nas.sequenceNumber) {
+ setverdict(fail, "Received NAS SeqNr ", secp_nas.sequenceNumber,
+ " doesn't match expected SeqNr ", nus.rx_count, ": ", secp_nas, " | nus: ", nus);
+ return false;
+ }
if (exp_mac != secp_nas.messageAuthenticationCode) {
setverdict(fail, "Received NAS MAC ", secp_nas.messageAuthenticationCode,
" doesn't match expected MAC ", exp_mac, ": ", secp_nas, " | nus: ", nus);
@@ -173,12 +179,14 @@
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");
}
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");
}

To view, visit change 35366. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I1ee25fd8fde6fbce95444ee4b73918ce1f61b427
Gerrit-Change-Number: 35366
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-MessageType: merged