Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

2013 Palestinian International Conference on Information and Communication Technology

A Novel Cryptography Method Based on Image for Key


Generation
Tawfiq S. Barhoom Zakaria M. Abusilmiyeh
IT. Department, Islamic University of Gaza IT. Department, Gaza Community/Training College,
tbarhoom@iugaza.edu.ps UNRWA
zsilmiyeh@gtc.edu.ps

Abstract—This study proposes a method for encrypting the cryptography is a powerful tool to achieve information
sender’s messages using new algorithm with a secret key which security, the security of cryptosystems relies on the fact that
is generated from using color image and the difference in the cryptographic keys are secret and known only to the
LSB of the image pixels. This key will be used for encrypting legitimate user [9]. In secure communication, key
and decrypting the messages which are transmitted between
generation phase has many challenges and this problem can
two sides. The length of the key varies according to the size of
be solved if the sender and the receiver share the key in any
the message as it varies in every session according to the
session type. It is a reliable and flexible way to generate the key
other form or if they generate the keys readily during
to secure the information which is transferred through the encryption and decryption separately, thus, the concept of
networks and it is easy to implement. This method ensures the generating the key from an image came to the role [1]. The
prevention of guesses or breaking the key and provides a more main objective of this study is to create a new algorithm to
secure way for information encryption. secure connection by using the content of an image. The
algorithm uses a color RGB image to generate a key which
Keywords: Cryptography, Cryptography key, RGB image, LSB, will be used in the encryption and decryption operations.
image key. Our algorithm is distinguished from the other ones as the
generated key length varies according to the size of the
1. Introduction message and the session type. This makes the encryption
The cryptography has been proposed to ensure the algorithm more powerful. The proposed algorithm is simple
confidentiality and authenticity of the message. The to implement and easy to use.
encryption key must be long. Yet, it is difficult to remember The remaining parts of this paper are organized as follows:
it and even storing the key in a database or in a file may be In section 3, we described the materials needed for the
insecure. In addition the protection of the confidentiality of proposed approach. We described the details of the
encryption keys is one of the important issues to be dealt proposed approach in section 4. In section 5, we provided
with. This issue can be efficiently solved through generating and analyzed the experimental results. In section 7, we
the key before starting the process of encryption and concluded the paper.
decryption, rather than storing it. Here we will use an image
to generate the key. The main objective of this study is to 2. Literature review
increase security in communication by encrypting the Santhi et al. [1], have proposed a novel algorithm for key
information using a key that is created through using an generation using image features. This study uses the Gray
image. Cryptography presents various methods for taking Level Co-occurrence matrix of an image to extract the Gray
legible, readable data, and transforming it into unreadable Level Co-occurrence properties of the image. A 56-bit sub-
data for the purpose of secure transmission, and then using a key is generated from the extracted Gray Level Co-
key to transform it back into readable data when it reaches occurrence properties. Lifang et al. [3], have proposed a
its destination [8]. Cryptography is considered to be one of novel method for key generation using face features.
the fundamental building blocks of computer security [4]. Seshadriand Trivedi [4], have proposed a method for
The need of reliable and effective security mechanisms to generation of cryptographic key which is generated using
protect information systems is increasing due to the rising biometrics. They used fingerprint patterns, which are stable
magnitude of identity theft in our society. Although throughout person’s lifetime. The key is derived directly

978-0-7695-4984-2/13 $26.00 © 2013 IEEE 71


DOI 10.1109/PICICT.2013.22
ffrom the biom metric data and is not stored in the databaase. has threee channels: R
Red, green, andd blue. If the R RGB image
WWong et al.[5],, have showed that the user’ss image from the t is 24-biit, each channeel has 8 bits, foor red, green, aand blue, in
wwebcam can bee a good sourcce of randomcrryptographic keey. other w
words, the imagge is composedd of three imagges (one for
TThe least significant bit of thhe ambienceweebcam image has h each chhannel), where each image caan store discrette pixels
bbeen statisticallly proven to bee random. Murraliand Palraj [6],
hhave proposed a new metho od for generatiing True rando om
nnumbers based d on image wh hich generates 256 bits key or
hhigher for key exchange algo orithm. Tanmay et al. [7], haave
ddeveloped a meethod for key generation
g baseed on sessions. In
ggeneral, the keey generated by b the cryptog graphic metho ods
mmust be remem mbered and they y can be easily cracked.

