Commit be2bda49 authored by Yann Garcia's avatar Yann Garcia
Browse files

Restore AtsAVM files in ttcn submodule

parent cad2f7dc
Loading
Loading
Loading
Loading

ItsAvm_TestCases.ttcn

0 → 100644
+487 −0
Original line number Diff line number Diff line
/**
 *    @author      ETSI / TTF T051
 *    @desc        Testcases for CA Protocol
 *    @reference   ETSI TS 103 900 v2.2.1
 *    @copyright   ETSI Copyright Notification
 *                 No part may be reproduced except as authorized by written permission.
 *                 The copyright and the foregoing restriction extend to reproduction in all media.
 *                 All rights reserved.
 */

module ItsAvm_TestCases {

    import from LibSecurity_Checksums all;

    // LibItsAvm
    import from LibItsAvm_TestSystem all;
    import from LibItsAvm_Checksums_function all;

    // Ats Avm
    import from ItsAvm_TpFunctions all;

    // 5.2.1
    group MIM {

        group mimMessageDissemination {

            group mimMessageFormat {

                /**
                * @desc Check that protocolVersion is set to 2 and messageID is
                *       set to 18.
                * <pre>
                * Pics Selection: PICS_MIM_GENERATION
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *     ensure that {
                *         when {
                *             a MIM is generated
                *         }
                *         then {
                *             the IUT sends a valid MIM
                *                 containing ITS PDU header
                *                     containing protocolVersion
                *                         indicating value 2
                *                     and containing messageID
                *                         indicating value 18
                *         }
                *     }
                * </pre>
                *
                * @see       ETSI TS 104 202-2 v2.2.1 TP/AVM/MSD/FMT/BV-01
                * @reference ETSI TS 103 882 v2.2.1, Annex B
                */
                testcase TC_MIM_MSD_FMT_BV_01() runs on ItsAvm system ItsAvmSystem {

                    f_MIM_MSD_FMT_BV_01();

                } // End of TC_MIM_MSD_FMT_BV_01

                /**
                * @desc Check that the IUT generates e2eProtection CRC properly.
                * <pre>
                * Pics Selection: PICS_MIM_GENERATION
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *     ensure that {
                *         when {
                *             a MIM is generated
                *         }
                *         then {
                *             the IUT sends a valid MIM
                *                 containing e2EProtection
                *                     containing crc32
                *                         indicating correct CRC value calculated over the e2eProtection.length_ field and the rest of the message (excluding the first 6 bytes and the 4 bytes of crc32)
                *         }
                *     }
                * </pre>
                *
                * @see       ETSI TS 104 202-2 v2.2.1 TP/AVM/MSD/FMT/BV-02
                * @reference ETSI TS 103 882 v2.2.1, Annex B
                */
                testcase TC_MIM_MSD_FMT_BV_02() runs on ItsAvm system ItsAvmSystem {

                    f_MIM_MSD_FMT_BV_02();

                } // End of TC_MIM_MSD_FMT_BV_02

            } // End of group mimMessageFormat

            group mimLowerLayerParameters {

                /**
                * @desc Check that MIM is encapsulated in BTP type B packet
                * <pre>
                * Pics Selection: PICS_MIM_GENERATION AND NOT PICS_IS_IUT_SECURED
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *  ensure that {
                *      when {
                *          a MIM is generated
                *      }
                *      then {
                *          the IUT sends a MIM
                *              encapsulated in a BTP-B packet
                *      }
                *  }
                * </pre>
                *
                * @see       ETSI TS 102 868-2 v2.2.1 TP/AVM/MSD/PAR/BV-01
                * @reference ETSI TS 103 900 v2.2.1, clause 5.3.4.1
                */
                testcase TC_MIM_MSD_PAR_BV_01() runs on ItsAvm system ItsAvmSystem {

                    f_MIM_MSD_PAR_BV_01();

                } // End of TC_MIM_MSD_PAR_BV_01

                /**
                * @desc Check that MIM is encapsulated in SHB packet
                * <pre>
                * Pics Selection: PICS_MIM_GENERATION AND NOT PICS_IS_IUT_SECURED
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *  ensure that {
                *      when {
                *          a MIM is generated
                *      }
                *      then {
                *          the IUT sends a MIM
                *              encapsulated in a SHB packet
                *      }
                *  }
                * </pre>
                *
                * @see       ETSI TS 102 868-2 v2.2.1 TP/MIM/MSD/PAR/BV-02
                * @reference ETSI TS 103 900 v2.2.1, clause 5.3.4.1
                */
                testcase TC_MIM_MSD_PAR_BV_02() runs on ItsAvm system ItsAvmSystem {

                    f_MIM_MSD_PAR_BV_02();

                } // End of TC_MIM_MSD_PAR_BV_02

                /**
                * @desc Check that MIM is encapsulated in GN packet with lifetime lower than 1s
                * <pre>
                * Pics Selection: PICS_MIM_GENERATION AND NOT PICS_IS_IUT_SECURED
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *  ensure that {
                *      when {
                *          a MIM is generated
                *      }
                *      then {
                *          the IUT sends a MIM
                *              encapsulated in a GN packet
                *                  containing Basic Header
                *                      containing Lifetime field
                *                          indicating value lower than 1s
                *      }
                *  }
                * </pre>
                *
                * @see       ETSI TS 102 868-2 v2.2.1 TP/MIM/MSD/PAR/BV-03
                * @reference ETSI TS 103 900 v2.2.1, clause 5.3.4.1
                */
                testcase TC_MIM_MSD_PAR_BV_03() runs on ItsAvm system ItsAvmSystem {

                    f_MIM_MSD_PAR_BV_03();

                } // End of TC_MIM_MSD_PAR_BV_03

            } // End of group mimLowerLayerParameters

        } // End of group mimMessageDissemination

    } // End of group MIM

