1

I've read here that :

If you’ve watched a security certificate being generated on your computer ..., here is exactly what happens – it produces two large numbers , checks that they are both prime and multiplies them together. This gives you your “public key”, which you can share freely with the world. It allows other people to send you messages by encrypting them with your public key; however, since getting the original two prime numbers from your public key is hard (only your computer knows them because it generated them in the first place), you are the only one who can actually decrypt them!

So I wanted to test how much it takes to "Extract" the prime numbers from a multiplication of 2 big prime numbers :

I won't take huge huge number ( just for demonstration) so I went to this site and took 2 large ( not huge) prime numbers :

32,452,867

and

15,485,867

Let's multiply them and we have : 502560782130689

Now let's see what prime numbers is this number made of :

void Main()
{
 double a, b;
Console.WriteLine("Please enter your integer: ");
a = double.Parse(Console.ReadLine());


for (b = 2; a > 1; b++)
    if (a % b == 0)
    {
        int x = 0;
        while (a % b == 0)
        {
            a /= b;
            x++;
        }
        Console.WriteLine("{0} is a prime factor {1} times!", b, x);
    }

}

It took 2 seconds to find out :

enter image description here

Question

I'm positive that I didn't understand the paragraph above becuase , to me ,it's seems pretty easy to find out what prime numbers is the number is made of : so I don't understand this part :

however, since getting the original two prime numbers from your public key is hard (???)

**Update : **

I wanted to go further and choose greater numbers :

941,083,987 and 295,075,153 ( multiplication = 277690501449875011 )

And again the time was short enough :

enter image description here

Royi Namir
  • 144,742
  • 138
  • 468
  • 792
  • Those numbers arent large. Usually, RSA keys are 2048 bit in size, or even more. That equates to approx. 600 or more decimal digits. – CBenni Feb 21 '15 at 12:39
  • @CBenni Thanks for reply. do you know where I can find and play with those (such) numbers ( link maybe?) – Royi Namir Feb 21 '15 at 12:39
  • I dont know if there is a website that has prime numbers like that, formatted as numbers, usually they are stored as signature files. The linux command `ssh-keygen -t rsa` can be used to generate such a key randomly. – CBenni Feb 21 '15 at 12:42

1 Answers1

1

As noted in my comment, RSA keys are usually way larger in size. Your examples can be brute forced easily (!). RSA keys as used for SSH and similar are usually 2048 or even 4096 bit long (approx 616 resp. 1233 decimal digits). At that point, trying to brute-force them takes essentially forever, even the best algorithms known dont improve the time to crack them significantly.

The question if there is an algorithm that does this efficiently is still an open question.

EDIT: You asked about why prime numbers are used in the first place: If you dont choose prime numbers, the algorithm will no longer work. I suggest reading a book on discrete mathematics (or perhaps simply the wikipedia article) for details on how RSA works.

CBenni
  • 555
  • 1
  • 7
  • 20