A Practical Analysis of the Fermat Factorization and Pollard Rho Method for Factoring Integers

The development of public-key cryptography generation using the factoring method is very important in practical cryptography applications. In cryptographic applications, the urgency of factoring is very risky because factoring can crack public and private keys, even though the strength in cryptographic algorithms is determined mainly by the key strength generated by the algorithm. However, solving the composite number to find the prime factors is still very rarely done. Therefore, this study will compare the Fermat factorization algorithm and Pollard rho by finding the key generator public key algorithm's prime factor value. Based on the series of test and analysis factoring integer algorithm using Fermat's Factorization and Pollards' Rho methods, it could be concluded that both methods could be used to factorize the public key which specifically aimed to identify the prime factors. During the public key factorizing process within 16 bytes – 64 bytes, Pollards' Rho's average duration was significantly faster than Fermat's Factorization.


Introduction
Information security is a major challenge in an era of information flood like today. The cryptology method can be one of the solutions used to secure this information [1]. Cryptology consists of two parts, namely cryptography and cryptanalysis. The main task of cryptography is to hide data using specific algorithms, while cryptanalyst is a method for investigating the security of a cryptographic system by finding weaknesses in codes, ciphers, protocols, or key management schemes. [2]. Usually, cryptanalysis refers to analyzing and solving the keys used to perform the encryption and decryption processes. Therefore, cryptanalysts are needed to test the robustness of the encryption algorithm. There are several mathematical approaches in testing the robustness of cryptographic algorithms, including discrete logarithms and factorization. In this study, the factorization method is used to break numbers into smaller numbers [3]. This factorization method is used for the RSA algorithm to generate public and private keys There are several methods that can be used to factor the composite number into prime numbers, namely Fermat's factorization and Pollard rho. Fermat factorization looks for the factor of an odd number by utilizing the property of an odd number which can be expressed as the difference of 2 squares from another number [4]. In contrast, the pollard rho method integrates a polynomial function in a modulo (the number to be factored) and a seed (generator number) [5]. The importance of the two algorithms is that if they can return two large prime factors of modulus processing, it can be ascertained that the public and private keys can be found [6]. Thus, this integer factorization problem has a significant impact on the security of the public-key cryptography system. The research conducted by Chinniah et al. created a factorization method that aims to find composite number factors resulting from two different prime numbers [7]. Then Li et al. researched the implementation of algorithms with a mathematical model used for factoring integers. The results of this study were a comparison between Pollard's Rho and SpSqAlgorithm based on execution time. [8]. This study aimed to analyze Fermat's Factorization and Pollards' Rho due to vulnerability by factorizing the prime factors. Furthermore, the purpose is to figure out the receiving the factorization attack by comparing the factorization time between both methods.
The ultimate goal of the proposed research is to discover an opportunity to extend the previous study to contribute in the area of cryptanalysis and cryptography.

Fermat's Factorization
The following section is the attack method as the technique of factorization. p and q can be easily found using Fermat's Factorization with the following steps [6]: The variable of on equation (1) is the value of square root n. The variable of 2 on equation (2) is the value of the perfect square. The variable of ℎ 2 on equation (4) is the ultimate value of the perfect square. The variable of and on equation (5) is the sought prime. Figure 1 shows the pseudocode of Fermat's factorization.
Input : value public key (n) Output: p and q for k from ceil (sqrt (n)) to n h square = k * k-n if p > 1 and p < n do h = sqrt (hSquared) p = k + h q = k -h

Figure 1. Flowchart Fermat's Factorization Algorithm
The input value of is used to get factorization from values and . The value will be checked to include square root or not. After knowing is the square root, it is processed again whether is greater than . Subsequently, the calculations can be done if the value is greater than the value . If it has a greater value, it proceeds by calculating the result of by performing square root.
Conversely, the calculation is continued by adding 1 to the value . After obtaining the square root value of , we find and values depicted in equation (8)

Pollard's Rho
Pollard's Rho factorization method calculates the factorization with polynomial modulo iteration. This algorithm is based on several mathematical concepts, such as integer factorization [9]. The following procedure explains the steps of Pollard's Rho algorithm as a method of factorization [2]: a. Input a value that are going to be factorized value b. = 2, = 2.
(7) e. ≠ 1 and ≠ . ( The and variable on equation (5) is the first step of factorization. The a 2 and b 2 variable on equation (6) is the value that has been square root from the previous result. The variable on equation (7) is the prime produced by equation gcd (the greatest divisor), and the variable is the prime of the public key. The variable on equation (8) is the prime generated from the division of variable and variable . Figure 3 shows pseudocode pollard's Rho in detail.

Figure 3. Pollard's Rho Algorithm
The first step in the pollards' rho method gets the public key value to be factored into and values. The next step is calculating the value, which must fulfill the equation > 1 < . If it does not fulfill the equation, it is recalculated from the beginning. If the value has been found, then the value can be calculated.

Scenario of Testing
The testing scenario was conducted by running the program and inserting the various number of public keys that have been generated and compiled using = < < 2 which finally created the public key n. Then the generated key was factorized by using Fermat's Factorization and Pollard's Rho method for obtaining the p and q values and figuring out the duration of factorization. The public key pairs were created within a range from 16 to 64 bytes complying with the equation = < < 2 .

Result and Discussion
To increase the security in public key so that it can be concluded afterward the characteristic of the strong public key that can withstand the attacks of factorization mainly by using the Fermat's Factorization and Pollard's Rho. The test results of Fermat's factorization method are presented in Table 1 and Table 2, while Pollard's Rho's test results are shown in Tables 3 and 4. The second column shows the public key factorized to obtain the value of and . The following columns present the digit length of , the found value of and , duration of factorization, and success rate of key public factorization.

Testing Using Fermat's Factorization
The experiment of Fermat's Factorization algorithm used the public key that was normally widely distributed. However, this test used the generated public key with the equation = < < 2 to make it difficult to find the value of and . Fermat's factorization was used to factorize the public key to find the value of and . The test results are illustrated in Table 1 and Table  2  In Table 2, Fermat's factorization method did not find the value of p and q. This was considered secure from Fermat's Factorization attack, proven by a 0% success rate in which the prime factors of public key were not found.

Factorization Using Fermat's Factorization
Fermat's factorization is used to identify the factors of public key (the value of and ) by factorizing the value of the public key. The test of Fermat's Factorization algorithm showed a 100% success rate in finding the value of and at 16 -32 bytes key generation, even though the key public generation has fulfilled the equation = < < 2 used to complicate the identification of the prime factors through Fermat's Factorization. Meanwhile, the key generation on variant above 32 -64 bytes showed a 0% success rate.

Testing Using Pollard's Rho
The second test applied Pollards' Rho method to factorize the public key n to identify the prime factors' values on variant above 32 -64 bytes. The duration of factorization was also investigated. The test results are presented in Table 3 and Table 4 below :