diff --git a/pkg/context/context.go b/pkg/context/context.go index b3c2d2d..63f80d6 100755 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -44,6 +44,7 @@ type N3UE struct { RanUeContext *security.RanUeContext MobileIdentity5GS nasType.MobileIdentity5GS IkeInitiatorSPI uint64 + IkeIDInitiator []byte Secert *big.Int Factor *big.Int Proposal *message.Proposal diff --git a/pkg/ike/handler.go b/pkg/ike/handler.go index 14db450..4dcc49c 100755 --- a/pkg/ike/handler.go +++ b/pkg/ike/handler.go @@ -503,7 +503,8 @@ func (s *Server) handleIKEAUTH( } var idPayload ike_message.IKEPayloadContainer - idPayload.BuildIdentificationInitiator(ike_message.ID_KEY_ID, []byte("UE")) + idInitiator := n3ueSelf.IkeIDInitiator + idPayload.BuildIdentificationInitiator(ike_message.ID_KEY_ID, idInitiator) idPayloadData, err := idPayload.Encode() if err != nil { ikeLog.Errorln(err) diff --git a/pkg/ike/send.go b/pkg/ike/send.go index aa5f7e0..e481c87 100755 --- a/pkg/ike/send.go +++ b/pkg/ike/send.go @@ -137,7 +137,16 @@ func (s *Server) SendIkeAuth() { var ikePayload ike_message.IKEPayloadContainer // Identification - ikePayload.BuildIdentificationInitiator(ike_message.ID_KEY_ID, []byte("UE")) + idByte := make([]byte, 8) + id, err := ike_security.GenerateRandomNumber() + if err != nil { + ikeLog.Errorf("error generating IDi: %d", err) + return + } + + binary.BigEndian.PutUint64(idByte, id.Uint64()) + ikePayload.BuildIdentificationInitiator(ike_message.ID_KEY_ID, idByte) + n3ueContext.IkeIDInitiator = idByte // Security Association n3ueContext.SecurityAssociation = ikePayload.BuildSecurityAssociation() @@ -196,7 +205,7 @@ func (s *Server) SendIkeAuth() { n3ueContext.N3IWFUe.IKEConnection = n3ueContext.IKEConnection[4500] } - err := s.SendIkeMsgToN3iwf( + err = s.SendIkeMsgToN3iwf( n3ueContext.N3IWFUe.IKEConnection, ikeMessage, n3ueContext.N3IWFUe.N3IWFIKESecurityAssociation)