Anda di halaman 1dari 4

International Journal of Emerging Technology and Advanced Engineering

Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 2, Issue 12, December 2012)

A Simple Cryptography Algorithm for Microcontroller


Zainul Abidin1, Adharul Muttaqin2
Department of Electrical Engineering, Faculty of Engineering, University of Brawijaya, Malang, Indonesia
Abstract Data security is very important in data transmission. There are many methods to make the data to be secure. One of the methods is by using cryptography algorithm to encrypt the data. Using the cryptography algorithm, no one can take the true information except the one with right key and decryption method. In data security processing, microcontroller can be used as a processor. In this paper, a simple cryptography algorithm for microcontroller was proposed for data (text) encryption and decryption. This algorithm can encrypt text (8 characters) with 8 key characters. The encrypted text (chipertext) can be decrypted to the original text (plaintext) by using the same key entered in encryption process. Experiment results show that the algorithm can work properly with error percentage of 0%. Keywords- data security, microcontroller, cryptography

Start Initialization of string Pi, char key, new_key, text, text_encr, data_receiv, data_decr

Receive data

No

Yes

Enter text

Enter key

Scan keypad

Scan keypad

Encryption

Decryption

Key expansion Display key and new_key (expanded key)

Display text_encr Display data_decr Send text

I.

INTRODUCTION

Cryptography is the art and science of keeping secure messages (Schneier, 1995). Someone who wants to take the messages (plaintext) is called as attacker or eavesdropper. Usually, attacker has complete access to a communication line between sender and receiver. Attacking of internet and telephone network is often happened. In some cases, serial communication using microcontroller has difficulty of cryptography algorithm. The algorithm must be simple and strong. Microcontroller has limitation of processing memory and mathematics function. A simple cryptography algorithm for microcontroller to support serial communication of text transmission was proposed to solve the problems. II. MATERIALS AND METHOD

End

Figure 1. Flowchart of Main Program

The key must be computed first before encryption and decryption process. The key expansion process is shown in flowchart of Figure 2 with detail explanation as mention below: 1. Initialize Pi with static string which consists of 16 hexadecimal digits. There are 20 string Pi in this process as mention below: P1 =0x243f6a882ffd72db P11=0xbe5466cf636920d8 P2 =0x85a308d3d01adfb7 P12=0x34e90c6c71574e69 P3 =0x13198a2eb8e1afed P13=0xc0ac29b7a458fea3 P4 =0x037073446a267e96 P14=0xc97c50ddf4933d7e P5 =0xa4093822ba7c9045 P15=0x3f84d5b50d95748f P6 =0x299f31d0f12c7f99 P16=0xb5470917728eb658 P7 =0x082efa9824a19947 P17=0x9216d5d9718bcd58 P8 =0xec4e6c89 b3916cf7 P18=0x8979fb1b82154aee P9 =0x452821e60801f2e2 P19=0xd1310ba67b54a41d P10=0x38d01377858efc16 P20=0x98dfb5acc25a59b5 2. Key (entered by user) which is 8 characters will be changed into 16 hexadecimal digits based on ASCII

A. Main Program Main program consists of sub functions, such as scan keypad, key expansion, encryption, decryption. The main program flowchart is shown in Figure 1. Process of sending and receiving is described in the flowchart. The process indicates text transmission using serial communication based on microcontroller. B. Key Expansion In this algorithm, key expansion is a process of randomization the original key to new key.

672

International Journal of Emerging Technology and Advanced Engineering


Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 2, Issue 12, December 2012) 3. XOR operation of Pi with 64 bits key must be executed, do XOR P2 with 64 bits first XOR result, do similar process until P20, and then 64 bits new key will be obtained. The new key will be saved into New_key and user can do encryption or decryption.
Start
no

Start Initialization of Int i, i=1

4.

i=21

yes

text^=new_key

text_encr=text

Initialization of Int i
text+=0x0101010101010101

For (i=1,i<21,i++) yes

no

i++

key^=Pi

New_key=key

End

Figure 3. Flowchart of Encryption

2. 3.
End

4.
Figure 2. Flowchart of Key Expansion

A. Encryption Encryption process consists of 20 simple function iterations. Each iteration consists of XOR operations and additions of 64 bits. The encryption process is shown in flowchart of Figure 3 with detail explanation as mention below: 1. Text message (8 characters) is changed to hexadecimal. 2. Do XOR operation for the hexadecimal with new key and then add to 0x0101010101010101. 3. Do similar process for the result until 20th iteration. 4. Chipertext is obtained and ready to be secure. C. Decryption Decryption process is the opposite of ecryption process that consists of XOR operations and subtractions. The decryption process is shown in flowchart of Figure 4 with detail explanation as mention below: 1. Received data (chipertext) is converted to hexadecimal and the subtracted by 0x0101010101010101

