Open DonaldTsang opened 5 years ago
224 | 256 | 384 | 512 | |
---|---|---|---|---|
BMW | - [ ] | - [ ] Faster than MD5 | - [ ] | - [ ] Faster than SHA1 |
ECHO | - [ ] | - [ ] Faster than SHA1 | - [ ] | - [ ] Slower than SHA256 |
ECHO single pipe | - [ ] | - [ ] Faster than SHA1 | - [ ] | - [ ] Faster than SHA256 |
BLAKE2 | - [ ] (2s/224) | - [ ] Faster than MD5 (BLAKE2s) | - [ ] (2b/384) | - [ ] Faster than SHA1 (BLAKE2b) |
SHAVite3 | - [ ] | - [ ] Faster than MD5 | - [ ] | - [ ] Faster than SHA1 |
CubeHash | - [ ] (8/32) | - [ ] (8/32 but for 256-bit) | - [ ] (8/32) | - [ ] Faster than MD5 (CubeHash8/32) |
SHABAL | - [ ] | - [ ] Faster than SHA256 | - [ ] | - [ ] Faster than SHA512 |
Skien512 | - [ ] | - [ ] Faster than SHA256 | - [ ] | - [ ] Faster than SHA256 |
BLAKE | - [ ] | - [ ] Faster than SHA256 | - [ ] | - [ ] Faster than SHA256 |
BBLAKE | - [ ] | - [ ] Faster than SHA256 | - [ ] | - [ ] Slower than SHA256 |
SKEIN1024 | - [ ] (384~448bit) | - [ ] Slower than SHA256 (512bit) | - [ ] (768bit) | - [ ] Faster than SHA256 (1024bit) |
SHA3 | - [ ] | - [ ] Faster than SHA256 | - [ ] | - [ ] Slower than SHA256 |
Keccak Treed2 | - [ ] | - [ ] Faster than MD5 | - [ ] | - [ ] Faster than SHA256 |
SHA2 | - [ ] | - [ ] | - [ ] | - [ ] |
Yep, this code is very draft and ported from JS version. Need to refactor and speedup.
@zebra-lucky Cubehash and keccak should be easy Here are the notes I made for Cubehash
def s(x):
for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 1
for i in range(16): x[i]=((x[i]<<7)+(x[i]>>25))%(1<<32)# step 2
for i in range(8): x[i],x[8+i]=x[8+i],x[i] # step 3
for i in range(16): x[i]^=x[16+i] # step 4
for i,j in range(0,16,4), [0,1]: x[16+i+j],x[18+i+j]=x[18+i+j],x[16+i+j] # step 5
for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 6
for i in range(16): ((x[i]<<11)+(x[i]>>21))%(1<<32)# step 7
for i,j in [0,8], range(4): x[i+j],x[4+i+j]=x[4+i+j],x[i+j] # step 8
for i in range(16): x[i]^=x[16+i] # step 9
for i in range(0,16,2): x[i],x[16+i]=x[16+i],x[i] # step 10
return x
def cubehash(msg,i,r,b,f,h):
assert isinstance(msg,bytes)
ctx=[h/8,b,r]+[0 for _ in range(29)]
for _ in range(i): ctx = s(ctx) # initialization
msg=[msg[n:n+b] for n in range(0,len(msg),b)]
msg[-1] += (b'\x80'+b'\x00'*(b-len(msg[-1])-1)) if len(msg[-1])!=b else b''
for m in msg:
int.from_bytes(???, byteorder='big') # convert and then XOR into ctx
for _ in range(r): ctx = s(ctx)
ctx[31]^=1
for _ in range(f): ctx = s(ctx)
# return the first h/8 bytes of the ctx
Thank you for comments!
Sorry, at the moment I have no time to continue enhance code of this repo. This was a dirty try to port JS version without redoing code structure. There was a think to limit expectation of length of input data to all hashes to prev output lenght, and refactor all code structure, but no time left currently.
@zebra-lucky Does it get the same hash with the reference implementations in C? Just wondering.
@zebra-lucky here is a short version for cubehash https://github.com/tearsofphoenix/cubehash/blob/master/index.js and one for keccak https://github.com/XKCP/XKCP/blob/master/Standalone/CompactFIPS202/Python/CompactFIPS202.py https://github.com/XKCP/XKCP/blob/master/Standalone/KangarooTwelve/Python/K12.py
Cubehash and keccak should be easy Here are the notes I made for Cubehash
def s(x):
for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 1
for i in range(16): x[i]=((x[i]<<7)+(x[i]>>25))%(1<<32)# step 2
for i in range(8): x[i],x[8+i]=x[8+i],x[i] # step 3
for i in range(16): x[i]^=x[16+i] # step 4
for i,j in range(0,16,4), [0,1]: x[16+i+j],x[18+i+j]=x[18+i+j],x[16+i+j] # step 5
for i in range(16): x[16+i]=(x[16+i]+x[i])%(1<<32) # step 6
for i in range(16): ((x[i]<<11)+(x[i]>>21))%(1<<32)# step 7
for i,j in [0,8], range(4): x[i+j],x[4+i+j]=x[4+i+j],x[i+j] # step 8
for i in range(16): x[i]^=x[16+i] # step 9
for i in range(0,16,2): x[i],x[16+i]=x[16+i],x[i] # step 10
return x
def cubehash(msg,i,r,b,f,h):
assert isinstance(msg,bytes)
ctx=[h/8,b,r]+[0 for _ in range(29)]
for _ in range(i): ctx = s(ctx) # initialization
msg=[msg[n:n+b] for n in range(0,len(msg),b)]
msg[-1] += (b'\x80'+b'\x00'*(b-len(msg[-1])-1)) if len(msg[-1])!=b else b''
for m in msg:
int.from_bytes(???, byteorder='big') # convert and then XOR into ctx
for _ in range(r): ctx = s(ctx)
ctx[31]^=1
for _ in range(f): ctx = s(ctx)
# return the first h/8 bytes of the ctx