Abstract
One-time password algorithms are widely used in digital services to improve security. However, many such solutions use a constant secret key to encrypt (process) one-time plaintexts. A paradigm shift from constant to one-time keys could introduce tangible benefits to the application security field. This paper analyzes a one-time password concept for the Rivest–Shamir–Adleman algorithm, in which each key element is hidden, and the value of the modulus is changed after each encryption attempt. The difference between successive moduli is exchanged between communication sides via an unsecure channel. Analysis shows that such an approach is not secure. Moreover, determining the one-time password element (Rivest–Shamir–Adleman modulus) can be straightforward. A countermeasure for the analyzed algorithm is proposed.
Keywords:
RSA; OTP; one-time password; RSA-OTP; small prime divisors attack; cryptography; encryption 1. Introduction
Cryptography is the basis of modern secure communication. Cryptographic algorithms are very important for the security of data or information [1]. Commonly used algorithms such as the Advanced Encryption Standard (AES) and the Secure Hash Algorithm 2 (SHA-2) are often assumed to be unbreakable. However, the predecessors of these algorithms typically experienced decreased levels of security throughout their lifetimes. Hence, despite modern algorithms appearing secure, increasingly safe solutions must be sought [2,3,4].
Commonly used algorithms are often combined with an authentication process such as one-time password (OTP) to enhance communication security. The most popular OTP implementations, known as HOTP algorithms [5], are derived from hash-based message authentication code (HMAC) [6] algorithms. Given that HMAC algorithms use hash functions as symmetric keys, they represent ideal solutions for challenge-response authentication. However, the algorithms are effectively one-way and so cannot be used directly to encrypt data. This problem is not shared by AES-based OTP authentication algorithms (AES-OTP) [7]. These two examples, despite differing in approach and algorithm utilization, both use an OTP mechanism based on non-repeating challenges with a constant cryptographic key.
Jabłoński and Wójtowicz [8] propose a novel use of the Rivest–Shamir–Adleman (RSA) [9] algorithm in the context of OTP (RSA-OTP): following each sign or encryption operation, the RSA modulus is replaced by a newly generated value . This approach ensures the secrecy of the initial key elements and their secure exchange between two communicating parties. Although this OTP-based approach no longer uses a public key, an important RSA attribute, it allows using shorter keys.
The primary advantage of RSA-OTP over AES-OTP or HOPT is a kind of one-time pad structure: each message is encrypted with a new random key which can be used for native cloning detection. A further advantage is the asymmetric nature of RSA and its mathematical simplicity. Research throughout the past four decades has shown that the primary threat to RSA is large integer factorization, a result of public knowledge of used moduli. Some research [10,11] additionally shows that the implementation method of RSA can produce unintended weaknesses. However, in the case of secret exponents and moduli, many public key RSA threats are no longer relevant.
The novel contributions of this paper are a small prime divisors attack against the RSA-OTP algorithm [8] and a countermeasure using XOR operation.
2. The RSA Algorithm
Many applications require the secure communication or storage of data. The RSA algorithm is a commonly used solution in various types of security applications. Despite the difficulty in breaking RSA keys, RSA algorithms still suffer varied attacks [12,13].
As an asymmetric encryption algorithm, RSA is widely deployed in public key cryptosystems (public key cryptography). A plaintext is encrypted by a public key and the resultant ciphertext is transmitted to the receiver where it can be decrypted by a private key. Encryption security is contingent on the difficulty of factoring the product of two large prime numbers [14].
To generate a private and public key pair, two large prime numbers p and q are randomly chosen. They are used to generate a semiprime n, where:
and Euler’s totient function , where:
The public key is a pair, where e is an integer. Additionally, e is not a factor of , and . The private key is a pair, where d is the modular multiplicative inverse of e modulo :
The public key encrypts a plaintext x into a ciphertext y:
To recover the original message, the corresponding private key decrypts the ciphertext:
Example 1.
Let us choose two prime numbers , and compute by means of (1). The Euler’s totient (2) is . Let us choose e such that and e and are coprime: . Let us compute a value for d (3): 23. The public key is , while the private key is . Let us encrypt letter A <ASCII 65>. The encryption (4) of is and the decryption (5) x of y is 65.
3. The RSA-OTP Concept
The RSA-OTP algorithm also uses asymmetric keys e and . Following each encrypted transaction, a new modulus generation process is initiated by one of the communicating parties. The party is hence the owner of key . A differential value is created from the previous modulus and the new modulus :
This value is then transmitted to the second party: the owner of key e. As claimed by Jabłoński and Wójtowicz [8], can be exchanged across a public, unsecure channel. According to the authors, such a communication method guarantees an “unconditional security level”. Moreover, the modulus length at even 128 bits should be sufficiently secure for certain applications. RSA-OTP scheme is presented in Figure 1.
Figure 1.
RSA-OTP scheme.
Assuming the privacy of each modulus , 128-bit RSA-OTP can be secure under several conditions. However, given that the values are closely related to the values, the unsecure exchange of values raises serious concerns regarding unintended leakage. These concerns precipitate a deeper analysis of the RSA-OTP approach.
Consider the dependency between modulus n and ciphertext y within RSA, as described in Equation (4). Given that y is always smaller than n, y represents the lower bound of the range which can contain a modulus. The upper bound is the product of the two largest primes for which the bit length is equal to the maximum modulus size (e.g., 128-bit). From this, an attacker observing RSA-OTP communication can attempt to estimate the boundaries of the current moduli via Algorithm 1.
| Algorithm 1k-bit RSA-OTP modulus bounding |
|
During empirical tests with 128-bit moduli, observations show that after transactions in which ciphertext and differential value are exchanged, at least twenty of the most significant bits of and match. Following this, to further reduce the security of modulus , the condition in which many of the most significant bits of are set must be detected. When this occurs, the number of possible modulus combinations decreases substantially, as shown in Table 1.
Table 1.
Summary of RSA-OTP moduli security as a function of the number of known most significant bits (MSBs) of 128-bit moduli.
The results presented in the first two columns of Table 1 are prime number approximations generated by
Consider the smallest 128-bit number t that has its s most significant bits set (e.g., for ). The division of t by the largest 64-bit prime number produces a lower bound of possible prime values that can generate t or greater. Determining these prime values allows the estimation of prime numbers in a given range as follows:
The number of unique combinations represents the estimated number of possible modulus values, as displayed in the third column of Table 1. Among these combinations exist many values that do not produce sufficient “large” moduli. Such values can be justifiably included given that their existence can only be verified following the multiplication of two primes larger than . To summarize, RSA-OTP modulus leakage occurs via the following process:
- Observation of approximately consecutive random RSA-OTP transactions, using Algorithm 1, determines at least 20 most significant bits of each modulus.
- Following this, the condition being reached that many of the most significant bits of are set brings a substantial decrease in the number of possible primes that can generate modulus .
Empirical tests over RSA-OTP 128-bit transactions bounded the number of possible prime combinations that could generate the sought moduli to 91–84 bits. While this represents substantial progress toward discovering the RSA-OTP moduli, their final designation remains a computationally demanding task. Moreover, a trivial countermeasure can be applied to prevent such reduction in possible combinations of RSA-OTP moduli. This entails the verification of generated moduli and the rejection of those for which many most significant bits are set. The maximum modulus value can be limited to . Additionally, the extension of moduli to 256-bit should make this type of attack infeasible.
4. Small Prime Divisors Attack
The RSA-OTP attack method presented in the previous section degrades security but is somewhat impractical. This section presents an alternative attack method. Three lemmas lay the framework.
Lemma 1.
If a value is a sought RSA-OTP modulus , then possesses only two divisors with bit length approximately half that of . Similarly, each of the successive moduli , computed by the addition of RSA-OTP values, possess only two divisors with bit length approximately half that of the corresponding modulus.
Lemma 2.
For a prime number p and a k-element set of random numbers , such that , the probability that p is not a divisor of any is .
Lemma 3.
Consider a set of “candidates” for RSA-OTP moduli which are determined using . The RSA-OTP moduli are generated in a random manner such that the are also random. Hence, a k-element set of candidates M can be also considered random, and when it does not contain real moduli (), then with probability at least one of them will be divisible by the selected, smaller prime number p.
This attack is derived from the fact that prime numbers, or large composite numbers such as RSA moduli, do not have small divisors (Lemma 1). Hence, such numbers can be “reconstructed” using equations for values that are not divisible by a set of small primes. The divisibility of integers by prime numbers is cyclic. Primes and have a cycle of . Primes , , and have a cycle of . In this manner, any value s which is non-divisible by the set of the first k primes can be described as:
where the offset t is an odd natural number and i is the largest natural number such that . Hence, there exists only one possible t which is always smaller than . Via this process, discovery of RSA moduli is undertaken by considering only odd values. As such, it holds that for every RSA-OTP modulus.
None of the practically used RSA-OTP moduli are divisible by 3, which, in conjunction with Equation (10), results in three possible offsets to describe such moduli:
Example 2.
Let us assume that . It can be observed that Equation (13) holds. For the next prime, 5, noting that each offset differs by , the following equations must be verified:
Of these, Equation (15) holds. Hence, for the following prime, 7, the modulus n is described by an offset 11:
As (where: lcm is least common multiple), Equation (19) must determine the correct value of n, with .
Table 2 summarizes the attack. It presents the number of primes required to precisely determine moduli of set binary sizes. The attack is surprisingly effective for even 4096-bit moduli with a computational complexity on the order of 32 bits. The requirement to observe a large set of consecutive values presents the only drawback. This follows from Lemma 2: to achieve a high probability of success, the examined set must be sufficiently large so as not to verify an offset as a false positive (i.e., non-divisible by the selected prime number).
Table 2.
hlSummary of the RSA-OTP small prime division attack.
For each subsequent small prime, the number of equations increases. As such, the discovery of the correct offset for primes larger than two appears difficult. However, the task is made considerably easier in the case of RSA-OTP by the observation of a sufficiently large set of consecutive public values. The complete process is presented in Algorithm 2, which demonstrates the determination of the correct offset using Lemma 3. Upon validation of the correct offset, none of the checked values are divisible by the selected prime (line 18 in Algorithm 2). In another case, with probability (Lemma 2) some value will be divisible by the selected prime.
The designation of the RSA-OTP secret moduli makes treating them as a one-time element meaningless but does not lead to a complete breakdown of the RSA-OTP scheme: all time exponents e and remain unknown. However, in specific scenarios, especially for short (128/256 bit) version of RSA-OTP, it may seriously affect the secrecy of encrypted data.
| Algorithm 2 Small prime divisors attack |
Require:
Ensure:
|
5. Countermeasures
The primary conclusion to be drawn from the presented attack is the need for secure, encrypted exchange of RSA-OTP values. Multiple possible solutions exist, the most straightforward of which is an AES encryption algorithm. However, this approach would significantly increase the complexity of the solution. On the other hand, the values look pseudo-random to an external observer, as shown in Figure 2. This bitmap, containing 256 randomly generated consecutive values exchanged between communication parties, looks like (except for the few most significant bits) white noise.
Figure 2.
Example bitmap of 256 values from following 256-bit RSA-OTP random transactions (one value per row). (1) *. (2) * … (256) *. * The least significant bit of each value is a sign bit (1: negative, 0: positive).
Given the random nature of the values, a more effective approach could be implemented. Consider a basic XOR operation between consecutive differential values:
Assuming is a secret, random value securely exchanged between both communication sides, this approach nullifies the presented attack because an attacker cannot determine from . As shown in Figure 3 values except for those most significant bits are approximately white noise. The figure presents a series of 256 transactions corresponded to ones in Figure 2 and :
.
Figure 3.
Example bitmap of 256 values from following 256-bit RSA-OTP random transactions (one value per row). (1) 0xDC5FEA97982EA6FBA2A76B7E76D91A1BF1A83E7262CC81BC739F0957AA61AD38. (2) 0x7C46EBB147831FB09966AB28C4EF7B5889D6778D738916D2E554045EE59A432C … (256) 0x177 A17001C0DAC110B7F4EDF42428ABC497E54C5684E0A737C7EC7BE2FD6DC08.
The improved RSA-OTP scheme is presented in Figure 4.
Figure 4.
Improved RSA-OTP scheme.
The principle of operation (20) is similar to that of the Vernam cipher, because each is derived from two randomly generated values (6) and then is a XOR result of two such consecutive values; hence, an attacker observing such communication cannot revert original value from it. As in the case of the Vernam cipher, achieving secrecy of exchanged data does not guarantee its integrity and authenticity; however, the simplicity of the mechanism increases the security of the OTP algorithm. Depending on the application, algorithms such as HMAC or Poly1305 can assure the integrity and authenticity of the approach.
6. Conclusions
The paradigm shift from constant to one-time keys is an interesting direction in the development of secure applications and services. Such an approach can potentially solve many problems regarding recovery following a system being compromised and resistance against side channel attacks. However, the case of RSA-OTP shows that exact RSA-OTP moduli delta values exchanged via insecure channels can be totally compromised, invalidating their classification as an OTP element. This is caused by the particular nature of those values: they are products of relatively large prime numbers which have no small divisors. Fortunately, despite the success of the small prime divisors attack, basic encryption via XORing consecutive differential values should prove to be a sufficient countermeasure.
Author Contributions
Conceptualization, S.S.; methodology, S.S.; software, S.S.; validation, S.S.; formal analysis, S.S.; investigation, S.S. and R.C.; resources, S.S. and R.C.; data curation, S.S.; writing—original draft preparation, S.S. and R.C.; supervision, S.S. funding acquisition, R.C. All authors have read and agreed to the published version of the manuscript.
Funding
This work was supported by the Polish Ministry of Science and Higher Education funding for statutory activities.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
Not applicable.
Conflicts of Interest
The authors declare no conflict of interest.
Abbreviations
The following abbreviations are used in this manuscript:
| RSA | Rivest–Shamir–Adleman |
| OTP | One-Time Password |
| AES | Advanced Encryption Standard |
| HMAC | Hash-based Message Authentication Code |
| HOTP | HMAC OTP |
| XOR | Exclusive or |
References
- Obaid, T. Study A Public Key in RSA Algorithm. Eur. J. Eng. Technol. Res. 2020, 5, 395–398. [Google Scholar] [CrossRef] [Scilit]
- Alkim, E.; Ducas, L.; Pöppelmann, T.; Schwabe, P. Post-quantum key exchange—A new hope. In Proceedings of the 25th USENIX Security Symposium, Austin, TX, USA, 10–12 August 2016. [Google Scholar]
- Rajasekar, P.; Premalatha, J.; Sathya, K. Multi-factor signcryption scheme for secure authentication using hyper elliptic curve cryptography and bio-hash function. Bull. Pol. Acad. Sci. Tech. Sci. 2020, 68, 923–935. [Google Scholar] [CrossRef] [Scilit]
- Nastase, L. Security in the Internet of Things: A Survey on Application Layer Protocols. In Proceedings of the 21st International Conference on Control Systems and Computer Science (CSCS), Bucharest, Romania, 29–31 May 2017; pp. 659–666. [Google Scholar]
- M’Raihi, D.; Bellare, M.; Hoornaert, F.; Naccache, D.; Ranen, O. RFC4226: HOTP: An HMAC-Based One-Time Password Algorithm; RFC, Ed.; Internet Engineering Task Force (IETF): Fremont, CA, USA, 2005. [Google Scholar]
- Krawczyk, H.; Bellare, M.; Canetti, R. RFC2104: HMAC: Keyed-Hashing for Message Authentication; RFC, Ed.; Internet Engineering Task Force (IETF): Fremont, CA, USA, 1997. [Google Scholar]
- Yubico, Yubico-OTP. Available online: https://developers.yubico.com/OTP/OTPs_Explained.html (accessed on 10 November 2021).
- Jabłoński, J.; Wójtowicz, M. Unconditionally Secure Cryptographic System (Bezwarunkowo bezpieczny system kryptograficzny). Logistyka 2014, 12, 611–616. (In Polish) [Google Scholar]
- Rivest, R.; Shamir, A.; Adleman, L. A method for obtaining digital signatures and public-key cryptosystems. Commun. ACM 1978, 21, 120–126. [Google Scholar] [CrossRef] [Scilit]
- Kocher, P. Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems. In Proceedings of the Advances in Cryptology—CRYPTO’96, Santa Barbara, CA, USA, 18–22 August 1996; pp. 104–113. [Google Scholar]
- Karbownik, P.; Russek, P.; Wiatr, K. Weak RSA Keys Discovery on GPGPU. Int. J. Electron. Telecommun. 2019, 65, 25–31. [Google Scholar] [CrossRef] [Scilit]
- Overmars, A.; Venkatraman, S. Mathematical Attack of RSA by Extending the Sum of Squares of Primes to Factorize a Semi-Prime. Math. Comput. Appl. 2020, 25, 63. [Google Scholar] [CrossRef] [Scilit]
- Ariffin, M.R.K.; Abubakar, S.I.; Yunos, F.; Asbullah, M.A. New Cryptanalytic Attack on RSA Modulus N=pq Using Small Prime Difference Method. Cryptography 2019, 3, 2. [Google Scholar] [CrossRef] [Scilit]
- Yan, S.Y. Factoring Based Cryptography. In Cyber Cryptography: Applicable Cryptography for Cyberspace Security; Springer: Berlin/Heidelberg, Germany, 2018; pp. 217–286. [Google Scholar]
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).



