A new block cipher algorithm that adopts the magic square of the fifth order with messages of different lengths and multi-function in GF(2 8 )

This paper is considered as a development of encryption algorithms based on Magic Square of Order Five. Both GF(P) and GF(2 8 ) are used to encode both images and text. Where two different algorithms were used, the first using message length = 10 and the second message length = 14, and an unspecified number of rounds were added and a mask will be used in the even round will use the addition operation and in the odd round will used the multiplication operation so that the text resulting from the first round will be as input text for the next Round, and thus. The speed, complexity, NIST tests and histogram for the first ten rounds were calculated and compared with the results of the previous algorithm before the rounds were made, where the complexity in the first algorithm was = ((256) 15 ) r+1 × (256) 10 + or × (256) 25 and the complexity in the second algorithm = ((256) 11 ) r+1 ×(256) 14 + or × (256) 25 where r represents the number of round used.


Introduction
The development in life and the importance of the information transmitted between people on various sites has resulted in not being satisfied with the traditional and well-known methods and the need to develop new proposed algorithms [1]. Magic squares played prominent roles in life in general, as it was found back to the ages B.C. As life developed, magic squares were exploited in many areas of life [2]. Mathematicians were particularly interested in magic squares, as they, together with cryptologists, designed and implemented several games and methods based mainly on magic squares, as in the game of Sudoku [3]. Where the magic square of the third degree was used in encryption by allocate some locations for the key and others for the message, and the work was developed using the magic square of the fourth degree so that the number of message locations was equal to 8 and the number of keys locations = 8 as well, And the work in the two algorithms was mainly based on magic, as it was considered as the encrypted text and it was not required that the result of the encrypted texts be equal in their values [4]. Cryptologists are very interested in magic squares and their properties, as we will see in this paper. Also will include a group of previous works that are related to the proposed work, as shown below In 2015, a group of researchers presented a proposed encryption algorithm based on the magic square, whereby two specific magic squares were created, and during which the even and odd magic square were used [6]. In the same year, a group of researchers proposed a cipher algorithm using asymmetric encryption (public key), which depends on Diffie-Hellman, and during which 6 magic squares of the third degree (magic cube) were used [7].In 2016, Rahma, Abdul Hossen and Dawood proposed a cryptographic algorithm using Diffie-Hellman, through which it shows the dimensions of the magic square, and it relied heavily on the value of the magic constant and the magic sum [8]. In the same year, a group of researchers proposed an encryption algorithm based on folding 6 magic squares to obtain the magic cube to be used in encryption, regardless of the type of magic square, whether it is odd or even [9]. In 2017, Kaur , Bharadwaj and Mankotia developed an encryption algorithm based on multi-level encryption, where the development was done on the RSA and DES encryption algorithms , and the results were discussed [10]. In 2018, Habboush proposed an encryption algorithm using multi-level encryption, where was combine symmetry strength with the AES algorithm and the Feistel network. Also discussed and compared the results with different algorithms such as RC5, DES and 3DES [11]. In 2019, Al-Hashemi and Mahdi proposed an algorithm for encoding color images where the information was placed in a normal matrix and then multiplied by the magic square, as well as using the XOR process for the two sets of the resulting matrix [12]. In the year 2020, researchers Mohammed and Hasan proposed a method by which to get rid of redundancy characters of cipher text by using the magic square of order 3 [14].