    group MVM {

        group mvmMessageDissemination {

            group mvmMessageFormat {

                /**
                * @desc Check that protocolVersion is set to 2 and messageID is
                *       set to 19.
                * <pre>
                * Pics Selection: PICS_MVM_GENERATION
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *     ensure that {
                *         when {
                *             a MVM is generated
                *         }
                *         then {
                *             the IUT sends a valid MVM
                *                 containing ITS PDU header
                *                     containing protocolVersion
                *                         indicating value 2
                *                     and containing messageID
                *                         indicating value 8
                *         }
                *     }
                * </pre>
                *
                * @see       ETSI TS 104 202-2 v2.2.1 TP/AVM/MSD/FMT/BV-01
                * @reference ETSI TS 103 882 v2.2.1, Annex B
                */
                testcase TC_MVM_MSD_FMT_BV_01() runs on ItsAvm system ItsAvmSystem {

                    f_MVM_MSD_FMT_BV_01();

                } // End of TC_MVM_MSD_FMT_BV_01

            } // End of group mvmMessageFormat

            group mvmLowerLayerParameters {

                /**
                * @desc Check that MVM is encapsulated in BTP type B packet
                * <pre>
                * Pics Selection: PICS_MVM_GENERATION AND NOT PICS_IS_IUT_SECURED
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *  ensure that {
                *      when {
                *          a MVM is generated
                *      }
                *      then {
                *          the IUT sends a MVM
                *              encapsulated in a BTP-B packet
                *      }
                *  }
                * </pre>
                *
                * @see       ETSI TS 102 868-2 v2.2.1 TP/AVM/MSD/PAR/BV-01
                * @reference ETSI TS 103 900 v2.2.1, clause 5.3.4.1
                */
                testcase TC_MVM_MSD_PAR_BV_01() runs on ItsAvm system ItsAvmSystem {

                    f_MVM_MSD_PAR_BV_01();

                } // End of TC_MVM_MSD_PAR_BV_01

                /**
                * @desc Check that MVM is encapsulated in SHB packet
                * <pre>
                * Pics Selection: PICS_MVM_GENERATION AND NOT PICS_IS_IUT_SECURED
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *  ensure that {
                *      when {
                *          a MVM is generated
                *      }
                *      then {
                *          the IUT sends a MVM
                *              encapsulated in a SHB packet
                *      }
                *  }
                * </pre>
                *
                * @see       ETSI TS 102 868-2 v2.2.1 TP/MVM/MSD/PAR/BV-02
                * @reference ETSI TS 103 900 v2.2.1, clause 5.3.4.1
                */
                testcase TC_MVM_MSD_PAR_BV_02() runs on ItsAvm system ItsAvmSystem {

                    f_MVM_MSD_PAR_BV_02();

                } // End of TC_MVM_MSD_PAR_BV_02

                /**
                * @desc Check that MVM is encapsulated in GN packet with lifetime lower than 1s
                * <pre>
                * Pics Selection: PICS_MVM_GENERATION AND NOT PICS_IS_IUT_SECURED
                * Initial conditions:
                *     with {
                *         the IUT being in the "initial state"
                *     }
                * Expected behaviour:
                *  ensure that {
                *      when {
                *          a MVM is generated
                *      }
                *      then {
                *          the IUT sends a MVM
                *              encapsulated in a GN packet
                *                  containing Basic Header
                *                      containing Lifetime field
                *                          indicating value lower than 1s
                *      }
                *  }
                * </pre>
                *
                * @see       ETSI TS 102 868-2 v2.2.1 TP/MVM/MSD/PAR/BV-03
                * @reference ETSI TS 103 900 v2.2.1, clause 5.3.4.1
                */
                testcase TC_MVM_MSD_PAR_BV_03() runs on ItsAvm system ItsAvmSystem {

                    f_MVM_MSD_PAR_BV_03();

                } // End of TC_MVM_MSD_PAR_BV_03

            } // End of group mvmLowerLayerParameters

        } // End of group mvmMessageDissemination

    } // End of group MVM

