Evaluation of Image Cryptography by Using Secret Session Key and SF Algorithm

In the unreliable domain of data communication, safeguarding information from unauthorized access is imperative. Given the widespread application of images across various fields, ensuring the confidentiality of image data holds paramount importance. This study centers on the session keys concept, addressing the challenge of key exchange between communicating parties through the development of a random-number generator based on the Linear Feedback Shift Register. Both encryption and decryption hinge on the Secure Force algorithm, supported by a generator. The proposed system outlined in this paper focuses on three key aspects. First, it addresses the generation of secure and randomly generated symmetric encryption keys. Second, it involves the ciphering of the secret image using the SF algorithm. Last, it deals with the extraction of the image by deciphering its encrypted version. The system’s performance is evaluated using image quality metrics, including histograms, peak signal-to-noise ratio, mean square error, normalized correlation, and normalized absolute error (NAE). These metrics provide insights into both encrypted and decrypted images, analyzing the extent to which the system preserves image quality. This assessment underscores the system’s capability to safeguard and maintain the confidentiality of images during data transmission. SF, LFSR, secure

II.RELATED WORKS Kholood J. Moulood (2017) introduces a novel design for a pseudo-random generator, detailed in [6], aimed at creating binary sequences applicable as encryption keys in Stream Cipher Cryptosystems (SCC).The Address Shift LFSR (ASLFSR) cryptosystem, formed through a combination of nonlinear functions and LFSRs, employs LFSRs as the building blocks of the SCC.The ASLFSR generator's output undergoes analysis using Basic Efficient Criteria (BEC) to assess its performance as an efficient random number generator.The adherence of the ASLFSR cryptosystem to specified requirements underscores its ability to generate secure and unpredictable encryption keys.
Noor K. Jumaa (2018) proposes a method utilizing a random number generator to generate a secret key.The subsequently created random key is then employed for both encrypting and decrypting messages.The method, employing the Advanced Encryption Standard (AES) and the random key generator, successfully encrypts and decrypts grayscale and colored RGB images.Evaluation based on image quality metrics, including mean square error (MSE), peak signal-to-noise ratio (PSNR), normalized correlation (NK), and normalized absolute error (NAE), demonstrates the preservation of image quality, with plain and decrypted images being fully matched (MSE = 0 and NK = 1) [2].
Maisa'a A. Ali and Alyaa H. Zwiad (2019) utilize the SF algorithm for image encryption, as presented in [7].Haar wavelet transform (HWT) is employed to convert plain images into frequency coefficients based on the Haar filter.Distortion measures such as PSNR, RMAE, MSE, and correlation measures are computed, revealing the efficiency, potency, and high security of the SF algorithm in cryptography.
Samer H. Majeed et al. (2020), through the application of the Taguchi method, as discussed in [8], demonstrate that an SF cryptographic system is a viable approach to encrypting images.Optimization experiments employing the L9 orthogonal array highlight key parameters, including the symmetric ciphering/deciphering key, cryptography algorithms (SF), and image file extension type (JPG images), as crucial settings for obtaining optimal grayscale encrypted image quality.The study concludes that the SF algorithm, coupled with any manual key, represents the most effective cryptographic technique.Through the use of the Taguchi Method, insights into the rationale behind using JPG image types for encryption and steganography purposes are provided.Balsam A. et al. (2022) employ Linear Congruential Generators (LCG) and Linear Feedback Shift Registers (LFSR) in their publication detailed in [9].This approach combines these technologies to generate pseudo-random numbers, enhancing confidentiality and unpredictability.The results affirm the success of the tests and the resistance to differential and brute-force attacks.This hybrid technique proves effective for applications requiring reliable key generation.
Fatima F. Saleh and Nada H. M. Ali (2022) introduce a new method utilizing LFSR and the concept of chaotic images to generate the initial key.Genetic Algorithm (GA) is subsequently employed to create the final keys.The randomness of the generated key is verified using the NIST test group, with the P-value consistently ≥ 0.01.This key is then utilized to encrypt images, as discussed in [10].
Mohammed A. and Saad Al-Momen (2023) engage in a discussion and comparison of two steganography techniques, outlined in [2].The first technique operates in the spatial domain, utilizing the least significant bits (LSBs) for data embedding, achieving a typical PSNR of 43.5292 and a payload capacity of up to 16% of the cover image.The second technique operates in the frequency domain, concealing the secret message in the LSBs of the discrete cosine transform (DCT) coefficients in the mediumfrequency area, offering a payload capacity of 8% and an average PSNR of 38.4092.This technique provides stronger defenses against attacks along with greater exposure.

