Commit 0f4704eb authored by garciay's avatar garciay
Browse files

Add functions to load certificates from files

parent c07ff371
Loading
Loading
Loading
Loading
+83 −16
Original line number Original line Diff line number Diff line
@@ -720,6 +720,40 @@ module LibItsSecurity_Functions {
        
        
        group certificateGetters {
        group certificateGetters {
            
            
            /**
             * @desc    Load in memory cache the certificates available
             * @param   p_rootDirectory     Root directory to access to the certificates identified by the certificate ID
             * @remark  This method SHALL be call before any usage of certificates
             * @return  true on success, false otherwise
             */
            function f_loadCertificates(
                                        in charstring p_rootDirectory
            ) return boolean {
                return fx_loadCertificates(p_rootDirectory);
            }
            
            /**
             * @desc    Read the specified certificate
             * @param   p_hashedId8     the certificate ID to read
             * @param   p_certificate   the exoected certificate
             * @return  true on success, false otherwise
             */
            function f_readCertificate(
                                       in HashedId8 p_hashedId8, 
                                       out Certificate p_certificate
            ) return boolean {
                var octetstring v_certificate;
                
                if (fx_readCertificate(p_hashedId8, v_certificate) == true) {
                    var integer v_result := decvalue(oct2bit(v_certificate), p_certificate);
                    if (v_result == 0) {
                        return true;
                    }
                }
                
                return false;
            }
            
            function f_getCertificateValidityRestriction(
            function f_getCertificateValidityRestriction(
                                                         in template (value) Certificate p_cert, 
                                                         in template (value) Certificate p_cert, 
                                                         in ValidityRestrictionType p_type,
                                                         in ValidityRestrictionType p_type,
@@ -809,6 +843,26 @@ module LibItsSecurity_Functions {
            
            
        } // End of group encryption
        } // End of group encryption
        
        
        group certificatesLoader {
            
            /**
             * @desc    Load in memory cache the certificates available
             * @param   p_rootDirectory     Root directory to access to the certificates identified by the certificate ID
             * @remark  This method SHALL be call before any usage of certificates
             * @return  true on success, false otherwise
             */
            external function fx_loadCertificates(in charstring p_rootDirectory) return boolean;
            
            /**
             * @desc    Read the specified certificate
             * @param   p_hashedId8     the certificate ID to read
             * @param   p_certificate   the exoected certificate
             * @return  true on success, false otherwise
             */
            external function fx_readCertificate(in HashedId8 p_hashedId8, out octetstring p_certificate) return boolean;
            
        } // End of group certificatesLoader
        
        group geodesic {
        group geodesic {
            
            
            /**
            /**
@@ -903,7 +957,8 @@ module LibItsSecurity_Functions {
         * 
         * 
         * @return  true on success, false otherwise
         * @return  true on success, false otherwise
         */
         */
        function f_isRectangularRegionsIntersected(in template (value) RectangularRegion p_r1,
        function f_isRectangularRegionsIntersected(
                                                   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 (    valueof(p_r2).northwest.longitude > valueof(p_r1).southeast.longitude
@@ -925,7 +980,8 @@ module LibItsSecurity_Functions {
         * @return true on success, false otherwise
         * @return true on success, false otherwise
         * @verdict Unchanged
         * @verdict Unchanged
         */
         */
        function f_isRectangularRegionsInside(in template (value) RectangularRegions p_parent,
        function f_isRectangularRegionsInside(
                                              in template (value) RectangularRegions p_parent,
                                              in template (value) RectangularRegions p_region
                                              in template (value) RectangularRegions p_region
        ) return boolean {
        ) return boolean {
            // TODO: convert rectangular regions to polygons and check polygons 
            // TODO: convert rectangular regions to polygons and check polygons 
@@ -956,7 +1012,8 @@ module LibItsSecurity_Functions {
         * @return true on success, false otherwise
         * @return true on success, false otherwise
         * @verdict Unchanged
         * @verdict Unchanged
         */
         */
        function f_isPolygonalRegionInside(in template (value) PolygonalRegion p_parent,
        function f_isPolygonalRegionInside(
                                           in template (value) PolygonalRegion p_parent,
                                           in template (value) PolygonalRegion p_region
                                           in template (value) PolygonalRegion p_region
        ) return boolean {
        ) return boolean {
            // Sanity check
            // Sanity check
@@ -970,7 +1027,8 @@ module LibItsSecurity_Functions {
        /**
        /**
         * @desc 
         * @desc 
         */
         */
        function f_isIdentifiedRegionInside(in template (value) UInt16 p_parent,
        function f_isIdentifiedRegionInside(
                                            in template (value) UInt16 p_parent,
                                            in template (value) UInt16 p_region
                                            in template (value) UInt16 p_region
        ) return boolean {
        ) return boolean {
            return valueof(p_parent) == valueof(p_region);
            return valueof(p_parent) == valueof(p_region);
@@ -983,7 +1041,8 @@ module LibItsSecurity_Functions {
         * @return true on success, false otherwise
         * @return true on success, false otherwise
         * @verdict Unchanged
         * @verdict Unchanged
         */
         */
        function f_isLocationInsideRegion(in template (value) GeographicRegion p_region,
        function f_isLocationInsideRegion(
                                          in template (value) GeographicRegion p_region,
                                          in template (value) ThreeDLocation p_location
                                          in template (value) ThreeDLocation p_location
        ) return boolean {
        ) return boolean {
            var boolean v_ret := false;
            var boolean v_ret := false;
@@ -1037,7 +1096,8 @@ module LibItsSecurity_Functions {
         * @return true on success, false otherwise
         * @return true on success, false otherwise
         * @verdict Unchanged
         * @verdict Unchanged
         */
         */
        function f_isLocationInsideRectangularRegion(in template (value) RectangularRegions p_region,
        function f_isLocationInsideRectangularRegion(
                                                     in template (value) RectangularRegions p_region,
                                                     in template (value) ThreeDLocation     p_location
                                                     in template (value) ThreeDLocation     p_location
        ) return boolean {
        ) return boolean {
            // Sanity check
            // Sanity check
@@ -1057,7 +1117,8 @@ module LibItsSecurity_Functions {
         * @return true on success, false otherwise
         * @return true on success, false otherwise
         * @verdict Unchanged
         * @verdict Unchanged
         */
         */
        function f_isLocationInsidePolygonalRegion(in template (value) PolygonalRegion  p_region,
        function f_isLocationInsidePolygonalRegion(
                                                   in template (value) PolygonalRegion  p_region,
                                                   in template (value) ThreeDLocation p_location
                                                   in template (value) ThreeDLocation p_location
        ) return boolean {
        ) return boolean {
            // Sanity check
            // Sanity check
@@ -1077,7 +1138,8 @@ module LibItsSecurity_Functions {
         * @return true on success, false otherwise
         * @return true on success, false otherwise
         * @verdict Unchanged
         * @verdict Unchanged
         */
         */
        function f_isLocationInsideIdentifiedRegion(in template (value) IdentifiedRegion p_region,
        function f_isLocationInsideIdentifiedRegion(
                                                    in template (value) IdentifiedRegion p_region,
                                                    in template (value) ThreeDLocation p_location
                                                    in template (value) ThreeDLocation p_location
        ) return boolean {
        ) return boolean {
            // Sanity check
            // Sanity check
@@ -1095,7 +1157,8 @@ module LibItsSecurity_Functions {
         * @return true on success, false otherwise
         * @return true on success, false otherwise
         * @verdict Unchanged
         * @verdict Unchanged
         */
         */
        function f_isLocationInsideOtherRegion(in template (value) octetstring p_region,
        function f_isLocationInsideOtherRegion(
                                               in template (value) octetstring p_region,
                                               in template (value) ThreeDLocation p_location
                                               in template (value) ThreeDLocation p_location
        ) return boolean {
        ) return boolean {
            // FIXME To be removed
            // FIXME To be removed
@@ -1111,8 +1174,12 @@ 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
         */
         */
        function f_dms2dd(in integer p_degrees, in integer p_minutes, in float p_seconds, in charstring p_latlon) 
        function f_dms2dd(
        return float {
                          in integer p_degrees, 
                          in integer p_minutes, 
                          in float p_seconds, 
                          in charstring p_latlon
        ) return float {
            var Oct1 v_latlon;
            var Oct1 v_latlon;
            
            
            // Sanity checks
            // Sanity checks