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.
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 |
- 1:
- 2:
- 3:
- 4:
for eachdo - 5:
if then - 6:
- 7:
end if - 8:
if then - 9:
- 10:
else - 11:
- 12:
end if - 13:
if then - 14:
- 15:
end if - 16:
end for
|
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.
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).
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 |
- 1:
Require: - 2:
{ k depends on , see Table 2} - 3:
- 4:
Ensure: - 5:
- 6:
- 7:
- 8:
fordo - 9:
- 10:
end for - 11:
whiledo - 12:
- 13:
- 14:
for do - 15:
- 16:
- 17:
for do - 18:
if then - 19:
- 20:
break - 21:
end if - 22:
end for - 23:
if then - 24:
- 25:
for do - 26:
- 27:
end for - 28:
break - 29:
end if - 30:
end for - 31:
end while - 32:
- 33:
returnm
|
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.
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
:
.
The improved RSA-OTP scheme is presented in
Figure 4.
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.