III.SECURE FORCE CRYPTOGRAPHY
The Secure Force (SF) algorithm is a low-complexity cryptographic technology designed for WSN operations.Only five rounds of encryption are used to increase energy efficiency and reduce power usage.With each encryption round, four bits of data are subject to six direct mathematical operations, thus enhancing security.To make the data resistant to various forms of attack, this tactical strategy seeks to provide sufficient uncertainty and disseminate the data.To produce unique keys for various encryption rounds, the key expansion method uses complex mathematical processes (multiplication, permutation, transposition, substitution, and rotation).The decryption now carries the bulk of the calculation, extending the life of the sensor nodes.The encryption algorithm receives the generated keys in a secure manner to begin the encryption.It is strong, secure, and built for WSNs [7,11,12].
The overall SF algorithm comprises the following blocks [11] The details of the SF and its block structure can be seen in [11] and [12].

IV.PROPOSED SYSTEM MODELING
The three main components of the proposed system are secret key generation, secret key distribution, and image encryption using SF.Subsequent subsections provide detailed coverage of each component.

A. Session Key Generation
To address the key generation aspect, this study employs the LFSR technique to generate a symmetric random key.The proposed technique randomly generates sixteen hexadecimal digits, serving as the cryptographic key utilized in both the encrypting and decrypting algorithms of SF.
When referring to "random numbers," the term actually denotes "pseudo-random numbers."This distinction arises because true random sequences are not employed; instead, pseudo-random sequences are generated through PRNGs.These PRNGs, based on internal equations, produce values that appear random and often align with various statistical definitions of randomness.All PRNGs have cycles, with the series of numbers repeating in the same order after completing one full cycle [2,4,13].
Applications that utilize cryptography, such as data encryption keys and secure communication channels, frequently rely on PRNGs based on LFSR.This preference is justified by the superior performance of LFSR-based PRNGs in terms of hardware, area, and speed compared to alternative counters [14].
In the LFSR, a feedback shift register is composed of two main components [2,10]: The LFSR, a type of feedback shift register (FSR), executes the feedback function through the XOR operation on a subset of the register bits, forming a "tap sequence" [2,13,14].Figure 1 illustrates a standard LFSR structure, and Table 1 provides an interface link between the tap sequence bits and the maximum length of the generated sequence.
Table 1 presents an interface link among the tap sequence bits and the maximum length of the sequence generated.An LFSR with n flip-flops produces (2 n -1) distinct states, excluding the "all-zeros" state to prevent counter lockup.Pseudo-random numbers generated by LFSRs form "maximal-length sequences" that do not repeat until reaching the state of (2 n -1).The following properties are found in the maximal sequence length generated [2]: 1.The number of 1s roughly equals the number of 0s. 2. The arithmetical distribution of 1s and 0s is consistently well defined.[15].
In this study, a 16-digit hexadecimal session key, generated using a 5-bit LFSR with 31 random states, serves as the secret key for encryption and decryption procedures.The 4-bit LFSR with 15 states is unsuitable for the SF method due to its insufficient 16 hexadecimal digits.Algorithm 1 outlines the pseudocode for a 5-bit LFSR.
Five bits are selected at random from the day, month, and year bits in accordance with a predetermined agreement between the originator and receiver through any traditional communication tool.By exchanging the positions of these bits, an initial state can be established for the LFSR.Let the initial state be: [Year (9), Day (3), Month (3), Day (5), Year (1)].These bits will constitute elements within the key generator algorithm, forming an agreement between the sender (Alice) and the transmitter (Bob).The binary date will serve as the initial state for the LFSR, as explained below.

Tap bits
For initial state 10111, 1 is the ninth bit in the year binary form, 0 is the third bit in the day binary form, 1 is the third bit in the month binary form, 1 is the fifth bit in the day binary form, and 1 is the first bit in the year binary form, as outlined in the previous array [Year (9), Day (3), Month (3), Day (5), Year (1)].This array defines the specifics of the initial state of the LFSR, marking the agreement between the sender (Alice) and the receiver (Bob).

B. Secure Key Distribution
In symmetric key cryptography systems, the communicating parties (Alice and Bob) use the same secret key for both encryption and decryption.However, ensuring the secure transfer of this key between the two parties, while preventing access by potential attackers, poses a significant challenge [16].
By configuring the initial state of the random key generator based on the current date for each ciphering process, this paper addresses the challenge of secret key distribution.Both Alice and Bob are well-versed in the 5-bit LFSR algorithm for key generation, as well as the associated processes of encryption and decryption.Alice can transmit a concise message to Bob, such as "Year (9), Day (3), Month (3), Day (5), Year (1)," to inform him of the initial state, facilitating the exchange of the secret key.Subsequently, Bob utilizes these bits as the initial state for the LFSR algorithm, thereby obtaining the secret key.
The following presumptions underpin the scenario presented in this study: 1.Both Alice and Bob are acquainted with the encryption and decryption algorithms.2. Both Alice and Bob are knowledgeable about the 5bit LFSR secret key generation algorithm.3. Alice and Bob share solely the initial state, derived from the encrypted image's date of delivery or receipt.Figure 3 shows how Alice and Bob communicate using the suggested method to share the secret key.