    testcase TC_CHECKSUMS_BV_01() runs on ItsAvm system ItsAvmSystem {

        if (f_compute_checksum_8('00000000'O) != '59'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8('ffffffff'O) != '74'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8('0000000059'O) xor4b 'ff'O != 'C4'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8('f20183'O) != '37'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8('332255AABBCCDDEEFF'O) != 'cb'O) {
            setverdict(fail);
        }

        if (f_compute_checksum_8H2F('00000000'O) != '12'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8H2F('0000000012'O) xor4b 'ff'O != '42'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8H2F('f20183'O) != 'c2'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8H2F('332255AABBCCDDEEFF'O) != '11'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_8H2F('ffffffff'O) != '6c'O) {
            setverdict(fail);
        }

        if (f_compute_checksum_16('00000000'O) != '84c0'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16('0000000084c0'O) xor4b '0000'O != '0000'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16('f20183'O) != 'd374'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16('332255AABBCCDDEEFF'O) != 'f53f'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16('ffffffff'O) != '1d0f'O) {
            setverdict(fail);
        }

         if (f_compute_checksum_16ARC('00000000'O) != '0000'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16ARC('000000000000'O) xor4b '0000'O != '0000'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16ARC('f20183'O) != 'c2e1'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16ARC('332255AABBCCDDEEFF'O) != 'ae98'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_16ARC('ffffffff'O) != '9401'O) {
            setverdict(fail);
        }

        if (f_compute_checksum_32('00000000'O) != '2144DF1C'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32('000000001CDF4421'O) xor4b 'FFFFFFFF'O != 'DEBB20E3'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32('f20183'O) != '24AB9D77'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32('332255AABBCCDDEEFF'O) != 'B0AE863D'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32('ffffffff'O) != 'FFFFFFFF'O) {
            setverdict(fail);
        }

        if (f_compute_checksum_32P4('00000000'O) != '6FB32240'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32P4('000000004022B36F'O) xor4b 'FFFFFFFF'O != '904CDDBF'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32P4('f20183'O) != '4F721A25'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32P4('332255AABBCCDDEEFF'O) != 'A65A343D'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_32P4('ffffffff'O) != 'FFFFFFFF'O) {
            setverdict(fail);
        }
        // ETSI TS 103 882 V2.1.1 (2024-05) Annex D.3 Step 6
        if (f_compute_checksum_32P4('00690DC1B30487DC3A31B6F9E7979F3D3BF769C8C983266C593070C5833607B7CEDD3CF9E9DFBB4E462C19B060C5930619C3D70408261B31E796D8F00171ADEBC9A7856341EFCCDBE7B65D1A71ECCBD3CF0CAEDBE79E1CD97A79E1CB7E6D3B3283ADE68A80'O) != '8524A071'O) {
            setverdict(fail);
        }

        if (f_compute_checksum_64('00000000'O) != 'F4A586351E1B9F4B'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_64('000000004B9F1B1E3586A5F4'O) xor4b 'FFFFFFFFFFFFFFFF'O != '49958C9ABD7D353F'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_64('f20183'O) != '319C27668164F1C6'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_64('332255AABBCCDDEEFF'O) != '701ECEB219A8E5D5'O) {
            setverdict(fail);
        }
        if (f_compute_checksum_64('ffffffff'O) != 'FFFFFFFF00000000'O) {
            setverdict(fail);
        }

        setverdict(pass)

    } // End of TC_MIM_MSD_FMT_BV_01

