Cryptography - RSA cryptanalysis : same message sent to different ppl with same low public

I have a set of three crypted messages (C1,C2,C3) (plus their modulus N1,N2,N3) from the same original message and I know the public exponent is 3, so I should be able to decrypt the original, shouldn't I?

So, if I understood well, I have to apply the Chinese remainder theorem and compute C'=M3 mod (N1*N2*N3). Plus N1*N2*N3 should be superior to M3, thus C'=M^3. Then a cube root of C' should give me the original message.

Problem is I know it can't be the original message because I have some rules to translate the decimal digits into letters and it should give me something readable, but I have nothing like that...

So the code

Chinese Remainder theorem :

public BigInteger CRT (BigInteger N1, BigInteger N2, BigInteger N3, BigInteger C1, BigInteger C2, BigInteger C3){

M = (N1.multiply(N2)).multiply(N3);

M1 = M.divide(N1);

M2 = M.divide(N2);

M3 = M.divide(N3);

Y1 = M1.modInverse(N1);

Y2 = M2.modInverse(N2);

Y3 = M3.modInverse(N3);

C = (((C1.multiply(M1)).multiply(Y1)).add((C2.multiply(M2)).multiply(Y2))).add((C3.multiply(M3)).multiply(Y3));

return C;

}

Newton Method to get the cube root on BigIntegers :

public BigInteger CubeRoot (BigInteger B,int iter){

BigInteger[] cubique =new BigInteger[2];

cubique[0] = B.divide(THREE);

for (int i=0;i<iter;i++){

cubique[1] = ((cubique[0].multiply(TWO)).add(B.divide(cubique[0].pow(2)))).divide(THREE);

cubique[0] = cubique[1];

}

return cubique[0];

}

I then enter N1,N2,N3,C1,C2,C3 in my main method and use the CRT with it, then the CubeRoot method.

I'm beginning to think my teacher messed up something (cause I have good CubeRoot (tried with google, same number), and the CRT doesn't seem bad o me..

Oh well...

[2425 byte] By [Hydexa] at [2007-11-26 23:32:06]
# 1
You could try posting the text of the assignment because it is not clear what you are trying to do and we have no way of testing what you are doing.
sabre150a at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 2

Ah, yes.

What I have :

N1=1267682768173705772121204466014351966420991747124296692738781

N2=594784728187929558157361061797280079304217376578704859396287

N3=671800525673311414176121424420561070006706636143564347159839

c1=73027778005252405544593327041436348569691170420622495551015

c2=305913617156006386034555579973415711489743094002030933386086

c3=414716605522784806237606817798193202630805281585499491403345

Some rules to read the decrypted message :

01:a;02:b...,26:z ; 27 : [space]; 28 : [-]; 29 : ! ; 30 : , ; 31 : '

So a 04310103 would be read d'ac (means something in ly own language)

The assignement : 3 users B1,B2,B3 using respectively public keys (3,N1), (3,N2), (3,N3) receive the same message m. So I have 3 different samples of the same message crypted differently but with the same p ublic exponent (3) : C1,C2,C3.

Goal : Decrypt m.

Hydexa at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 3

I don't see where you get the decryption algorithm from. It is not clear to me from your posting that you have to do anything other than RSA encrypt (N1,C1,3) to M1, (N2,C2,3) to M2 and (N3,C3,3) to M3 and then in some way merge the results.

You have not published anything to say that the merge is to take the cube root of M1*M2*M2 so I assume that there is some part of your assignment you have not posted.

sabre150a at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 4
I know I have to do a cube root somewhere, so I'm almost sure of the algorthm here (in theory). Plus I have to use Chinese Remainder's theorem somewhere, thus it directly points to hastad work which I am trying to implement here.
Hydexa at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 5
I fully understand RSA but I don't understand what you are doing. I don't think I can help.P.S. Trying to guess where the cube root comes in looks to be a way to waste lots of your time.Message was edited by: sabre150
sabre150a at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 6

I have a good explanation of what I'm doing but it's not in English. I'm looking for something in English right now.

Well the Hastad book isn't very clear so I'm looking for something else, there's a little explanation on the end of page 15 - beginning of page 16 of the pdf here :http://cobweb.ecn.purdue.edu/~kak/courses-i-teach/compsec/Lecture/Lecture_9.pdf

Message was edited by:

Hydex

Hydexa at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 7

Ah, yes.

What I have :

N1=1267682768173705772121204466014351966420991747124296692738781

N2=594784728187929558157361061797280079304217376578704859396287

N3=671800525673311414176121424420561070006706636143564347159839

c1=73027778005252405544593327041436348569691170420622495551015

c2=305913617156006386034555579973415711489743094002030933386086

c3=414716605522784806237606817798193202630805281585499491403345

I was able to do this using Pari; in other words, using the CRT with the above integers results in a perfect cube. Therefore, there must some bug in your code. I'll see if I can track it down later.

ghstarka at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 8
how about return C.mod(M);
ghstarka at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 9
how about return C.mod(M);YES ! That was it, thank you very much, It works now !
Hydexa at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 10

how about
return C.mod(M);

YES ! That was it, thank you very much, It works now !

:-( Looks like I was in way over my head!

sabre150a at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 11
The last concern I have is that I may have not understood the whole thing. I thought that C = M3 mod(N1*N2*N3) would imply C = M3 because I thought M^3 < (N1*N2*N3). But it seems that I had to calculate C mod (N1*N2*N3).It works, but why? :D
Hydexa at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...
# 12

The confusion is due partly to the fact that the word mod is sort of overloaded here. In math, a mod n is any of the infinite sequence of integers ..., a-2n, a -n, a, a+n, a+2n, ..., i.e. a +k*n, where k is any integer. Note that exactly one value in this sequence, call it 'r', satisfies, 0<= r < n. Now in computing, when we speak of a mod n, we usually mean this one value 'r'. This is what the BigInteger mod methods give you. The final twist is that in computational number theory, of which this is a simple example, both definitions come into play.

What the theory says is that when I do my CRT calculation I get a some C such that C = M3 + k*(N1*N2*N3). That is almost but not quite what I want for the cryptanalytic result. If instead I choose to use the magic smallest value 'r' from above, I still get an equation r = M3 + l*(N1*N2*N3), but now the facts 1) 0<= r< (N1*N2*N3), and 2) 0<=M3 < (N1*N2*N3) tell me that 'l' must equal 0, or r=M3.

When you computed C in your java CRT method, the intermediate result grows much larger than N1*N2*N3.

ghstarka at 2007-7-10 14:44:26 > top of Java-index,Security,Cryptography...