CryptoBook
Search…
RSA
Will be introduced in this page the fundamentals of RSA, mathematical requirement and also some application with python and openSSL.
This page is pretty long, probably could be split up
Edit: I haved deleted the last part, application with RSA, and i made a special part for this. Maybe we can do the same with the second part: Arithmetic for RSA.

I- Introduction:

RSA is a public-key cryptosystem that is widely used in the world today to provide a secure transmission system to millions of communications, is one of the oldest such systems in existence. The acronym RSA comes from the surnames of Ron Rivest, Adi Shamir, and Leonard Adleman, who publicly described the algorithm in 1977. An equivalent system was developed secretly, in 1973 at GCHQ (the British signals intelligence agency), by the English mathematician Clifford Cocks. That system was declassified in 1997.
All public-key systems are based on the concept of trapdoor functions, functions that are simple to compute in one direction but computationally hard to reverse without knowledge of some special information called the trapdoor. In RSA, the trapdoor function is based on the hardness of factoring integers. The function involves the use of a public key
NN
to encrypt data, which is (supposed to be) encrypted in such a way that the function cannot be reversed without knowledge of the prime factorisation of
NN
, something that should be kept private. Except in certain cases, there exists no efficient algorithm for factoring huge integers.
Further reading: Shor's algorithm
Formalize the introduction and include a discussion of the security based on the hardness of factoring integers.

II- Arithmetic for RSA

Before starting to introducing you RSA, a few arithmetic notions need to be introduce to understand perfectly other steps.

III- Key generation

    We pick two primes
    pp
    and
    qq
    Using
    pp
    and
    qq
    , we calculate modulus
    n=p×qn = p\times q
    and its Euler's totient
    ϕ(n)=(p1)×(q1)\phi(n) = (p-1) \times (q-1)
    Now, choose the public exponent
    e\mathbb{e}
    such as
    gcd(e,ϕ(n))=1\mathbb{gcd(e, \phi(n)) = 1}
    By using the Extended Euclidean algorithm, we compute the invert
    d\mathbb{d}
    of
    emodn\mathbb{e \mod n}
    :
    de1modϕ(n)d \equiv e^{-1} \mod \phi(n)
    which is our private exponent.
    Public key:
    n,en, e
    Private key:
    n,dn, d
    Now, chose a message
    m\mathbb{m}
    that you convert into integers
    We can encrypt this plaintext
    mm
    and receive a ciphertext
    cmemodnc \equiv m^e \mod n
    We can decrypt a ciphertext
    cc
    with
    mcdmodnm \equiv c^d \mod n

IV- Signature

A digital signature is a proof of the authenticity of a message, i.e. a proof that the message has not been tampered with. RSA allows us to sign messages by "encrypting" them using the private key, the result being a signature that anyone can verify by "decrypting" it with the public key and comparing it to the associated message. Any attempt to tamper with the message will result in it no longer matching the signature, and vice-versa. Futhermore, a signature can only be generated using the private key, making it a secure and efficient method of confirming the authenticity of messages.
Say Alice wants to send a message to Bob, but does not want Mallory, who has established herself as a middleman, to make changes to the message or swap it out entirely. Fortunately, Bob knows Alice's public key, and since
ee
and
dd
are inverses such that
ed1modϕ(n)ed \equiv 1\mod \phi(n)
, Alice can sign her message
mm
by "encrypting" it with the private key such that
smdmodns \equiv m^d \mod n
, where
ss
is the signature verifying that the message came from Alice. Alice can now send
mm
and
ss
to Bob, who is now able to check the authenticity of the message by checking if
msemodnm \equiv s^e \mod n
. If Mallory tries to change
mm
, this congruence no longer holds, and since she does not have the private key, she is also unable to provide a maching
ss
for her tampered message.

V- Format

Last modified 4mo ago