Current location - Quotes Website - Personality signature - Asymmetric encryption -RSA encryption
Asymmetric encryption -RSA encryption
Decomposition of a large integer, known as Fermat's last theorem in higher mathematics, has not been cracked so far.

RSA algorithm is the most popular public key cryptography algorithm, which uses variable-length keys. RSA is the first algorithm that can be used for data encryption and digital signature.

This is the most important encryption algorithm on the earth at present.

At this point, all calculations are completed.

Encapsulate n and e as public keys, and encapsulate n and d as private keys.

Looking back at the above key generation steps, six numbers appear in a * * *:

Of these six numbers, two (n and e) are used for public keys, and the other four numbers are not public. The most important thing is D, because N and D constitute the private key. Once d is leaked, it means that the private key is leaked.

So, if n and e are known, is it possible to deduce d?

Eventually converted into-> Conclusion: If n can be factorized, D can be calculated, indicating that the private key has been cracked.

Step 1: First, generate a key pair.

Step 2: public key encryption

Step 3: Decrypt the private key.

Interpretation of several global variables:

About the encryption filling method: I thought that the above operations could realize rsa encryption and decryption, thinking that everything was fine. Hehe, the tragedy still happened. The encrypted data on the android side can't be decrypted by the server, which leads to the reason that it can't be decrypted on the server after being encrypted on the Android machine, so we must pay attention to this when implementing it.

Realizing segmented encryption: I confidently thought everything was normal after I got the filling method, but the accident still happened. RSA asymmetric encryption content is limited in length, and 1024-bit key can only encrypt 127-bit data at most. Otherwise, an error will be reported (javax.crypto.illegalblockziexception: the data length should not exceed 1 17 bytes), and RSA is a commonly used asymmetric encryption algorithm. Recently, however, an "incorrect length" exception appeared, which was found to be caused by long data to be encrypted. RSA algorithm stipulates that the number of encrypted bytes cannot exceed the key length divided by 8 and then minus 1 1 (i.e. KeySize/8- 1 1), and the number of encrypted bytes is exactly the key length divided by 8 (i.e. KeySize/8).

Alice chose 6 1 and 53. (In practical application, the bigger these two prime numbers are, the more difficult it is to crack. )

Alice multiplies 6 1 by 53.

The length of n is the key length. 3233 is written as binary11001,and a * * * has 12 bits, so this key is 12 bits. In practical application, the RSA key is generally 1024 bits, and it is 2048 bits in important occasions.

Alice calculated that φ(3233) is equal to 60×52, which is 3 120.

Alice is between 1 and 3 120, and randomly chooses 17. (In practical application, 65537 is often selected. )

The so-called "modular inverse element" means having an integer d, which can divide the remainder of ed by φ(n) 1.

This formula is equivalent to

Therefore, finding the modulus inverse d is essentially solving the following binary linear equation.

E= 17,φ(n)=3 120,

So far, all the calculations have been completed.

In Alice's example, n=3233, e= 17 and d=2753, so the public key is (3233, 17) and the private key is (3233, 2753).

In practical application, the data of public key and private key are expressed in ASN. 1

Looking back at the above key generation steps, six numbers appear in a * * *:

Of these six numbers, two (n and e) are used for public keys, and the other four numbers are not public. The most important thing is D, because N and D constitute the private key. Once d is leaked, it means that the private key is leaked.

So, if n and e are known, is it possible to deduce d?

Conclusion: If n can be factorized, D can be calculated, indicating that the private key has been cracked.

However, factorization of large integers is a very difficult thing. At present, no other effective methods have been found except violent cracking. Wikipedia wrote like this

For example, you can factorize 3233 (6 1x53), but you can't factorize the following integers.

It is equal to the product of these two prime numbers.

In fact, the principle of RSA encryption is an unsolved problem in higher mathematics, so there is no reliable RSA cracking method.