Granthaalayah
DIGITAL IMAGE ENCRYPTION USING RSA AND LFSR

Digital Image Encryption using RSA and LFSR

 

Gandhi Srushti 1 , Ravi Gor 2

 

1 Research Scholar, Department of Mathematics, Gujarat University, Gujarat, India

2 Department of Mathematics, Gujarat University, Gujarat, India

 

ABSTRACT

In this world of hasty evolution of exchanging digital data, data protection is essential to keep the data safe from the unauthorized parities. With the broad use of digital images of various fields, it is important to preserve the confidentiality for the data of an image from any unauthorized access. In this paper, the keys are generated using a random number generator which is grounded on Linear Feedback Shift Register (LFSR). The encryption/decryption is based on Rivest–Shamir–Adleman (RSA) with the random key generator.

 

Received 01 June 2022

Accepted 08 July 2022

Published 23 July 2022

Corresponding Author

Gandhi Srushti,

srushtigandhi@gujaratuniversity.ac.in  

DOI 10.29121/IJOEST.v6.i4.2022.351   

Funding: This research received no specific grant from any funding agency in the public, commercial, or not-for-profit sectors.

Copyright: © 2022 The Author(s). This work is licensed under a Creative Commons Attribution 4.0 International License.

With the license CC-BY, authors retain the copyright, allowing anyone to download, reuse, re-print, modify, distribute, and/or copy their contribution. The work must be properly attributed to its author.

 

Keywords: LFSR, RSA, Image Encryption-Decryption

 

 

 


1. INTRODUCTION

As digital images are vital in multimedia technologies, protecting user privacy is more critical. Encrypting the image to prevent against unauthorised access is critical to ensure the user's security and privacy. Several industries, including Internet communication, multimedia systems, diagnostic imaging, telemedicine, and military communications, adopt image and video encryption. The Internet and wireless networks, which take advantage of the rapid growth of multimedia and network technologies, are used to send, and store massive amounts of images. Since 1949, cryptography has played a vital role in security. This has been the battleground for mathematicians and scientists. AES, DES, RSA, IDEA, and some cryptographic methods are now implemented.

The image is most widely used by the means of communication in a variety of fields, including medicine, research, industry, and the military. The crucial image transfer will take place across an unauthorized Internet network. As a result, sufficient security is required to ensure that the image prohibits unwanted access to critical information. The image has the advantage of covering more multimedia information and hence requires security. Cryptography is a form of image security method that allows to send and save images securely over the Internet. Any system's prime priority is maintaining the integrity, secrecy, and authenticity of an image. Although cryptography is the most efficient method, it also has security issues when dealing with data through grey levels.

 

2. LITERATURE REVIEW

Anandakumar (2015) proposed an image encryption algorithm that worked efficiently. It is extremely secure, using little computational power and having a strong security. The simulation results suggested that the method had advantages based on their image-processing approaches. As a result, the algorithms are found to be effective for image encryption. It can provide security in open networks.

Kapur et al. (2015) implied a modest and secure procedure to protect images. The image encryption technique used two Pseudo Random Number generators. In the first step, the rows of the original image were switched using the Linear Feedback Shift Register technique. This was followed by the exchange of the columns. An intermediate cypher image was created as a result. The next stage involved replacing the intensity of each pixel in the intermediary cypher image by using Blum Shub algorithm. This produced the ultimate encrypted image.

Mondal et al. (2016) presented extremely secure encryption algorithm. They used permutation-substitution architecture for encryption and decryption of an image. Using Linear Feedback Shift Register, the image pixels of the plain image are scrambled during the permutation phase (LFSR). The output of this phase is an intermediary cipher image. This measures the same as the plain image in size. In the substitution period, sequence of random numbers was produced applying RC4 key stream generator. It was XORed with the pixel value of the intermediary cipher image to generate ultimate encrypted image. The experimental outcomes and security analysis of planned scheme was efficient and secure.

Chepuri (2017) projected RSA algorithm for encrypting images. The RSA algorithm has been updated to work with RGB images. The results of the experiments showed that they were able to successfully encrypt and decrypt a variety of images. This technique has a decent encryption effect. When compared to the original image, the cipher image created by their technique was completely different. This method offers enhanced security and is appropriate to secure image transmission over the Internet.