OOur proposed algorithm


a diffeers from the oth
her ones; the key
k
ddoes not havee a fixed len ngth. The len ngth of the keyk
ggenerated by our
o algorithm varies
v accordinng to the size of
thhe message ass it varies in every
e session according to the
t
ssession type.
3. Mateerials and Methods
M
OOur scenario iss that the two sides need to co
ommunicate with
w Figure 11: Sender side block diagram
eeach other seecurely throug gh the local network or the t
innternet. They y need to en nsure the con nfidentiality and
a
aauthenticity off the messagess transmitted between
b them by
uusing cryptogrraphy algorithm m. The proposed algorithm is
ddescribed for th he sender and receiver respeectively in Figu
ure
1 and 2. Furth hermore, the algorithm is diviided up into foour
sstages which arre given in Tab ble 1 and are described
d in mo
ore
ddetails in sectio
on 4.
T
Table 1: Phasess in the entire process
p
P
Phases Process
P
P
Phase 1 Database
D creattion
P
Phase 2 Key
K generation n
P
Phase 3 Encryption
E
P
Phase 4 Decryption
D

BBinaries messsage: It converts the values of the messaage


Figure 2: Receiver side bblock diagram
ccharacters whicch are in decim
mal to binary vaalues. The binaary
vvalues are storeed in a multidimensional arrray as Data[N,N]
wwhere the numb ber of messagee bits will be less than or equual
too N*N. Assum ming that we use a messagee “Java 140” th hat
ccontains 8 charracters in whicch each charactter is representted
bby 8 bits, the best
b value of N to store the binary
b bits of the
t
mmessage wheree N*N <=64 is 8 thus, thee N=8. Figuree 3
ddescribes the array Data[8,8 8] content aftter applying thet
mmessage binary y operation. Figure 3: Binaryy Array of the M
Message “Java 1440“.
LLSB of RGB: Color digital images
i are maade of pixels, and
a
ppixels are maade of combin nations of prrimary colors, a with coonventional briightness intenssities between 0 and 255
cchannel is maade of just on ne of these prrimary colors,, a [2]. In this paper we used one channnel of RGB color image
ggreyscale imag ge has just onee channel, but the RGB imaage either rred, blue or greeen. So we havve to choose onne of these

