Asymmetric encryption (2) Asymmetric encryption algorithm

Source: Internet
Author: User
Tags decrypt asymmetric encryption

The basic process is very simple, then the public key encryption, the secret key decryption algorithm in the end what is it? This section briefly describes the basic principles of RSA algorithm, DSA algorithm, ECC algorithm, and Diffie-hellman algorithm, which involves many mathematical knowledge in number theory, discrete mathematics and analytic geometry, which interested readers can use to strengthen the theoretical basis.

RSA algorithm

RSA algorithm is currently the most famous and widely used public key system, 1978 by the Massachusetts Institute of Technology Ron Rivest, Adi Shamir and Leonard Adleman in the paper "Access to digital signature and public key cryptography system" proposed. This is an asymmetric (public key) cipher system based on number theory, which adopts the group encryption method. Its name comes from the initials of three inventors. Its security is based on the difficulty of large integer factor factorization, and the large integer factorization problem is a famous problem in mathematics, so far there is no effective method to solve it, so the security of RSA algorithm can be ensured. RSA system is the most typical method of public key system, most of the products and standards that use public key cryptography to encrypt and digitally sign use RSA algorithm.

RSA algorithm is the first algorithm that can be used both for data encryption and digital signature, so it provides a basic method for the encryption and identification of information on public networks. It is usually Mr. into a pair of RSA keys, one is a secret key, saved by the user, another for public key, can be public, or even in the Web server registration, people with public key encrypted files sent to individuals, individuals can use the private key to decrypt receive. The RSA key is typically 1024 or 2048 digits to increase the security strength.

The RSA algorithm works as follows:

Step 1 selects two different large prime numbers p and Q arbitrarily, and calculates the product r=p*q.

Step 2 Arbitrarily Select a large integer e,e and (p-1) * (q-1) coprime, integer e used as the encryption key. Note: The selection of E is easy, and all prime numbers greater than P and Q are available.

Step 3 determines the decryption key D:D * e = 1 mod (p-1) * (q-1) can easily compute d based on E, p, and Q.

Step 4 exposes integers r and E, but does not expose D.

Step 5 encrypts the plaintext P (p is an integer less than R) to ciphertext C, calculated as C = p^e mod R.

Step 6 decrypts ciphertext C to plaintext p, and the method is: p = c^d modulo R.

However only according to R and E (not p and Q) It is impossible to compute D. Therefore, anyone can encrypt plaintext, but only authorized users (known as D) can decrypt the ciphertext.

If you are interested in the mathematical proof of the RSA algorithm, you can see the extended reading.

Mathematical proof of extended reading RSA algorithm

Theorem if p, Q is a different prime number, RM = = 1 mod (p-1) (q-1); A is any positive integer, b = = a^m MoD PQ, c = = b^r MoD PQ, then C = a mod pq.

Fermat's little theorem m is any prime number, n is any integer, then n^m = = n mod m. (or if N and M coprime, then n^ (m-1) = = 1 mod m).
Prove
because RM = = 1 mod (p-1) (q-1), RM = K (p-1) (q-1) + 1, where k is an integer.
Because it's preserve multiplication in the modulo.

x = = y MoD z and u = v mod z => xu = = yv MoD Z

So

c = = B^r = = (a^m) ^r = = a^ (rm) = = a^ (k (p-1) (q-1) +1) MoD PQ
1. If a is not a multiple of p and is not a multiple of Q, then

a^ (p-1) = = 1 mod p (Fermat's little Theorem) => a^ (K (p-1) (q-1)) = = 1 mod p
a^ (q-1) = = 1 mod q (Fermat's little Theorem) => a^ (K (p-1) (q-1)) = = 1 mod q
So p, Q can all be divisible

a^ (K (p-1) (q-1))-1 => PQ | a^ (K (p-1) (q-1))-1
That

a^ (K (p-1) (q-1) = = 1 MoD PQ => c = = a^ (k (p-1) (q-1) +1) = = a mod PQ
2. If a is a multiple of p, but not a multiple of Q, then

a^ (q-1) = = 1 mod q (Fermat's little Theorem)
=> a^ (K (p-1) (q-1) = = 1 mod q
=> c = = a^ (k (p-1) (q-1) +1) = = a mod q
=> Q | C-a
Because P | A
=> c = = a^ (k (p-1) (q-1) +1) = = 0 mod p
=> p | C-a
So

PQ | C-a => C = a mod PQ
3. If a is a multiple of Q, but not a multiple of p, prove ditto.
4. If a is a multiple of both P and Q, then

PQ | A
=> c = = a^ (k (p-1) (q-1) +1 = = 0 MoD PQ
=> PQ | C-a => C = a mod PQ

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.