Skip to content
Snippets Groups Projects
Commit 4802fd24 authored by Abdullah Bin Zubair's avatar Abdullah Bin Zubair
Browse files

Beacon (sender) code following the draft-ietf-drip-auth-17 DRIP Authentication...

Beacon (sender) code following the draft-ietf-drip-auth-17 DRIP Authentication Formats structure. No Wi-Fi part is merged with this file it contains bt4, bt5 and updated Authentication Formats structure.
parent 6f7dc38a
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ FLIGHT_ID_FILE = os.path.join(FILE_DIR, "default_flight_id.txt")
load_dotenv()
hash_location = "" #hash of location info such lat & long, it is saved to send later in manifests
location_info = "" #location info such lat & long, it is saved to send later in manifests
def separate_bytes(hex_str, delim=' '):
return re.sub(r'.{2}', r'\g<0>{}'.format(delim), hex_str).strip()
......@@ -100,8 +100,9 @@ def Drip_Wrapper(gpsd: GpsPoller, iroha: DripIrohaAccount, flight_id, HostID: Ho
location_info = "10 00 00 00 {lat} {lon} 00 00 00 00 00 00 00 00 {ts} 00 00".format(
lat=lat, lon=lon, ts="00 00")
if(location_info):
hash_location = cSHAKE128( location_info,25,"", flight_id) # hash of location_info, 25 bytes
hash_location = cSHAKE128( location_info.encode('utf-8'),25,"", "") # hash of location_info, 25 bytes
if iroha: # if iroha private supplied, send location transactions on separate thread.
# location will be flight id concatenated with the bluetooth payload
# In order to save space we can b64encode the bytes of the payload,
......@@ -138,14 +139,14 @@ def Drip_Wrapper(gpsd: GpsPoller, iroha: DripIrohaAccount, flight_id, HostID: Ho
"hcitool -i hci0 cmd 0x08 0x0008 1f 1e 16 fa ff 0d 00 10 {hash_location}{payload}".format(hash_location=hash_location, payload=payload), shell=True)
def manifest_broadcast(HostID: HostIdentity, flight_id, prev_hash_loc, exp_date): ## Manifest broadcast can contain max 11 hashes (at 8-bytes each). For now we are sending one message.
def manifest_broadcast(HostID: HostIdentity, flight_id, exp_date, prev_loc = "" ): ## Manifest broadcast can contain max 11 hashes (at 8-bytes each). For now we are sending one message.
# ASTM F3-411 Location message 0x1
print("manifest_broadcast")
# If gpsd is active, check that it has received values
if hash_location == None:
print("payload is empty, cannot generate hash_payload for gps information")
if location_info == None:
print("payload is empty, location information missing from gps")
payload = HostID.generate_self_attestation_Manifests(cSHAKE128(prev_hash_loc,8, "",flight_id),cSHAKE128(hash_location,8,"",flight_id), get_timestamp(exp_date))
payload = HostID.generate_self_attestation_Manifests(cSHAKE128(prev_loc.encode('utf8'),8, "",""),cSHAKE128(location_info.encode('utf8'),8,"",""), get_timestamp(exp_date))
# Set (Extended) Advertising command
if is_bt5:
"""
......@@ -172,7 +173,6 @@ def manifest_broadcast(HostID: HostIdentity, flight_id, prev_hash_loc, exp_date)
# session id / hhit should be passed in the basic_id_update function
def basic_id_update(hhit):
......@@ -361,6 +361,7 @@ def main():
# this endorsement should be generated by the registry,
# but just for now, we are generating it according draft-ietf-drip-auth-17
attest = r_hi.generate_attestation_Endorsement_Broadcast(hhit,hid,get_timestamp(exp_date))
#attest = r_hi.generate_self_attestation(get_timestamp(exp_date))
if attest is None:
print("Expiration date has expired.")
......@@ -454,11 +455,11 @@ def main():
auth_update(auth_pages[2:], 2)
# saving the hash_location information such as lon & lat, to use as previous location_hash later in Manifests
prev_hash_location = hash_location
prev_location_info = location_info
# Location updates at least once every second.
Drip_Wrapper(gpsd, iroha, flight_id, hi, exp_date)
# Manifest broadcast
manifest_broadcast(hi, flight_id, prev_hash_location, exp_date)
manifest_broadcast(hi, flight_id, exp_date, prev_location_info)
if args.run_scenario:
g_lat += random.uniform(0.0001, 0.001) * \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment