Breaking RSA Encryption with MATLAB: A Detailed Lab Session 5

Verified

Added on  2023/03/31

|5
|496
|488
Practical Assignment
AI Summary
This assignment focuses on decrypting ciphertext using the RSA algorithm in MATLAB. The process begins with finding the private key associated with a given public key [n,e] = [2407,57] using MATLAB code that iteratively computes primes p and q such that n = p*q, calculates x = (p-1)*(q-1), and determines the private key d. The provided MATLAB code efficiently computes the private key [n,d] = [2407,1289]. Subsequently, the decryptString.m function is used to decrypt the initial ciphertext c, revealing a portion of the message. The process is then repeated with a new public key [n,e] = [7663,89] to decrypt the remaining ciphertext, ultimately uncovering the full message: 'There are two types of encryption: one that will prevent your sister from reading your diary and one that will prevent your government. (Bruce Schneir)'. This lab demonstrates a practical application of RSA decryption using computational tools, with Desklib providing resources for students.
Document Page
Running head: LABORATORY SESSION 5
LABORATORY SESSION 5
Name of the Student
Name of the University
Author Note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Method:
It is needed to decrypt a cipher text for given public key [n,e] = [2407,57].
The given cipher text is
c = [2050 2296 640 479 640 2377 1274 479 640 2377 2395 194 476 2377 2395 602 2014 640
1205 2377 476 1888 2377 640 1142 1421 479 602 2014 2395 586 476 1142 749 2377 476
1142 640 2377 2395 2296 1274 2395 2377 194 586 1285 1285 2377 2014 479 640 1904 640
1142 2395 2377 602 476 540 479 2377 1205 586 1205 2395 640 479 2377 1888 479 476
2011 2377 479 640 1274 1741 586 1142 1019 2377 602 476 540 479 2377 1741 586 1274
479 602 2377]
1. The decryptString.m in installed in the work directory.
2. Now, the private key associated with the public key [n,e] = [2407,57] is determined with
RSA algorithm by the following MATLAB code.
MATLAB code:
%% Given public key information
Document Page
n = 2407;
e = 57;
%% Computing primes p and q such that n = p*q
p = 2;q = n/p;
while mod(n,p) ~= 0 && mod(q,p) ~= 0 % repeat until n mod p = 0 and q mod p = 0
p = p + 1;
q = n/p;
end
%% Computing x
x = (p-1)*(q-1);
%% Computing private key
d = 0;
while mod(d*e,x) ~= 1 % repeat until(d*e) mod x = 1
d = d+1;
end
%% Display result
Document Page
fprintf('The computed private key for the public key [n,e]=[%i,%i] is [n,d] = [%i,%i] \
n',n,e,n,d)
Output:
>> privatekey
The computed private key for the public key [n,e]=[2407,57] is [n,d] = [2407,1289]
3. Now, the obtained private key is used to decrypt the cipher text c as given above by the
decryptString.m MATLAB function.
Execution and Output:
>> c = [2050 2296 640 479 640 2377 1274 479 640 2377 2395 194 476 2377 2395 602 2014
640 1205 2377 476 1888 2377 640 1142 1421 479 602 2014 2395 586 476 1142 749 2377
476 1142 640 2377 2395 2296 1274 2395 2377 194 586 1285 1285 2377 2014 479 640 1904
640 1142 2395 2377 602 476 540 479 2377 1205 586 1205 2395 640 479 2377 1888 479 476
2011 2377 479 640 1274 1741 586 1142 1019 2377 602 476 540 479 2377 1741 586 1274
479 602 2377];
>> n = 2407;
>> d = 1289;
>> [m] = decryptString(n, d, c)
m =
'There are two types of encryption: one that will prevent your sister from reading your
diary '
4.
Now, for obtaining the full message the process is repeated with public key [n,e] = [7663,89].
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Output for new public key:
privatekey
The computed private key for the public key [n,e]=[7663,89] is [n,d] = [7663,3113]
decryptString.m execution and output:
[m] = decryptString(n, d, c)
m =
'and one that will prevent your government. (Bruce Schneir)'
chevron_up_icon
1 out of 5
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]