Asymmetric encryption technology--analysis of the mathematical principle of RSA algorithm

Source: Internet
Author: User
Tags decrypt asymmetric encryption

Asymmetric encryption technology, in the current network, has a very wide range of applications. Encryption technology is the basis of digital money.

Asymmetric, which means that the algorithm requires a pair of keys, using one (public key) encryption, you need to use another (private key) to decrypt.
But for its principle most students should be smattering, today to analyze the classic asymmetric encryption algorithm-RSA algorithm.
Through the analysis of this paper, we can better understand the principle of asymmetric encryption, so that we can better use asymmetric encryption technology.

Off Topic:
This blog has been planning to write a series of popular cryptography, yesterday to the site of HTTPS, because of the use of RSA algorithm, looked up, found that the online introduction of the RSA algorithm article is written too difficult to understand, anyway also prepared to write cryptography, first write the RSA algorithm bar, below the beginning of the text.

Principles of RSA algorithm

The RSA algorithm is based on the mathematical fact that the large number multiplied by two large prime numbers is difficult to factorization.
Such as: There are very large prime numbers p and q, it is easy to calculate n, so that n = p * Q,
But given N, it's harder to find P Q (no good way, just keep trying)

This is actually the concept of one-way function.

Let's take a look at the mathematical calculus process :

  1. Select two large prime number p,q, calculate N = P q and φ (n) =φ (p) φ (q) = (p-1) * (q-1)

    Three Mathematical concepts:
    Prime Number (Prime Numbe): Also known as the prime number, for the natural numbers greater than 1, except 1 and itself no longer have other factors.
    coprime Relationship : If there are two positive integers, except 1, there is no other common factor, we call these two numbers a coprime relationship (coprime).
    φ (N): called Euler function , refers to any given positive integer n, in a positive integer less than or equal to N, how many and n constitute a coprime relationship.
    > If n is a prime number, then φ (n) =n-1.
    > If n can be decomposed into the product of an integer of two coprime, φ (n) =φ (P1P2) =φ (p1) φ (p2). The Euler function of the product is equal to the product of the Euler function of each factor.

  2. Select an e that is greater than 1 and less than φ (n) so that E and φ (n) coprime

    E is actually a prime number before 1 and φ (N)

  3. Calculates d so that De=1 modφ (n) is equivalent to equation ed-1 = k φ (n) to find a set of solutions.

    D is known as the modulo inverse of e, and E and φ (N) coprime must be present.
    > modulo inverse element means that if two positive integers a and n coprime, then the integer b must be found, so that the remainder of AB by N is 1, then B is called a modulo inverse element.
    > can prove the existence of modulo inverse element according to Euler theorem, and Euler's theorem refers to if N,a coprime, then:
    > a^φ (n) ≡1 (mod n) and a^φ (n) = a * a^ (φ (n)-1), which can be φ (n)-1 times A, is a modulo inverse element.

  4. (n, e) is encapsulated into a public key, (n, D) encapsulated into a private key.
    Assuming that M is plaintext, encryption is the calculation of the ciphertext C:
    M^e mod N = C (plaintext m encrypted with public key E and the random number N takes the remainder to get ciphertext c)
    The decryption is:
    C^d mod N = m (ciphertext c is decrypted with a key and the random number N takes the remainder to get clear m)

    Private key decryption This can be proved, this is not unfolded here.

Add and decrypt steps

Let's take a look at the steps, for example, assuming Alice and Bob have to communicate with each other again.

    1. Alice randomly takes a large prime number p1=53,p2=59, that n=53*59=3127,φ (N) =3016
    2. Take a e=3 and calculate the d=2011.
    3. Only pass n=3127,e=3 as public key to Bob (public key)
    4. Assuming Bob needs to encrypt the plaintext m=89,c = 89^3 mod 3127=1394, Bob returns to c=1394. (Public key cryptography process)
    5. Alice uses c^d mod N = 1394^2011 mod 3127 to get the plaintext m=89. (private key decryption process)

If the attacker can intercept the public key n=3127,e=3 and ciphertext c=1394, it is still impossible to decrypt the ciphertext without passing d.

Security analysis

So, is it possible to derive a d in the case of known N and e?

  1. ed≡1 (mod φ(n))。只有知道e和φ(n),才能算出d。  2. φ(n)=(p-1)(q-1)。只有知道p和q,才能算出φ(n)。  3. n=pq。只有将n因数分解,才能算出p和q。

If n can be decomposed by factoring, D can be calculated, so RSA security is based on the factorization of N. Factorization of large integers is a very difficult thing to do.
As long as the key length is long enough, the information encrypted with RSA is not actually broken.

Supplemental modulo operation rules
    1. Modulo operation Plus subtraction:
      (A + b) mod p = (a mod p + b mod p) mod p
      (A-B) mod p = (a mod p-b mod p) mod p
    2. Modulo operation multiplication:
      (a b) mod p = (a mod p b mod p) mod p
    3. Power of modulo operation
      A ^ b mod p = ((a mod p) ^b) mod p

Asymmetric encryption technology--analysis of the mathematical principle of RSA algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.