Previously technologies and advantages
The golden advantage in magic squares is that the sum of each diagonal, column or row is equal and then it is called the normal magic square, if it is a normal magic square and the numbers in it are all Prime Number then it is called Prime magic square [15]. from that, the properties of magic squares (MS) were used in encryption, as MS5 is filled with numbers from 1 to 25, but here each group of sums does not have to be equal with the other [16]. The specified system is relied upon, as all elements will be dependent on the prime number used (P) [17]. The 8-bit system was used because the current devices used were all based on the eight bits. Then the system of the field was changed from GF(P) to GF(2 8 ), where the polynomial numbers are used, and the specific field depends on irreducible polynomial number [18]. Let's make this clearer, let's assume that the prime number 151 is chosen for GF(P) and as known that the ASCII code for the existing texts has a value from 0 to 255. Therefore, the Prime number that was chosen does not succeed in retrieving all the numbers in the field because the numbers from 151 -255 will be neglected, so it is necessary to take a larger primary number, because we find that the largest prime number close to 255 is 251, the same problem will be reached as the numbers From 251 -255 it will be neglected, and if we raise the prime number from 255 (because 255 not prime number and can't be used) there will be another problem as the numbers from 256 -P will be outside the range, so GF(2 8 ) was used [19][20][21][22][23]. When using GF(2 8 ), the decimal numbers will be ignored and replace to the polynomial numbers, so they do not contain numbers except for two numbers zero and one and the rest is an X variable raised to the exponent of a positive integer greater from one [24]. A system of linear equations is a set of linear mathematical equations that may be one or more than that, but they must be within the same set of variables, and Gaussian deletion is a mathematical algorithm used to solve linear equations and consists of several steps and it use during that many operations such as multiplication and addition [25]. Cryptography is a science concerned with encrypting data, preserving its confidentiality, and transmitting it to the other party without change or modification by the third party (external) [11]. Multi-rounds Cryptography it is a system that consists of several rounds that are made in succession, unlike the single round that occurs only once [24].

The proposed cryptography technique
When taking the properties of the normal magic square, 12 equations will be obtained, since five of them are from the sum of the rows, five other equations from the sum of the columns, and two other additional equations for the sum of each diameter from the diagonals of MS5. This suggestion is considered as a development of the suggested algorithms for message length = 10 and 14. Where the suggestion is as follows: The encryption Process is repeated using MS5 several times in order to serve as rounds then In each round, a mask matrix is used which its size is equal to the size of the magic square used and depending on the number of rounds, where if the round number is even, the addition process of the magic square and the mask is used, while in the case of the round number is odd, the multiplication process between the mask and the magic square is used.

The 1st algorithm suggested: Insert key for message length = 10 using GF(2 8 )
After examining the resulting equations, it was found that two of them have dependency and therefore were removed, so the remaining number of equations became 10 equations. Depending on the message length, the length of the key will be 15 (according to MS5), and the selected keys locations have flexibility in the value and location of the keys. As a result, we will have 10 equations, each of which corresponds to each sum of the sums. It is assumed that the next key was chosen by the two parties that will exchange information (see Figure 1). Therefore, the message will be filled in at the remaining locations in order, and the result will be MS5 as shown in Figure 2. Then an addition or multiplication operation is used between the resulting magic square (in Figure 2) and the mask matrix used, depending on the round number used if it is odd or even as shown in figure 3.  s10 : Sum10 = N04+ N13 + N22 +N31+ N40 After that, we will start with new round, where a new key will be chosen in MS5 and the previous Sums will represent the message in the positions of the message, and then used the mask as in figure 3, and new sums will be found, and so forth, according to the number of rounds required. And the value of the final resulting sums represents the encrypted text, which is sent to the recipient.
The encryption work in this way was also developed using Galois Field based on the prime number GF(P). There is no fixed or specific algorithm for encoding or decoding, but steps have been put in place to explain the proposed algorithm for both encryption and decryption. Step3 : used the addition between the mask used and the MS5 formed.
Step4 : Find the sum of each row, column, and diameter in the matrix M (see Figure 2), as in (1).
Step5 : repeated the steps bellow many times depending on the number of rounds used i. Choose another Key value in new Positions. ii.
Put the last sums founds in the remaining positions. iii.
Used the addition or multiplication between the mask and MS5 depending on the number of round used is even or odd. iv.
Find the sums for each new row, column and the two diagnals. The Result of the final Sums will represent the ciphertext and will be send to the recipient. End. i. Put the key value in the agreed position in MS5, thus the length of the keys will be equal to 15. ii.
Subtrace the key from the mask if the number of round is even, or multiply MS5 by the inverse of the mask in the case of using odd round. iv.
There will be ten equations resulting; these equations will be arranged so that the main diameter does not contain the value zero. v.
Solve the ten equations way as linear equations. End Loop.
Step2: the final results will be the original message (Image or Text). End.

The 2nd Algorithm suggested: Insert key for message length = 14 using GF(2 8 ) :
The work was to add four new equations to the coding system, so that the total is 14 equations. In this proposed algorithm,the development will be similar to the first development, which is to add a number of rounds, their number according to the desire of the mutual parties, as there will be a new key and new key locations with each rounds. A mask was also used, and in the event that the number of the round used is even, the addition process is used, and otherwise, the multiplication process between MS5 and the mask is used. It is assumed that the following locations have been selected for the key (Figure 4) The work will be completely similar to the first algorithm, only the difference the 14 equations will use the first ten exactly as in (1) and the additional four equations (see (2)), where they were selected based on Figure 2. s1 : Sum11 = N02+ N11 + N20 + N34 + N43 (2) s2 : Sum12 = N01+ N10 + N24 + N33 + N42 s3 : Sum13 = N02+ N13 + N24 + N30 + N41 s4 : Sum14 = N03+ N14 + N20 + N31 + N42 The text of the second proposed algorithm will be similar to the first proposed algorithm a and b, and the only difference will be in both the length of the message used as it will be 14 instead of 10 and the key length also 11 instead of 15, and the rest of the steps are the same. In addition, a work development was made, where both types of GF were used.

Evaluation
Cryptography is the science that concerned with the encryption process using certain algorithm and Re-retrieval it by decryption process using inverse steps for the encryption algorithm and the work required private key between the mutual parties , Regardless of the type and name of the encryption algorithm , and the key are kept secret between the two parties to ensure that the message arrives safely without modification or change (data integrity). Here will discuss speed, complexity, NIST statistics, and histogram statistics for images, and compare the results together and compare them with the results of previous algorithms using the two types of data (images and text), and using both types of GF. Results and statistics were calculated using a laptop in the following specifications: system; Windows 10 Pro , 64-Bit Operating system , ×64-based processor, RAM; 8.00 GB , Processor; Intel(R) Core(TM) i5-4310M CPU @ 2.70GHz 2.70 GHz, Display Name: Intel(R) HD Graphics 4600.

The complexity for brute force
the complexity of the key will calculated in terms of the number of attempts necessary to try to break it and it is called Brute Force Attack, as it was calculated for each proposed algorithm and for the two types of GF. In MS5 Using the first algorithm (before adding rounds) the key complexity will be in GF(P) the prime number raised to the exponent of 15 multiplied by or added to the used mask depending on the number of the round. while when using GF(2 8 ) the complexity of brute force attack will be 256 raised to exponent 15. In other hand, for the second algorithm the complexity of Brute Force Attack using GF(P) will be the prime number used raised to the exponent 11 since MS5 used 14 length of message. And when using GF(2 8 ) the complexity of brute force attack will be 256 instead of the prime number. Upon the proposed development, the complexity in brute force Attack will be the same but all equation will be raised to the exponent number round used (r) plus one. The equations (3) -(10) will show the complexity of algorithm 1 using GF(P) , GF(2 8 ) , Algorithm 2 using GF(P) and GF(2 8 ) respectively.

The complexity for suggested algorithms
In the beginning we will discuss the complexity of the algorithm before development, where the complexity will be equal to the product of data complexity multiplied by the complexity of the key, the complexity of the key has been previously calculated (see sec. 5.1), while the complexity of the data will be the same for all algorithms which is equal to the value 256 (which represent the value of the ASCII code )raised to the message length according to the proposed algorithm.
In the first algorithm using GF(P), the total complexity will be the complex of the key multiplied by 256 raised to the power of 10 (message length), while when using GF (2 8 ) key complexity will be multiplied by 256 raised to Power 14. While in the second algorithm the total complexity with using GF(P) and GF(2 8 ) will be the key complexity of each one of them multiplied by the complexity of data which equal to 256 raised to the exponent of 14 which represent the length of the message used. and the general complexity for the development of adding Rounds will be the key complexity multiplied by the data complexity, the equations (11) - (18) will Illustrates the complexity of the first algorithm using GF(P), using GF(2 8 ), the second algorithm using GF(P) and using GF(2 8 ) Respectively. If r is even C1 = ((P) 15 ) r+1 × (256) 10 + (P) 25 (11) If r is odd v C1 = ((P) 15 ) r+1 × (256) 10 × (P) 25 (12) If r is even C2 = ((256) 15 ) r+1 × (256) 10 + (P) 25 (13) If r is odd v C2 = ((256) 15 ) r+1 × (256) 10 × (P) 25 (14) If r is even C2 =((P) 11 ) r+1 × (256) 14 + (P) 25 (15) If r is odd v C2 =((P) 11 (18) The figure 5 bellow will explain comparing the complexity for Algorithms 1 and 2 .

The time to implementation
The execution time was calculated for the proposed algorithms where the execution time was calculated for the encryption and decryption processes for each type of GF and for the first 10 rounds randomly.  And the following figures 6 and 7 shows a comparison between the first and second algorithms, using both types of GF.

Histogram accounts
Histogram calculations were made for a variety of images using both the first and second proposed algorithms, for each of GF(P) and GF (2 8 ), and for a different number of rounds for each proposed algorithm, and the results were compared and compared with the original image as shown below:
Output Image (for all algorithms the same)

Comparing and discussing all results
By comparing all the previous results with each other, was noted that the new development is much better than its predecessor in terms of complexity, as by comparing the percentage of time increase with complexity, it was noted that the increase in complexity ratio is much more compared to the increase in time between each round. The MS5 is distinguished from the MS3 by increasing the complexity ratio with a small difference in speed, which gives preference to the MS5 with distinction. The second proposed algorithm is faster than the first algorithm, and this is evident in the big data, while the first algorithm is more complex.
Using GF(2 8 ) gives a relatively good advantage as it gives faster execution, while using GF(P) is give more complexity.
When using a mask will give extra strength. When using addition in the even rounds it will give speed compared to multiplying in odd rounds. When multiplication is used in odd rounds, it will give a higher complexity compared to using addition in even rounds. When using an extra mask and using the addition and multiplication operations, some time will be lost, although the increase in complexity is much greater than the time loss.
This proposed cryptography can be utilized as future work to develop intelligent wireless communication along with microstrip filters, antenna and Arduino with effective performance [26][27][28].

Conclusion
The increase in rounds gave an excellent idea. The development of MS5 for MS3 is characterized by increased complexity with little increase in time. Using GF(2 8 ) gives speed while using GF(P) gives more complexity. The larger the prime number, the more complex. The greater the number of equations used, the higher the velocity is obtained on the opposite side, the complexity will be reduced. Using an extra mask gives an extra complex. Addition is faster than multiplication, but it gives less complexity.