Jumaa (2018) solved the problem of secret key exchanging with the communicated parities by using a random number generator established by Linear Feedback Shift Register (LFSR). Random key generator was used to encrypt and decrypt the data using Advance Encryption Standard (AES). They also encrypted and decrypted grayscale and colour RGB images. Three elements were important to the functionality of the proposed system in their paper. The first dealt with the challenge of creating a secure encryption key that was random, the second with encrypting the plain or secret image using the AES technique, and the third with recovering the original image by decrypting the encrypted or cipher one.

Devi et al. (2018) offered unique medical image encryption procedure. For image confusion, they applied a Henon map, and for diffusion, they used a Linear Feedback Shift Register (LFSR). Researchers looked at the measured values and claimed that their system could withstand differential attacks. They show that their approach can ensure the security of DICOM images.

Jain and Sharma (2019) presented a technique for digital image encryption which is enhancing its security by using the RSA Algorithm.

 

3. TERMINOLOGIES

3.1. RSA ALGORITHM Anandakumar (2015)

The most widely used asymmetric digital image encryption algorithm is RSA. The oldest known algorithm for combining, authorizing and encryption, RSA (called for Rivets, Shamir, and Adelman, who initially presented it publicly), was one of the first important advancements in public-key cryptography. It employs a pair of keys, one of which is used for digital image encryption in such a way that only the other key in pair can authenticate it.

The keys are generated using a common technique, but it is not possible to generate them in a feasible way among them. The safety of RSA is built on the idea that factorize a larger number is complicated. It relies only on finding the prime factors that are applied in the process of encrypting and decrypting the digital image.

RSA algorithm for key generation is shown below:

With suitably long passwords, it is usually assumed that RSA is safe. Find two prime numbers and use those two prime numbers to generate a pair of keys.

Step 1:  Firstly, select two distinct prime numbers  and . Here,  and  should be the similar bit-length. Primality testing is a useful method for identifying prime integers.

 

Step 2:  calculate the value of n. The modulus for both the public and the private keys is n. The length of the key is often indicated in bits.

 

Step 3:  Calculate φ , where φ is Euler's totient function. This value is confidential.

 

Step 4:  Select an integer e such that  and   ; i.e., e and   are co-prime. e is referred as the public key. e has a short bit-length and slight Mugging weight. This is more effective for encryption. However, it has been demonstrated that in some circumstances, lower values of e are less secure.

 

Step 5:  Determine d as ; i.e., d is the modular multiplicative inverse of   .

i.e., solve the d given . This is calculated using extended Euclidean algorithm. It uses pseudo code in the Modular integers section, inputs a and n are related to and , respectively.

 

Step 6: Value of d value referred as the private key. The private key consists of the modulus n and the public key e.

The private key has the modulus n along with the private key . and  values are kept secret since they are used to calculate d.

The generated sequence is later converted into a sequence of 8-bit binary. It is used in the generating key sequences.

 

3.2. LINEAR FEEDBACK SHIFT REGISTER (LFSR) Devi (2018)

A shift register called an LFSR has its input a liner function of its previous state. LFSR is built from simple shift register with a small number of XOR gates. Shift register is a form of digital circuit utilizing a flow of flipflops where the output of 1 flipflop is coupled with the input of the next.

Initial value of LFSR is known as seed. LFSR comprises of clocked storage elements (flipflops) and a feedback path. The amount of storage components determines the degree of LFSR. LFSR with m flipflops is said to be of m degree. As operation of register is deterministic, the stream of values generated by register is identified by its existing state. As register holds finite number, it must go through a repeating cycle. LFSR with relevant feedback function can produce a sequence of bits. It appears random and has exceptionally long cycle. LFSRs are n bits counter revealing pseudorandom comportment.

An m-stage linear feedback shift register (LFSR) is categorized by feedback polynomial of degree-m over . If the feedback polynomial is primitive, the sequence generated is periodic with period . Here, . There are 255 possible initial states. Each initial state generates a periodical sequence of the period . The sequence produced with different initial states are shifted versions of one another.

Figure 1

                                                                         

Figure 1 Linear Feedback Shift Register

 

LFSRs are applied in numerous key stream generators for the reason:

·        LFSRs are good for hardware implementation.

·        They can generate sequences with good statistical properties.