V.PROPOSED CRYPTOGRAPHIC SYSTEM IMAGE CIPHERING
The encryption for grayscale images, detailed in Algorithm 2, is depicted in Figure 4. Figure 5 illustrates the decryption, as outlined in Algorithm 3.
The SF cryptographic system takes both the plain image and the 64-bit session key generated by the LFSR as input.The plain image undergoes division into blocks of 8 bytes each.Subsequently, the SF cryptographic system combines each block with an 8-byte (64-bit) key generated by the LFSR for encryption, resulting in the generation of a cipher image.As each 8-byte cipher block is assembled, the resulting cipher image presents itself to the viewer as a seemingly nonsensical image.This entire cryptographic system was implemented using Matlab 2018a on an HP Pavilion PC equipped with an Intel Core i7 CPU and running a 64-bit Windows 11 OS.The decryption mirrors the encryption procedures in reverse.Step 1: take the hexadecimal form of the LFSR bits to be output as the LFSR-session key.

Day
Step 2: shifting to the RIGTH all bits in LFSR stream by one step.
Step 3: doing an XOR operation between tap bits to be the next first bit in the LFSR stream.
Step 4: INSERT the next first bit in position 1 from the LFSR stream.

Start
Step 1: divide the image matrix into blocks with 64 bits each.
Step 2: convert each pixel to binary.
Step 3: convert session key to binary.
Step 4: do the SF encryption operations between the binary image block and the binary session key.
Step 5: convert each 64-bit block to a decimal.
Step 6: merge blocks to be a 256×256 image matrix.

Start
Step 1: divide the cipher image matrix into blocks with 64 bits each.
Step 2: convert each pixel to binary.
Step 3: convert session key to binary.
Step 4: do the SF decryption operations between the binary image block and the binary session key.
Step 5: convert each 64-bit block to a decimal.
Step 6: merge blocks to be a 256×256 image matrix.Where N and M are the sizes of the image's matrix, f(i,j) is the original image, and f̅ (i,j) is the encrypted/decrypted image.

IV.
Normalized Correlation (NK) assesses the similarity between two images, specifically the plain image and the encrypted image.Elevated NK levels suggest diminished image quality.This study includes calculations of NK between the original image and the ciphered image as well as between the original image and the deciphered image.
Normalized Absolute Error (NAE) is a metric for gauging the degree of dissimilarity between the modified image and the original image, with a value of zero indicating an exact match.This study computes the NAE between the original image and the ciphered image as well as between the original image and the deciphered image.
Further details on PSNR, MSE, NK, and NAE are available in [18,19].Table 2 provides a comprehensive presentation of histogram measurements, serving as one of the image quality parameters for plain images, encrypted images, and decrypted images.

Encrypted Image
Within the context of image cryptography, a histogram is a visual representation of the frequency distribution of pixel values present in an image.It elucidates the number of pixels in the image with a specific intensity or color value.In this research, 8-bit grayscale images were employed.Consequently, the horizontal axis of the histogram illustrates the range of pixel values (from 0 to 255), whereas the vertical axis portrays the proportion of pixels corresponding to each value.
Table 2 reveals that the histogram values of the decrypted images closely align with those of the original plain images, signifying the successful recovery of the original pixel intensity during decryption.The congruence of histogram values in both decrypted and plain images is a pivotal indicator that the SF image cryptographic system effectively maintains the image's integrity throughout encryption and decryption.The images featured histograms with seven bins covering the entire spectrum of possible pixel frequencies, ranging from 0 to 255.Across this full range, the histogram delineates the distribution of pixels within each of the seven intervals.Each bin represents a distinct range of pixel values.This type of histogram, presenting the distribution of pixel intensities on a broader scale, proves valuable when reducing the level of detail in pixel intensity information.Figures 6 to 11 illustrate the histogram of the plain, encrypted, and decrypted images, along with the vision illustrations of these images.Table 3 lists the parameters measuring the image quality for grayscale images of (plain-encrypted) and (plain-decrypted) pairs.The calculated MSE values for the six images varied, ranging from a minimum of 105.5244 to a maximum of 178.1490, encompassing a span of 256 pixels.This considerable range underscores a significant difference between the encrypted image and the original one.The MSE for plain-decrypted images was 0, indicating that neither encryption nor any other form of image manipulation altered it in any way.
For plain encrypted images, the PSNR values exhibited a range from 0.6221 to 1.0502 across the six images.This implies a low signal-to-noise ratio, signifying increased distortion in the encrypted images.This distortion is attributed to the SF encryption and its data manipulation.Conversely, a PSNR value of ꝏ for plaindecrypted images implies an indiscernible difference between the original plain image and the decrypted image.
The NK values for plain-encrypted images were close to 1, indicating a positive correlation between the plain and encrypted images.This suggests that the encryption method preserved the most crucial details of the image with minimal alteration.A NK value of 1 for plaindecrypted images signifies a perfect match between the original plain and the decrypted images, affirming the precise restoration of the image without any loss.
The NAE values for plain-decrypted images ranged from 0.3647 to 0.5395, highlighting the dissimilarity between the plain and decrypted images.The SF algorithm successfully restored the original plain image without introducing distortion or error, as evidenced by recorded NAE values of 0 for the plain-decrypted images.

