Commit be87d41f authored by garciay's avatar garciay
Browse files

Add CAM UT trigger support

parent a81323ba
Loading
Loading
Loading
Loading
+141 −131
Original line number Original line Diff line number Diff line
@@ -128,6 +128,7 @@ module LibItsSecurity_Functions {
            function f_buildSecuredMessagePayloadToBeSigned(
            function f_buildSecuredMessagePayloadToBeSigned(
                                                            in boolean p_includeCertificate := false
                                                            in boolean p_includeCertificate := false
            ) runs on ItsSecurityBaseComponent return ToBeSignedSecuredMessage {
            ) runs on ItsSecurityBaseComponent return ToBeSignedSecuredMessage {
                
                // Local variables
                // Local variables
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                var template (value) ToBeSignedSecuredMessage v_toBeSignedSecuredMessage;
                
                
@@ -147,7 +148,7 @@ module LibItsSecurity_Functions {
                            )
                            )
                        }, // End of field HeaderFields
                        }, // End of field HeaderFields
                        {
                        {
                            m_payload_unsecured(
                            m_payload_signed(
                                'AAAAAAAAAA'O                                       // To be replaced by TA with real payload
                                'AAAAAAAAAA'O                                       // To be replaced by TA with real payload
                            )
                            )
                        }, // End of field HeaderFields
                        }, // End of field HeaderFields
@@ -168,7 +169,7 @@ module LibItsSecurity_Functions {
                            )
                            )
                        }, // End of field HeaderFields
                        }, // End of field HeaderFields
                        {
                        {
                            m_payload_unsecured(
                            m_payload_signed(
                                'AAAAAAAAAA'O                                       // To be replaced by TA with real payload
                                'AAAAAAAAAA'O                                       // To be replaced by TA with real payload
                            )
                            )
                        }, // End of field HeaderFields
                        }, // End of field HeaderFields
@@ -195,6 +196,7 @@ module LibItsSecurity_Functions {
                                             in template (omit) HeaderFields p_headerFields := omit,
                                             in template (omit) HeaderFields p_headerFields := omit,
                                             in UInt8 p_securityProfile := 0
                                             in UInt8 p_securityProfile := 0
            ) runs on ItsSecurityBaseComponent return boolean {
            ) runs on ItsSecurityBaseComponent return boolean {
                
                // Local variables
                // Local variables
                var octetstring v_secPayload, v_signature;
                var octetstring v_secPayload, v_signature;
                var Oct32 v_hash;
                var Oct32 v_hash;
@@ -206,8 +208,7 @@ module LibItsSecurity_Functions {
                // Prepare headers
                // Prepare headers
                if (not(ispresent(p_headerFields))) {
                if (not(ispresent(p_headerFields))) {
                    v_headerFields := p_mandatoryHeaders;
                    v_headerFields := p_mandatoryHeaders;
                }
                } else {
                else {
                    // Merge p_headerFields and v_mandatoryHeaders into v_headerFields
                    // Merge p_headerFields and v_mandatoryHeaders into v_headerFields
                        
                        
                    i := 0; // index for p_headerFields
                    i := 0; // index for p_headerFields
@@ -228,7 +229,7 @@ module LibItsSecurity_Functions {
                                // mandatory header already in p_HeaderFields
                                // mandatory header already in p_HeaderFields
                                break;
                                break;
                            }
                            }
                        }
                        } // End of 'for' statement
                        if (n >= lengthof(p_headerFields)) {
                        if (n >= lengthof(p_headerFields)) {
                            if (p_mandatoryHeaders[j].type_ != e_signer_info) {
                            if (p_mandatoryHeaders[j].type_ != e_signer_info) {
                                // Add headers from p_headerFields having lower number than mandatory header
                                // Add headers from p_headerFields having lower number than mandatory header
@@ -243,14 +244,14 @@ module LibItsSecurity_Functions {
                            k := k + 1;
                            k := k + 1;
                            j := j + 1;
                            j := j + 1;
                        }
                        }
                    }
                    } // End of 'for' statement
                        
                        
                    // Add remaining headers from p_HeaderFields
                    // Add remaining headers from p_HeaderFields
                    for ( i := i; i < lengthof(p_headerFields); i := i + 1) {
                    for ( i := i; i < lengthof(p_headerFields); i := i + 1) {
                        // Add headers from p_headerFields having lower number than mandatory header
                        // Add headers from p_headerFields having lower number than mandatory header
                        v_headerFields[k] := valueof(p_headerFields[i]);
                        v_headerFields[k] := valueof(p_headerFields[i]);
                        k := k + 1;
                        k := k + 1;
                    }
                    } // End of 'for' statement
                }
                }
                
                
                // Prepare payloads to be signed
                // Prepare payloads to be signed
