def generate_bad_geo_artefact(drone_id, drone_pub_key, bad_coords): # generate a permission artefact with incorrect coords. permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, bad_coords, drone_pub_key) signed_permission = sign_permission_artefact(permission) return signed_permission
def generate_valid_permission(drone_id, drone_pub_key, coords): # A passable permission artefact for which the RPAS should ARM/TAKEOFF permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, coords, drone_pub_key) signed_permission = sign_permission_artefact(permission) return signed_permission
def generate_bad_sign_artefact(drone_id, drone_pub_key, coords): # Signing the permission artefact with a fake key. permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, coords, drone_pub_key) signed_permission = sign_permission_artefact(permission, private_key=fake_dgca_pri_key) return signed_permission
def generate_valid_permission(drone_id, drone_pub_key, coords): # coords = [[77.609316, 12.934158], [77.609852, 12.934796], # [77.610646, 12.934183], [77.610100, 12.933551], [77.609316, # 12.934158]] # placeholder , replace the coordinates with the correct one permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, coords, drone_pub_key) signed_permission = sign_permission_artefact(permission) return signed_permission
def generate_bad_geo_artefact(drone_id, drone_pub_key, bad_coords): # bad_coords = [[77.592402, 12.951447], [77.602959, 12.950946], # [77.604418, 12.935554], [77.587767, 12.936809], # [77.592402, 12.951447]] # coords = [[77, 12], [77, 13], [78, 13], [78, 12]] permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, bad_coords, drone_pub_key) signed_permission = sign_permission_artefact(permission) return signed_permission
def generate_bad_time_artefact(drone_id, drone_pub_key): # BAD time is currently the same as the start time.RPAS should not pass this coords = [[77.609316, 12.934158], [77.609852, 12.934796], [77.610646, 12.934183], [77.610100, 12.933551], [77.609316, 12.934158] ] # placeholder , replace the coordinates with the correct one permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, START_TIME, coords, drone_pub_key) signed_permission = sign_permission_artefact(permission) return signed_permission
def generate_bad_sign_artefact(drone_id, drone_pub_key): coords = [[77.609316, 12.934158], [77.609852, 12.934796], [77.610646, 12.934183], [77.610100, 12.933551], [77.609316, 12.934158] ] # placeholder , replace the coordinates with the correct one permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, coords, drone_pub_key) # Signing the permission artefact with a a signed_permission = sign_permission_artefact(permission, private_key=fake_dgca_pri_key) return signed_permission
def generate_bad_time_artefact( drone_id, drone_pub_key, coords, ): # BAD time is currently the same as the start time.RPAS should not pass this permission = createArtifact( drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME - datetime.timedelta(minutes=random.randint(1, 60)), START_TIME - datetime.timedelta(minutes=random.randint(1, 60)), coords, drone_pub_key) signed_permission = sign_permission_artefact(permission) return signed_permission
def generate_bad_pin_artefact(drone_id, drone_pub_key): # Incorrect PIN is a invalid 6 digit PIN coords = [[77.609316, 12.934158], [77.609852, 12.934796], [77.610646, 12.934183], [77.610100, 12.933551], [77.609316, 12.934158] ] # placeholder , replace the coordinates with the correct one permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, coords, drone_pub_key, secret_pin=b'654321') signed_permission = sign_permission_artefact(permission) return signed_permission
def generate_tampered_artefact( drone_id, drone_pub_key, coords, ): # Tampered permission artefact is different from the bad signature permission artefact. This has the contents # changed after signing, whereas the other has the PA signed by a illegitimate entity. permission = createArtifact(drone_id, FLIGHT_PURPOSE, PAYLOAD_WEIGHT, PAYLOAD_DETAILS, START_TIME, END_TIME, coords, drone_pub_key) signed_permission = sign_permission_artefact(permission) from lxml import etree pa_obj = etree.ElementTree(signed_permission) root_obj = pa_obj.getroot() root_obj.attrib['txnId'] = str(uuid.uuid1()) return root_obj