VI.
Concluded Remarks This research introduces a secure key exchange method employing session keys generated by a LFSR, applicable to any cryptographic system.The efficacy of the SF algorithm in image encryption is substantiated through comprehensive image quality assessments.This proposed key exchange technique involves utilizing the LFSR as a generator for the 16 hexadecimal digits (64 bits), forming session keys crucial for encrypting and decrypting images with the SF algorithm.
The effectiveness of the SF algorithm in image encryption/decryption is underscored by its performance evaluation using various image quality measures.The MSE values distinctly differentiate between encrypted and original images, whereas an MSE of 0 for plain and decrypted images highlights the algorithm's ability to maintain image integrity.Variable distortion levels in encrypted images, revealed by PSNR values, result from the SF modification.A PSNR of ꝏ for plain and decrypted images underscores the precision of the technique in restoring original images.Moreover, the NK readings of 1 for plain and decrypted images, along with the NAE scores of 0, indicate that the SF algorithm accurately returns the decrypted data of images to their exact origin, regardless of their file type (tif, jpg, or png).Although NK and NAE values suggest extreme similarity between plain and encrypted images, Figures 6 to 11 visually demonstrate that encrypted images closely resemble their plain counterparts.This underscores the SF method's efficacy in preserving the main features of original images during encryption and decryption, albeit with potential considerations as a drawback for the SF cryptographic technique when applied to images.

Figure 2
Figure 2 illustrates the 5-bit LFSR used as a secret key generator.The random encryption/decryption hexadecimal key is [171B0D060211181C].

Step 5 :Fig 4 .
Fig 4. Structure of the Ciphering System for Grayscale image.Algorithm (2): Image encryption by session key and SF algorithm Input: 256 × 256 grey-scale plain image, 16 digit hexadecimal session key Output: cipher image

Fig 5 .
Fig 5. Structure of the Deciphering System for Grayscale image.
The outcomes obtained in this study are assessed based on the quality of images, with a focus on visual results.The following parameters are used to evaluate quality of images: I. Histogram serves as a gauge of unpredictability or uncertainty inherent in the pixel values of an image.It functions as a statistical measure, quantifying the information encapsulated within an image.The computation of an image's entropy entails the utilization of the pixel value histogram.Images characterized by higher entropy are typically more intricate, whereas those with lower entropy may exhibit a greater degree of simplicity or uniformity.This paper undertakes the measurement of histograms for plain, encrypted, and decrypted images [17].Histogram can be calculated using the frequency density obtained with the following formula:  =   …………….(1) Where D is the frequency density of a class interval in an image, F is the frequency, and W is the class width.II.Peak Signal to Noise Ratio (PSNR) functions as a measure for the compressed reconstruction of an image.In this study, PSNR was computed between the original plain image and the ciphered image, as well as between the plain image and the deciphered image.(MSE) is the average of the squared intensity differences between two images.In this study, MSE was calculated between the original plain image and the ciphered image, as well as between the plain image and the deciphered image.Following the PSNR, MSE stands out as one of the most frequently employed quality parameters. = 1  ∑ ∑ ((, ) −  ̅ (, ))

Fig 7 .
Figure 6.Histogram and vision results of

Fig 8 .
Fig 8. Histogram and vision results of Lina jpg image.

Fig 9 .
Fig 9. Histogram and vision results of football jpg image.

Fig. 10 .
Fig.10.Histogram and vision results of onion png image.

Fig. 11 .
Fig.11.Histogram and vision results of bird png image.

Table II .
Histogram readings.

Table III .
Histogram readings.