Hello readers,

Lately i came across a piece of software that had an interesting piece of build in cryptography. My intention is to understand how it works and to know if it relies on a 'standard' crypto algorithm or that it is something more fancy.

First an introduction (coded in Java, i left most pieces out):

-----

Secure Hash Algorithm (SHA-1) hashes the data of three files thus creating the following constant values:

* serenv1 (1024 bit) - prime number

* serenv2 (128 bit) - prime number

* serenv3 (1024 bit)

* serkey (1024 bit)

* array - with 2^14 128-bit positive numbers

After some playing around the input message is encrypted (in a reversible way) to a 144 bit number. The last 14 bit form the index into the array (bi2). Furthermore the most significant bit is removed resulting in bi4 (129 bits number).

Note: modInverse: (x xor -1) % y

modPow: (x ^ z) % y (where ^ stands for power, not XOR)

BigInteger bi2 = index;

BigInteger bi4 = 129bit_number;

BigInteger bi5 = array[index_array];

BigInteger bi6 = bi4.modInverse(serenv2);

BigInteger bi7 = bi2.multiply(bi6).mod(serenv2);

BigInteger bi8 = bi5.multiply(bi6).mod(serenv2);

BigInteger bi9 = serenv3.modPow(bi7, serenv1).multiply(serkey.modPow(bi8, serenv1)).mod(serenv1).mod(serenv2);

if(bi5.equals(bi9))

//Bingo! Free beers if the index is between 0 and 16000

-----

my first thoughts were a combination between SHA-1 and RSA. the extensive use of modPow and the use of modInverse gave me that idea, but since the modInverse operation in RSA is only used when calculating the private exponent i'm slightly confused. i think the multiply operations have something to do with the input message being bigger then 128 bits so it had to be 'hacked to pieces'.

if there anyone that can explain to me what is happening here (in crypto language, i can see what happens to the values ). every scrap of information would be helpfull!

regards & thanks in advance!

rhythm

## Bookmarks