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

Updated New functionalities for All SAM types

parent 7479a08d
No related branches found
No related tags found
No related merge requests found
...@@ -74,13 +74,37 @@ class HostIdentity: ...@@ -74,13 +74,37 @@ class HostIdentity:
sign_key = SigningKey(unhexlify(self._priv_key)) sign_key = SigningKey(unhexlify(self._priv_key))
return hexlify(sign_key.sign(unhexlify(message))) return hexlify(sign_key.sign(unhexlify(message)))
## Function for DRIP_Wrapper
def generate_self_attestation_Wrapper(self,payload, expiration):
if expiration <= astm_time():
print("expiration timestamp has already expired.")
return None
#hash of SAM Type for Wrapper, which is 0x02
hash_SAM = cSHAKE128( '0x02', 1,"","")
message = hash_SAM + self._hhit + payload + "{:>08x}".format(convert_be_to_le(astm_time())) + "{:>08x}".format(convert_be_to_le(expiration))
sign_key = SigningKey(unhexlify(self._priv_key))
return hexlify(sign_key.sign(unhexlify(message)))
## Function for DRIP_Manifests
def generate_self_attestation_Manifests(self, prev_hashed_loc, hashed_loc, expiration): #hashed_loc is hashes of location for now its single, but it can be upto 11(Each 8 byte)
if expiration <= astm_time():
print("expiration timestamp has already expired.")
return None
#hash of SAM Type for Manifests, which is 0x03
hash_SAM = cSHAKE128( '0x03', 1,"","")
message = hash_SAM + self._hhit + prev_hashed_loc + hashed_loc + "{:>08x}".format(convert_be_to_le(astm_time())) + "{:>08x}".format(convert_be_to_le(expiration))
sign_key = SigningKey(unhexlify(self._priv_key))
return hexlify(sign_key.sign(unhexlify(message)))
def generate_self_concise_attestation(self, expiration): def generate_attestation_Endorsement_Broadcast(self, Drone_hhit, Drone_hid, expiration):
if expiration <= astm_time(): if expiration <= astm_time():
print("expiration timestamp has already expired.") print("expiration timestamp has already expired.")
return None return None
message = self._hhit + "{:>08x}".format(convert_be_to_le(expiration)) message = self._hhit + Drone_hhit + Drone_hid +"{:>08x}".format(convert_be_to_le(astm_time())) + "{:>08x}".format(convert_be_to_le(expiration))
sign_key = SigningKey(unhexlify(self._priv_key)) sign_key = SigningKey(unhexlify(self._priv_key))
return sign_key.sign(unhexlify(message)) return sign_key.sign(unhexlify(message))
......
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