Loading ttcn/Security/LibItsSecurity_Functions.ttcn3 +220 −88 Original line number Original line Diff line number Diff line Loading @@ -734,31 +734,12 @@ module LibItsSecurity_Functions { }// End of group certificateGetters }// End of group certificateGetters group CertRequests{ function f_askForCertificate (in template (value) HashedId8 p_digest) { // Send CAM message with insert the request_unrecognized_certificate // header containing specified digest /* TODO: Waiting Alex to understand how to send message var SecuredMessage v_msg; if ( f_buildGnSecuredCam (v_msg, in octetstring p_unsecuredPayload, in ThreeDLocation p_threeDLocation, in template (omit) HeaderFields p_headerFileds := omit )) { } */ } } // End of group CertRequests } // End of group helpersFunctions } // End of group helpersFunctions group externalFunctions { group externalFunctions { group signing { /** /** * @desc Produces a 256-bit (32-byte) hash value * @desc Produces a 256-bit (32-byte) hash value * @param p_toBeHashedData Data to be used to calculate the hash value * @param p_toBeHashedData Data to be used to calculate the hash value Loading Loading @@ -794,6 +775,69 @@ module LibItsSecurity_Functions { */ */ external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean; external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean; } // End of group signing group encryption { } // End of group encryption group geodesic { /** * @desc Check that given polygon doesn't have neither self-intersections nor holes. * @param p_region Polygonal Region * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isValidPolygonalRegion(in template (value) PolygonalRegion p_region) return boolean; /** * @desc Check if a polygonal regin is inside another one * @param p_parent The main polygonal region * @param p_region The polygonal region to be included * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isPolygonalRegionInside(in template (value) PolygonalRegion p_parent, in template (value) PolygonalRegion p_region) return boolean; /** * @desc Check that the location is inside a circular region * @param p_region The circular region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsideCircularRegion(in template (value) CircularRegion p_region, in template (value) ThreeDLocation p_location) return boolean; /** * @desc Check that the location is inside a rectangular region * @param p_region The rectangular region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsideRectangularRegion(in template (value) RectangularRegions p_region, in template (value) ThreeDLocation p_location) return boolean; /** * @desc Check that the location is inside a polygonal region * @param p_region The polygonal region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsidePolygonalRegion(in template (value) PolygonalRegion p_region, in template (value) ThreeDLocation p_location) return boolean; /** * @desc Check if the location is inside an identified region * @param p_region The identified region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsideIdentifiedRegion(in template (value) IdentifiedRegion p_region, in template (value) ThreeDLocation p_location) return boolean; } // End of group geodesic } // End of group externalFunctions } // End of group externalFunctions group geometryFunctions { group geometryFunctions { Loading @@ -803,11 +847,13 @@ module LibItsSecurity_Functions { * @param p_location location to be checked * @param p_location location to be checked * @return true on success, false otherwise * @return true on success, false otherwise */ */ function f_isValidTwoDLocation(in template (value) TwoDLocation p_location function f_isValidTwoDLocation( in template (value) TwoDLocation p_location ) return boolean { ) return boolean { return valueof(p_location).longitude != c_maxLongitude+1 return and valueof(p_location).latitude != c_maxLatitude+1; (valueof(p_location).longitude != c_maxLongitude + 1) and } (valueof(p_location).latitude != c_maxLatitude + 1); } // End of function f_isValidTwoDLocation /** /** * @desc Check that two given rectanlular regions are intersected * @desc Check that two given rectanlular regions are intersected Loading @@ -825,51 +871,81 @@ module LibItsSecurity_Functions { or valueof(p_r2).southeast.longitude < valueof(p_r1).northwest.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).southeast.latitude > valueof(p_r1).northwest.latitude or valueof(p_r2).northwest.latitude < valueof(p_r1).southeast.latitude); or valueof(p_r2).northwest.latitude < valueof(p_r1).southeast.latitude); } } // 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; } } // End of function f_isRectangularRegionsIntersected /** * @desc Check if a polygonal regin is inside another one * @param p_parent The main polygonal region * @param p_region The polygonal region to be included * @return true on success, false otherwise * @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 return true; return true; } } // End of function f_isRectangularRegionsInside /** /** * @desc Check that given polygon doesn't have neither self-intersections no holes. * @desc Check that given polygon doesn't have neither self-intersections nor holes. * @param p_region Polygonal Region * @param p_region Polygonal Region * @return true on success, false otherwise * @return true on success, false otherwise * @verdict Unchanged */ */ function f_isValidPolygonalRegion(in template (value) PolygonalRegion p_region function f_isValidPolygonalRegion( in template (value) PolygonalRegion p_region ) return boolean { ) return boolean { // TODO: call external function // Sanity check return true; if (not isbound(p_region) or (lengthof(p_region) == 0)) { return false; } } return fx_isValidPolygonalRegion(p_region); } // End of function f_isValidPolygonalRegion /** * @desc Check if a polygonal regin is inside another one * @param p_parent The main polygonal region * @param p_region The polygonal region to be included * @return true on success, false otherwise * @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 { // TODO: call external function // TODO: call external function return true; return true; } } // End of function f_isPolygonalRegionInside /** * @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 { // TODO: call external function // TODO: call external function return valueof(p_parent) == valueof(p_region); return valueof(p_parent) == valueof(p_region); } } // End of function f_isIdentifiedRegionInside /** * @desc Check that the location is inside a region * @param p_region The region to consider * @param p_location The device location * @return true on success, false otherwise * @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; select (p_region.region_type) { select (p_region.region_type) { case (e_none) { case (e_none) { v_ret := true; v_ret := true; Loading @@ -890,40 +966,96 @@ module LibItsSecurity_Functions { v_ret := f_isLocationInsideOtherRegion(p_region.region.other_region, p_location); v_ret := f_isLocationInsideOtherRegion(p_region.region.other_region, p_location); } } } } return v_ret; return v_ret; } } // End of function f_isLocationInsideRegion /** * @desc Check that the location is inside a circular region * @param p_region The circular region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: distance between center and location must be less then radius // Sanity check // Do not forget aboout passing throw 0 meridian if (not isbound(p_region) or not isbound(p_location)) { return true; return false; } } return fx_isLocationInsideCircularRegion(p_region, p_location); } // End of function f_isLocationInsideCircularRegion /** * @desc Check that the location is inside a rectangular region * @param p_region The rectangular region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: implement it // Sanity check // Do not forget aboout passing throw 0 meridian if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) { return true; return false; } } return fx_isLocationInsideRectangularRegion(p_region, p_location); } // End of function f_isLocationInsideRectangularRegion /** * @desc Check that the location is inside a polygonal region * @param p_region The polygonal region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: implement it // Sanity check // Do not forget aboout passing throw 0 meridian if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) { return true; return false; } } return fx_isLocationInsidePolygonalRegion(p_region, p_location); } // End of function f_isLocationInsidePolygonalRegion /** * @desc Check if the location is inside an identified region * @param p_region The identified region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: implement it // Sanity check return true; if (not isbound(p_region) or not isbound(p_location)) { return false; } } return fx_isLocationInsideIdentifiedRegion(p_region, p_location); } // End of function f_isLocationInsideIdentifiedRegion /** * @desc Check if the location is inside an undefined region * @param p_region The identified region to consider * @param p_location The device location * @return true on success, false otherwise * @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 return false; return false; } } // End of function f_isLocationInsideOtherRegion } // End of group geometryFunctions } // End of group geometryFunctions } // End of module LibItsSecurity_Functions } // End of module LibItsSecurity_Functions Loading
ttcn/Security/LibItsSecurity_Functions.ttcn3 +220 −88 Original line number Original line Diff line number Diff line Loading @@ -734,31 +734,12 @@ module LibItsSecurity_Functions { }// End of group certificateGetters }// End of group certificateGetters group CertRequests{ function f_askForCertificate (in template (value) HashedId8 p_digest) { // Send CAM message with insert the request_unrecognized_certificate // header containing specified digest /* TODO: Waiting Alex to understand how to send message var SecuredMessage v_msg; if ( f_buildGnSecuredCam (v_msg, in octetstring p_unsecuredPayload, in ThreeDLocation p_threeDLocation, in template (omit) HeaderFields p_headerFileds := omit )) { } */ } } // End of group CertRequests } // End of group helpersFunctions } // End of group helpersFunctions group externalFunctions { group externalFunctions { group signing { /** /** * @desc Produces a 256-bit (32-byte) hash value * @desc Produces a 256-bit (32-byte) hash value * @param p_toBeHashedData Data to be used to calculate the hash value * @param p_toBeHashedData Data to be used to calculate the hash value Loading Loading @@ -794,6 +775,69 @@ module LibItsSecurity_Functions { */ */ external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean; external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean; } // End of group signing group encryption { } // End of group encryption group geodesic { /** * @desc Check that given polygon doesn't have neither self-intersections nor holes. * @param p_region Polygonal Region * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isValidPolygonalRegion(in template (value) PolygonalRegion p_region) return boolean; /** * @desc Check if a polygonal regin is inside another one * @param p_parent The main polygonal region * @param p_region The polygonal region to be included * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isPolygonalRegionInside(in template (value) PolygonalRegion p_parent, in template (value) PolygonalRegion p_region) return boolean; /** * @desc Check that the location is inside a circular region * @param p_region The circular region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsideCircularRegion(in template (value) CircularRegion p_region, in template (value) ThreeDLocation p_location) return boolean; /** * @desc Check that the location is inside a rectangular region * @param p_region The rectangular region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsideRectangularRegion(in template (value) RectangularRegions p_region, in template (value) ThreeDLocation p_location) return boolean; /** * @desc Check that the location is inside a polygonal region * @param p_region The polygonal region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsidePolygonalRegion(in template (value) PolygonalRegion p_region, in template (value) ThreeDLocation p_location) return boolean; /** * @desc Check if the location is inside an identified region * @param p_region The identified region to consider * @param p_location The device location * @return true on success, false otherwise * @verdict Unchanged */ external function fx_isLocationInsideIdentifiedRegion(in template (value) IdentifiedRegion p_region, in template (value) ThreeDLocation p_location) return boolean; } // End of group geodesic } // End of group externalFunctions } // End of group externalFunctions group geometryFunctions { group geometryFunctions { Loading @@ -803,11 +847,13 @@ module LibItsSecurity_Functions { * @param p_location location to be checked * @param p_location location to be checked * @return true on success, false otherwise * @return true on success, false otherwise */ */ function f_isValidTwoDLocation(in template (value) TwoDLocation p_location function f_isValidTwoDLocation( in template (value) TwoDLocation p_location ) return boolean { ) return boolean { return valueof(p_location).longitude != c_maxLongitude+1 return and valueof(p_location).latitude != c_maxLatitude+1; (valueof(p_location).longitude != c_maxLongitude + 1) and } (valueof(p_location).latitude != c_maxLatitude + 1); } // End of function f_isValidTwoDLocation /** /** * @desc Check that two given rectanlular regions are intersected * @desc Check that two given rectanlular regions are intersected Loading @@ -825,51 +871,81 @@ module LibItsSecurity_Functions { or valueof(p_r2).southeast.longitude < valueof(p_r1).northwest.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).southeast.latitude > valueof(p_r1).northwest.latitude or valueof(p_r2).northwest.latitude < valueof(p_r1).southeast.latitude); or valueof(p_r2).northwest.latitude < valueof(p_r1).southeast.latitude); } } // 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; } } // End of function f_isRectangularRegionsIntersected /** * @desc Check if a polygonal regin is inside another one * @param p_parent The main polygonal region * @param p_region The polygonal region to be included * @return true on success, false otherwise * @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 return true; return true; } } // End of function f_isRectangularRegionsInside /** /** * @desc Check that given polygon doesn't have neither self-intersections no holes. * @desc Check that given polygon doesn't have neither self-intersections nor holes. * @param p_region Polygonal Region * @param p_region Polygonal Region * @return true on success, false otherwise * @return true on success, false otherwise * @verdict Unchanged */ */ function f_isValidPolygonalRegion(in template (value) PolygonalRegion p_region function f_isValidPolygonalRegion( in template (value) PolygonalRegion p_region ) return boolean { ) return boolean { // TODO: call external function // Sanity check return true; if (not isbound(p_region) or (lengthof(p_region) == 0)) { return false; } } return fx_isValidPolygonalRegion(p_region); } // End of function f_isValidPolygonalRegion /** * @desc Check if a polygonal regin is inside another one * @param p_parent The main polygonal region * @param p_region The polygonal region to be included * @return true on success, false otherwise * @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 { // TODO: call external function // TODO: call external function return true; return true; } } // End of function f_isPolygonalRegionInside /** * @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 { // TODO: call external function // TODO: call external function return valueof(p_parent) == valueof(p_region); return valueof(p_parent) == valueof(p_region); } } // End of function f_isIdentifiedRegionInside /** * @desc Check that the location is inside a region * @param p_region The region to consider * @param p_location The device location * @return true on success, false otherwise * @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; select (p_region.region_type) { select (p_region.region_type) { case (e_none) { case (e_none) { v_ret := true; v_ret := true; Loading @@ -890,40 +966,96 @@ module LibItsSecurity_Functions { v_ret := f_isLocationInsideOtherRegion(p_region.region.other_region, p_location); v_ret := f_isLocationInsideOtherRegion(p_region.region.other_region, p_location); } } } } return v_ret; return v_ret; } } // End of function f_isLocationInsideRegion /** * @desc Check that the location is inside a circular region * @param p_region The circular region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: distance between center and location must be less then radius // Sanity check // Do not forget aboout passing throw 0 meridian if (not isbound(p_region) or not isbound(p_location)) { return true; return false; } } return fx_isLocationInsideCircularRegion(p_region, p_location); } // End of function f_isLocationInsideCircularRegion /** * @desc Check that the location is inside a rectangular region * @param p_region The rectangular region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: implement it // Sanity check // Do not forget aboout passing throw 0 meridian if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) { return true; return false; } } return fx_isLocationInsideRectangularRegion(p_region, p_location); } // End of function f_isLocationInsideRectangularRegion /** * @desc Check that the location is inside a polygonal region * @param p_region The polygonal region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: implement it // Sanity check // Do not forget aboout passing throw 0 meridian if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) { return true; return false; } } return fx_isLocationInsidePolygonalRegion(p_region, p_location); } // End of function f_isLocationInsidePolygonalRegion /** * @desc Check if the location is inside an identified region * @param p_region The identified region to consider * @param p_location The device location * @return true on success, false otherwise * @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 { // TODO: implement it // Sanity check return true; if (not isbound(p_region) or not isbound(p_location)) { return false; } } return fx_isLocationInsideIdentifiedRegion(p_region, p_location); } // End of function f_isLocationInsideIdentifiedRegion /** * @desc Check if the location is inside an undefined region * @param p_region The identified region to consider * @param p_location The device location * @return true on success, false otherwise * @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 return false; return false; } } // End of function f_isLocationInsideOtherRegion } // End of group geometryFunctions } // End of group geometryFunctions } // End of module LibItsSecurity_Functions } // End of module LibItsSecurity_Functions