Configuration Workpad
1. Prime Selection
Select two prime numbers. In reality, these would be 2048-bit numbers. We use small primes for visibility.
2. Core Parameters
Calculate the modulus and totient.
3. Key Generation
Must be coprimeCoprime
Two numbers are coprime if their Greatest
Common Divisor (GCD) is exactly 1. They share no common prime factors. to
φ. Typically 65537.
The Modular
InverseModular Multiplicative Inverse
Finds a
number 'd' such that (d × e) remainder φ = 1. Found using the Extended Euclidean
Algorithm. of e mod φ.
4. Encryption Input
Input an integer M where 0 ≤ M < n.
Factoring Complexity
Time to derive keys grows exponentially with Bit Length.
Live Encryption Stream
Public Key
Shared with everyone.
{ e: -, n: - }
Private Key
Kept strictly secret.
{ d: -, n: - }
Vulnerability Scanner
Real-time analysis of cryptographic weaknesses in the current RSA configuration.
Eth-Root Attack
If the public exponent e is very small (like 3) and the message M is short, M^e might not wrap around the modulus n.
import gmpy2
# Intercepted from network stream
C = None
e = None
# When e is small (e.g., 3) and padding is missing
def eth_root_crack(ciphertext, exponent):
# gmpy2.iroot calculates the precise integer root
m, exact = gmpy2.iroot(ciphertext, exponent)
if exact:
return m # Original Plaintext!
return None
# Execute Hack
plaintext = eth_root_crack(C, e)
print(f"Cracked Message: {plaintext}")
Fermat Factorization
Exploits the RSA modulus n if the chosen primes p and q are mathematically too close.
import math
# Requires no keys, only the public Modulus
def fermat_crack(n):
a = math.ceil(math.sqrt(n))
b2 = a*a - n
# Loop until b2 is a perfect square
while not math.isqrt(b2)**2 == b2:
a += 1
b2 = a*a - n
b = math.isqrt(b2)
return (a - b, a + b) # Returns p & q!