From 6e163a5385fd9534338909bc4c7cc20b97543bbd Mon Sep 17 00:00:00 2001 From: brianchennn Date: Tue, 19 Mar 2024 08:11:17 +0000 Subject: [PATCH] fix: use SecurityHeaderTypeIntegrityProtectedAndCiphered as Security Header Type in Configuration Update Complete message Signed-off-by: brianchennn --- .../mm_5gs/configuration-update-complete.go | 18 +++++++++++++++--- .../mm_5gs/registration-complete.go | 2 +- .../ue/nas/trigger/trigger.go | 6 ++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/configuration-update-complete.go b/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/configuration-update-complete.go index c3bd86cf..b1ad7828 100644 --- a/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/configuration-update-complete.go +++ b/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/configuration-update-complete.go @@ -7,19 +7,31 @@ package mm_5gs import ( "bytes" "fmt" + "my5G-RANTester/internal/control_test_engine/ue/context" + "my5G-RANTester/internal/control_test_engine/ue/nas/message/nas_control" + "github.com/free5gc/nas" "github.com/free5gc/nas/nasMessage" - "my5G-RANTester/internal/control_test_engine/ue/context" ) -func ConfigurationUpdateComplete(ue *context.UEContext) (nasPdu []byte) { +func ConfigurationUpdateComplete(ue *context.UEContext) ([]byte, error) { + pdu := getConfigurationUpdateComplete() + pdu, err := nas_control.EncodeNasPduWithSecurity(ue, pdu, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true, false) + if err != nil { + return nil, fmt.Errorf("error encoding %s IMSI UE NAS Registration Complete Msg", ue.UeSecurity.Supi) + } + + return pdu, nil +} + +func getConfigurationUpdateComplete() (nasPdu []byte) { m := nas.NewMessage() m.GmmMessage = nas.NewGmmMessage() m.GmmHeader.SetMessageType(nas.MsgTypeConfigurationUpdateComplete) configurationUpdateComplete := nasMessage.NewConfigurationUpdateComplete(0) configurationUpdateComplete.SetExtendedProtocolDiscriminator(nasMessage.Epd5GSMobilityManagementMessage) - configurationUpdateComplete.SetSecurityHeaderType(0x00) + configurationUpdateComplete.SetSecurityHeaderType(nas.SecurityHeaderTypeIntegrityProtectedAndCiphered) configurationUpdateComplete.SetSpareHalfOctet(0x00) configurationUpdateComplete.SetMessageType(nas.MsgTypeConfigurationUpdateComplete) diff --git a/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/registration-complete.go b/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/registration-complete.go index 824fa6db..fdec9a9a 100644 --- a/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/registration-complete.go +++ b/internal/control_test_engine/ue/nas/message/nas_control/mm_5gs/registration-complete.go @@ -20,7 +20,7 @@ func RegistrationComplete(ue *context.UEContext) ([]byte, error) { pdu := getRegistrationComplete(nil) pdu, err := nas_control.EncodeNasPduWithSecurity(ue, pdu, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true, false) if err != nil { - return nil, fmt.Errorf("Error encoding %s IMSI UE NAS Registration Complete Msg", ue.UeSecurity.Supi) + return nil, fmt.Errorf("error encoding %s IMSI UE NAS Registration Complete Msg", ue.UeSecurity.Supi) } return pdu, nil diff --git a/internal/control_test_engine/ue/nas/trigger/trigger.go b/internal/control_test_engine/ue/nas/trigger/trigger.go index a267bcc1..f88f2218 100644 --- a/internal/control_test_engine/ue/nas/trigger/trigger.go +++ b/internal/control_test_engine/ue/nas/trigger/trigger.go @@ -133,8 +133,10 @@ func InitConfigurationUpdateComplete(ue *context.UEContext) { log.Info("[UE] Initiating Configuration Update Complete") // trigger Configuration Update Complete. - identityResponse := mm_5gs.ConfigurationUpdateComplete(ue) - + identityResponse, err := mm_5gs.ConfigurationUpdateComplete(ue) + if err != nil { + log.Fatal("[UE][NAS] Error sending Configuration Update Complete: ", err) + } // send to GNB. sender.SendToGnb(ue, identityResponse) }