·        They can generate sequences of large period.

·        They may be quickly studied using algebraic methods due to their composition.

In the purposed scheme, sequences of 8 bit are used for generating key sequences. The sequence is denoted as .

 

 

 

4. PROPOSED WORK

4.1. ENCRYPTION ALGORITHM

Step 1: An 8-bit image of size  pixels is converted into a one-dimensional array of pixel , where  and . Then, each unsigned pixel value between 0 and 255 is converted into an 8-bit block.

 

Step 2: Bit by bit XOR operation is done between sequence  generated by RSA and   produced from LFSR using  to obtain final key sequence .

 

                                                                                                                           

 

Step 3: The binary image pixels are XORed with key sequence  to get encrypted pixel . This block of 8-bit subsequently converted into decimal digit  Є 0 to 255.

 

                                                                                                                      

 

Step 4: Repeat step 3 to encrypt the entire image pixels. Convert all encrypted digits   into an array of size  to obtain the encrypted image.

 

4.2. DECRYPTION ALGORITHM

Step 1: Encrypted image of size  pixels is transmuted into one dimensional array of pixels  where  and   . Later, convert each unsigned pixel values into a block of 8 bit.

 

Step 2: The key sequence   is attained by  and    as defined in Step:3 of encryption algorithm. It is used to decrypt image. The obtained block of decrypted 8-bit is converted into decimal digits called .

 

                                                                                                                       

 

Step 3: One dimensional array of decrypted pixels  is the transformed into an array of size  to get decrypted image.

 

5. EXAMPLE

Figure 2

                                                      

Figure 2 Original Image Pinterest (2021)

 

Using PYTHON.

Image array: <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=368x258 at 0x122523A2FA0>

Numpy array: <class 'numpy.ndarray'>

Image shape (258, 368, 3)

Pillow image: <class 'PIL.Image.Image'>

Image mode: RGB

Image size: (368, 258)

Image array/in matrix form:

Total pixel value: 284832

 

 

Key generation using RSA:

Here,  and  is taken for this example. Any large primes can also be chosen to get better result. Using this, the key

obtained is 210 which is converted into binary .

Key generation using LFSR:

Using RSA key  and a primitive polynomial   for 8 bits; the output is.

Table 1

Table 1

11010010

0

 

00011100

1

 

11010000

0

01101001

1

 

10001110

0

 

01101000

0

10110100

1

 

01000111

0

 

00110100

1

11011010

0

 

00100011

1

 

10011010

0

01101101

1

 

10010001

1

 

01001101

0

10110110

0

 

11001000

1

 

00100110

0

01011011

1

 

11100100

1

 

00010011

0

10101101

1

 

11110010

0

 

00001001

0

11010110

1

 

01111001

1

 

00000100

0

11101011

0

 

10111100

0

 

00000010

1

01110101

0

 

01011110

0

 

10000001

1

00111010

1

 

00101111

0

 

11000000

0

10011101

0

 

00010111

0

 

01100000

1

01001110

0

 

00001011

1

 

10110000

1

00100111

1

 

10000101

1

 

11011000

1

10010011

0

 

11000010

1

 

11101100

0

01001001

0

 

11100001

0

 

01110110

0

00100100

1

 

01110000

1

 

00111011

0

10010010

1

 

10111000

0

 

00011101

0

11001001

0

 

01011100

1

 

00001110

0

01100100

1

 

10101110

1

 

00000111

0

10110010

0

 

11010111

0

 

00000011

0

01011001

0

 

01101011

0

 

00000001

1

00101100

1

 

00110101

0

 

10000000

0

10001011

1

 

00011010

0

 

01000000

0

11000101

1

 

00001101

0

 

00100000

1

11100010

0

 

00000110

1

 

10010000

0

01110001

0

 

10000011

0

 

01001000

1

00111000

0

 

01000001

1

 

10100100

1

 

 

 

10100000

1

 

11010010

(Repeating)

89th clock, period will be repeating and will give pseudorandom sequence.

So, 10100100 is considered as key .

 

5.1. ENCRYPTION ALGORITHM

Step 1: An 8-bit image of size  pixels is converted into a one-dimensional array of pixel , where  and . Then, each unsigned pixel value between 0 and 255 is converted into an 8-bit block.

