In the two-prime RSA cryptosystem, choose distinct odd prime numbers , set , and choose an integer coprime to . A private exponent satisfies . The public key is ; the private key permits the inverse modular exponentiation. For a message representative ,Correctness holds even when is not coprime to : modulo each prime the zero case is immediate, while the nonzero case follows from Fermat's little theorem; the Chinese remainder theorem recombines the two congruences.
For example, , , and give ; encrypts to and decrypts back to . These tiny parameters only illustrate the arithmetic. The raw deterministic exponentiation is textbook RSA; practical encryption uses an encoding scheme rather than encrypting an unencoded message directly.[ref]
Based on the fact that we don't have a P algorithm for integer factorization as of 2020. But nor proof that one does not exist!
The private key is made of two randomly generated prime numbers: and . How such large primes are found: how large primes are found for RSA.
The public key is made of:
n = p*q- a randomly chosen integer exponent between
1ande_max = lcm(p -1, q -1), wherelcmis the Least common multiple
Given a plaintext message This operation is called modular exponentiation can be calculated efficiently with the Extended Euclidean algorithm.
m, the encrypted ciphertext version is:c = m^e mod nThe inverse operation of finding the private
m from the public c, e and is however believed to be a hard problem without knowing the factors of n.Bibliography:
- www.comparitech.com/blog/information-security/rsa-encryption/ has a numeric example
New to topics? Read the docs here!