Analysis of encryption and decryption process of RSA encryption algorithm

Source: Internet
Author: User
Tags asymmetric encryption

1. Overview of cryptographic algorithms

The encryption algorithm can be divided into reversible and non-reversible encryption depending on whether the content is restored.

Reversible encryption can be divided into symmetric and asymmetric encryption according to whether the same key is used for encryption and decryption.

Symmetric encryption refers to the same key that is used when encrypting and decrypting: For a simple example, do a simple cryptographic processing of a string C, for each word nonalphanumeric and a Do XOR, form ciphertext s. When decrypting, use ciphertext s and key A to make a different or revert to the original string C. One of the big drawbacks of this encryption is that it's unsafe, because once the encryption key is compromised, you can use that key to hack all the other ciphertext.

Asymmetric encryption uses a different key, the public key and the private key, during encryption and decryption. The public key is used for encryption, and everyone is visible, the private key is used for decryption, only the decryption holder. Even if the original text and ciphertext leak in a single encryption process, the cracker can not infer the private key in the case of knowing the original text, ciphertext and public key, which ensures the security of the data to a great extent.

Here, we introduce a very representative asymmetric encryption algorithm, RSA encryption algorithm. RSA algorithm was invented in 1977, the full name is the RSA public key System, which is the common key.

2. Key calculation and acquisition process

The key is calculated as: first select two prime numbers p and Q, to make n=p*q.

Make k=? (n) = (p?1) (q?1), see Principle 4 analysis

Select any integer d to ensure that it is with the K coprime

Take the integer e, making [De]k=[1]k. This means that de=kt+1,t is an integer.

The process of using 3.RSA encryption algorithm

Similarly, for example, to encrypt a string, such as the art of programming, the RSA algorithm provides two public keys E and N, with a value of two positive integers, the decryption party holds a private key D, and then begins the process of encrypting and decrypting.

1. The string is converted to a positive integer z based on a certain regularity, for example, 0 to 36, and an integer sequence is formed after the conversion.

2. For each character corresponding to the positive integer mapping value z, calculate its encrypted value m= (n^e)%n. Where N^e represents the e-time side of N.

3. After the decryption party receives the ciphertext, it begins to decrypt and calculates the decrypted value (m^d)%n, where the positive integer z is obtained.

4. Depending on the public conversion rules that you set up, you can convert Z to the corresponding character and get clear text.

Principle analysis of 4.RSA encryption algorithm

The following analysis of its intrinsic mathematical principles, the RSA encryption algorithm will have to talk about Euler's theorem.

Euler's theorem (Euler's theorem) is a more applicable theorem found in the process of proving Fermat theorem.
First, define a function called the Euler phi function, i.e. (n), where n is a positive integer.
? (n) = Total (from 1 to n?1, and n coprime integers)
For example 5, then 1,2,3,4, all with 5 coprime. With 5 coprime the number has 4.? (5) =4
Again such as 6, with 1,5 coprime, and 2,3,4 not coprime. So? (6) =2
For a prime number p, it and 1, 2, 3, ..., p–1 are coprime, so? (p) =p?1. Like what? (7) = 6,? (11) =10

Euler's theorem is described as follows:
Euler's theorem: if n is a positive integer, a is either a non-0 integer, and N and a coprime. So, a^? (n)? 1 can be divisible by N.

Corollary 1: If M and n are positive integers of coprime. So? (MN) =? (m)? (n)

Inference 2:[ab]n=[[a]n[b]n]n

Proof: Suppose that the remainder of a and b divided by N is c1,c2. A and B can be written as A=NT1+C1,B=NT2+C2. So, ab=n2t1t2+nt1c2+nt2c1+c1c2. So the remainder of AB divided by N is c1c2. That is [Ab]n=[a]n[b]n.

with the above theorem, the intrinsic principle of RSA algorithm can be deduced .

According to Euler's theorem, for any z, if z and N coprime, then:
[z^? (n)] N=[z^k]n=[1]n

So
[z^ (DE)]n=[z^ (kt+1)]n=[z^ (kt) *z]n=[z^kt]n*[z]n= [Z]n because [z^k]n = [1]n
The above mainly uses de=kt+1 and inference 2. Other words:
[z^ (DE)]n=[z]n

According to the inference of 2, there is
([Z^e]n) ^d=[z]n

That is, the D remainder is multiplied because its product may be greater than n, so the [Ab]n=[[a]n[b]n]n, for example, A and B are 5,n to 3, the conclusion

Therefore, the formula can be described as [([Z^e]n) ^d]n=[z]n=z, that is, the original number of the balance of the remainder, and then the remainder after the second to obtain the original number of the process of obtaining evidence.

Public encryption method, private decryption method. The key to RSA security is that it is difficult to factor the decomposition of a large integer.

Disadvantages of 5.RSA Encryption

1) It is troublesome to generate a key, which is limited by the technology of prime number generation, so it is difficult to do it once.
2) security, RSA Security relies on the large number of factor decomposition, but did not theoretically prove that the difficulty of deciphering RSA and large number decomposition is equivalent, and the majority of cryptography scholars tend to factor decomposition is not NP problem.

3) too slow, due to the RSA packet length is too large, in order to ensure security, n at least more than BITX, so that the cost of the operation is very high, especially the speed is slow, more than symmetric cipher algorithm several orders of magnitude, and with the development of large number decomposition technology, this length is still increasing, not conducive to standardization of data format.

Analysis of encryption and decryption process of RSA encryption 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.