Uploaded by sri324110

iced.2014.7015781

advertisement
QG,QWHUQDWLRQDO&RQIHUHQFHRQ(OHFWURQLF'HVLJQ ,&(' $XJXVW3HQDQJ0DOD\VLD
An Implementation of Caesar Cipher and XOR
Encryption Technique in a Secure Wireless
Communication
Lim Chong Han
Nor Muzlifah Mahyuddin
School of Electrical and Electronic Engineering,
Engineering Campus, Universiti Sains Malaysia
14300 Nibong Tebal, Penang, Malaysia
henrylim_1990@hotmail.com
School of Electrical and Electronic Engineering,
Engineering Campus, Universiti Sains Malaysia
14300 Nibong Tebal, Penang, Malaysia
ee.mnmuzlifah@eng.usm.my
Abstract—Due to the openness of the wireless
communication, security aspect of data transmission plays
important role in respect to the effective measure of the
transmission, where cryptography method is often
implemented to sustain the security of the communication. A
secure communication program is proposed in this paper
which involves three design stages, i.e. the encryption
technique, serial-transmission and encoding technique. The
encryption technique adopts a combination of Caesar Cipher
and XOR encryptions, and programmed using C++.
Subsequently, few possible cases have been tested to verify the
strength of the security program, which indicates an
improvement in security of data transmission in wireless
medium without affecting the processing time.
security goals are accomplished [2]. In cryptography, the
process to transcribe information into different form so that
only authorized parties can read it [3] is called encryption
while the process to convert unreadable form back to original
message is called decryption.
Symmetric Cryptography Algorithm which is also known
as Secret Key Encryption uses a secret key to change the
content in a message text. There are two types of Symmetric
Encryption technique used in this work, which are Caesar
Cipher and XOR encryption. The Caesar Cipher encryption
works by replacing each letter in the plaintext with another
letter with a fixed position apart by a numerical value which
is used as a secret key [4]. The XOR encryption uses bitwise
exclusive OR logic gate to perform the work. Sender and
recipient can encrypt and decrypt message using secret key
that only known by both of them. Both Caesar Cipher and
XOR encryption are used in this program because they are
simple while this reduce the complexity of the
implementation.
Keywords—encryption; serial port; secure communication;
cryptography; Caesar Cipher
I. INTRODUCTION
Currently, wireless technology is widely used in much
daily application for example remote control, mobile devices
and internet. It has almost replacing the wired
communication and has become increasingly convenient.
Due to the increasing of usage in wireless communication, it
has become less secure and exposes to serious security
threats among communication networks. Various
information will be easily eavesdropped by adversaries (third
party) therefore secure communication are needed to avoid
hacking from other parties. Secure communication has
played a very important role in avoiding this matter, and
several systems have been introduced or applied, even as
early as in World War II [1].
The encryption technique is implemented using the 433
MHz RF modules which are cheaper and simple compares to
other wireless modules. Hence, it is chosen in this work to
provide wireless data transmission. The data transmission
through USB is in serial RS232 protocol while the RF
module incorporates the UART-TTL protocol. Meanwhile
the USB-to-UART converter [5] is used to shift level from
RS232 to UART-TTL protocol [6]. Therefore, a serial port
program is built for sending or receiving data between USB
and RF module.
For the wireless medium, it is an open area transmission
and no wire is required. The signal or data travels in a form
of electromagnetic wave through the air. There are many
unknown data and noise present in the air. In addition, these
RF modules used in this work are exposed to more noise
compared to other high end RF module [7]. Hence, data
transmission through the air is prone to error. Therefore,
accurate data is difficult to receive from sender. To
Fundamentally,
secure
communication
is
a
communication between two parties with no third parties to
listen and join in. There are many studies in secure
communication field, which involves cryptography.
Cryptography is a well-known method and is the study and
practice in secure communication with the present of
adversaries. Cryptography is the algorithm method in which
‹,(((
QG,QWHUQDWLRQDO&RQIHUHQFHRQ(OHFWURQLF'HVLJQ ,&(' $XJXVW3HQDQJ0DOD\VLD
overcome this problem, encoding technique is also needed in
wireless transmission.
II.
Another XOR operation is added to (6) to increase the
security level by XOR it with numerical value, N.
Therefore, (6) becomes,
METHODOLOGY
C1 = M ‫( ٺ‬K X 2) ‫ٺ‬N
A. Encryption design technique
First, the encryption technique designed for both
encryption and decryption process in the secure
communication program. The idea is to combine both Caesar
cipher and XOR encryption. Therefore the data goes through
twice of the encryption process; starts with the XOR
encryption and then follows by Caesar cipher. For the XOR
encryption part, the letter in a plaintext is XOR bitwise 1 by
1 with the 8 bit secret key to form first encrypted text. Then
each letter in the first encrypted text is shifted to a fixed
position separated by a numerical value. Assume that,
The numerical value, N keeps changing from the first
letter to last letter in the plaintext. N starts the counting at
zero at first character in plaintext, then increasing by 1 for
each character until the end of plaintext. Therefore this
indicates that C1 is randomly encrypted.
Equation (7) still can be improved by using Caesar
cipher. This is the final modification. The C1 from (7) is
shifted by a numerical value N which the N is same as in
(7). The final ciphertext C2 based on (3) becomes,
M = Plaintext
K = Secret key
N = Numerical value
C1 = First encrypted text
C2 = Final Ciphertext
C2 = [M ‫( ٺ‬K X 2) ‫ ٺ‬N] + N
C1 = M ‫ ٺ‬K
(1)
C2 = C1 + N
(2)
C = [M ‫(( ٺ‬K X 2) %255) ‫( ٺ‬N %255)] + N
(3)
M = (C – N) ‫(( ٺ‬K X 2) %255) ‫( ٺ‬N %255)
(5)
B. Serial port communication program
There is no direct connection from the RF module to the
computer. The RF module used TTL level UART protocol
while USB serial port is RS232 protocol and they are both
different in voltage and polarity level. Therefore, there is a
need to shift level from RS232 data to TTL level UART
protocol or vice versa by using a USB-to-UART converter.
When connect USB-to-UART to USB port, it will appear as
a Virtual COM port which is also called Virtual Serial Port.
The USB-to-UART collects the serial RS232 data and
converts it into TTL level UART format, then sends it to RF
module for wireless transmission.
The above example is the basic idea of the combined
encryption technique. It should be enhanced to a more
powerful data encryption.
From the example, we can add more calculation into the
technique in order to achieve high security encryption. The
enhanced technique from (1) can be done by multiply the
secret key K by 2 which becomes,
C1 = M ‫( ٺ‬K X 2)
(9)
Where,
C = Ciphertext
M = Plaintext
K = Secret Key
N = Numerical value (Increasing by 1 for each character)
(4)
The C1 then is shifted to right by the adding a numerical
value, N which is 5 (in binary is “00000101”) into C1.
C2 = C1 + 00000101 = 00111110 (in hex 3EH)
(8)
And the decryption equation that inversed of the encryption
equation will be,
For example, let’s say plaintext M has an “A” letter
which is expressed in binary “01000001” and a binary secret
key K “01111000”, the first encrypted text is
C1 = 01000001 ‫ ٺ‬01111000 = 00111001 (in hex 39H)
(7)
Some components in C2 are then modulo by 255 to
ensure that the result will never exceed 255. This is because
the American Standard Code for Information Interchange
(ASCII) character is available in 8 bits and has 255
characters only.
In conclusion, the final equation of combined technique
is,
Therefore, the overall equation is,
C2 = (M ‫ ٺ‬K) + N
(7)
(6)
QG,QWHUQDWLRQDO&RQIHUHQFHRQ(OHFWURQLF'HVLJQ ,&(' $XJXVW3HQDQJ0DOD\VLD
World!”. This showed that 100% efficiency of this
encryption technique.
For this encryption technique, the difficult part is the
increment of numerical value N. The N value will increased
by 1 with each letter. Therefore, if there is a repeating
character in the plaintext, there is a low possibility to get the
same repeating letter in the ciphertext. For example there is a
repeating character in the plaintext M which is “ll”, it would
not get the same ciphertext character as shown in Table 1.
B. Designed encoding technique
There are 10 different sizes of message samples used to
evaluate the secure communication program with and
without the encoding method. Table 2 shows the result for
secure communication program with and without encoding
method in different message sizes. Every message sent from
the sender is successfully received at the receiver. However
in program without encoding method, there are errors exist in
every message sample. Therefore, this result indicates that
there is 100% possibility to get error in any message size
after decryption process without the encoding method.
Subsequently, the result for secure communication program
with encoding method for different message size indicates
there is no error detected after implementing the encoding
technique. Therefore, there is no any data redundancy in
message.
Fig. 1. An illustration of data flow from computer to RF module.
Before creating a serial port communication program, a
GUI is created. The GUI is created using C++ windows form
application in Visual Studio 2010. Fig. 1 describes the flow
of data from computer to RF module. The left hand side
shows the sending part of the program where message from
program is sent to USB port and transmit it serially to USBto-UART. In this stage, the serial RS232 data is converted
into TTL level UART and is sent to RF transmitter module
for transmission to wireless medium.
C. Encoding pattern design
In overcoming the problem of RF module in wireless
transmission, an encoding technique is designed in order to
avoid receiving any unknown data. At the sender, before
sending a message, three numbers “111” is inserted before
the first letter of the message, and then an “A” is added after
the last letter of the message. For example, a message
“Hello”, after encoded, it will become “111HelloA”.
TABLE I.
At the receiver, the same pattern is used to decode the
received message. Let say “???&&$??111HelloA” is
received at the RF receiver; all the unknown data needs to
be eliminated from the received message to recover the
original message. In receiver part, every time when a
message is received, it will eliminate the unknown letter one
by one until it detects three continuous “1”, and then it will
detect whether there is an “A” at the last letter. If it is an
“A” at the last letter, the letter between “111” and “A” are
the exact message from the sender, whereas the whole
message will be eliminated and a new data will be
transmitted, if “A” is not detected at the last coding.
III. RESULTS AND DISCUSSION
A. Designed encryption technique
Table 1 shows the result of a plaintext encryption M,
“Hello World!” to a ciphertext C “ŖòáóƒňºƒÆķ¿Õ”. It is
clear that each of the character in the plaintext M is
encrypted one by one into a special character. Table 1 also
shows the result of decryption of ciphertext C
“ŖòáóƒňºƒÆķ¿Õ” to recover back the plaintext M “Hello
ENCRYPTION AND DECRYPTION RESULT
Encryption
Plain
text
M
Plain
text in
decimal
Secret
key, K
H
e
l
l
o
<space>
W
o
r
l
d
!
72
101
108
108
111
32
87
111
114
108
100
33
Cipher
text, C
Cipher
text in
decimal
Secret
key,
K
Ŗ
ò
á
ó
ƒ
ň
º
ƒ
Æ
ķ
¿
Õ
184
149
160
162
159
218
167
159
146
158
168
229
x
x
x
x
x
x
x
x
x
x
x
x
N
value
Cipher
text,
C
Cipher
text in
decimal
Ŗ
ò
á
ó
ƒ
ň
º
ƒ
Æ
ķ
¿
Õ
184
149
160
162
159
218
167
159
146
158
168
229
N
value
Plain
text, M
Plain
text in
decimal
0
1
2
3
4
5
6
7
8
9
10
11
H
e
l
l
o
<space>
W
o
r
l
d
!
72
101
108
108
111
32
87
111
114
108
100
33
x
0
x
1
x
2
x
3
x
4
x
5
x
6
x
7
x
8
x
9
x
10
x
11
Decryption
QG,QWHUQDWLRQDO&RQIHUHQFHRQ(OHFWURQLF'HVLJQ ,&(' $XJXVW3HQDQJ0DOD\VLD
TABLE II.
Message
Size
100
150
200
250
300
350
400
450
500
550
SECURE COMMUNICATION PROGRAM WTHOUT ENCODING
METHOD IN DIFFERENT MESSAGE SIZES
Are data
received at
receiver?
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Without encoding
Error exists after
decryption?
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
With encoding
Error exists after
decryption?
No
No
No
No
No
No
No
No
No
No
C. Analysis for secure communication program
The secure communication program is tested in different
baud rate which are 1200, 2400, 4800 and 9600. Table 3
shows the data transmission in different baud rate. For 4800
and 9600 baud rates, data fails to transmit because the baud
rate is too high for the data transmission. It is also affected
by hardware limitation. Therefore, the data is lost and
receive error at the receiver.
Fig. 2. Duration of data transmission in different baud rate.
In addition, the efficiency of data transmission is also
investigated. From Error! Reference source not found.,
messages with length of 100 is transmitted 10 times in
wireless medium to investigate the efficiency of data
transmission of this secure communication program. There
are five errors occurrence during this data transmission. The
error in data received may cause by data loss, interference
and redundant present in wireless transmission medium.
Therefore, the efficiency of data transmission of this secure
communication program is 50%.
The maximum number of letter allowed in a message in
different baud rate is also investigated. There are two baud
rate used in this investigation which is 1200 and 2400. Both
baud rates have the same maximum number of letters that is
allowed in a message which is 500 letters. If the maximum
number of letter exceeds 500 letters, the program will show
error. It is due to the software implementation which there
can be only 500 byte for data transmission.
TABLE III.
SUCCESS OF DATA TRANSMISSION IN DIFFERENT BAUD
RATE
Baud rate
1200
2400
4800
9600
Success of Data Transmission
Yes
Yes
No
No
On the other hand, the different baud rate affects the data
transmission duration. Fig. 2 shows the duration of data
transmission in different baud rate. Different length of
message sample is used in this test. From Error! Reference
source not found., the higher the baud rates the faster the
duration of data transmission.
Fig. 3. Efficiency of data transmission in wireless medium.
Besides that, the data transmission time of designed
encryption technique is compared to existing technique
which are XOR encryption and Caesar Cipher encryption.
This is to find out the processing time of each technique
used. Assumed that the data transmission of same size
message in medium is same for all three techniques. From
Fig. 4, the lower transmission time the faster the processing
time of the technique. By comparing three of them, XOR
encryption technique has the fastest processing time. While
QG,QWHUQDWLRQDO&RQIHUHQFHRQ(OHFWURQLF'HVLJQ ,&(' $XJXVW3HQDQJ0DOD\VLD
Known Caesar Cipher or XOR encryption technique in
encryption formula: There is a possibility that the attacker
detect the used of either the Caesar cipher or XOR
encryption technique in the encryption formula. However,
the designed encryption technique uses both Caesar Cipher
and XOR encryption method. Therefore, even if the secret
key is known, the original message will never be recovered
if only either Caesar Cipher or XOR encryption technique in
designed encryption formula is known.
for both Caesar Cipher and designed encryption technique
are close to each other. Although the designed encryption
technique is combination of both XOR and Caesar Cipher
encryption technique, but the processing time is not
increased. Therefore, the processing time is improved.
Known encryption technique: There is a possibility the
attackers discover the designed encryption technique.
However, the original message never be recovered without
the shared secret key.
Fig. 5 shows the result of recovered plaintext where the
encryption technique is known to the attackers but without
the secret key. Sender used “x” as the secret key, but the
receiver used “y” to decrypt the ciphertext. Besides that, the
encoding technique is also important if entire encryption
technique is known. The used of encoding technique must
be known by both sender and receiver so that they are
synchronized to each other to obtain the exact ciphertext.
Fig. 4. Comparison of data transmission time of designed encryption
technique to existing techniques.
D. Strength of the secure communication program
The level of security for this secure communication
program depends on the designed encryption technique and
encoding technique. Secure communication program without
the designed encoding method to decode the received
ciphertext, resulting in the recipient unable to retrieve the
original message from sender.
Subsequently, the designed encryption technique also
affects the strength of the secure communication program.
The strength of the secure communication program is tested
by varying the decryption technique at the receiver. There is
a possibility of attack on this secure communication
program, in which this work has identified, which is when
the attacker is aware of the secret key, the Caesar cipher used
in encryption formula, the XOR encryption technique used in
encryption formula and finally, the designed encryption
formula. Subsequently, this work will also show that with
these known possible attacks, the attempt will result in
failure, as the system is designed to preserve one aspect of
the mechanism with another.
Fig. 5. Result of recovered plaintext where the encryption technique is
known but without the secret key.
Therefore these analyses indicate the efficiency of this
system in terms of preserving its secure communication
mechanism. By incorporating the secret key, the Caesar
cipher and the XOR encryption technique into the system,
hackers or third party will have a difficult time in interfering
with the system.
IV. CONCLUSION
Known Secret Key: For this possible attack, the attackers
only know of the secret key used for the secure
communication program between two parties. However, the
pattern of designed encryption formula is not known by
them, thus the plaintext cannot be recovered. Although the
secret key is the same for encryption and decryption
process, the original message cannot be recovered due to the
wrong decryption formula used at the receiver.
The encryption technique designed for this work that
combines two present techniques which are Caesar Cipher
and XOR encryption have proven to provide a secure
wireless communication. The data processing time is not
affected by a combination of both techniques. Subsequently,
the designed encoding technique for wireless transmission
works well in elimination of noise and redundancy and gives
QG,QWHUQDWLRQDO&RQIHUHQFHRQ(OHFWURQLF'HVLJQ ,&(' $XJXVW3HQDQJ0DOD\VLD
a good synchronization between sender and receiver. In
addition, few possible attacks have been taken account and
analyzed as to verify the strength of the security program
incorporating these encryption techniques.
ACKNOWLEDGMENT
This work was supported in part by Research Creativity
and Management Office (RCMO), Universiti Sains Malaysia
under Fund for Short Term Grant.
REFERENCES
[1]
[2]
[3]
[4]
[5]
[6]
[7]
Campbell Jr, J.P. and R.A. Dean, A History of Voice Coding: Insights
Drawn from the Career of One of the Earliest Practitioners of the Art
of Speech Coding. Digital Signal Processing, 1993. 3(3): p. 220-224.
St Denis, T. and S. Johnson, Chapter 1 - Introduction, in
Cryptography for Developers. 2006, Syngress: Burlington. p. 1-19.
Overill, R.E., Review: Foundations of Cryptography, Volume II:
Basic Applications. Journal of Logic and Computation, 2005. 15(3):
p. 405-405.
Dey, S., J. Nath, and A. Nath, An Integrated Symmetric Key
Cryptographic Method–Amalgamation of TTJSA Algorithm,
Advanced Caesar Cipher Algorithm, Bit Rotation and Reversal
Method: SJA Algorithm. International Journal of Modern Education
and Computer Science (IJMECS), 2012. 4(5): p. 1.
Lim, S. USB to UART Converter, UC00A. 2010; Available from:
http://tutorial.cytron.com.my/2012/05/16/uc00a-usb-to-uartconverter/.
Kong, W. UART – Universal Asynchronous Receiver and
Transmitter.
2010;
Available
from:
http://tutorial.cytron.com.my/2012/02/16/uart-universalasynchronous-receiver-and-transmitter/.
Weng, K.W. Low Cost Wireless UART. 2010; Available from:
http://tutorial.cytron.com.my/2012/04/05/low-cost-wireless-uart
Download