@@ -258,7 +259,7 @@ module LibItsSecurity_Functions {
                    if (p_payloadFields[i].type_ == e_signed or p_payloadFields[i].type_ == e_signed_and_encrypted) {
                    if (p_payloadFields[i].type_ == e_signed or p_payloadFields[i].type_ == e_signed_and_encrypted) {
                        v_toBeSignedPayloads[lengthof(v_toBeSignedPayloads)] := p_payloadFields[i];
                        v_toBeSignedPayloads[lengthof(v_toBeSignedPayloads)] := p_payloadFields[i];
                    }
                    }
                }
                } // End of 'for' statement
                
                
                v_toBeSignedSecuredMessage := m_toBeSignedSecuredMessage(
                v_toBeSignedSecuredMessage := m_toBeSignedSecuredMessage(
                    p_securityProfile,
                    p_securityProfile,
@@ -317,6 +318,7 @@ module LibItsSecurity_Functions {
                                         in template (omit) charstring p_certificateName := omit,
                                         in template (omit) charstring p_certificateName := omit,
                                         in boolean p_addMissingHeaders := true
                                         in boolean p_addMissingHeaders := true
            ) runs on ItsSecurityBaseComponent return boolean {
            ) runs on ItsSecurityBaseComponent return boolean {
                
                // Local variables
                // Local variables
                var Certificate v_aaCertificate, v_atCertificate;
                var Certificate v_aaCertificate, v_atCertificate;
                var HeaderFields v_mandatoryHeaders := {};
                var HeaderFields v_mandatoryHeaders := {};
@@ -362,7 +364,7 @@ module LibItsSecurity_Functions {
                
                
                return f_buildGnSecuredMessage(p_securedMessage, p_payloadFields, v_mandatoryHeaders, p_headerFields, c_security_profileCAMs);
                return f_buildGnSecuredMessage(p_securedMessage, p_payloadFields, v_mandatoryHeaders, p_headerFields, c_security_profileCAMs);
                
                
            } // end f_buildGnSecuredCam
            } // End of function f_buildGnSecuredCam


            /**
            /**
            * @desc This function build and sign the SecureMessage part covered by the signature process
            * @desc This function build and sign the SecureMessage part covered by the signature process
@@ -384,6 +386,7 @@ module LibItsSecurity_Functions {
                                          in template (omit) charstring p_certificateName := omit,
                                          in template (omit) charstring p_certificateName := omit,
                                          in boolean p_addMissingHeaders := true
                                          in boolean p_addMissingHeaders := true
            ) runs on ItsSecurityBaseComponent return boolean {
            ) runs on ItsSecurityBaseComponent return boolean {
                
                // Local variables
                // Local variables
                var Certificate v_aaCertificate, v_atCertificate;
                var Certificate v_aaCertificate, v_atCertificate;
                var HeaderFields v_mandatoryHeaders := {};
                var HeaderFields v_mandatoryHeaders := {};
@@ -432,7 +435,7 @@ module LibItsSecurity_Functions {
                // Build the secured message and return it
                // Build the secured message and return it
                return f_buildGnSecuredMessage(p_securedMessage, p_payloadFields, v_mandatoryHeaders, p_headerFields, c_security_profileDENMs);
                return f_buildGnSecuredMessage(p_securedMessage, p_payloadFields, v_mandatoryHeaders, p_headerFields, c_security_profileDENMs);
                
                
            } // end f_buildGnSecuredDenm
            } // End of function f_buildGnSecuredDenm


            /**
            /**
            * @desc This function build and sign the SecureMessage part covered by the signature process
            * @desc This function build and sign the SecureMessage part covered by the signature process
@@ -644,9 +647,8 @@ module LibItsSecurity_Functions {
                                                                      in template (value) SecuredMessage p_securedMessage,
                                                                      in template (value) SecuredMessage p_securedMessage,
                                                                      in template (value) Certificate p_certificate
                                                                      in template (value) Certificate p_certificate
            ) return boolean {
            ) return boolean {
                var integer v_counter;
                
                
                for (v_counter := 0; v_counter < lengthof(p_certificate.subject_attributes); v_counter := v_counter + 1) {
                for (var integer v_counter := 0; v_counter < lengthof(p_certificate.subject_attributes); v_counter := v_counter + 1) {
                    var SubjectAttribute v_subjectAttribute := valueof(p_certificate.subject_attributes[v_counter]);
                    var SubjectAttribute v_subjectAttribute := valueof(p_certificate.subject_attributes[v_counter]);
                    
                    
//                    log("f_verifyGnSecuredMessageSignatureWithCertificate: processing ", v_subjectAttribute);
//                    log("f_verifyGnSecuredMessageSignatureWithCertificate: processing ", v_subjectAttribute);
@@ -814,12 +816,14 @@ module LibItsSecurity_Functions {
                                                         in ValidityRestrictionType p_type,
                                                         in ValidityRestrictionType p_type,
                                                         out ValidityRestriction p_return
                                                         out ValidityRestriction p_return
            ) return boolean {
            ) return boolean {
                
                for (var integer i := 0; i < lengthof(p_cert.validity_restrictions); i := i + 1) {
                for (var integer i := 0; i < lengthof(p_cert.validity_restrictions); i := i + 1) {
                    if (valueof(p_cert).validity_restrictions[i].type_ == p_type ) {
                    if (valueof(p_cert).validity_restrictions[i].type_ == p_type ) {
                        p_return := valueof(p_cert).validity_restrictions[i];
                        p_return := valueof(p_cert).validity_restrictions[i];
                        return true;
                        return true;
                    }
                    }
                }
                } // End of 'for' statement
                
                return false;
                return false;
            } // End of function f_getCertificateValidityRestriction
            } // End of function f_getCertificateValidityRestriction
            
            
@@ -1032,13 +1036,16 @@ module LibItsSecurity_Functions {
                                                   in template (value) RectangularRegion p_r1,
                                                   in template (value) RectangularRegion p_r1,
                                                   in template (value) RectangularRegion p_r2
                                                   in template (value) RectangularRegion p_r2
        ) return boolean {
        ) return boolean {
            return not (    valueof(p_r2).northwest.longitude > valueof(p_r1).southeast.longitude
            return not (
                or valueof(p_r2).southeast.longitude < valueof(p_r1).northwest.longitude
                valueof(p_r2).northwest.longitude > valueof(p_r1).southeast.longitude or 
                or valueof(p_r2).southeast.latitude  > valueof(p_r1).northwest.latitude
                valueof(p_r2).southeast.longitude < valueof(p_r1).northwest.longitude or 
                or valueof(p_r2).northwest.latitude  < valueof(p_r1).southeast.latitude);
                valueof(p_r2).southeast.latitude  > valueof(p_r1).northwest.latitude or 
                valueof(p_r2).northwest.latitude  < valueof(p_r1).southeast.latitude
            );
        } // End of function f_isRectangularRegionsIntersected
        } // End of function f_isRectangularRegionsIntersected
        
        
        function f_isContinuousRectangularRegions(in template (value) RectangularRegions regions
        function f_isContinuousRectangularRegions(
                                                  in template (value) RectangularRegions regions
        ) return boolean {
        ) return boolean {
            // TODO: call external function
            // TODO: call external function
            return true;
            return true;
@@ -1149,7 +1156,8 @@ module LibItsSecurity_Functions {
        * @return true on success, false otherwise
        * @return true on success, false otherwise
        * @verdict Unchanged
        * @verdict Unchanged
        */
        */
        function f_isLocationInsideCircularRegion(in template (value) CircularRegion p_region,
        function f_isLocationInsideCircularRegion(
                                                  in template (value) CircularRegion p_region,
                                                  in template (value) ThreeDLocation p_location
                                                  in template (value) ThreeDLocation p_location
        ) return boolean {
        ) return boolean {
            // Sanity check
            // Sanity check
@@ -1175,8 +1183,8 @@ module LibItsSecurity_Functions {
            if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) {
            if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) {
                return false;
                return false;
            }
            }
            log("f_isLocationInsideRectangularRegion: p_polygonalArea: ", p_region);
//            log("f_isLocationInsideRectangularRegion: p_polygonalArea: ", p_region);
            log("f_isLocationInsideRectangularRegion: p_location: ", p_location);
//            log("f_isLocationInsideRectangularRegion: p_location: ", p_location);
            
            
            return fx_isLocationInsideRectangularRegion(valueof(p_region), valueof(p_location));
            return fx_isLocationInsideRectangularRegion(valueof(p_region), valueof(p_location));
        } // End of function f_isLocationInsideRectangularRegion
        } // End of function f_isLocationInsideRectangularRegion
@@ -1270,8 +1278,9 @@ module LibItsSecurity_Functions {
        * @return The converted latitude
        * @return The converted latitude
        * @verdict Unchanged
        * @verdict Unchanged
        */
        */
        function f_ddlat2int(in float p_latitude)
        function f_ddlat2int(
        return WGSLatitude {
                             in float p_latitude
        ) return WGSLatitude {
            return float2int(p_latitude * 10000000.0); // Significand length shall be 7 digits length
            return float2int(p_latitude * 10000000.0); // Significand length shall be 7 digits length
        }
        }
        
        
@@ -1281,8 +1290,9 @@ module LibItsSecurity_Functions {
        * @return The converted longitude
        * @return The converted longitude
        * @verdict Unchanged
        * @verdict Unchanged
        */
        */
        function f_ddlon2int(in float p_longitude)
        function f_ddlon2int(
        return WGSLongitude {
                             in float p_longitude
        ) return WGSLongitude {
            return float2int(p_longitude * 1000000.0); // Significand length shall be 6 digits length
            return float2int(p_longitude * 1000000.0); // Significand length shall be 6 digits length
        }
        }
        
        
+0 −8
Original line number Original line Diff line number Diff line
@@ -7,14 +7,6 @@
 */
 */
module LibItsSecurity_Pixits {
module LibItsSecurity_Pixits {
    
    
    // LibCommon
    import from LibCommon_BasicTypesAndValues all;
    import from LibCommon_DataStrings all;
    
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Templates all;
    
    /**
    /**
     * @desc Root path to access certificate stored in files, identified by certficate ID
     * @desc Root path to access certificate stored in files, identified by certficate ID
     */
     */