Commit 3e1c73c4 authored by garciay's avatar garciay
Browse files

Add support of Geodsic functionalities

parent add59aa1
......@@ -734,65 +734,109 @@ module LibItsSecurity_Functions {
}// 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
group externalFunctions {
/**
* @desc Produces a 256-bit (32-byte) hash value
* @param p_toBeHashedData Data to be used to calculate the hash value
* @return The hash value
*/
external function fx_hashWithSha256(in octetstring p_toBeHashedData) return Oct32;
/**
* @desc Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
* @param p_toBeSignedSecuredMessage The data to be signed
* @param p_privateKey The private key
* @return The signature value
*/
external function fx_signWithEcdsaNistp256WithSha256(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
group signing {
/**
* @desc Produces a 256-bit (32-byte) hash value
* @param p_toBeHashedData Data to be used to calculate the hash value
* @return The hash value
*/
external function fx_hashWithSha256(in octetstring p_toBeHashedData) return Oct32;
/**
* @desc Produces a Elliptic Curve Digital Signature Algorithm (ECDSA) signaturee
* @param p_toBeSignedSecuredMessage The data to be signed
* @param p_privateKey The private key
* @return The signature value
*/
external function fx_signWithEcdsaNistp256WithSha256(in octetstring p_toBeSignedSecuredMessage, in octetstring/*UInt64*/ p_privateKey) return octetstring;
/**
* @desc Verify the signature of the specified data
* @param p_toBeVerifiedData The data to be verified
* @param p_signature The signature
* @param p_ecdsaNistp256PublicKeyX The public key (x coordinate)
* @param p_ecdsaNistp256PublicKeyY The public key (y coordinate)
* @return true on success, false otherwise
*/
external function fx_verifyWithEcdsaNistp256WithSha256(in octetstring p_toBeVerifiedData, in octetstring p_signature, in octetstring p_ecdsaNistp256PublicKeyX, in octetstring p_ecdsaNistp256PublicKeyY) return boolean;
/**
* @desc Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
* This function should not be used by the ATS
* @param p_privateKey The new private key value
* @param p_publicKeyX The new public key value (x coordinate)
* @param p_publicKeyX The new public key value (y coordinate)
* @return true on success, false otherwise
*/
external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
} // End of group signing
/**
* @desc Verify the signature of the specified data
* @param p_toBeVerifiedData The data to be verified
* @param p_signature The signature
* @param p_ecdsaNistp256PublicKeyX The public key (x coordinate)
* @param p_ecdsaNistp256PublicKeyY The public key (y coordinate)
* @return true on success, false otherwise
*/
external function fx_verifyWithEcdsaNistp256WithSha256(in octetstring p_toBeVerifiedData, in octetstring p_signature, in octetstring p_ecdsaNistp256PublicKeyX, in octetstring p_ecdsaNistp256PublicKeyY) return boolean;
group encryption {
} // End of group encryption
/**
* @desc Produce a new public/private key pair based on Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm.
* This function should not be used by the ATS
* @param p_privateKey The new private key value
* @param p_publicKeyX The new public key value (x coordinate)
* @param p_publicKeyX The new public key value (y coordinate)
* @return true on success, false otherwise
*/
external function fx_generateKeyPair(out octetstring/*UInt64*/ p_privateKey, out octetstring p_publicKeyX, out octetstring p_publicKeyY) return boolean;
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
......@@ -803,11 +847,13 @@ module LibItsSecurity_Functions {
* @param p_location location to be checked
* @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 valueof(p_location).longitude != c_maxLongitude+1
and valueof(p_location).latitude != c_maxLatitude+1;
}
return
(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
......@@ -824,52 +870,82 @@ module LibItsSecurity_Functions {
return not ( valueof(p_r2).northwest.longitude > valueof(p_r1).southeast.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).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
) return boolean {
// TODO: call external function
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,
in template (value) RectangularRegions p_region
) return boolean {
// TODO: convert rectangular regions to polygons and check polygons
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
* @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 {
// TODO: call external function
return true;
}
// Sanity check
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,
in template (value) PolygonalRegion p_region
) return boolean {
// TODO: call external function
return true;
}
} // End of function f_isPolygonalRegionInside
/**
* @desc
*/
function f_isIdentifiedRegionInside(in template (value) UInt16 p_parent,
in template (value) UInt16 p_region
) return boolean {
// TODO: call external function
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,
in template (value) ThreeDLocation p_location
) return boolean {
var boolean v_ret := false;
select (p_region.region_type) {
case (e_none) {
v_ret := true;
......@@ -890,40 +966,96 @@ module LibItsSecurity_Functions {
v_ret := f_isLocationInsideOtherRegion(p_region.region.other_region, p_location);
}
}
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,
in template (value) ThreeDLocation p_location
) return boolean {
// TODO: distance between center and location must be less then radius
// Do not forget aboout passing throw 0 meridian
return true;
}
// Sanity check
if (not isbound(p_region) or not isbound(p_location)) {
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,
in template (value) ThreeDLocation p_location
) return boolean {
// TODO: implement it
// Do not forget aboout passing throw 0 meridian
return true;
}
// Sanity check
if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) {
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,
in template (value) ThreeDLocation p_location
) return boolean {
// TODO: implement it
// Do not forget aboout passing throw 0 meridian
return true;
}
// Sanity check
if (not isbound(p_region) or not isbound(p_location) or (lengthof(p_region) == 0)) {
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,
in template (value) ThreeDLocation p_location
) return boolean {
// TODO: implement it
return true;
}
// Sanity check
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,
in template (value) ThreeDLocation p_location
) return boolean {
// FIXME To be removed
return false;
}
} // End of function f_isLocationInsideOtherRegion
} // End of group geometryFunctions
} // End of module LibItsSecurity_Functions
\ No newline at end of file
} // End of module LibItsSecurity_Functions
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment