slash icon indicating copy to clipboard operation
slash copied to clipboard

How does the code work?

Open subtra3t opened this issue 4 years ago • 2 comments

I went though slash.c, but I didn't understand a single thing. Is there an explanation of the code?

subtra3t avatar Mar 18 '21 07:03 subtra3t

I went though slash.c, but I didn't understand a single thing. Is there an explanation of the code?

I didn't write this code but from what I understood:

there is lookup table called box[] contains 256 numbers which is used to give a good avalanche effect to the algorithm.

The combine macro takes two arguments and XOR them (pretty common in hash functions and encryption algorithms).

The mix macro takes one argument and shifts it then performs logical AND with 0xff, then it is repeated few times except that each time it will be shifted with a different value (according to what author of this repo thinks gives better avalanche effect) and each one of them is passed to the lookup table to give appropriate value, and finally everything is combined with logical OR, then after that the result is multiplied by a number then shifted by 56 and XOR operation is performed then everything is multiplied by some number again

I guess if you could understand this it wouldn't be hard to understand what slash() function does. also It does help if you see source code of slash.c while you're reading this, so you can understand what I'm explaining better

It's really hard to know exactly why everything is shifted or multiplied this way and why box[] is filled with these values but in general it is supposed to give more unique values (avalanche effect) and cause less collisions

Hussein-L-AlMadhachi avatar Aug 23 '22 09:08 Hussein-L-AlMadhachi

I went though slash.c, but I didn't understand a single thing. Is there an explanation of the code?

I didn't write this code but from what I understood:

there is lookup table called box[] contains 256 numbers which is used to give a good avalanche effect to the algorithm.

The combine macro takes two arguments and XOR them (pretty common in hash functions and encryption algorithms).

The mix macro takes one argument and shifts it then performs logical AND with 0xff, then it is repeated few times except that each time it will be shifted with a different value (according to what author of this repo thinks gives better avalanche effect) and each one of them is passed to the lookup table to give appropriate value, and finally everything is combined with logical OR, then after that the result is multiplied by a number then shifted by 56 and XOR operation is performed then everything is multiplied by some number again

I guess if you could understand this it wouldn't be hard to understand what slash() function does. also It does help if you see source code of slash.c while you're reading this, so you can understand what I'm explaining better

It's really hard to know exactly why everything is shifted or multiplied this way and why box[] is filled with these values but in general it is supposed to give more unique values (avalanche effect) and cause less collisions

Thanks!

subtra3t avatar Sep 21 '22 14:09 subtra3t