Commit 092cf3ee authored by Yann Garcia's avatar Yann Garcia
Browse files

Implement TPs TP_5GNAS_AMF_AUT_ABN_01, TP_NGNAS_AMF_AUT_SEQ_01 and TP_5GNAS_AMF_SEC_ACC_01

parent bfc5ff0b
Loading
Loading
Loading
Loading
+76 −73
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ module NG_NAS_TCFunctions {
                                                                                                                                                                m_nR_CGI,
                                                                                                                                                                m_tAI
                                    )))));
                    // Get response
                    // Await response
                    f_recv_NGAP_PDU(
                                    mw_ngap_initMsg(
                                                    mw_n2_DownlinkNASTransport(
@@ -294,18 +294,18 @@ module NG_NAS_TCFunctions {
                                                                                                                                                                m_nR_CGI,
                                                                                                                                                                m_tAI
                                    )))));
                    // Get response
                    // Await response
                    f_recv_NGAP_PDU(
                                    mw_ngap_initMsg(
                                                    mw_n2_DownlinkNASTransport(
                                                                               PX_AMF_UE_NGAP_ID,
                                                                               PX_RAN_UE_NGAP_ID,
                                                                               ? // IdentityRequest
                                                                               ?
                    )));
                    f_NASPDU_Get(vc_recvNGAP_PDU);
                    if (f_Check_5GAKA_NAS_DL_Message(
                                                     vc_recvNAS_PDU, 
                                                     mw_NG_IDENTITY_REQUEST(
                                                     mw_NG_AUTHENTICATION_REQUEST(
                                                                                  complement(ngKSI)
                                                     )) == false) {
                        setverdict(fail);
@@ -330,16 +330,53 @@ module NG_NAS_TCFunctions {

                    // Preamble
                    f_NGAP_gnb_init();
                    f_send_NGSetupRequest_await_NGSetupRespone();
                    f_send_NasRegistrationRequest();
                    f_selfOrClientSyncAndVerdict(c_prDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Preamble done. ***");

                    // Body
                    // TODO
                    // Send error message
                    vt_NgNasUl_Msg := m_NG_AUTHENTICATION_FAILURE(
                                                                  m_GMM_GSM_Cause(
                                                                                  -,
                                                                                  int2bit(26, 8) // Non-5G authentication unacceptable
                                                                  ));
                    vc_sendNAS_PDU := bit2oct(encvalue(valueof(vt_NgNasUl_Msg)));
                    f_send_NGAP_PDU(
                                    m_ngap_initMsg(
                                                    m_n2_UplinkNASTransport(
                                                                            PX_AMF_UE_NGAP_ID,
                                                                            PX_RAN_UE_NGAP_ID,
                                                                            vc_sendNAS_PDU,
                                                                            m_uPTransportLayerInformation_userLocationInformationNR(
                                                                                                                                    m_userLocationInformationNR(
                                                                                                                                                                m_nR_CGI,
                                                                                                                                                                m_tAI
                                    )))));
                    // Await IdentityRequest
                    f_recv_NGAP_PDU(
                                    mw_ngap_initMsg(
                                                    mw_n2_DownlinkNASTransport(
                                                                               PX_AMF_UE_NGAP_ID,
                                                                               PX_RAN_UE_NGAP_ID,
                                                                               ? // IdentityRequest
                    )));
                    f_NASPDU_Get(vc_recvNGAP_PDU);
                    if (f_Check_5GAKA_NAS_DL_Message(
                                                     vc_recvNAS_PDU, 
                                                     mw_NG_IDENTITY_REQUEST(
                                                                            
                                                     )) == false) {
                        setverdict(fail);
                        log("*** " & __SCOPE__ & ": FAIL: Unexpected NG_IDENTITY_REQUEST ***");
                    }
                    f_selfOrClientSyncAndVerdict(c_tbDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Testbody done. ***");

                    // Postamble
                    // Terminate call with rejection
                    f_terminate_NasRegistrationRequest_with_reject();
                    //TODO: f_postamble_NGAP_gNB();
                    f_selfOrClientSyncAndVerdict(c_poDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Postamble done. ***");
@@ -358,84 +395,33 @@ module NG_NAS_TCFunctions {
                    // Preamble
                    f_NGAP_gnb_init();
                    f_send_NGSetupRequest_await_NGSetupRespone();
                    f_send_NasRegistrationRequest();
                    f_recv_NGAP_PDU(
                                    mw_ngap_initMsg(
                                                    mw_n2_DownlinkNASTransport(
                                                                               PX_AMF_UE_NGAP_ID,
                                                                               PX_RAN_UE_NGAP_ID,
                                                                               ? // AuthenticationRequest
                                                                                        // vt_NgNasUl_Msg := m_NG_AUTHENTICATION_REQUEST(
                                                                                        //                                               '100'B,
                                                                                        //                                               { iei := omit, iel : =omit, otherDigits := '0000'O},
                                                                                        //                                               { iei := '00100001'B, randValue := oct2bit('a218b7e415a50b63b4f5afd7db2c9529'O) },
                                                                                        //                                               { iei := '20'O, iel := '1000'B, aUTN := oct2bit('e4ca34194b428000f058119c1778db23'O) }
                                                                                        //                                               );
                    )));
                    f_NASPDU_Get(vc_recvNGAP_PDU);
                    if (f_Check_5GAKA_NAS_DL_Message(vc_recvNAS_PDU, mw_NG_AUTHENTICATION_REQUEST) == false) {
                        setverdict(inconc);
                        log("*** " & __SCOPE__ & ": INCONC: Unexpected NG_AUTHENTICATION_REQUEST ***");
                    }
                    f_await_NasAuthorizationRequest_send_NasAuthorizationResponse();
                    f_selfOrClientSyncAndVerdict(c_prDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Preamble done. ***");

                    // Body
                    vt_NgNasUl_Msg := m_NG_AUTHENTICATION_RESPONSE(
                                                                   { iei := '2d'O, iel := '10'O, res := oct2bit('a7c39d021cc8070960775ce133f05be3'O) }
                                                                   );
                    vc_sendNAS_PDU := bit2oct(encvalue(valueof(vt_NgNasUl_Msg)));
                    log("===> vc_sendNAS_PDU (2): ", vc_sendNAS_PDU);
                    f_send_NGAP_PDU(
                                    m_ngap_initMsg(
                                                   m_n2_UplinkNASTransport(
                                                                           PX_AMF_UE_NGAP_ID,
                                                                           PX_RAN_UE_NGAP_ID,
                                                                           vc_sendNAS_PDU,
                                                                           m_uPTransportLayerInformation_userLocationInformationNR(
                                                                                                                                   m_userLocationInformationNR(
                                                                                                                                                               m_nR_CGI,
                                                                                                                                                               m_tAI
                                    )))));
                    // Await SecurityModeCommand
                    f_recv_NGAP_PDU(
                                    mw_ngap_initMsg(
                                                    mw_n2_DownlinkNASTransport(
                                                                               PX_AMF_UE_NGAP_ID,
                                                                               PX_RAN_UE_NGAP_ID,
                                                                               ? // SecurityModeCommand
                                                                               ? // Security mode command
                    )));
                    f_NASPDU_Get(vc_recvNGAP_PDU);
                    if (f_Check_5GAKA_NAS_DL_Message(vc_recvNAS_PDU, mw_NG_SECURITY_MODE_COMMAND) == false) {
                        log("*** " & __SCOPE__ & ": FAIL: NG_SECURITY_MODE_COMMAND mismatch. ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                    if (f_Check_5GAKA_NAS_DL_Message(
                                                     vc_recvNAS_PDU, 
                                                     mw_NG_SECURITY_MODE_COMMAND
                                                     ) == false) {
                        setverdict(fail);
                        log("*** " & __SCOPE__ & ": FAIL: Unexpected NG_SECURITY_MODE_COMMAND ***");
                    }
 
                    vt_NgNasUl_Msg := m_NG_SECURITY_MODE_COMPLETE(
                                                                  m_NG_MobileIdentitySUCI('0000'B,'00f110214300014444330302'O),
                                                                  { iei := '2d'O, iel := int2oct(2 + lengthof('a7c39d021cc8070960775ce133f05be3'O), 2), replayedNASMsgContainerValue := 'a7c39d021cc8070960775ce133f05be3'O },
                                                                  m_NG_MobileIdentitySUCI('0000'B,'00f110214300014444330302'O)
                                                                );
                    vc_sendNAS_PDU := bit2oct(encvalue(valueof(vt_NgNasUl_Msg)));
                    log("===> vc_sendNAS_PDU (3): ", vc_sendNAS_PDU);
                    f_send_NGAP_PDU(
                                    m_ngap_initMsg(
                                                   m_n2_UplinkNASTransport(
                                                                           PX_AMF_UE_NGAP_ID,
                                                                           PX_RAN_UE_NGAP_ID,
                                                                           vc_sendNAS_PDU,
                                                                           m_uPTransportLayerInformation_userLocationInformationNR(
                                                                                                                                   m_userLocationInformationNR(
                                                                                                                                                               m_nR_CGI,
                                                                                                                                                               m_tAI
                                    )))));
                    f_recv_NGAP_PDU(
                                    mw_ngap_initMsg(
                                                    mw_n2_InitialContextSetupRequest_withPDUSessionList
                                    ));
                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    log("*** " & __SCOPE__ & ": PASS: Testbody done. ***");
                    f_selfOrClientSyncAndVerdict(c_tbDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Testbody done. ***");

                    // Postamble
                    // Terminate call with rejection
                    f_terminate_NasRegistrationRequest_with_reject();
                    //TODO: f_postamble_NGAP_gNB();
                    f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                    log("*** " & __SCOPE__ & ": INFO: Postamble done. ***");
@@ -449,16 +435,33 @@ module NG_NAS_TCFunctions {

                    // Preamble
                    f_NGAP_gnb_init();
                    f_NGAP_gnb_init();
                    f_send_NGSetupRequest_await_NGSetupRespone();
                    f_await_NasAuthorizationRequest_send_NasAuthorizationResponse();
                    f_await_NasSecurityModeCommand_send_SecurityModeComplete();
                    f_selfOrClientSyncAndVerdict(c_prDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Preamble done. ***");

                    // Body
                    // TODO

                    // Await next next command (InitialContextSetupRequest) with NAS encrypted payload
                    f_recv_NGAP_PDU(
                                    mw_ngap_initMsg(
                                                    mw_n2_DownlinkNASTransport(
                                                                               PX_AMF_UE_NGAP_ID,
                                                                               PX_RAN_UE_NGAP_ID,
                                                                               ? // Security mode command
                    )));
                    f_NASPDU_Get(vc_recvNGAP_PDU);
                    if (f_Check_5GAKA_NAS_UL_Message_is_encrypted(vc_recvNAS_PDU) == false) {
                        setverdict(fail);
                        log("*** " & __SCOPE__ & ": FAIL: Message is not encrypted ***");
                    }
                    f_selfOrClientSyncAndVerdict(c_tbDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Testbody done. ***");

                    // Postamble
                    // Terminate call with rejection
                    f_terminate_NasRegistrationRequest_with_reject();
                    //TODO: f_postamble_NGAP_gNB();
                    f_selfOrClientSyncAndVerdict(c_poDone, f_getVerdict());
                    log("*** " & __SCOPE__ & ": INFO: Postamble done. ***");
+10 −0
Original line number Diff line number Diff line
@@ -1023,6 +1023,8 @@ type record NBIFOMContainer {
    IEI8_Type                   iei optional,
    Type4Length_Type            iel,
    O8_Type                     hashMME
  } with {
    variant "FIELDLENGTH(4), FIELDORDER(msb), FORCEOMIT(iei)"
  };

  type record PDN_Address {                                     /* 24.301 cl. 9.9.4.9 */
@@ -1031,12 +1033,20 @@ type record NBIFOMContainer {
    B5_Type                     spare,
    B3_Type                     typeValue,
    octetstring                 adressInfo length(4..12)
  } with {
    variant "FIELDORDER(msb)";
    variant "FORCEOMIT(iei)";
    variant (iel) "LENGTHTO (adressInfo)";
  };

  type record ReplayedNASMessageContainer { /* 24.301 cl. 9.9.3.51 @sic R5s170597 Baseline Moving sic@ */
    IEI8_Type                   iei optional,
    Type6Length_Type            iel,
    octetstring                 replayedNASMsgContainerValue
  } with {
    variant "FIELDORDER(msb)";
    variant "FORCEOMIT(iei)";
    variant (iel) "LENGTHTO(replayedNASMsgContainerValue)";
  };

  type record NAS_SecurityAlgorithms {                          /* 24.301 cl. 9.9.3.23 */
+1 −1
Original line number Diff line number Diff line
@@ -581,7 +581,7 @@ module NG_NAS_TypeDefs {
    NAS_SequenceNumber                  sequenceNumber,                         /* cl. 9.10      M V 1   */
    NG_NAS_Message                      plainNASMessage                         /* cl. 9.9       M V 3-n */
  } with {
    variant (spareHalfOctet,securityHeaderType) "FIELDORDER(msb)"
    variant "FIELDORDER(msb)";
  } 

  
+135 −52

File changed.

Preview size limit exceeded, changes collapsed.

+31 −0
Original line number Diff line number Diff line
@@ -2166,5 +2166,36 @@ module Lib_NG_NAS_Templates {
                                                          ) modifies cr_PayloadContainer := {
  } // End of template mw_PayloadContainer
  
  template (value) NG_SECURITY_PROTECTED_NAS_MESSAGE m_NG_SECURITY_PROTECTED_NAS_MESSAGE(
                                                                                         in template (value) ExtdProtocolDiscriminator p_protocolDiscriminator,
                                                                                         in template (value) SpareHalfOctet p_spareHalfOctet,
                                                                                         in template (value) SecurityHeaderType p_securityHeaderType,
                                                                                         in template (value) MessageAuthenticationCode p_messageAuthenticationCode,
                                                                                         in template (value) NAS_SequenceNumber p_sequenceNumber,
                                                                                         in template (value) NG_NAS_Message p_plainNASMessage
                                                                                         ) := {                  /* 24.501 cl. 8.2.28 Significance:  dual Direction:     both */
    protocolDiscriminator     := p_protocolDiscriminator,     /* cl. 9.2       M V 1   */
    spareHalfOctet            := p_spareHalfOctet,            /* cl. 9.5       M V 1/2 */
    securityHeaderType        := p_securityHeaderType,        /* cl. 9.3       M V 1/2 */
    messageAuthenticationCode := p_messageAuthenticationCode, /* cl. 9.8       M V 4   */
    sequenceNumber            := p_sequenceNumber,            /* cl. 9.10      M V 1   */
    plainNASMessage           := p_plainNASMessage            /* cl. 9.9       M V 3-n */
  } // End of template m_NG_SECURITY_PROTECTED_NAS_MESSAGE

  template (present) NG_SECURITY_PROTECTED_NAS_MESSAGE mw_NG_SECURITY_PROTECTED_NAS_MESSAGE(
                                                                                            template (present) ExtdProtocolDiscriminator p_protocolDiscriminator := ?,
                                                                                            template (present) SpareHalfOctet p_spareHalfOctet := ?,
                                                                                            template (present) SecurityHeaderType p_securityHeaderType := ?,
                                                                                            template (present) MessageAuthenticationCode p_messageAuthenticationCode := ?,
                                                                                            template (present) NAS_SequenceNumber p_sequenceNumber := ?,
                                                                                            template (present) NG_NAS_Message p_plainNASMessage := ?
                                                                                            ) := {                  /* 24.501 cl. 8.2.28 Significance:  dual Direction:     both */
    protocolDiscriminator     := p_protocolDiscriminator,     /* cl. 9.2       M V 1   */
    spareHalfOctet            := p_spareHalfOctet,            /* cl. 9.5       M V 1/2 */
    securityHeaderType        := p_securityHeaderType,        /* cl. 9.3       M V 1/2 */
    messageAuthenticationCode := p_messageAuthenticationCode, /* cl. 9.8       M V 4   */
    sequenceNumber            := p_sequenceNumber,            /* cl. 9.10      M V 1   */
    plainNASMessage           := p_plainNASMessage            /* cl. 9.9       M V 3-n */
  } // End of template mw_NG_SECURITY_PROTECTED_NAS_MESSAGE

} // End of module Lib_NG_NAS_Templates
 No newline at end of file