Implementation_of_RSA_Encryption_Using_Identical_Modulus_Algorithm-Oseily2008
Implementation_of_RSA_Encryption_Using_Identical_Modulus_Algorithm-Oseily2008
Modulus Algorithm
Hassan Amine Osseily Ali Massoud Haidar Abdallah Kassem
Electrical Department, Faculty of Computer Department, Faculty of Computer Department, Faculty of
Engineering Engineering Engineering
Beirut Arab University Beirut Arab University Beirut Arab University
Beirut-Lebanon Beirut-Lebanon Beirut-Lebanon
E-mail: [email protected] E-mail: [email protected]
Authorized licensed use limited to: Beirut Arab University. Downloaded on February 02,2023 at 10:43:02 UTC from IEEE Xplore. Restrictions apply.
C. Security of the Private Key C. Decryption
A public-key system can be only safe if it is impossible to The decryption of RSA is based on the following theorem. If
compute the private keys from the public keys in reasonable (N, e) is a public key and d is the according private key in the
time. Today this is ensured by the complexity of computation RSA system, then we have
in order to resolve the corresponding problems of number
theory. There is however no certain knowledge about the (Me mod N)d mod N = M (6)
persistence of this situation in the future. It is well known for
example, that quantum computers can make all common for each natural number M
public-key systems unsafe. However, this does not imply that Proof:
such computers can really be built. Therefore, it is absolutely
necessary to design security infrastructures in a way that Since e · d =1 mod K, there is an integer x, so that:
enables the easy replacement of the used cryptographic (7)
techniques. e · d = 1 + x · k.
Therefore,
II. RSA ALGORITHM
The RSA cryptosystem, designated after its inventors Ron (Me)d = Me·d =M1+xK = M · MxK (8)
Rivest, Adi Shamir, and Len Adleman. It was the first
publication of a public-key system and is still one of the most This equation shows that:
important ones. Its security is closely associated with the
difficulty of factorizing large numbers. The following section (Me)d =M · MxK=M mod p (9)
describes how to use the RSA cryptosystem. Especially key
generation, the encryption, and the decryption are treated in If p is not a divisor of M, this congruence results from the
detail. small theorem of Fermat. Otherwise, the statement is trivial
since both sides of the congruence are 0 mod p Exactly the
A. Generating Keys same applies to
Alice selects two random prime numbers p and q and
computes the products: (Me)d = M mod q. (10)
Additionally Alice selects a natural number e with If C was computed as in equation 5, we can reconstruct M by
means of
1 < e < K and gcd(e, K) = 1 (3)
M = Cd mod N. (12)
and computes a natural number d with
(4) D. Security of RSA
1 < d < K and d·e =1 mod K To find out the secret RSA key is as difficult as factorizing the
RSA modulus. However, the attacker can also have the
Since gcd(e,K) = 1, there is actually such a number d. It can intention to find the plain text from the cipher-text. It is not
be computed with the extended Euclidean algorithm. We also known whether it is therefore necessary to find the secret RSA
consider that e is always odd. The public key consists of the key. But even if it could be proved that breaking RSA is as
pair (e, N). The private key is d. The number N is called RSA difficult as factorizing the RSA modulus, this would not
modulus, e is called encryption exponent and d is called automatically signify that RSA is totally secure, since there is
decryption exponent. no knowledge about the difficulty of factorizing natural
numbers.
B. Encryption
The finite set of plain text (M) consists of all natural numbers. E. The Selection of p and q
Zero and one should not be used because in that case the To make the factorization of the RSA modulus N as difficult
resulting cipher-text would equal the plaintext. A plaintext M as possible, both prime factors p and q should be chosen the
is encrypted with same size.
Authorized licensed use limited to: Beirut Arab University. Downloaded on February 02,2023 at 10:43:02 UTC from IEEE Xplore. Restrictions apply.
choice e = 2 is always excluded because K = (p−1)·(q−1) is architecture is based on Straight (At Sight) Division algorithm
even and gcd(e, K) = 1 must be matched. Therefore, the of Ancient Indian Vedic Mathematics [6]. To simplify the
smallest exponent would be three. With e = 3 a low exponent understanding of the algorithm, it is explained for 3 digits
attack is going to be successful. number (X2X1X0) by 2 digits number (Y1Y0).
• If less than zero: divisor did not fit once, so left shift The division architecture takes 2N bits for dividend and N bits
in a 0 in quotient and add divisor back to partial for divisor to generate the quotient and the remainder. The
remainder. architecture is based on the straight division algorithm of
identical modulus. To simplify the understanding of algorithm,
• If >= zero: it fit, left shift a 1 in quotient and shift it is explained in the following steps.
divisor register right.
Based on the RSA algorithm, Let M be a plain text where M is
For example when dividing two binary numbers with 32 bit a binary digit with n bits and e is the encryption exponent.
dividend (11011101010101010101010101010111) and 6 bits Based on the equation 5, the cipher text will be:
for divisor (110110) here a lot of subtraction and shifting
operation will be applied up to get the final results. Cipher = Me mod N
Authorized licensed use limited to: Beirut Arab University. Downloaded on February 02,2023 at 10:43:02 UTC from IEEE Xplore. Restrictions apply.
Cipher = M*M*M*M*M… mod N M.M.M.M.M mod N = 40*40*40*40*40 mod 35
= [(M mod N)*(M mod N)*...] mod N (19) 102400000 mod 35 = 10
To analyze this equation, we have two cases: Discussion: comparing the biggest cells of modulus (500) with
the original number (102400000), we found that division of
A. For M > N the number 500 by 35 is much easier than 102400000 by 35.
In this case, the following steps are required
• Step 1: We compute only one cell (M mod N) = R1 B. For M < N
(remainder) since all cells are identical. In this case, we go directly to step 4, but with R=M
• Step 2: Replacing all cells by the remainder R1 in the • Step 4: Splitting the term Me into M(X*Z+Y)
equation (19), we get Where:
Mx>=N.
(R1*R1*R1*R1….) mod N = Re mod N My<N
(20)
z is the number of term Mx
• Step 3: Verify if R < N,e
• Step 5: Replacing the term Me by M(x*z+y) , Then,
-If yes, then the final remainder is RD = Re
-If no, then we go to the next step. Me mod N = M(x * z + y) mod N = (M(x * z) * M y ) mod N
= [(M x * M x * M x *….) mod N * M y ] mod N (23)
• Step4: Splitting the term Re into sets as,
The factors of multiplication (MX mod N) are
x*z+y=e identical and consisting of identical cells.
(21)
Where, We compute only one of these cells (MX mod N = R1
Rx>=N. where R1 is a remainder with R1<N)
Ry < N, then Ry is a remainder • Step 6: Replacing M x, M y in the equation (19),
z is the number of term Rx
(R1*R1*R1*R1….M y) mod N = R e-y * M y mod N (24)
• Step 5: Replacing the term Re by R(x * z + y)
in the • Step 7: Verify if Re-y * My < N,
equation 20, we get If yes, then the final remainder is RD= Re-y * My
If no, then we do repetition of the algorithm or we refer to
Re mod N = R (x * z + y) mod N= (R(x * z) *R y ) mod N step 5 with same sequence and logic.
= [(Rx * Rx * Rx *….) mod N * Ry] mod N (22) We repeat the computation up to get a product of all
remainders less than the divisor N.
• Step 6: We repeat this computation until getting all
terms less than the number N. the next step shows an • Example 2
example to prove the case M>N. Let we have a message to be encrypted with 6 bits
M=101000=40 and e=3=11, let p=7=111 and q=7=111
• Example 1 Then:
Let a message M with 6 bits M=101000=40 to be encrypted N=7*7=49=110001 (M<N)
and the encryption key e=5=101, the prime numbers p=5=101 Grouping M*M*M into two sets
and q=7=111 M*M=40*40>49=N
Then: M=40<49=N
N=5 * 7 =35 = 100011 (M>N) Then we have only two sets with e = z * x + y=5
M mod N = 101000 mod 100011=5=101=R y=1
Computing [R * R * R * R * R] mod N = R1 x=2
=[5*5*5*5*5] mod 35. z=(3-1)/2 =1
Grouping into sets the remainder R Compute M*M mod N = 1600 mod 35 = 32 = R1
R*R=5*5<35=N The second set M=40<49 then R2=40
R*R*R=5*5*5=125>35 Check R1*R2= 32*40=1280>N then repeat the computation
Then we have only two sets with e = z * x + y = 5 1280 mod 49 = 6
y=2 To prove this result we can apply directly:
x=3 M*M*M mod N = 40*40*40 mod 49
z=(5-2)/3 =1 64000 mod 49 = 6
Compute (R * R * R mod N = 125 mod 35 = 20 = R1)
The second set R*R=25<35 then R2=25 C. FLOW CHART
Check R1*R2= 20*25=500>N then repeat the computation The flow chart figure 1 shows the sequence of operations of
500 mod 35 = 10 division and multiplication. It is very clear that division
To prove this result we can apply directly: operations are minimized to the least possible case.
Authorized licensed use limited to: Beirut Arab University. Downloaded on February 02,2023 at 10:43:02 UTC from IEEE Xplore. Restrictions apply.
V. ANALYSIS OF ALGORITHMS
The RSA encryption/decryption circuitry achieves a
significant improvement in performance using the identical
modulus algorithm as reflected by the results shown in
examples compared with traditional division algorithm since
in cryptography, we care only about the remainder or the
modulus to get the cipher and plain text and we do not take
any care to get the quotient. Hence, the main advantage of this
algorithm is the simplicity comparing with other techniques
and the uniqueness of output (remainder instead of remainder
+ quotient). Then it is found that when implemented with this
algorithm, as proven in the annex of programming software,
the RSA circuitry has less timing delay compared to its
implementation using traditional multipliers and division
algorithms. We can see that multiplication and division
operations are two of the most important operations in
computation of AB mod N and a high performance
multiplication and division algorithm/ architecture will
considerably improve the speeds of encryption and decryption.
Two known methods of multiplication are array and booth
multiplication each with its own limitations [5,6]. Another
prominent operation in computation of ABmod N is division
operation and there are several well-known methods for
implementing integer multiply and divide circuits. These
methods employ operational algorithms with components such
as shift registers and adder circuits [7]. From the architecture
point of view, division circuits are usually much larger than
multiplier circuits for an equivalent data word length and
division is generally performed through restoring and non-
restoring algorithms [8,9]. These conventional methods of
performing digital division typically involve subtracting the
divider from a reference number, referred to as a current
number, and generally require that the divider to be added
back to the current number after each computation stage.
While in the restoring method, the decision of adding back the
divider to the current number depends on the result of the
subtraction stage, in non-restoring method, the choice between
addition and subtraction is made in the next computation
stage, that is, after the subtraction stage. Thus, in order to
circumvent the limitations of conventional multiplication and
division algorithms, this paper proposes the implementation of
identical modulus algorithm that result in improved efficiency.
A faster and novel hierarchical overlay multiplier has earlier
been proposed based on Ancient Indian Vedic Mathematics
[11,12] that performs better than the conventional multiplier
architectures [6]. While this paper still utilizes the same
multiplier in computation of AB mod N, it also proposes a
novel division algorithm and architecture based on identical
modulus cells to minimize the length of dividend number.
VI. CONCLUSION
The RSA encryption implemented with identical modulus
algorithm improved efficiency in terms of speed and area. It
has the advantage that as the number of bits increases the
Figure 1. Flow Chart of RSA Identical Modulus Algorithm execution time of operations increase very slowly as compared
Authorized licensed use limited to: Beirut Arab University. Downloaded on February 02,2023 at 10:43:02 UTC from IEEE Xplore. Restrictions apply.
to RSA encryption employing traditional multipliers and End If
division algorithms [6]. End If
Else
VII. ANNEX: PROGRAMMING SOFTWARES b = power(CDbl(Me.Text1), Me.Text2)
The software is given in visual basics VB where we can verify 'MsgBox (b)
the algorithm with timing spent through using the algorithm or r1 = b Mod Me.Text3
the direct implementation of ABmod N. MsgBox (" Le resultst est: " & r1)
If b < Me.Text3 Then
Public Function power (m As Double, n As Double) As remainder = b
Double 'MsgBox (" Le resultst est: " & remainder)
Dim r As Double, i As Integer Else
f=1
i=1 i=0
r=1 Do While f < Me.Text3
Do While i <= n f = f * Me.Text1
r=r*m i=i+1
i=i+1 Loop
Loop s = (f Mod Me.Text3) * (power(CDbl(Me.Text1),
power = r Me.Text2 - i))
End Function remainder = s Mod Me.Text3
MsgBox (" Le resultst est: " & remainder)
Private Sub Command1_Click() End If
Dim result1 As Double, result2 As Double End If
Dim timein As Variant, timeout As Variant timeout = Second(Time())
Me.Label2 = (timeout - timein)
'first step End Sub
result1 = CLng(power(Me.Text1, Me.Text2) Mod Me.Text3)
MsgBox (" Le resultst est: " & result1) REFERENCES
timeout = Second(Time()) [1] R. Rivest, A. Shamir and L. Adleman, “A Method for Obtaining Digital
Signatures and Public-Key
Me.Label1.Caption = (timeout - timein) Cryptosystems”. Communications of the ACM, 21 (2), pp. 120-126, February
'second step 1978.
End Sub [2] Daeman, J., and Rijmen, V. “Rijndael : “The Advanced Encryption
Standard.” , Dr. Dobb’s Journal, March
Private Sub Command2_Click() 2001.
[3] Daeman, J., and Rijmen, V. “ The Design of Rijndael: The Wide Trail
timein = Second(Time()) Strategy Explained”, New York,
Springer- Verlag, 2000.
If Me.Text1 > Me.Text3 Then [4] William Stallings, “ Cryptography and Nework Security”, Third Edition,
Pearson Education, 2003
a = Me.Text1 Mod Me.Text3
[5]Himanshu Thapliyal, R.V Kamala and M.B Srinivas "RSA
b = power(CDbl(a), Me.Text2) Encryption/Decryption in Wireless Networks Using
r1 = b Mod Me.Text3 an Efficient High Speed Multiplier", Proceedings of IEEE International
MsgBox (" Le resultst est: " & r1) Conference On Personal Wireless
Communications (ICPWC-2005) , New Delhi, pp-417-420, Jan 2005.
[6] Himanshu Thapliyal and M.B Srinivas, "High Speed Efficient Hierachical
If b < Me.Text3 Then OverlayMultiplier Architecture
remainder = b Based on Ancient Indian Vedic Mathematics", Proceedings of International
'MsgBox (" Le resultst est: " & remainder) Conference on Signal Processing,
Else ICSP 2004, Turkey, Dec 2004.
[7] M.M. Mano, “Computer System Architecture”, 2nd Ed, Prentice Hall,
If b > Me.Text3 Then 1982.
[8] V.C. Hamacher, Z.G. Vranesic, S.G. Zaky, “Computer Organisation”, PP-
f=1 281-285, 4th Ed, The Mcgraw Hill
Company, 1996.
i=0
[9] J.P. Hayes, “Computer Architecture and Organisation”, PP-244-250, 3rd
Do While f < Me.Text3 Ed, The Mcgraw Hill Company,1998.
f=f*a [10]Martin, Langhammer ; “Method and apparatus for performing digital
i=i+1 division”, United States Patent,
Loop 6,317,771, November 13, 2001.
[11] Jagadguru Swami Sri Bharath, Krsna Tirathji, “Vedic Mathematics or
s = (f Mod Me.Text3) * (power(CDbl(a), Me.Text2 - i)) Sixteen Simple Sutras From The
remainder = s Mod Me.Text3 Vedas”, Motilal Banarsidas , Varanasi(India),1986.
MsgBox (" Le resultst est: " & remainder) [12] A.P. Nicholas, K.R Williams, J. Pickles, “Application of Urdhava Sutra”,
Spiritual Study Group, Roorkee (India),1984.
Authorized licensed use limited to: Beirut Arab University. Downloaded on February 02,2023 at 10:43:02 UTC from IEEE Xplore. Restrictions apply.