Then, do XOR operation with new key Do similar process for the result until 20th iteration and then hexadecimal of plaintext is obtained The hexadecimal is converted to text message that can be read by user who have right key and suitable decryption algorithm.

Figure 4. Flowchart of Decryption

673

International Journal of Emerging Technology and Advanced Engineering


Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 2, Issue 12, December 2012) D. Data Format Data format in this cryptography algorithm is designed uniquely. This can make easier to receive and recognize the encrypted text. There is a process for recognize the first character. The recognition determines start sign and end sign of text to decrease error probability. The data format is shown in Figure 6.

Head Dot (.)

Text/message

Tail
(a)

xxxxxxxx
Figure 6. Data Format

There are 3 parts in the data format. Head : signed by character . which is placed at first slot. It defines that next character is first text character. Text/message : consists of 8 characters (16 hexadecimal digits) Tail : signed by character @ which is placed at last slot. It defines that the last text character is before this character. III. RESULTS AND D ISCUSSIONS

(b) Fig. 7 Experiment results (a) Encryption result, (b) Decryption result with true key

Experiment of this cryptography algorithm proves performance of the implementation. Experiment is based on condition explained below. A. Experiment of Encryption Experiment data is obtained by observe ecryption process result and decryption process result. Text before encrypted must be similar with the one after decrypted. For example, the experiment uses 8 characters of ZAINUL A as the key. T here is text message that consists of SRP SBH!. The text must be typed appropriate to data format rule (Fig. 6). The text and ecrypted text can be seen in Fig 7 (a). It seems that almost all characters are converted to strange characters. B. Experiment of Decryption by Using True Key Experiment result of true key implementation shows in LCD. Figure 7(b) is the LCD appearance that consists of encrypted text (1st line) and decryption result (2nd line). Comparing Figure 7(a) and 7(b), it can be concluded that encryption and decryption process can work properly with suitable key (ZAINUL A).

C. Experiment of Decryption by Using False Key Experiment result of false key implementation also shows in LCD. Figure 8 is the LCD appearance that consists of encrypted text (1st line) and decryption result (2nd line). Comparing Figure 7(a) and 8, it can be concluded that encryption and decryption process can not work properly with unsuitable key. The decryption result is not similar with the true text/message. People who do not know the right key and the implemented algorithm will not get the true information.

Fig. 8 Decryption result with false key

674

International Journal of Emerging Technology and Advanced Engineering


Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 2, Issue 12, December 2012)
TABLE 1 EXPERIMENT OF SIMPLE CRYPTOGRAPHY IMPLEMENTATION

Experiment 1 2 3 4 5 6 7 8 9 10

True decrypted text 8 8 8 8 8 8 8 8 8 8

% error 0 0 0 0 0 0 0 0 0 0

In the future, advanced cryptography algorithm for longer text will be developed for text transmission and compared to other cryptography algorithms, such as blowfish, RAS, and DES. REFERENCES
[1 ] Atmel, 1997, Flash Microcontroller: Architectural Overview, Atmel Inc. (http://www.atmel.com), USA. [2 ] Helfrick, D. Albert., and Cooper, W.D., 1992. Electronic Instrumentation and Measurement Techniques. Prentice Hall of India Limited, New Delhi. [3 ] Muttaqin, A. and Abidin, Z., 2008. Implementasi Kriptografi Transmisi Teks Menggunakan Mikrokontroler. EECCIS, vol. II, no. 1: 17-21. [4 ] Schneier, B., 1995. Applied Cryptography-Protocols, Algorithms, and Source Code in C, 2nd. New York. John Wiley & Son.

Experiments of cryptography implementation are executed 10 times. The result is shown in Table 1. Table 1 indicates that the simple cryptography algorithm can work properly in microcontroller with error percentage of 0%. IV. CONCLUSIONS AND F UTURE W ORK

In this paper, a simple cryptography algorithm for microcontroller has been proposed and examined. The proposed algorithm consists of hexadecimal-character conversion, XOR operation, addition, and subtraction. The proposed algorithm has been successfully implemented to microcontroller. The experiment results show that it can work properly with error percentage of 0%.

675

Anda mungkin juga menyukai