0% found this document useful (0 votes)
7 views

Implementation_of_RSA_Encryption_Using_Identical_Modulus_Algorithm-Oseily2008

Uploaded by

Bahaa Azzam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Implementation_of_RSA_Encryption_Using_Identical_Modulus_Algorithm-Oseily2008

Uploaded by

Bahaa Azzam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Implementation of RSA Encryption Using Identical

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]

symmetric cryptosystem or a secret-key system. If such a


Abstract— The purpose of this paper is to present new
system is employed, Alice and Bob must exchange the key e
algorithms and circuits to convert from MVL (Multiple
at the beginning of the communication over a safe channel and
Valued Logic) to MVL Coded Decimal (MVL-CD) and vice
then keep it secret. The decryption key d can be computed
versa. We will introduce two conversion techniques: the first
from e. In asymmetric cryptosystems, d and e are different and
one is called "Addition-Subtraction technique" (AST) while
d can not be computed in reasonable time from e. If Bob wants
the other method is called "Division-Multiplication
to receive encrypted messages, he publishes the encryption
Technique" (DMT). Based on AST, we will develop the
key e and keeps the decryption key d secret. Everyone can use
algorithm and circuit of converters for quaternary and
e now, in order to send an encrypted message to Bob.
quinary systems. The Addition technique will be applied for
converting from MVL to MVL-CD while Subtraction is used Therefore, e is also called the public key and d is called the
for reverse operation. In addition, we will develop the private key. A cryptosystem where the private key cannot be
derived from the public available data (the public key) is also
algorithm and circuit of DMT converter for quinary system
known as a public-key system. Such cryptosystems are also
by using delta gate [8] elements. The division technique will
called asymmetric cryptosystems. Public-key systems often
be used to convert MVL to MVL-CD while multiplication
use two different key spaces, since encoding and decoding
will be used for the inverse conversion. At the end of this
keys have different representations. RSA uses a public key
paper, a brief comparison will show the advantages and
consisting of a pair (e, N) of natural numbers, while the private
disadvantages of these methods in terms of cost and
key is one natural number d. Clifford Cocks has developed the
performance. Moreover, we will compare our techniques
first asymmetric algorithm in the year 1970. The algorithm
with other authors' methods and algorithms.
was reinvented by Rivest, Shamir and Adleman in the year
I. INTRODUCTION 1976 at the MIT [1,2,3].
The standard techniques for providing privacy and security B. Advantages of Public-Key Cryptography
in data networks include encryption/decryption algorithms The disadvantage when using symmetric coding algorithms is
such as Advanced Encryption System (AES) (private-key) and the distribution and administration of secret keys. Before each
RSA (public-key) [1,2,3]. RSA is one of the safest standard secret communication, Alice and Bob must exchange a secret
algorithms, based on public-key, for providing security in key. Therefore, a safe channel must be available. This problem
networks. While hardware implementation of this algorithm becomes increasingly difficult if more participants in a
tends to be faster compared to its software counterpart, there is network want to communicate with one another. When using
a scope for further improvement of performance of RSA public-key algorithms, the key management becomes
hardware. One of the most time consuming processes in RSA substantially simpler, because there is no need to exchange
encryption/decryption algorithm is the computation of (Me secret keys beforehand. A problem of public-key cryptography
mod N) where M is the text , (e,N) is the key[4] and this paper is the mapping of public keys to a particular person. If
examines how this computation could be speeded up drawing someone wants to send an encrypted message to Alice, he has
up on the repeated modulus. to ensure that the public key he uses really was published by
Alice. If an attacker succeeds in replacing the public key of
A. Problem Analysis and Theoretical Alice by his own, then the attacker can decrypt all messages
If Alice wants to send messages to Bob, which are encrypted which were intended for Alice. In practice, asymmetric and
with a cryptosystem, Alice needs a key e for encryption and symmetric cryptography were often mixed because
Bob the associated key d for decryption. If in the cryptosystem asymmetric cryptography is too slow for bulk encryption.
the encryption key e is equal to the appropriate decryption key Therefore, asymmetric cryptography is used for generation
d or d can be easily computed from e, we speak of a and verification of digital signatures and key establishment.
Symmetric cryptography is used for bulk encryption.

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)

N=p·q (1) Because p and q are different prime numbers, we achieve

K =(p-1).(q-1) (2) (Me)d =M mod N. (11)

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.

C = Me mod N. (5) F. The Selection of e


The exponent e should be chosen in such a manner that the
where C is the cipher-text. encryption is efficient, without decreasing the security. The

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).

G. The Selection of d Steps:


The decryption exponent d has to be greater than 292, • First do X2/Y0 (divide) to get Z1 as quotient and C1
otherwise the RSA cryptosystem can be broken. as remainder.
• Call Procedure ADJUST (Z1, C1, X1, Y1, Y0).
III. ALGORITHM TO COMPUTE MODULUS • Now take the next dividend as
We will make here a quick revision for two algorithms to K = (C1 * 10 + X1) - (Y1 * Z1) (15)
determine the quotient and the remainder (or the modulus).
The first is the classical algorithm with repeated operation • Do K/Y0(divide) to get Z0 as quotient and C0 as
multiplication /subtraction for dividend by divisor. The other Remainder,
algorithm is based on the Vedic division algorithm of ancient
Indian mathematics. After, we will introduce our algorithm
• Call procedure ADJUST (Z0, C0, X0, Y1, Y0).
with a brief comparison to other methods. Now our required remainder,
A. Integer Division Classical Algorithm RD = (C0 * 10 + X0) - (Y1 * Z1) (16)
In general, we divide a number A with 2n bit by a number N
with n bit. we get from this operation a quotient Q and And hence the Quotient
remainder R. we can write:
Qt = Z1.Z0 (17)
A=Q*N+R (13)
The algorithm can be generalized for N digit/bit by N digit/bit
The remainder could be written by notation as:
but for numbers with great length, the number of equation will
(14) be also great.
R = A mod N
IV. IDENTICAL MODULUS ALGORITHM
For example to divide 32 bits dividend by a 6 bits divisor, we Based on the arithmetic properties of modulus, we can
use the same approach as multiplication where we make use of develop an algorithm to simplify the operations when
positional representation of binary integers to avoid simple encrypting a plain text in order to get a cipher text. Let A, B, C
repeated subtraction algorithm. But in higher valued logic, the and D are natural numbers then,
matter will be different and much difficult.
(A*B*C*D mod N) = [(A mod N) * (B mod N) * (C mod N) *
B. Unsigned Binary Division Algorithm (D mod N) * …..] mod N
To apply the division operation, we need one iteration per bit (18)
by subtracting the divisor from a partial remainder and test it This reduces the intermediate results to modulo N and makes
to see if less than 0. the calculation practical.

• 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

Where, (N = p . q) and e<N


C. Vedic Division Algorithm Then M is multiplied by itself e times. Applying the equation
The Division architecture takes N bits of dividend and N bits (18),
of divisor to generate the quotient and the remainder. The

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.

You might also like