Commit 2ebabe5d authored by ASN.1 Documenter's avatar ASN.1 Documenter
Browse files

Initial

parent 1e118329
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ module ItsSecurity_Functions {
    import from LibCommon_Time all;
    
    // LibIts
    import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
    import from Ieee1609Dot2 language "ASN.1:1997" all;
    import from EtsiTs103097Module language "ASN.1:1997" all;
    import from ITS_Container language "ASN.1:1997" all;
    import from DENM_PDU_Descriptions language "ASN.1:1997" all;
+16 −16
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@ module ItsSecurity_TestCases {
    
    // LibIts
    //import from DENM_PDU_Descriptions language "ASN.1:1997" all;
    import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
    import from Ieee1609Dot2 language "ASN.1:1997" all;
    import from EtsiTs103097Module language "ASN.1:1997" all;
    
    // LibItsCommon
@@ -3000,8 +3000,8 @@ module ItsSecurity_TestCases {
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload(
                                                mw_ieee1609Dot2Data(
                                                    mw_ieee1609Dot2Data_unsecured
                                                mw_Ieee1609Dot2Data(
                                                    mw_Ieee1609Dot2Data_unsecured
                                            )),
                                            mw_headerInfo_cam
                                        )
@@ -3017,8 +3017,8 @@ module ItsSecurity_TestCases {
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload(
                                                mw_ieee1609Dot2Data(
                                                    mw_ieee1609Dot2Data_unsecured
                                                mw_Ieee1609Dot2Data(
                                                    mw_Ieee1609Dot2Data_unsecured
                                            )),
                                            mw_headerInfo_cam
                                        )
@@ -5199,8 +5199,8 @@ module ItsSecurity_TestCases {
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload(
                                                mw_ieee1609Dot2Data(
                                                    mw_ieee1609Dot2Data_unsecured
                                                mw_Ieee1609Dot2Data(
                                                    mw_Ieee1609Dot2Data_unsecured
                                            )),
                                            mw_headerInfo_denm
                                        )
@@ -6775,8 +6775,8 @@ module ItsSecurity_TestCases {
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload(
                                                mw_ieee1609Dot2Data(
                                                    mw_ieee1609Dot2Data_unsecured
                                                mw_Ieee1609Dot2Data(
                                                    mw_Ieee1609Dot2Data_unsecured
                                            )),
                                            mw_headerInfo_gn
                                        )
@@ -6881,8 +6881,8 @@ module ItsSecurity_TestCases {
                                        -, 
                                        mw_toBeSignedData(
                                            mw_signedDataPayload(
                                                mw_ieee1609Dot2Data(
                                                    mw_ieee1609Dot2Data_unsecured
                                                mw_Ieee1609Dot2Data(
                                                    mw_Ieee1609Dot2Data_unsecured
                                            )),
                                            mw_headerInfo_gn
                                        )
@@ -9667,7 +9667,7 @@ module ItsSecurity_TestCases {
//                        [] geoNetworkingPort.receive(
//                            mw_geoNwInd(
//                                mw_geoNwSecPdu(
//                                    mw_ieee1609Dot2Data_dummy, 
//                                    mw_Ieee1609Dot2Data_dummy, 
//                                    mw_geoNwBroadcastPacketWithArea(
//                                        mw_longPosVectorPosition(
//                                            v_longPosVectorNodeB
@@ -9682,7 +9682,7 @@ module ItsSecurity_TestCases {
//                        [] geoNetworkingPort.receive(
//                            mw_geoNwInd(
//                                mw_geoNwSecPdu(
//                                    mw_ieee1609Dot2Data_dummy
//                                    mw_Ieee1609Dot2Data_dummy
//                        ))) {
//                            // Do not restart tc_ac timer
//                            log("*** " & testcasename() & ": INFO: Unexpected GN message ignored ***");
@@ -9718,7 +9718,7 @@ module ItsSecurity_TestCases {
//                        [] geoNetworkingPort.receive(
//                            mw_geoNwInd(
//                                mw_geoNwSecPdu(
//                                    mw_ieee1609Dot2Data_dummy, 
//                                    mw_Ieee1609Dot2Data_dummy, 
//                                    mw_geoNwBroadcastPacketWithArea(
//                                        mw_longPosVectorPosition(
//                                            v_longPosVectorIut
@@ -9733,7 +9733,7 @@ module ItsSecurity_TestCases {
//                        [] geoNetworkingPort.receive(
//                            mw_geoNwInd(
//                                mw_geoNwSecPdu(
//                                    mw_ieee1609Dot2Data_dummy
//                                    mw_Ieee1609Dot2Data_dummy
//                        ))) {
//                            // Do not restart tc_ac timer
//                            log("*** " & testcasename() & ": INFO: Unexpected GN message ignored ***");
+11 −11
Original line number Diff line number Diff line
module LibItsSecurity_EncdecDeclarations {
    
    // LibIts
    //import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    //import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
    import from Ieee1609Dot2 language "ASN.1:1997" all;
    //import from EtsiTs103097Module language "ASN.1:1997" all;
  
    import from LibItsSecurity_TypesAndValues all;
@@ -12,35 +12,35 @@ module LibItsSecurity_EncdecDeclarations {
     * @param p The certificate to encode
     * @return The encode message in OER format
     */
    external function fx_enc_CertificateBase(in IEEE1609dot2.CertificateBase p) return bitstring
    external function fx_enc_CertificateBase(in Ieee1609Dot2.CertificateBase p) return bitstring
      with {extension "prototype(convert) encode(PER)"}
    
    external function fx_dec_CertificateBase(inout bitstring b, out IEEE1609dot2.CertificateBase p) return integer
    external function fx_dec_CertificateBase(inout bitstring b, out Ieee1609Dot2.CertificateBase p) return integer
        with {extension "prototype(sliding) decode(PER)"}
    
    /**
     * @desc Encoding function for IEEE1609dot2.ToBeSignedCertificate
     * @desc Encoding function for Ieee1609Dot2.ToBeSignedCertificate
     * @param p The ToBeSign part of the certificate
     * @return The encode message in OER format
     */
    external function fx_enc_ToBeSignedCertificate(in IEEE1609dot2.ToBeSignedCertificate p) return bitstring
    external function fx_enc_ToBeSignedCertificate(in Ieee1609Dot2.ToBeSignedCertificate p) return bitstring
        with {extension "prototype(convert) encode(PER)"}
    
    /**
     * @desc Encoding function for IEEE1609dot2.Ieee1609Dot2Data
     * @desc Encoding function for Ieee1609Dot2.Ieee1609Dot2Data
     * @param p The Ieee1609Dot2Data part of the certificate
     * @return The encode message in OER format
     */
    external function fx_enc_Ieee1609Dot2Data(in IEEE1609dot2.Ieee1609Dot2Data p) return bitstring
    external function fx_enc_Ieee1609Dot2Data(in Ieee1609Dot2.Ieee1609Dot2Data p) return bitstring
    with {extension "prototype(convert) encode(PER)"}

    external function fx_dec_Ieee1609Dot2Data(inout bitstring p_data, out IEEE1609dot2.Ieee1609Dot2Data p_ieee1609Dot2Data) return integer
    external function fx_dec_Ieee1609Dot2Data(inout bitstring p_data, out Ieee1609Dot2.Ieee1609Dot2Data p_Ieee1609Dot2Data) return integer
        with {extension "prototype(sliding) decode(PER)"}
    
    external function fx_enc_Ieee1609Dot2ToBeSignedData(in IEEE1609dot2.ToBeSignedData p) return bitstring
    external function fx_enc_Ieee1609Dot2ToBeSignedData(in Ieee1609Dot2.ToBeSignedData p) return bitstring
    with {extension "prototype(convert) encode(PER)"}

    external function fx_dec_Ieee1609Dot2ToBeSignedData(inout bitstring p_data, out IEEE1609dot2.ToBeSignedData p_toBeSignedData) return integer
    external function fx_dec_Ieee1609Dot2ToBeSignedData(inout bitstring p_data, out Ieee1609Dot2.ToBeSignedData p_toBeSignedData) return integer
        with {extension "prototype(sliding) decode(PER)"}
    
    external function fx_enc_SspCAM (LibItsSecurity_TypesAndValues.SspCAM p_ssp) return bitstring
+60 −49
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ module LibItsSecurity_Functions {
    import from LibCommon_DataStrings all;

    // LibIts
    import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
    import from Ieee1609Dot2 language "ASN.1:1997" all;
    import from EtsiTs103097Module language "ASN.1:1997" all;
    
    // LibItsCommon
@@ -1036,7 +1036,7 @@ module LibItsSecurity_Functions {
                        }
                    );
                } else if (p_trailerStatus == 3) { // Signature with reserved algorthm
                    p_securedMessage := m_ieee1609Dot2Data_wrong_protocol(
                    p_securedMessage := m_Ieee1609Dot2Data_wrong_protocol(
                        p_protocolVersion,
                        valueof(v_toBeSignedData.header_fields),
                        p_payloadField,
@@ -1184,7 +1184,7 @@ module LibItsSecurity_Functions {
                
                // Local variables
                var EtsiTs103097Certificate v_aaCertificate, v_atCertificate;
                var HeaderInfo v_mandatoryHeaders := valueof(m_ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_mandatoryHeaders := valueof(m_Ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_signerInfo;
                 
                // Load certificates if required
@@ -1473,7 +1473,7 @@ module LibItsSecurity_Functions {
                                             ) runs on ItsSecurityBaseComponent return boolean {
                // Local variables
                var EtsiTs103097Certificate v_aaCertificate, v_atCertificate;
                var HeaderInfo v_mandatoryHeaders := valueof(m_ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_mandatoryHeaders := valueof(m_Ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_signerInfo;
                 
                // Load certificates if required
@@ -1630,7 +1630,7 @@ module LibItsSecurity_Functions {
                
                // Local variables
                var EtsiTs103097Certificate v_aaCertificate, v_atCertificate;
                var HeaderInfo v_mandatoryHeaders := valueof(m_ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_mandatoryHeaders := valueof(m_Ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_signerInfo;
                 
                // Load certificates if required
@@ -1705,7 +1705,7 @@ module LibItsSecurity_Functions {
                
                // Local variables
                var EtsiTs103097Certificate v_aaCertificate, v_atCertificate;
                var HeaderInfo v_mandatoryHeaders := valueof(m_ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_mandatoryHeaders := valueof(m_Ieee1609Dot2_headerInfo(0));
                var HeaderInfo v_signerInfo;
                
                // Load certificates if required
@@ -3076,37 +3076,45 @@ module LibItsSecurity_Functions {
                                                 in EtsiTs103097Certificate p_cert, 
                                                 in EtsiTs103097Certificate p_cert_issuer
        ) return boolean {
            var ValidityPeriod v_cert_region, v_cert_issuer_region;
            var GeographicRegion v_cert_region, v_cert_issuer_region;
            var boolean v_cert_issuer_region_result;
            
            /* FIXME To be reviewed v_cert_issuer_region_result := f_getCertificateValidityRestriction(p_cert_issuer, e_region, v_cert_issuer_region);
            if (f_getCertificateValidityRestriction(p_cert, e_region, v_cert_region) == false) {
                if (v_cert_issuer_region_result == true) {
                    if (v_cert_issuer_region.validity.region.region_type != e_none) {
            // FIXME To be reviewed

            // Sanity checks
            if (ispresent(p_cert.toBeSigned.region) == false) {
                log("f_checkRegionValidityRestiction: GeographicRegion missig into certificate");
                return false;
            }
            if (ispresent(p_cert_issuer.toBeSigned.region) == false) {
              // No greographical constraints
              return true;
            }
            } else if (
                        (v_cert_issuer_region_result == true) and 
                        (v_cert_issuer_region.validity.region.region_type != e_none)
            ) {
                if (v_cert_region.validity.region.region_type == e_circle) {
                    if (v_cert_issuer_region.validity.region.region_type == e_circle) {
            v_cert_region := p_cert.toBeSigned.region;
            v_cert_issuer_region := p_cert_issuer.toBeSigned.region;
            if (ispresent(v_cert_region.circularRegion) and ispresent(v_cert_issuer_region.circularRegion)) {
              // Check v_cert_region 'circle' is inside v_cert_issuer_region 'circle'
                        if (f_areCirclesInside(v_cert_region.validity.region.region.circular_region, v_cert_issuer_region.validity.region.region.circular_region) == false) {
                            log("*** " & testcasename() & ": FAIL: Issuer and issuing certificates circle area does not match ***");
              if (f_areCirclesInside(valueof(v_cert_region.circularRegion), valueof(v_cert_issuer_region.circularRegion)) == false) {
                log("f_checkRegionValidityRestiction: FAIL: Issuer and issuing certificates circle area does not match");
                return false;
              }
                    }
                } else if (v_cert_region.validity.region.region_type == e_rectangle) {
                    if (v_cert_issuer_region.validity.region.region_type == e_rectangle) {
            } else if (ispresent(v_cert_region.rectangularRegion) and ispresent(v_cert_issuer_region.rectangularRegion)) {
              // Check v_cert_region 'rectangle' is inside v_cert_issuer_region 'rectangle'
                        if (f_areRectanglesInside(v_cert_region.validity.region.region.rectangular_region, v_cert_issuer_region.validity.region.region.rectangular_region) == false) {
                            log("*** " & testcasename() & ": FAIL: Issuer and issuing certificates rectangle area does not match ***");
              if (f_isRectangularRegionsIntersected(v_cert_region.rectangularRegion, v_cert_issuer_region.rectangularRegion) == false) {
                log("f_checkRegionValidityRestiction: FAIL: Issuer and issuing certificates rectangle area does not match");
                return false;
              }
            } else if (ispresent(v_cert_region.polygonalRegion) and ispresent(v_cert_issuer_region.polygonalRegion)) {
              // Check v_cert_region 'polygon' is inside v_cert_issuer_region 'polygon'
              log("f_checkRegionValidityRestiction: FAIL: Not implemented");
              // TODO
              return false;
            } else if (ispresent(v_cert_region.identifiedRegion) and ispresent(v_cert_issuer_region.identifiedRegion)) {
              log("f_checkRegionValidityRestiction: FAIL: Not implemented");
              // Check id_region
              // TODO
            }
                } else if (v_cert_region.validity.region.region_type == e_polygon) {
            /*if (v_cert_region.validity.region.region_type == e_polygon) {
                    if (v_cert_issuer_region.validity.region.region_type == e_polygon) {
                        // Check v_cert_region 'polygon' is inside v_cert_issuer_region 'polygon'
                        if (f_arePolygonsInside(v_cert_region.validity.region.region.polygonal_region, v_cert_issuer_region.validity.region.region.polygonal_region) == false) {
@@ -3215,20 +3223,23 @@ module LibItsSecurity_Functions {
         * @return  true on success, false otherwise
         */
        function f_isRectangularRegionsIntersected(
                                                   in template (value) RectangularRegion p_r1,
                                                   in template (value) RectangularRegion p_r2
                                                   in template (value) SequenceOfRectangularRegion p_r1,
                                                   in template (value) SequenceOfRectangularRegion p_r2
        ) return boolean {
            return not (
//FIXME RGY Titan doesn't support dot notation after valueof at the moment
//                valueof(p_r2).northWest.longitude > valueof(p_r1).southEast.longitude or 
//                valueof(p_r2).southEast.longitude < valueof(p_r1).northWest.longitude or 
//                valueof(p_r2).southEast.latitude  > valueof(p_r1).northWest.latitude or 
//                valueof(p_r2).northWest.latitude  < valueof(p_r1).southEast.latitude
                valueof(p_r2.northWest.longitude) > valueof(p_r1.southEast.longitude) or 
                valueof(p_r2.southEast.longitude) < valueof(p_r1.northWest.longitude) or 
                valueof(p_r2.southEast.latitude)  > valueof(p_r1.northWest.latitude) or 
                valueof(p_r2.northWest.latitude)  < valueof(p_r1.southEast.latitude)
            );
          var integer v_min := f_min(lengthof(p_r1), lengthof(p_r2));

          for (var integer i := 0; i < v_min; i := i + 1) {
            if (not (
                    valueof(p_r2[i].northWest.longitude) > valueof(p_r1[i].southEast.longitude) or 
                    valueof(p_r2[i].southEast.longitude) < valueof(p_r1[i].northWest.longitude) or 
                    valueof(p_r2[i].southEast.latitude)  > valueof(p_r1[i].northWest.latitude) or 
                    valueof(p_r2[i].northWest.latitude)  < valueof(p_r1[i].southEast.latitude)
                     )) {
              return false;
              }
          } // End of 'for' statement

          return true;
        } // End of function f_isRectangularRegionsIntersected
        
        function f_isContinuousRectangularRegions(
+2 −2
Original line number Diff line number Diff line
@@ -12,8 +12,8 @@
module LibItsSecurity_Pics {
    
    // LibIts
    import from IEEE1609dot2BaseTypes language "ASN.1:1997" all;
    import from IEEE1609dot2 language "ASN.1:1997" all;
    import from Ieee1609Dot2BaseTypes language "ASN.1:1997" all;
    import from Ieee1609Dot2 language "ASN.1:1997" all;
    import from EtsiTs103097Module language "ASN.1:1997" all;
        
    // LibItsSecurity
Loading