Link to this headingSipHash
Link to this headingExample
Link to this headingImplementation
"""docstring for siphash"""
= 16
= 64
= 0
= None
#Check Key size
assert == 16
=
=
#print(int_key0, int_key1)
#Set inital vectors with inital bytes with the key duplicated
=
#self._printVectors()
#Using a,b,c,d as 0,1,2,3 in the array
=
#d ^ block
^=
## 1 Round
# (((b & 0x7ffffffffffff) << 13) | (b >> 51)) ^ (a + b)
=
= ^
= +
=
=
# print(f"e = {step_1}")
# print(f"i = {step_2}")
# print(f"f = {step_3}")
# print(f"j = {step_4}")
# print(f"h = {step_5}")
#Set New Temp Vectors
= +
= ^
=
#print(f"k = {temp_vectors[0]}")
#print(f"l = {temp_vectors[1]}")
#print(f"o = {temp_vectors[3]}")
## 2nd Round
=
= ^
= +
=
=
=
#print(f"p = {step_1}")
#print(f"q = {step_2}")
#print(f"r = {step_3}")
#print(f"s = {step_4}")
#print(f"t = {step_5}")
#print(f"u = {step_6}")
#Set New Temp Vectors
= ^
= ^
=
= ^
=
#return temp_vectors
#Split into 8 length chunks
=
#Process the full block
= *8
#print(f"v: {self.vectors}")
#Do SIP Round on block
=
#print(f"v: {self.vectors}")
#Set Finalize Varables
=
#Finalize a partial blocks
return
#Setup end data
=
|=
#print(f"v1: {self.vectors}")
#Do SIP round with data end
#print(f"v2: {self.vectors}")
#Finalize
^= 0xff
#print(f"v3: {self.vectors}")
#Do Double sipround with 0 data
#print(f"v4: {self.vectors}")
return
#Test Vectors
= b #os.urandom(16)
=
=
=
=
assert ==
#sip = siphash(b'0123456789ABCDEF')
#sip.vectors = [4925064773550298181, 2461839666708829781, 6579568090023412561, 3611922228250500171]
#sip._sip_round(0x100000000000061)
#print(f"v2: {sip.vectors}")
#sip = siphash(key)
#output = sip.hash(b"\x00\x01\x02\x03\x04\x05\x06\x07")
#print(f"sip({b"\x00\x01\x02\x03\x04\x05\x06\x07"}) = {output.hex()}")
#Hash data