A one-dimensional array of pixel :

 

                                      ...


 

Step 2: Bit by bit XOR operation is employed between sequence  which is generated by RSA and   which is generated by LFSR using by  to obtain final key sequence .

 

                    10100100

                                                                                                   

 

Input a binary number: .

The decimal value of the number is 118.

 

Step 3: The binary image pixels are XORed with key sequence { } to get encrypted pixel . This block of 8-bit subsequently converted into decimal digit  Є 0 to 255.

 

                                                                                         

                       

                                

                                                ...,

              

               

      

Step 4: Repeat step 3 to encrypt the entire image pixels. Convert all encrypted digits  into an array of size  to obtain the encrypted image.

Data type: Unit 8

Figure 3

                                                                          

Figure 3 Encrypted image

 

For encrypted image:

Total pixel value: 854496

Image array:

NumPy array: <class 'numpy. ndarray'>

Image shape: (258,1104)

 

5.2. DECRYPTION ALGORITHM

Step 1: Encrypted image of size  pixels is transmuted into one dimensional array of pixels , where  and   . Later, convert each unsigned pixel values into a block of 8 bit.

,

       ,

       ,

                                  ...,

       ,

       ,

      

 

Step 2: The key sequence  is attained by  and  as defined in Step:3 of encryption algorithm. It is used to decrypt image. The obtained block of decrypted 8-bit is converted into decimal digits called .

                   

                     

                                   ...
                      

               

               

Figure 4

                                                                            

Figure 4  image

 

For  image.

Total pixel value: 854496

Image array:

Numpy array: <class 'numpy. ndarray'>

Image shape: (258,1104)

 

Step 3: One dimensional array of decrypted pixels  is the transformed into an array of size  to get decrypted image.

 

Figure 5

                                                                        

Figure 5 Decrypted image

 

6. RESULTS AND DISCUSSION

6.1. VISUAL TESTING

The visual testing is done online on https://www.textcompare.org/image/.

Figure 6

                                                                         

Figure 6 Visual Testing

 

Comparing original and encrypted image, similarity between them is shown in the below table. White dotes show the similar pixel values of original image and encrypted image.

By comparing original image with encrypted image and  image, the difference is shown in below table. The white dot indicates the similar pixel value of original image and encrypted image. The difference is found with full transparency when less ignored along with original size and movement with different intensity.

Figure 7

                                                                         

Figure 7 Difference between original and  image

 

Figure 8

                                                                         

Figure 8 Difference between original and encrypted image

 

Table 2

Table 2

Image

Difference

Encrypted image

99.88%

 image

99.55%

 

By comparing original image with encrypted image and  image, the difference is shown in below table. The white dot indicates the similar pixel value of original image and encrypted image. The difference is found with full transparency when less ignored along with scale to same size and movement with different intensity.

Figure 9

                                                                        

Figure 9 Difference between original and  image

                                                                     

Figure 10

                                                                         

Figure 10 Difference between original and encrypted image

 

Table 3

Table 3

Image

Difference

Encrypted image

99.78%

 image

99.97%

 

6.2. SENSITIVITY ANALYSIS

Image quality and vision outcomes were generated by the experiment. The following parameters are used to evaluate image quality:

 

 

 

 

 

6.2.1.  Number of Pixels Change Rate (NPCR)

When the difference between two encrypted images is negligible, NPCRs are used to verify the number of changing pixels among themselves. The NPCR can be mathematically defined as follows:

 

NPCR=  

Where

 

 is the weight and height of the encrypted interferogram,

 is the interferogram encrypted before pixel change,

 is the interferogram encrypted after pixel change,

 is the bipolar network.

The optimal NPCR value is:

 

Table 4

Table 4

Image

NPCR

Encrypted image

100%

 image

100%

This experimental result is executed in python

 

6.2.2.  Mean Squared Error (MSE) and Peak Signal to Noise Ratio (PSNR)

The peak signal-to-noise ratio (PSNR) between any two images is examined in decibels by PSNR block investigates. The PSNR ratio compares the quality of the original and encrypted images. The PSNR increases with the quality of the compressed or rebuilt image.

To compare image compression quality, the mean square error (MSE) and peak signal-to-noise ratio (PSNR) are evaluated. The MSE is a rate of the peak error between the encrypted and original image, whereas the PSNR is a measure of the cumulative squared error.