    testcase TC_CHECKSUMS_BV_02() runs on ItsAvm system ItsAvmSystem {

         // ETSI TS 103 882 V2.1.1 (2024-05) Annex D.3 Steps 1-5
        var octetstring v_mvm := '0013A0B1C2D300690DC1B30487DC000000003A31B6F9E7979F3D3BF769C8C983266C593070C5833607B7CEDD3CF9E9DFBB4E462C19B060C5930619C3D70408261B31E796D8F00171ADEBC9A7856341EFCCDBE7B65D1A71ECCBD3CF0CAEDBE79E1CD97A79E1CB7E6D3B3283ADE68A80'O;
        var octetstring v_data := v_mvm;

        if (f_avm_e2e_compute_checksum(v_data) != 0) { // ETSI TS 103 882 V2.1.1 (2024-05) Annex D.3
            setverdict(fail);
        }
        if (substr(v_data, 6 + 2 + 2 + 4, 4) != '8524A071'O) { // ETSI TS 103 882 V2.1.1 (2024-05) Annex D.3 Step 6
            setverdict(fail);
        }
        if (substr(v_data, 0, 6 + 2 + 2 + 4) != substr(v_mvm, 0, 6 + 2 + 2 + 4)) { // Check bytes before checksum are not modified
            setverdict(fail);
        }
        if (substr(v_data, 6 + 2 + 2 + 4 + 4, lengthof(v_data) - (6 + 2 + 2 + 4 + 4)) != substr(v_mvm, 6 + 2 + 2 + 4 + 4, lengthof(v_mvm) - (6 + 2 + 2 + 4 + 4))) { // Check bytes after checksum are not modified
            setverdict(fail);
        }
        if (f_avm_e2e_verify_checksum(v_data) == false) { // ETSI TS 103 882 V2.1.1 (2024-05) Annex D.3 Step 7
            setverdict(fail);
        }
        // Modify a byte in the data and check that checksum verification fails
        v_data := substr(v_data, 0, 15) & 'AA'O & substr(v_data, 16, lengthof(v_data) - 16);
        if (f_avm_e2e_verify_checksum(v_data) == true) {
            setverdict(fail);
        }

        setverdict(pass)

    } // End of TC_MIM_MSD_FMT_BV_02

} // End of module ItsAvm_TestCases
+45 −0
Original line number Diff line number Diff line
/**
 *    @author   ETSI / TTF T051
 *    @desc     Test Control file for AVM
 *    @copyright   ETSI Copyright Notification
 *                 No part may be reproduced except as authorized by written permission.
 *                 The copyright and the foregoing restriction extend to reproduction in all media.
 *                 All rights reserved.
*
 */
module ItsAvm_TestControl {
    
    // ATS AVM
    import from ItsAvm_TestCases all;
    
    // LibIts
    import from LibItsAvm_Pics all;
    
    // Test Execution
    control {
        
        if (PICS_RO_ROLE) {

            if (PICS_MIM_GENERATION) {
                execute(TC_MVM_MSD_FMT_BV_01());
            }

            execute(TC_MIM_MSD_PAR_BV_01());
            execute(TC_MIM_MSD_PAR_BV_02());
            execute(TC_MIM_MSD_PAR_BV_03());
        }
    
        if (PICS_VO_ROLE) {

            if (PICS_MVM_GENERATION) {
                execute(TC_MVM_MSD_FMT_BV_01());
            }

            execute(TC_MVM_MSD_PAR_BV_01());
            execute(TC_MVM_MSD_PAR_BV_02());
            execute(TC_MVM_MSD_PAR_BV_03());
        }

    } // End of 'control' statement
    
} // End of ItsAvm_TestControl
 No newline at end of file
