RSA algorithm tutorial

Source: Internet
Author: User
Tags modulus

Comments: It is the first algorithm that can be used for both data encryption and digital signature. It is easy to understand and operate, and is also popular. The algorithm is named by the inventor Ron Rivest, Adi Shamir, and Leonard Adleman. However, the security of RSA has never been proved theoretically. It has experienced various attacks and has not been completely cracked yet. I. RSA algorithm: first, it is the first algorithm that can be used for both data encryption and digital signature. It is easy to understand and operate, and is also popular. The algorithm is named by the inventor Ron Rivest, Adi Shamir, and Leonard Adleman. However, the security of RSA has never been proved theoretically. It has experienced various attacks and has not been completely cracked yet. I. RSA algorithm: first, find three numbers, p, q, r,
Where p, q are two different prime numbers, r is the number of interconnectivity with P-1) (q-1 ......
P, q, r these three numbers are private key next, find m, so rm = 1 mod (PM) (q-1 ).....
This m must exist, because r and (p-1) (q-1) Interoperability, with the moving phase division can be obtained .....
Then, calculate n = pq .......
M, n is the public key encoding process. If the data is a, it is regarded as a large integer. Suppose a <n ....
If a> = n, the table is converted into s-carry (s <= n, usually s = 2 ^ t ),
Then each digit is less than n, and the subsequent encoding is ......
Next, calculate B = a ^ m mod n, (0 <= B <n ),
B is the encoded data... the decoding process is: Calculate c = B ^ r mod pq (0 <= c <pq ),
So, the decoding is completed ...... will prove that c and a are actually equal: if a third party eavesdroppers, he will get several numbers: m, n (= pq), B ......
If he wants to decode it, he must find a way to get the r ......
Therefore, he must first perform prime factor decomposition on n .........
To prevent decomposition, the most effective method is to find two very large numbers p, q,
Making it difficult for a third party to conduct factor decomposition .........
<Theorem>
If p, q is a different prime number, rm = 1 mod (PM) (q-1 ),
A is any positive integer, B = a ^ m mod pq, c = B ^ r mod pq,
Then, the process of c = a mod pq proof will use the ferma's theorem, which is described as follows:
M is any prime number, n is any integer, then n ^ m = n mod m
(In other words, if n and m are mutually qualitative, then n ^ (S-1) = 1 mod m)
Using some basic group theory knowledge, it is easy to prove the theory of Fei Ma's small theorem... <proof>
Because rm = 1 mod (PM) (q-1), rm = k (PM) (q-1) 1, where k is an integer
Because it is preserve multiplication in modulo.
(X = y mod z and u = v mod z => xu = yv mod z ),
So c = B ^ r = (a ^ m) ^ r = a ^ (rm) = a ^ (p-1) (q-1) 1) mod pq 1. if a is not a multiple of p or a multiple of q,
Then a ^ (p-1 = 1 mod p (ferma's theorem) => a ^ (k (PM) (q-1) = 1 mod p
A ^ (q-1) = 1 mod q (ferma's theorem) => a ^ (p-1) (q-1) = 1 mod q
So p, q can divide all a ^ (k (PM) (q-1)-1 => pq | a ^ (k (PM) (q-1)-1
That is, a ^ (p-1) (q-1) = 1 mod pq
=> C = a ^ (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 (ferma's theorem)
=> A ^ (p-1) (q-1) = 1 mod q
=> C = a ^ (p-1) (q-1) 1) = a mod q
=> Q | c-
Because p |
=> C = a ^ (p-1) (q-1) 1) = 0 mod p
=> P | c-
Therefore, pq | c-a => c = a mod pq 3. if a is a multiple of q, but not a multiple of p, it is proved to be the same as 4. if a is a multiple of p and q At the same time,
Then pq |
=> C = a ^ (p-1) (q-1) 1) = 0 mod pq
=> Pq | c-
=> C = a mod pq
Q. E.D.
This theorem indicates that when a is encoded as B and decoded as c, a = c mod n (n = pq )....
However, when encoding and decoding, the limit is 0 <= a <n, 0 <= c <n,
So this means that a is equal to c, so this process can indeed implement the encoding and decoding function ..... ii. RSA Security the security of RSA depends on the decomposition of large numbers, but whether it is equivalent to the decomposition of large numbers has never been proved theoretically, because it does not prove that the cracking of RSA requires a big number decomposition. Suppose there is an algorithm that does not need to break down large numbers, it can be modified into a big number decomposition algorithm. At present, some variant algorithms of RSA have been proved to be equivalent to large number decomposition. In any case, decomposition of n is the most obvious attack method. Now, people can break down the large prime numbers of multiple decimal places. Therefore, the modulus n must be larger, depending on the specific application. III. The speed of RSA is calculated by a large number, which leads to the fastest speed of RSA than that of DES, whether in software or hardware. Speed has always been a defect of RSA. Generally, it is used only for a small amount of data encryption. 4. RSA select Ciphertext Attack RSA is vulnerable to select ciphertext attacks. Generally, attackers disguise a piece of information and sign the entity with the private key. Then, the desired information is obtained after calculation. In fact, the attack uses the same weakness, that is, the fact that the multiplication structure of the input is retained by the power:
(XM) ^ d = X ^ d * M ^ d mod n
As mentioned above, this inherent problem comes from the most useful feature of the public key cryptography system-everyone can use the public key. However, the algorithm cannot solve this problem. There are two main measures: one is to use a good public key protocol to ensure that the entity does not decrypt any information generated by other entities during the work process, you do not need to sign any information that you do not know about. The other is never to sign a random document sent by strangers. When signing a document, use One-Way HashFunction to HASH the document, or use different signature algorithms at the same time. I mentioned several different types of attack methods. 5. RSA Public module attacks if the system has a module, but different people have different e and d, the system will be dangerous. The most common situation is that the same information is encrypted with different public keys. These public keys are common mode and are mutually compatible, so that the information can be restored without the private key. If P is set to plaintext, the two encryption keys are e1 and e2, and the public modulus is n, then:
C1 = P ^ e1 mod n
C2 = P ^ e2 mod n
The password analyzer knows n, e1, e2, C1, and C2 to obtain P.
Because of the mutual quality between e1 and e2, the Euclidean algorithm can be used to locate r and s to meet the following requirements:
R * e1 s * e2 = 1
Assume that r is a negative number and the Euclidean algorithm is used to calculate C1 ^ (-1 ).
(C1 ^ (-1) ^ (-r) * C2 ^ s = P mod n
In addition, there are several other methods to use public modulus attacks. In short, if we know a pair of e and d for a given modulus, one is conducive to the decomposition of modulus by attackers, and the other is conducive to the calculation of other pairs of e and d, without the need to break down the modulus. There is only one solution, that is, do not share the modulus n.
Small index attack of RSA. We recommend that you set the public key e to a smaller value to increase the RSA speed. This will make encryption easier and faster.
. However, this is not safe. The solution is to take a large value for both e and d.
The RSA algorithm is the first algorithm that can be used for both encryption and digital signature, and is easy to understand and operate. RSA is the most widely studied public key algorithm. It has been nearly two decades since it was proposed. It has been tested by various attacks and is gradually accepted by people, it is generally regarded as one of the best public key solutions. The security of RSA depends on the factorization of large numbers, but it is not theoretically proved that the difficulty of deciphering RSA is equivalent to the difficulty of decomposing large numbers. That is to say, the major defect of RSA is that it cannot theoretically grasp its confidentiality performance. In addition, most people in the cryptographic field tend to issue factor decomposition rather than NPC. The main disadvantages of RSA are as follows: A) It is difficult to generate keys, which is restricted by the technology of generating prime numbers. Therefore, it is difficult to achieve one-time password at A time. B) The Group length is too large. To ensure security, n must be at least 600 bits, which results in a high computing cost, especially when the speed is low, which is several orders of magnitude slower than that of symmetric cryptographic algorithms; with the development of big data decomposition technology, this length is still increasing, which is not conducive to the standardization of data formats. Currently, the SET (Secure Electronic Transaction) protocol requires CA to use a bit-long key, while other entities use a bit key.

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.