The smaller the MSE value, the smaller the error.

The PSNR is obtained by first calculating the mean-squared error (MSE) utilizing the equation:

 

MSE  

                                                                      

                                                                                 

 

PSNR can be calculated as:

 

PSNR

 

   

 

The optimal MSE and PSNE values are:

Table 5

Table 5

Image

MSE

PSNR

Encrypted image

 image

This experimental result is executed in python

 

6.2.3.  Unified Average Changing Intensity (UACI)

UACI is used to calculate the average intensity of the difference between two encrypted images (  and ). It is used to determine the strength of an encryption scheme. Its quality is determined by the format and size of the image. The average intensity variation between the ciphered and original images is measured using UACI. The highest UACI suggests that the recommended technique is resistant enough for certain attacks.

For an image of size m× n, UACI is calculated as follows:

 

UACI  

 

From the encrypted image and  image, the optimum UACI value is 0%.

On comparing the original image with encrypted image and  image, the optimum UACI value is 78.125%.

 

6.2.4.  Entropy Analysis

A random event's level of uncertainty is measured by information entropy. The event contains a significant amount of information. With uncertainty or unpredictability, it increases. It is used in a variety of applications, including encryption, lossless data compression, and statistical inference. The entropy  of m can be calculated as Kapur et al. (2015)

 

 

Where L is the total number of symbols.

   and  is the probability of symbol .

For the original digital image,  should theoretically be equal to 8 as there are 256 values of the data source in red, blue, and green colours of the image with the same probability.

Entropy values are:

Table 6

Table 6

Image

Entropy

Original image

Encrypted image

 image

 

6.2.5.  Time taken for encryption and decryption of an image

The time taken to encrypt the image is 0.0 sec and time taken to decrypt the image is 3.796875 sec.

 

7. CONCLUSION

The key utilized for image encryption and decryption in this paper is produced using RSA and Linear Feedback Shift Register (LFSR). The suggested method is extremely sensitive to the LFSR's initial state. An RSA generates the first key, and LFSR uses the first key to generate the second key. Then both keys are XORed together to produce a strong key, which is the final key. As a result, in terms of guessing that key, the hacker will have a great difficulty. Consequently, if the wrong key is used, the image will be radically different.

The results show original and encrypted image is extremely uncorrelated and unique. RSA uses more controlled parameters as compared to another algorithms, which enhances the data security. The computations and coding were done using the capabilities of PYTHON.

 

CONFLICT OF INTERESTS

None. 

 

ACKNOWLEDGMENTS

None.

 

REFERENCES

Anandakumar, S. (2015). Image cryptography using RSA algorithm in network security. International Journal of Computer Science & Engineering Technology, 5(9), 326-330.

Chepuri, S. (2017). An RGB image encryption using RSA algorithm. International Journal of Current Trends in Engineering & Research (IJCTER), 3(3), 1-7.

Devi, S. R. Rajarajeswari, V. Thenmozhi, K. RengarajanAmirtharajan, and Praveenkumar, P. (2018). Henon and LFSR assisted key based encryption. International Journal of Pure and Applied Mathematics, 119(16), 455-460.

Jain, A. & Sharma, S. (2019). A Novel Digital Image Encryption Method Based on RSA Algorithm. 11(1), 650-654.

Jumaa, N. K. (2018). Digital image encryption using AES and random number generator. Iraqi Journal of Electrical and Electronic Engineering, 14(1). https://doi.org/10.37917/ijeee.14.1.8

Kapur, V. Paladi, S. T. & Dubbakula, N. (2015). Two level image encryption using pseudo random number generators. International Journal of Computer Applications, 115(12). https://doi.org/10.5120/20200-2446 

Pinterest (2021).

TextCompare (2021).

Mondal, B. Sinha, N. & Mandal, T. (2016). A secure image encryption algorithm using lfsr and rc4 key stream generator. In Proceedings of 3rd International Conference on Advanced Computing, Networking and Informatics, 227-237.  https://doi.org/10.1007/978-81-322-2538-6_24

Creative Commons Licence This work is licensed under a: Creative Commons Attribution 4.0 International License

© Granthaalayah 2014-2022. All Rights Reserved.