RSA
1977 year , Three mathematicians Rivest、Shamir and Adleman An algorithm is designed , Asymmetric encryption can be achieved . The algorithm is named after the three of them , be called RSA Algorithm .
RSA The security of the algorithm is based on judging whether a number is prime or not , But it is difficult to decompose a number into prime factors .
RSA Public and private key generation steps
- Find two large prime numbers \(P\) and \(Q\), The bigger the better , Calculation \(P\) and \(Q\) The product of the \(N\)
- Calculation N The Euler function of \(\varphi(N)\), Make it worth \(M\)
- Find one and \(M\) Reciprocal integers \(E\)
- Calculate the whole number \(E\) model \(M\) Multiplicative inverse element of \(D\)
Final , take \((N,D)\) As the private key ,\((N,E)\) As a public key
RSA Encryption and decryption steps
The following is encrypted with the private key , The process of public key decryption :
- encryption :
- Decrypt :
You can restore the encrypted data here because
Euler's theorem is used in the above derivation :\(X^{\varphi(N)}\equiv 1\,mod\,N\), But it takes \(X\) And \(N\) Coprime
When \(X\) Not with \(N\) Coprime , Only possible \(X=tP\) perhaps \(X=tQ\), Here we deduce \(X=tP\) The situation of , Here you are \(tP\) And \(Q\) It must be reciprocal
Introduction
because \(P|t'Q\) therefore
The above formula is equivalent to
RSA Security
RSA It can be seen from the generation process of public and private keys that , From you to \(E\) Deduce \(D\) Or vice versa , You have to know how to count \(N\) The Euler function of \(\varphi(N)=(P-1)(Q-1)\)
therefore RSA The security of the algorithm is equivalent to that of large integers \(N\) Factoring to find large prime numbers \(P\) and \(Q\), At present, there is no polynomial solution to prime factor decomposition , So it is possible to ensure that a public-private key pair cannot be cracked within a certain period of time