Permalink : www/retr0_dev/posts/5_post.html
Post date : Fri Mar 24 2023 0339
Upd. date : Fri May 26 2023 0159
First of all, we will be discussing on Asymmetric , Public Key Encryption : RSA.
So, how RSA works? :
We will need two (very) long prime numbers ; p and q
For the sake of simplicity, we will choose 3 and 11 as our prime number. Also, these numbers must be kept secret.
Now, we will calculate n = p * q
n = 3 * 11 = 33
n value should be made public.
Now, we will calculate what we call the totient funct. from Euler : φ(n) = (p-1)(q-1)
φ(n) = (3 - 1)(11 - 1) = (2)(10) = 20
Next, we can derive the public key from this equation : e, with gcd(φ(n), e) = 1 ; 1 < e < φ(n)
e value should be made public since it's public key. This key is used to encrypt messages, on sender side.
Let's say hypothetically e = 7
Next, we can derive the private key from this equation : d = e^-1 (mod φ(n))
If value of e or d is already derived, then this equation should be used : de mod φ(n) = 1. Using simple algebra, we need to find values of e or d that conform to this equation.
de mod φ(n) = 1 ; d(7) mod 20 = 1 ; (3)(7) mod 20 = 1 ; d = 3
d value must be kept private as it is the key to decrypt messages that was encrypted by the public key, on receiver side.
p = 61 ; q = ? ; n = 3233 ; e = 17 ; d = ?
So we plug in our previous equations (with simple algebra):
n = p * q ; 3233 = 61 * q ; q = 3233 / 61 = 53
φ(n) = (p - 1)(q - 1) = (61-1)(53-1) = (60)(52) = 3120
e has already derived = 17
de mod φ(n) = 1 ; d(17) mod 3120 = 1 ; (2753)(17) mod 3120 = 1 ; d = 2753
Now, here where is the problem with large numbers calc. By the rule, in order to encrypt message : Ct = M^e mod n and to decrypt message : M = Ct^d mod n
Following the rule, given a Ct = 2790, the equation should be : M = 2790^2753 mod 3120
That will yield : 5.6023677355623908532752104320819e+9485 mod 3120. That is obviously a comically large number for a Casio fx-570MS calculator to calculate. During the exam, it returned MATH ERROR.
However, continuing to mod the number, we get seemingly small value : 65
In symm. dec. , we are taught to use alphabetic-numerical table to derive the plaintext (0=A, 1=B, 2=C,...), but the value derived from the decryption process is not a garbage value either.
Instead, it corresponds to " A " ; using ASCII value and convert it to text.
To conclude, I still don't understand, why do large numbers are used for the derivation of the private key. There is probably a mishap in the making of the question itself. It's not thought through thoroughly. The calculation of power on large numbers is simply not possible on simple calculators.
However, I do appreciate that I (might) be the first to crack the Ct, if not.