72
channels where each pixel should donate only one bit, called 7. Scan the LSB Img[x,y] to find two neighbor values
the Least Significant Bit (LSB). where the absolute difference between them is one.
Key: A cryptographic key is the information generated to 8. Key[i,c] = First LSB value.
encrypt and decrypt the message. At the encryption side, the 9. Key[i,c+1] = Second LSB value.
cipher text is generated from the plain text by using the key. 10. End loop
At the decryption side the exact reverse is done to get back 11. End loop
the plain text [1].In this paper, the key represented as binary
Phase 3: Encryption
array Key [N, K] where k value is even and between 2 and
In this section, we present the pseudo code for the
N. For example, when we need to generate the key to
encryption algorithm and the algorithm steps as follows:
encrypt the message we mentioned above “Java 140”, where
the value of N was 8 and if we set the value of K to 6, 1. Get the value of K variable.
accordingly, we need array 8*6 size to store the key bits 2. Read a message to encrypt
(Key [8, 6]). 3. Binaries the message and store the binary data in
array Data[N,N] where message bits <= N*N
4. Proposed Algorithm 4. Generate the key using key generation algorithm
From Figure 1 and 2, we can conclude that both the sender and create Key [N, k].
and receiver before they start to communicate with each 5. Create array EncData [N, N] to store the encrypted
other, they should use the same images database, image data
channel (R, G or B), K value for the key array, and the 6. c=0
session type.This study implemented the key generation as 1 7. Loop i=0 to N-1// for each row in Data
image/session. The session period can be an hour or one /* the elements in the Data array row i comparewith
day. For instance, hourly session uses one image for each twocolumns of Key array start from c */
hour and the daily session uses one image for each day. 8. Loop j=0 to N-1// for each bit in the row i
9. If Data[i,j] = Key[j,c]
Phase 1: Database creation: In this phase, we create a
10. EncData[i,j]=0 // the value in the first column
database of color RGB images which would be used for
11. Else
generating the key for encryption/decryption process. In
12. EncData[i,j]=1 // the value in the second column
case of using hourly session, the database should contain 24
13. End loop
images; otherwise, it should contain 7 images for the daily
14. c=c+2// go to next two columns of Key array.
session. Both the sender and the receiver should use the
15. if c >= K then c=0// return to the first two columns of Key
same database of images (24 or 7 images) as the names of
array
the images should be the same in both sides. 16. End loop
Phase 2: Key Generation: 17. Convert the EncData from binary data to text.
In this section, we present the pseudo code for the key Phase 4: Decryption
generation algorithm and the algorithm steps as follows: In this section, we present the pseudo code for the
decryption algorithm and the algorithm steps as follows:
1. Get the value of K variable and the value of N from
binaries message step. 1. Get the value of K variable.
2. Select color image from the database according to 2. Binaries the encrypted message and store the
the session type and current date or time. binary data in array EncData[N,N]
3. Retrievethe image and create array Img [x, y] as 3. Generate the key using key generation algorithm
LSB of the pixels for one channel (red, green or and create Key [N, k].
blue) where the image has x*y dimension. 4. Create Data[N, N] to store the original data
4. Create array Key [N, k] to represent the encryption 5. c=0
key. 6. Loop i=0 to N-1 /* for each row in Data*/
5. Loop i=0 to N-1 /* for each row in Key*/ /* the elements in the Data array row i compare with two
6. Loop c=0 to k/2-1 step 2//fill array by two each columns of Key array start from c */
step 7. Loop j=0 to N-1 // for each bit in the row i
8. If Encdata[i,j]=0 then

