Final Report RSA
Final Report RSA
Final Report RSA
On
by
Md Saif H2016124031
Mounesh H2016124024
Symmetric-key cryptography:
Symmetric-key cryptography refers to encryption methods in which both
the sender and receiver share the same key (or, less commonly, in which
their keys are different, but related in an easily computable way). This was
the only kind of encryption publicly known until June 1976.
Symmetric key ciphers are implemented as either
Block ciphers
Stream ciphers
A block cipher enciphers input in blocks of plaintext.
A stream cipher enciphers input as individual characters.
The Data Encryption Standard (DES) and the Advanced Encryption
Standard (AES) are block cipher designs that have been designated
cryptography standards by the US government. DES remains quite
popular; it is used across a wide range of applications, from ATM
encryption to e-mail privacy and secure remote access.
RSA:[2]
At present, the best known and most widely used public key system is
RSA. It is considered secure when sufficiently long keys are used. The
security of RSA depends on the difficulty of factoring large integers.
1)Key generation:
a) Select any two prime numbers p, q, where p and q should be large.
Typical values for these primes are 512 to 4096bits.
b) Compute
=
c) Compute totient function (n). Totient function counts the positive
integers up to a given integer n that are relatively prime n.
() = ( ) ( )
d) Then public Key e is selected as follows
< < () ((), ) =
Key Distribution:
Public key is (, ) => (, ) known to everyone
Private key is (, ) => (, ) intended receiver
Encryption:
= ^ ( )
If we want encrypt letter h. ASCII value of h is 104. It is encrypted as
follows
= ( )
comes out as =
Decryption:
= ( )
= ( )
=
Advantages and Disadvantages of RSA
Advantages:
RSA relies on the fact that it is easy to multiply two large prime numbers
together but extremely hard [time consuming] to factor them back to
result.
for ex: the product of 3391 and 23279 can be calculated easily its
78939089 but its extremely difficult to factorize the same number to get
back factors 3391 23279
Disadvantages:
1. If factorization of n [p*q] is possible then whole RSA algorithm is
compromised.
2. Encryption and Decryption takes a long time for large p and q.
Hence we have to bring some modifications which increases the security
of existing algorithm but not at the cost of time
POSSIBLE SOLUTIONS
For Enhancing the security
1. Use of fake modulus i.e. instead of sending n , Fake modulus Fn is
sent over the channel.
2. Instead of using Two prime to calculate n, we can use three prime
there by making factorization more complex.
For Enhancing the Speed
1. Offline key generation
2. Montgomery Multiplication
3. Improving Modular Exponentiation
4. Many more mathematical improvements using concepts of number
theory.
PROPOSED DESIGN
RSA algorithm can be improved in two areas as mentioned
1)Security
2)Time
Decryption:
In our modified RSA decryption is three step process
1) First cipher is decrypted to get random number using private key
= ( )
2) In second step we calculate unique integer using random number
(. ) = such that < <
3) In third step we decrypt cipher using
= ( . )
Flow Chart Modified RSA Encryption
numbers
Plain text
Cipher 2
Cipher 1
Flow Chart Modified RSA Decryption
No
Calculate from 1 ( ) = 1
yes
Plain Text
SIMULATED RESULTS
Discussion on results
[c1]=encryption_MOD(k,e,n);
%m=input('enter the message to be encrypted');
m=input('enter the message to be encrypted\n','s');
x=length(m);
for i=1:x
[c(i)]=text2ascii_MOD(m(i));
[c2(i)]=encryption_MOD_1(k,c(i),e,n);
end
disp( sprintf( 'The value of first cipher is c1= %d\n', char(c1) ) );
disp( sprintf( 'The value cipher Corresponding to message is c2 = %s\n', c2 )
);
[k]=decryption_MOD(c1,d,n);
%disp(k);
[s]=random_MOD(k,n);
disp('the value of number S is');
disp(s);
for j=1:x
Fn(j)=c2(j)*s;
[m(j)]=decryption_MOD(Fn(j),d,n);
end
disp ( sprintf( 'The encrypted message is = %s\n', char(c2) ) );
disp ( sprintf( 'The decrypted message is = %s\n', char(m)) );
Function for Calclation of phi,n,d,e,k
function[phi,n,d,e,k]=INIT(p,q)
n=p*q;
phi=(p-1)*(q-1);
e=1;
i=2;
while i>1
e=e+1;
i=gcd(phi,e);
end
d=1;
j=2;
while j>1
if rem(d*e,phi)~=1
d=d+1;
j=rem(d*e,phi);
end
end
k=5;
i=2;
while i>1
k=k+5;
i=gcd(n,k);
end
end
a=zeros(1,65535);
while d >= 2
r=rem(d,2);
if r==1
a(i)=1;
else
a(i)=0;
end
i=i+1;
d=floor(d/2);
end
if d == 2
a(i) = 0;
else
a(i) = 1;
end
Function for Decryption
function[en]=decryption_MOD(c,e,n)
[e]=dtob(e);
k = 65535;
c = c;
cf = 1;
cf=mod(c*cf,n);
for i=k-1:-1:1
c = mod(c*c,n);
j=k-i+1;
if e(j)==1
cf=mod(c*cf,n);
end
end
en=cf;
function[d]=random_MOD(e,n)
d=1;
j=2;
while j>1
if rem(d*e,n)~=1
d=d+1;
j=rem(d*e,n);
end
end
end
if rem(s*k,phi)~=1
d=d+1;
j=rem(s*k,phi);
end
end