Commit 7e714d0e authored by garciay's avatar garciay
Browse files

Starting review of AtsSecurity TCs

parent 97a6d123
Loading
Loading
Loading
Loading
+73 −22
Original line number Original line Diff line number Diff line
@@ -146,6 +146,9 @@ module LibItsGeoNetworking_Functions {
            f_connect4SelfOrClientSync();
            f_connect4SelfOrClientSync();
            activate(a_cf01Down());
            activate(a_cf01Down());
            
            
            // Initialise secured mode
            f_initialiseSecuredMode();
            
            //Initialze the IUT
            //Initialze the IUT
            f_initialState();
            f_initialState();
            
            
@@ -156,11 +159,10 @@ module LibItsGeoNetworking_Functions {
            
            
        } // end f_cf01Up
        } // end f_cf01Up
        
        
        /**
         * @desc Deletes configuration cf01
         */
        function f_cf01Down() runs on ItsGeoNetworking {
        function f_cf01Down() runs on ItsGeoNetworking {
            
            
            f_uninitialiseSecuredMode();
            
            // Unmap
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:utPort, system:utPort);
@@ -213,6 +215,9 @@ module LibItsGeoNetworking_Functions {
            
            
            //Initialze the IUT
            //Initialze the IUT
            if(p_mainUtComponent == c_compMTC) {
            if(p_mainUtComponent == c_compMTC) {
                // Initialise secured mode
                f_initialiseSecuredMode();
                
                // MTC intializes IUT
                // MTC intializes IUT
                f_initialState();
                f_initialState();
            }
            }
@@ -240,8 +245,11 @@ module LibItsGeoNetworking_Functions {
         */
         */
        function f_cf02Down() runs on ItsMtc {
        function f_cf02Down() runs on ItsMtc {
            
            
            // Local variables
            var integer i;
            var integer i;
            
            
            f_uninitialiseSecuredMode();
            
            // Unmap & Disconnect
            // Unmap & Disconnect
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
@@ -297,6 +305,9 @@ module LibItsGeoNetworking_Functions {
            
            
            //Initialze the IUT
            //Initialze the IUT
            if(p_mainUtComponent == c_compMTC) {
            if(p_mainUtComponent == c_compMTC) {
                // Initialise secured mode
                f_initialiseSecuredMode();
                
                // MTC intializes IUT
                // MTC intializes IUT
                f_initialState();
                f_initialState();
            }
            }
@@ -324,8 +335,11 @@ module LibItsGeoNetworking_Functions {
         */
         */
        function f_cf03Down() runs on ItsMtc {
        function f_cf03Down() runs on ItsMtc {
            
            
            // Local variables
            var integer i;
            var integer i;
            
            
            f_uninitialiseSecuredMode();
            
            // Unmap & Disconnect
            // Unmap & Disconnect
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
@@ -383,6 +397,9 @@ module LibItsGeoNetworking_Functions {
            
            
            //Initialze the IUT
            //Initialze the IUT
            if(p_mainUtComponent == c_compMTC) {
            if(p_mainUtComponent == c_compMTC) {
                // Initialise secured mode
                f_initialiseSecuredMode();
                
                // MTC intializes IUT
                // MTC intializes IUT
                f_initialState();
                f_initialState();
            }
            }
@@ -410,8 +427,11 @@ module LibItsGeoNetworking_Functions {
         */
         */
        function f_cf04Down() runs on ItsMtc {
        function f_cf04Down() runs on ItsMtc {
            
            
            // Local variables
            var integer i;
            var integer i;
            
            
            f_uninitialiseSecuredMode();
            
            // Unmap & Disconnect
            // Unmap & Disconnect
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
@@ -465,6 +485,9 @@ module LibItsGeoNetworking_Functions {
            
            
            //Initialze the IUT
            //Initialze the IUT
            if(p_mainUtComponent == c_compMTC) {
            if(p_mainUtComponent == c_compMTC) {
                // Initialise secured mode
                f_initialiseSecuredMode();
                
                // MTC intializes IUT
                // MTC intializes IUT
                f_initialState();
                f_initialState();
            }
            }
@@ -491,8 +514,11 @@ module LibItsGeoNetworking_Functions {
         */
         */
        function f_cf05Down() runs on ItsMtc {
        function f_cf05Down() runs on ItsMtc {
            
            
            // Local variables
            var integer i;
            var integer i;
            
            
            f_uninitialiseSecuredMode();
            
            // Unmap & Disconnect
            // Unmap & Disconnect
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
@@ -547,6 +573,9 @@ module LibItsGeoNetworking_Functions {
            
            
            //Initialze the IUT
            //Initialze the IUT
            if(p_mainUtComponent == c_compMTC) {
            if(p_mainUtComponent == c_compMTC) {
                // Initialise secured mode
                f_initialiseSecuredMode();
                
                // MTC intializes IUT
                // MTC intializes IUT
                f_initialState();
                f_initialState();
            }
            }
@@ -573,8 +602,11 @@ module LibItsGeoNetworking_Functions {
         */
         */
        function f_cf06Down() runs on ItsMtc {
        function f_cf06Down() runs on ItsMtc {
            
            
            // Local variables
            var integer i;
            var integer i;
            
            
            f_uninitialiseSecuredMode();
            
            // Unmap & Disconnect
            // Unmap & Disconnect
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
@@ -628,6 +660,9 @@ module LibItsGeoNetworking_Functions {
            
            
            //Initialze the IUT
            //Initialze the IUT
            if(p_mainUtComponent == c_compMTC) {
            if(p_mainUtComponent == c_compMTC) {
                // Initialise secured mode
                f_initialiseSecuredMode();
                
                // MTC intializes IUT
                // MTC intializes IUT
                f_initialState();
                f_initialState();
            }
            }
@@ -654,8 +689,11 @@ module LibItsGeoNetworking_Functions {
         */
         */
        function f_cf07Down() runs on ItsMtc {
        function f_cf07Down() runs on ItsMtc {
            
            
            // Local variables
            var integer i;
            var integer i;
            
            
            f_uninitialiseSecuredMode();
            
            // Unmap & Disconnect
            // Unmap & Disconnect
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) { 
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
                unmap(vc_componentTable[i].gnComponent:utPort, system:utPort);
@@ -667,7 +705,7 @@ module LibItsGeoNetworking_Functions {
            unmap(self:utPort, system:utPort);
            unmap(self:utPort, system:utPort);
            disconnect(self:syncPort, mtc:syncPort);
            disconnect(self:syncPort, mtc:syncPort);
            
            
        } // end f_cf06Down
        } // end f_cf0yDown
        
        
        /**
        /**
         * @desc    Behavior function for initializing component's variables and tables
         * @desc    Behavior function for initializing component's variables and tables
@@ -693,9 +731,6 @@ module LibItsGeoNetworking_Functions {
        function f_startBeingNeighbour() runs on ItsGeoNetworking {
        function f_startBeingNeighbour() runs on ItsGeoNetworking {
            
            
            vc_neighbourDefault := activate(a_neighbourDefault());
            vc_neighbourDefault := activate(a_neighbourDefault());
            if (PICS_SECURED_MODE == true) {
                f_acEnableSecurity();
            }
            f_acTriggerEvent(m_startBeaconing(m_beaconHeader(f_getPosition(vc_componentName)).beaconHeader));
            f_acTriggerEvent(m_startBeaconing(m_beaconHeader(f_getPosition(vc_componentName)).beaconHeader));
            f_sleepIgnoreDef(PX_NEIGHBOUR_DISCOVERY_DELAY);
            f_sleepIgnoreDef(PX_NEIGHBOUR_DISCOVERY_DELAY);
        } // end f_startBeingNeighbour
        } // end f_startBeingNeighbour
@@ -706,13 +741,25 @@ module LibItsGeoNetworking_Functions {
        function f_stopBeingNeighbour() runs on ItsGeoNetworking {
        function f_stopBeingNeighbour() runs on ItsGeoNetworking {
            
            
            f_acTriggerEvent(m_stopBeaconing);
            f_acTriggerEvent(m_stopBeaconing);
            if (PICS_SECURED_MODE == true) {
                f_acDisableSecurity();
            }
            deactivate(vc_neighbourDefault);
            deactivate(vc_neighbourDefault);
            
            
        } // end f_stopBeingNeighbour
        } // end f_stopBeingNeighbour
        
        
        /**
         * @desc Initialise secure mode if required
         */
        function f_initialiseSecuredMode() runs on ItsBaseGeoNetworking {
            if (PICS_SECURED_MODE == true) {
                f_acEnableSecurity();
            }
        } // End of function f_initialiseSecuredMode()
        
        function f_uninitialiseSecuredMode() runs on ItsBaseGeoNetworking {
            if (PICS_SECURED_MODE == true) {
                f_acDisableSecurity();
            }
        } // End of function f_initialiseSecuredMode()
        
    } // end geoConfigurationFunctions
    } // end geoConfigurationFunctions
    
    
    group componentFunctions {
    group componentFunctions {
@@ -1052,7 +1099,7 @@ module LibItsGeoNetworking_Functions {
            in float p_squareMeters
            in float p_squareMeters
        ) return float {
        ) return float {
         
         
            log("*** f_distance: INFO: calling fx_computeRadiusFromCircularArea() ***");
//            log("*** f_distance: INFO: calling fx_computeRadiusFromCircularArea() ***");
            return fx_computeRadiusFromCircularArea(p_squareMeters);
            return fx_computeRadiusFromCircularArea(p_squareMeters);
        }
        }
        
        
@@ -1068,7 +1115,7 @@ module LibItsGeoNetworking_Functions {
            in LongPosVector p_pointB
            in LongPosVector p_pointB
        ) return float {
        ) return float {
         
         
            log("*** f_distance: INFO: calling fx_computeDistance() ***");
//            log("*** f_distance: INFO: calling fx_computeDistance() ***");
            return fx_computeDistance(p_pointA.latitude, p_pointA.longitude, p_pointB.latitude, p_pointB.longitude);
            return fx_computeDistance(p_pointA.latitude, p_pointA.longitude, p_pointB.latitude, p_pointB.longitude);
        }
        }
        
        
@@ -1512,7 +1559,6 @@ module LibItsGeoNetworking_Functions {
            f_utInitializeIut(m_gnInitialize);
            f_utInitializeIut(m_gnInitialize);
        }
        }
        
        
        
        /**
        /**
         * @desc    Receive and reply to LS Requests
         * @desc    Receive and reply to LS Requests
         * @param   p_reqSeqNumber          Expected sequence number of the received LS Request
         * @param   p_reqSeqNumber          Expected sequence number of the received LS Request
@@ -1665,7 +1711,9 @@ module LibItsGeoNetworking_Functions {
         * @desc    Triggers test adapter to enable security support
         * @desc    Triggers test adapter to enable security support
         * @return  FncRetCode
         * @return  FncRetCode
         */
         */
        function f_acEnableSecurity() runs on ItsGeoNetworking return FncRetCode {
        function f_acEnableSecurity() runs on ItsBaseGeoNetworking return FncRetCode {
            
            // Local variables
            var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
            var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
            
            
            // Build the beacon template
            // Build the beacon template
@@ -1688,7 +1736,7 @@ module LibItsGeoNetworking_Functions {
         * @desc    Triggers test adapter to disable security support
         * @desc    Triggers test adapter to disable security support
         * @return  FncRetCode
         * @return  FncRetCode
         */
         */
        function f_acDisableSecurity() runs on ItsGeoNetworking return FncRetCode {
        function f_acDisableSecurity() runs on ItsBaseGeoNetworking return FncRetCode {
            
            
            return f_acTriggerEvent(AcGnPrimitive:{ acDisableSecurity := m_disableSecurity } );
            return f_acTriggerEvent(AcGnPrimitive:{ acDisableSecurity := m_disableSecurity } );
            
            
@@ -2300,13 +2348,16 @@ module LibItsGeoNetworking_Functions {
        altstep a_securedMessageWithCertificate(
        altstep a_securedMessageWithCertificate(
                                                out SecuredMessage p_received
                                                out SecuredMessage p_received
        ) runs on ItsGeoNetworking {
        ) runs on ItsGeoNetworking {
            var SecuredMessage v_secMsg;
            
            [] a_securedMessage (
            [] a_securedMessage (
                mw_securedMessage (superset(mw_header_field_signer_info_certificate)),
                mw_securedMessage (superset(mw_header_field_signer_info_certificate)),
                p_received
                p_received
            ) {}
            ) {
                //Nothing to do
            }
            }
            
            
        } // End of altstep a_securedMessageWithCertificate

        /**
        /**
         * @desc         Receive GN message with security containing certificate chain as a signer info
         * @desc         Receive GN message with security containing certificate chain as a signer info
         * @param p_cert returns the certificate used for sign received message
         * @param p_cert returns the certificate used for sign received message
+18 −6
Original line number Original line Diff line number Diff line
@@ -110,7 +110,9 @@ module LibItsSecurity_Functions {
                    return p_cert.signer_infos[v_counter].signerInfo.digest;
                    return p_cert.signer_infos[v_counter].signerInfo.digest;
                }
                }
            } // End of 'for' statement
            } // End of 'for' statement
            // digest not found, compute it 
            
            // Digest not found, compute it 
            log ("f_calculateDigestFromCertificate: Not found in certificate, compute it");
            v_toBeHashedData := bit2oct(encvalue(p_cert));
            v_toBeHashedData := bit2oct(encvalue(p_cert));
            v_hash := f_hashWithSha256(v_toBeHashedData);
            v_hash := f_hashWithSha256(v_toBeHashedData);
            return substr(v_hash, lengthof(v_hash) - 8, 8);
            return substr(v_hash, lengthof(v_hash) - 8, 8);
@@ -658,9 +660,12 @@ module LibItsSecurity_Functions {
                for (var integer i := 0; i < v_length; i := i + 1) {
                for (var integer i := 0; i < v_length; i := i + 1) {
                    if (valueof(p_securedMessage).header_fields[i].type_ == p_headerFieldType) {
                    if (valueof(p_securedMessage).header_fields[i].type_ == p_headerFieldType) {
                        p_return := valueof(p_securedMessage).header_fields[i];
                        p_return := valueof(p_securedMessage).header_fields[i];
//                        log("f_getMsgHeaderField: p_return=", p_return);
                        return true; 
                        return true; 
                    }
                    }
                }
                }
                
                log("f_getMsgHeaderField: return false");
                return false;
                return false;
            }
            }
            
            
@@ -672,12 +677,16 @@ module LibItsSecurity_Functions {
                                         out SignerInfo p_signerInfo
                                         out SignerInfo p_signerInfo
            ) return boolean {
            ) return boolean {
                var HeaderField v_hf;
                var HeaderField v_hf;
                if(f_getMsgHeaderField(p_securedMessage, e_signer_info, v_hf)){
                
                if (f_getMsgHeaderField(p_securedMessage, e_signer_info, v_hf) == true) {
                    if (isbound(v_hf.headerField.signer)) {
                    if (isbound(v_hf.headerField.signer)) {
                        p_signerInfo := v_hf.headerField.signer;
                        p_signerInfo := v_hf.headerField.signer;
                        log("f_getMsgSignerInfo: p_signerInfo=", p_signerInfo);
                        return true;
                        return true;
                    }
                    }
                }
                }
                
                log("f_getMsgSignerInfo: return false");
                return false;
                return false;
            }
            }
            
            
@@ -838,7 +847,7 @@ module LibItsSecurity_Functions {
             * @return The decimal coordinate on success, 0.0, otherwise
             * @return The decimal coordinate on success, 0.0, otherwise
             * @verdict Unchanged
             * @verdict Unchanged
             */
             */
            external function fx_dms2dd(in integer p_degrees, in integer p_minutes, in float p_seconds, in charstring p_latlon) return float;
            external function fx_dms2dd(in Int p_degrees, in Int p_minutes, in float p_seconds, in Oct1 p_latlon) return float;
            
            
        } // End of group geodesic
        } // End of group geodesic
        
        
@@ -1078,14 +1087,17 @@ module LibItsSecurity_Functions {
         */
         */
        function f_dms2dd(in integer p_degrees, in integer p_minutes, in float p_seconds, in charstring p_latlon) 
        function f_dms2dd(in integer p_degrees, in integer p_minutes, in float p_seconds, in charstring p_latlon) 
        return float {
        return float {
            var Oct1 v_latlon;
            
            // Sanity checks
            // Sanity checks
            if (lengthof(p_latlon) != 1) {
            if (lengthof(p_latlon) != 1) {
                return 0.0;
                return 0.0;
            } else if ((p_latlon != "N") and (p_latlon != "S") and (p_latlon != "E") and (p_latlon != "W")) {
            } else if ((p_latlon != "N") and (p_latlon != "S") and (p_latlon != "E") and (p_latlon != "W")) {
                return 0.0;
                return 0.0;
            }
            }
            v_latlon := char2oct(p_latlon);
            
            
            return fx_dms2dd(p_degrees, p_minutes, p_seconds, p_latlon);
            return fx_dms2dd(p_degrees, p_minutes, p_seconds, v_latlon);
        } // End of function f_dms2dd
        } // End of function f_dms2dd
        
        
        /**
        /**