+533 −0

File added.

Preview size limit exceeded, changes collapsed.

LICENSE

0 → 100644
+23 −0
Original line number Diff line number Diff line
Copyright 2019-2026 ETSI

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation 
   and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors 
   may be used to endorse or promote products derived from this software without 
   specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
OF THE POSSIBILITY OF SUCH DAMAGE.
 No newline at end of file
+62 −0
Original line number Diff line number Diff line
module LibItsAvm_Checksums_function {

  // Titan framework Security
  import from LibSecurity_Checksums all;

  // LibIts
  import from AVM_Commons language "ASN.1:1997" all;
  import from MIM_PDU_Descriptions language "ASN.1:1997" all;
  import from MVM_PDU_Descriptions language "ASN.1:1997" all;
  
  // LibItsAvm
  import from LibItsAvm_TypesAndValues all; 

  function f_avm_e2e_compute_checksum(
                                      inout octetstring p_data
                                      ) return integer {
    log(">>> f_avm_e2e_compute_checksum: p_data: ", p_data);

    // Calculate the checksum over the e2eProtection.length_ field and the rest of the message (excluding the first 6 bytes and the 4 bytes of crc32)
    var octetstring v_data := 
      int2oct(lengthof(p_data) - 6, 2) &                                         // e2eProtection.length_
      substr(p_data, 6 + 2, 2 + 4) &                                             // rollingCounter + dataID - crc32
      substr(p_data, 6 + 2 + 2 + 4 + 4, lengthof(p_data) - (6 + 2 + 2 + 4 + 4)); // rest of the message
    log("f_avm_e2e_compute_checksum: v_data: ", v_data);
    var octetstring v_checksum := f_compute_checksum_32P4(v_data);
    log("f_avm_e2e_compute_checksum: v_checksum: ", v_checksum);
    // Insert checksum into the message
    p_data := 
            substr(p_data, 0, 6 + 2 + 2 + 4) &                                         // Header + e2eProtection.length_ field + e2eProtection.rollingCounter + e2eProtection.dataID
            v_checksum &                                                               // e2eProtection.crc32
            substr(p_data, 6 + 2 + 2 + 4 + 4, lengthof(p_data) - (6 + 2 + 2 + 4 + 4)); // mims field
    log("f_avm_e2e_compute_checksum: p_data: ", p_data);

    log("<<< f_avm_e2e_compute_checksum: p_data: ", p_data);
    return 0;
  }
  
  function f_avm_e2e_verify_checksum(
                                     in octetstring p_data
                                     ) return boolean {
    log(">>> f_avm_e2e_verify_checksum: p_data: ", p_data);

    // Calculate the checksum over the e2eProtection.length_ field and the rest of the message (excluding the first 6 bytes and the 4 bytes of crc32)
    var octetstring v_data := 
      int2oct(lengthof(p_data) - 6, 2) &                                         // e2eProtection.length_
      substr(p_data, 6 + 2, 2 + 4) &                                             // rollingCounter + dataID - crc32
      substr(p_data, 6 + 2 + 2 + 4 + 4, lengthof(p_data) - (6 + 2 + 2 + 4 + 4)); // rest of the message
    log("f_avm_e2e_verify_checksum: v_data: ", v_data);
    var octetstring v_checksum := f_compute_checksum_32P4(v_data);
    log("f_avm_e2e_verify_checksum: v_checksum: ", v_checksum);
    // Check with the checksum in the message
    var octetstring v_expected_checksum := substr(p_data, 6 + 2 + 2 + 4, 4);
    if (v_expected_checksum != v_checksum) {
      log("<<< f_avm_e2e_verify_checksum, v_expected_checksum: ", v_expected_checksum, ": false");
      return false;
    }

    log("<<< f_avm_e2e_verify_checksum: true");
    return true;
  }
  
} // End of module LibItsAvm_Checksums_function
 No newline at end of file
Loading