73
9. Data[ii,j]= Key[j,c] /// value from firsst column
10. Else
11. Data[ii,j]= Key[j,c+1]// value from seecond column
12. End looop
13. c=c+2 2// go to next two columns
c of Key arrray.
14. if c >=
= k then c=0// reeturn to the first tw
wo columns of Keyy
array
oop
15. End lo the secret mess
16. Conveert the Data fro
om binary data to text.
5. Expeerimental Results
R Figure 4: The inary array for ge.
AAs we mention ned before, the sender and thee receiver havee to
aagree on many y settings beforre they can co ommunicate withw
eeach other. Bo oth the senderr and receiverr should use the t
ssame images database,
d the same
s color immage channel anda
thhe same valuee for K variablle. In our expeeriment, we haave
ccreated a dataabase of colo or images which contains 24
immages named as 1, 2…24 to o specify the daay hours becau use
wwe used hourly y session. We used red colo or image chann nel
aand K value equal
e to 8. Thee time of imp plementation was
w
001:20:05, so thet image 1.jpg will be chosen
c from the
t
ddatabase for keey generation phase
p to encryypt or decrypt the
t
mmessage text. WeW used the implementation to encrypt the t
mmessage “1Tessting” which has 8 charactters, so the best
cchoice for N to o create a binaary array to sttore the messaage
bbits is 8. Thereefore, we needd array 8*8 to store the binaary
bbits of the messsage and thiss array is Dataa [8, 8] which h is
Figure 5: Key ggeneration phasee and the key arrray.
ddescribed in fiigure 4. As we w described above,
a the imaage
11.jpg has been n chosen for key
k generation where N=8 and a
KK=8. Accordin ng to that, wee need array 8*8 8 to store the t
bbinary bits off the key. Th hus, the key is generated by
sscanning the LSB
L of the red color channell of the image to
ffind the two neeighbor valuess where the absolute differen nce
bbetween them is i one and then n store them inn array key [8, 8]
wwhere the scan nning process is done two by b two. The keyk
ggeneration proccess is describeed in figure 5. After generatiing
thhe key, we im mplemented th he encryption phase which is
ddescribed in figgure 6. We crreated a new array
a to store the
t
eencrypted data EncData[8,8] as the same size of Data arraay.
TThe first row ofo Data array is i processed with
w the first tw wo
ccolumns of key y array as we described
d in figgure 6 where the
t
bbits will be sub
bstituted to 0 or 1 according tot the key bits.. If
thhe Data array bit equals to key
k bit in the first
f column, itt is Figure 6: The encryptioon process.
ssubstituted to 0 else while is substituted to 1. For examp ple,
DData[0,0] is compared
c with
h Key[0,0] an nd Key[0,1], we w
ffound the Daata[0,0]=Key[0 0,0] then EnccData[0,0]=0 in
wwhich 0 represents the colum mn index of thee two columns of and Keey[1,1] and w we found that sso EncData[0,1]=1. This
KKey array. Thee column index x might be 0 or o 1, the next bit comparrison is repeatted for the nexxt bits of the ffirst row of
DData[0,1] is commpared with Data[0,1]=Key[
D [1,1], Key[1,0] for the next
Data arrray. After thaat the operationn is repeated fo
Data roow and next twwo Key columnns and so on too all bits in

74
Data array where the Key array has a specific number of Table 2: Shows the key generated and the encryption for deferent
columns. But when we end up with the last two columns, Messages.
we return back to the first two columns. The result of this
phase was a binary array EncData[8,8] as shown in figure 6 Time Selected Img K Message
then the EncData array is transformed to a text format. 3:08:15 3.jpg 8 Java JDK
Thus, we get the encrypted form of the message “1Testing” Key length 64 bits , 8 bytes
which is “Þtö: Iý.”.
Key "jªf ©jff "
Encrypted " Z¥~ 0 L®"
All algorithms have been implemented using C#
Time Selected Img K Message
programming language. We tested the proposed algorithms
for different messages in different time “different images”. 3:25:05 3.jpg 8 Hi yr. no. is 40
The results of this test are shown in table2. This is Key length 128 bits , 16 bytes
illustrated in figure 7 which describes the operations of the Key "jªf ©jffVV¥Ui ªU "
binary message, generation of the key from an image and "
Encrypted
the encryption of the message using the generated key on Xõäöz Åõ ²äæ{ Ñ«0¼ä¯( Å»0¼ä¯( Å»"
the sender’s side. The encrypted message is sent to the Time Selected Img K Message
receiver by the sender using TCP/IP. The receiver receives 3:30:01 3.jpg 10 Hi yr. no. is 40
the encrypted message and does the reverse operation of the Key length 160 bits , 20 bytes
encryption to decrypt the message. Figure 8 describes the Key " jªf ©jffVV¥Ui ªU¥Zij "
receiver’s side operations decrypting the encrypted message "
Encrypted
è l.Ò|ñ| » ?w bñ2Ƶ Ólw rñ2Ƶ Ó"
to produce the original secret message. Table 2 shows that
Time Selected Img K Message
the length of the key has a positive correlation with the
4:05:07 4.jpg 8 Hi yr. no. is 40
length of the message from the expression key length=N*k.
Key length 128 bits, 16 bytes
Accordingly, the key length varies by the message length, as
the key varies according to the time of transmission. As a Key "©i¦© Vej© ¦¥Zj Y ¦ "
result for each message we have different key. The second Encrypted " âD7BüÂ^$¥D'CòÖk«DnòÂk«Dnò "
message in table 2 has three different encryption forms that Time Selected Img K Message
happen when we change the K value or the time. It is hard 4:35:07 4.jpg 8
Testing by Eng. Zakaria
to guess or to break the key because of these variations. The M. Abusilmiyeh
results show that the proposed method is cheap, simple, Key length 192 bits , 24 bytes
flexible and the key generation has performance O(N). This Key "©i¦© Vej© ¦¥Zj Y ¦ U¦Vf "
prevents the key loss as the users (sender and receiver) don’t " îj ' Wò9 %ì7D [³) Qñ
need to remember their keys. This is also a completely Encrypted ¥9%, C»7 Y¨.ã9DnÔ ò{Â ñk«9DnÔ ò{Â
ñk«9DnÔ ò{Â ñ"
automated way of cryptography. This helps the users store
Time Selected Img K Message
the key securely. They can use an image whenever they
Color digital images are
want to encrypt their messages before sending them to made of pixels, and pixels
5:10:07 5.jpg 8
another side. In general, this is a reliable and effective are made of combinations
method of cryptography. of primary
Key length 256 bits , 32 bytes
6. Conclusion "©¥ V©fUi f ¥U eYii Ui ª ¥ eª©©
Key
The Cryptography provides security to the data which is "
transferred in publicly shared media. When the " : ì »¦ÔÌwþ Ík¼ }Î
§ô Ú{¹ Ønµ v ¬± Û2¹
Cryptography keys are long, they are unguessable by the ×nðÕhÊ ôµ Í>ô
Encrypted
attacker, but they are difficult to be remembered. Storing ÝoðÊ 0Ì ¶½ Éjð ×yðÊ 0ß
¹µ Ñ>¹J *ð G0 ÓOôôÔ >¹J *ð G0 ÓOô
them in a database or in a file may be insecure. The security ôÔ >¹J *ð G0"
of the cryptographic system relies on the fact that the
cryptographic keys are secret and known only to the
legitimate user. Thus we proposed a new Cryptography method based on the key that is generated directly from an
image stored in the database and the process of key

75
ggeneration baseed on sessions. This creates more
m complexxity
too crack or guess
g the keyys by using th he cryptanaly
ysis
techniques. To break this alg gorithm, we need
n to know the
t
immages databasse, color imagee channel, the key
k value and the
t
ssession type.

TThe experimen ntal results revealed that this method is mo ore


ssecure than traditional crryptographic processes. The T
aalgorithm proceess has an advantage of key generation bassed
oon sessions an nd the key leength varies according
a to the
t
mmessage lengthh. This process is more flexibble that any RGGB
immage can be used
u for key geeneration as th
he key generatiion
is directly based on the imagee content.
7. Refeerences
[1] Santhi, B., K.S.
K Ravichand dran, A.P. Aru
un and L.
Figurre 7: Key generaation and encrypttion of the secrett message
CChakkarapani, “A Novel Cry yptographic Keey Generation
MMethod Using Image Features”, Research Jo ournal of
IInformation Teechnology 4(2): 88-92, 2012.
[2] Wikipedia, Channel (digittal image).
hhttp://en.wikipeedia.org/wiki/C
Channel_(digitaal_image), Jan
n 1,
22013.
[3] Lifang, W., L. Xingsheng, Y. Songlong and X. Peng, “
A novel key geeneration cryptoosystem based on face
ffeatures”. 2010
0 IEEE 10th Intternational Con
nference on
SSignal Processiing, 24-28 Oct..2010. Figure 8: Deccryption of the enncrypted messagge.

[4] Seshadri,R. and T.RaghuTTrivedi, “Efficiient [8] Cryyptography andd Network Secuurity - Principlles and
C
Cryptographic Key Generatio on using Biomeetrics”, Int. J. Practicees;”William Sttallings”, Pearsson Education Third
C
Comp. Tech. Appl.,
A Vol 2 (1)), 183-187. Editionn.
[5] WongSiaw Lang, NurAzm man Abu, Shah hrin Sahib, [9] Ashha Ali, LiyamoolAliyar andNissha V K, “RC55
““Cryptographicc Key From Webcam Image””,International Encrypption Using Keyy Derived Fromm Fingerprint IImage”,
JJournal of Cryp
ptology Researrch 1 (1): 115-1
127,2009. Compuutational Intelliigence and Com
mputing Reseaarch
[6] Murali,P. 1 and R.Palraj 2,
2 “True Rando om number (ICCICC), 2010 IEEE International CConference, 28-29 Dec.
ggenerator method based on immage for key ex
xchange 2011.
09 Internationaal Symposium on Computing,
aalgorithm”, 200
CCommunication n, and Control.
[7] Tanmay Bh hattacharya, SirrshenduHore ,AAyan Mukherjeee
aand S. R. BhadraChaudhuri, “A “ novel data encryption
e
technique by geenetic crossoveer of robust bio
ometric key and
d
ssession based password”.
p Inteernational Journ
nal of Network
k
SSecurity & Its Applications
A (IIJNSA), Vol.3,, No.2, March
22011.

76

You might also like