flat assembler
Message board for the users of flat assembler.

 Index > Main > testing Hash algorithms
Author
r22

Joined: 27 Dec 2004
Posts: 805
r22 01 May 2005, 06:28
Anyone know of a good program and/or insane mathematical formula for testing collisions in hash algorithms?

Code:
```hashInit dw 5381,6833,4649,7577,6199,5209,3739,6143 ;primes
HashBuffer:
.pointer equ EBP+8
.length equ EBP+12
.output equ EBP+16
push ebp
mov ebp,esp
mov edx,[.pointer] ;str/data buffer pointer
lea ecx,[.length] ;length of buffer
shr ecx,4 ;str ptr memory will always have
add ecx,1 ;at least 16 nulls after the
shl ecx,4 ;last char so make len multiple of 16
mov eax,hashInit
movq mm0,[eax]
movq mm1,[eax+8]
movq mm4,[edx]
movq mm5,[edx+8]
.hash:
cmp ecx,0
je .done
movq mm2,mm0
movq mm3,mm1
pslld mm2,5
pslld mm3,5
sub ecx,16
movq mm4,[edx]
movq mm5,[edx+8]
jmp .hash
.done:
mov eax,[.output]
movntq [eax],mm0
movntq [eax+8],mm1
mov esp,ebp
pop ebp
ret 12
```

It's a variation of the djb algorithm only expanded and optimized. Well it could be optimized further using XMMX instructions. BUT in any case anyone know of a way to test it for collisions?
01 May 2005, 06:28
Reverend

Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 01 May 2005, 11:06
Afaik, there;s no specific method for finding collisions. It's mathematicians who find (sometimes searching even a few years) them. For example, collision in SHA-160 algorithm was found not long ago, but an algorithm itself is quite old.
01 May 2005, 11:06

Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 07 May 2005, 10:54
Hmm was it 256bit in length? It takes days to find solutions even on faster machines.

If your hash would be 16 or 32bit one it should be a matter of seconds, but I think you can be really sure that the collisions are very rare for 256bit ones.
07 May 2005, 10:54
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum