Commit 7ddb861d authored by filatov's avatar filatov
Browse files

add altsteps for message with certs or digests

put mw_geoNwSecPdu to LibItsGeoNetworking_Templates
parent d72e348f
Loading
Loading
Loading
Loading
+74 −0
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ module LibItsGeoNetworking_Functions {
    import from LibItsCommon_Functions all;
    import from LibItsCommon_TestSystem all;
    import from LibItsCommon_TypesAndValues all;
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Templates all;
    import from LibItsSecurity_Functions all;
    import from LibItsGeoNetworking_TestSystem all;
    import from LibItsGeoNetworking_TypesAndValues all;
    import from LibItsGeoNetworking_Templates all;
@@ -25,6 +28,7 @@ module LibItsGeoNetworking_Functions {
    import from LibItsGeoNetworking_Pics all;
    import from LibItsExternal_TypesAndValues {type MacAddress};

    
    group utFuntions {
        
        /**
@@ -2244,4 +2248,74 @@ module LibItsGeoNetworking_Functions {
        external function fx_computeGnTimestamp() return UInt32;
    }

    group security {
        /**
         * @desc    Waiting for the GN message with Security
         * @param   p_InSecMsg  SecurityMessage template 
         * @param   p_received  returns received SecurityMessage 
         */
        altstep a_securedMessage (
            in template (present) SecuredMessage p_InSecMsg,
            out SecuredMessage p_received
        ) runs on ItsGeoNetworking {
            var GeoNetworkingInd v_geoNw;
            [] geoNetworkingPort.receive(mw_geoNwInd(
                                            mw_geoNwSecPdu(
                                                p_InSecMsg,
                                                mw_geoNwAnyPacket_withPayload(?)
                                        ))) -> value (v_geoNw) {
                    p_received := f_getSecuredMessage(v_geoNw.msgIn);
            }
        }
        
        /**
         * @desc         Receive GN message with security containing certificate as a signer info
         * @param p_cert returns the certificate used for sign received message
         */
        altstep a_securedMessageWithCertificate (
            out SecuredMessage p_received
        ) runs on ItsGeoNetworking {
            var SecuredMessage v_secMsg;
            []a_securedMessage (
                mw_securedMessage (superset(mw_header_field_signer_info_certificate)),
                p_received
            ) {}
        }

        /**
         * @desc         Receive GN message with security containing digest as a signer info
         * @param p_cert returns the certificate used for sign received message
         */
        altstep a_securedMessageWithDigest (
            out SecuredMessage p_received
        ) runs on ItsGeoNetworking {
            []a_securedMessage (
                mw_securedMessage (superset(mw_header_field_signer_info_certificate)), 
                p_received
            ) {}
        }

    }// End of group altSteps
    
    group waitingHelpers {
        
        /**
         * @desc  Wait for GN message with security containing certificate as a signer info
         * @return the certificate used for sign received message
         */
        function f_waitForCertificate ()
        runs on ItsGeoNetworking
        return Certificate {
            var SecuredMessage v_recv;
            var Certificate v_cert;
            alt {
                [] a_securedMessageWithCertificate(v_recv){
                    var SignerInfo v_si := f_getMsgSignerInfo(v_recv); 
                    v_cert :=  v_si.signerInfo.certificate
                }
            }
            return v_cert;
        }
    }
            
} // end LibItsGeoNetworking_Functions
 No newline at end of file
+17 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ module LibItsGeoNetworking_Templates {
    import from LibItsIpv6OverGeoNetworking_Templates all;
    import from LibItsBtp_Templates all;
    import from LibItsExternal_TypesAndValues all;
    import from LibItsSecurity_TypesAndValues all;
    
    group geoNwPrimitivesTemplates {
        
@@ -473,6 +474,21 @@ module LibItsGeoNetworking_Templates {
            }
        }

        /**
         * @desc    Receive template for secured GeoNetworking PDU
         * @param   p_secMsg    Secured message
         * @param   p_packet    Clear-text version of the packet
         */
        template (present) GeoNetworkingPdu mw_geoNwSecPdu(
            in template (present) SecuredMessage p_secMsg,
            in template (present) GnNonSecuredPacket p_packet := ?
        ) := {
            basicHeader := mw_basicHeader(),
            gnPacket := {
                packet := p_packet,
                securedMsg := p_secMsg
            }
        }
    } // end geoNwPduTemplates
    
    group geoNwPacketTemplates {
+0 −32
Original line number Diff line number Diff line
module LibItsSecurity_GNTemplates {
    // LibCommon
    import from LibCommon_BasicTypesAndValues {
        type UInt8, UInt16, UInt32, 
             Int32 
    }
    import from LibCommon_DataStrings {
        type Oct2, Oct20
    }
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Pixits all;
    import from LibItsGeoNetworking_TypesAndValues all;
    import from LibItsGeoNetworking_Templates {
        group geoNwHeadersTemplates, geoNwPduTemplates
    }

    /**
     * @desc    Receive template for secured GeoNetworking PDU
     * @param 	p_secMsg	Secured message
     * @param   p_packet    Clear-text version of the packet
     */
    template (present) GeoNetworkingPdu mw_geoNwSecPdu(
        in template (present) SecuredMessage p_secMsg,
        in template (present) GnNonSecuredPacket p_packet := ?
    ) := {
        basicHeader := mw_basicHeader(),
        gnPacket := {
            packet := p_packet,
            securedMsg := p_secMsg
        }
    }
}
 No newline at end of file