TL:DR I'm learning RSA. I've made it to the decryption stage but I don't know how to handle huge exponents. These are my values:
p = 17
q = 31
e = 7
m = 2
n = 527
(n) = 480
de = 7(343) = 2401
d = 343
PU = {7, 527}
PK = {343, 527}
C = 128
So I'm unable to handle the processing of the decryption of Cipher text 128, without a calculator or tool. With a tool, I think the value is 2
. How can I process this value? (edit: fixed mod typo below)
M = 128343(mod 480 527)
More Details
Solving using Special Algorithm
I've found a possible solution but can't understand the explanation.
The Stallings textbook mentions an algorithm that means converting d
to binary. It provides pseudocode but next to no explanation, unless you consider this explanation enough (cuz I don't).
The pseudocode:
a = C, b = d, f = given as 1 to start, c = given as 0 to start
Solving by Breaking Apart Exponent
(edit: I don't really understand this after all. If I did, I would understand how to perform on any number, large or small)
I do understand how to break up small exponents. It seems like this is an easier way to do it without all this processing, since I am doing this by hand. Is there anyway to extend this method to a number like 343
? What is the process? It's not always as simple as doubling the power of 2.
i.e. 887 mod 187 = [(884 mod 187) * (882 mod 187) * (881 mod 187)] mod 187
Updating original post with more details:
I think I misunderstood what I was even asking. I seemed to be asking two questions unintentionally, since it is like this in my textbook. Each are separate, but since they perform the same action, I have not removed anything (i.e. to make the question simpler). I've just tried to make it more clear.
Part1: getting the overall solution
I think I understand this now, but just to confirm, for the problem
M = 7560(mod 561)
Running the binary value of 560 (1000110000) through that algorithm produces the table below, each cell relates to one binary digit (from the Stallings). Is the solution to M
1? If yes, then I think I get this idea now.
Part 2: Breaking up the exponents
This seems to be totally separate from just getting the answer using the algorithm. It seems nice since there is no need to convert to binary which is (for me anyway) quite error prone by hand.
But I don't understand how to do it.
Example: Why is exponent 8 repeated? How do you arrive at this breakdown? I see the exponents add up to 23 but how do you determine which values to use to get there? What if it was some other number like 103, or 243, etc?
i.e. 1123 mod 187 = [(111 mod 187) * (112 mod 187) * (114 mod 187) * (118 mod 187) * (118 mod 187)] mod 187