The encryption process of https uses a combination of symmetric and asymmetric

(1) Symmetric Cryptography --- Shared Key Encryption
Symmetric encryption is the fastest and simplest encryption method. The same secret key is used for encryption and decryption. , This method is called symmetric encryption algorithm in cryptography. Symmetric encryption has many kinds of algorithms, and because of its high efficiency, it is widely used in the core of many encryption protocols.
Symmetric encryption usually uses relatively small keys, typically less than 256 bits. Because the larger the key, the stronger the encryption, but the slower the encryption and decryption process. If you only use 1 bit for this key, hackers can try to decrypt it with 0 first, and if that doesn't work, use 1; but if your key is 1 MB, hackers may never be able to crack it. But the process of encryption and decryption takes a long time. The size of the key should take into account both security and efficiency, which is a trade-off.
One of the big drawbacks of symmetric encryption is the management and distribution of the keys, in other words, how to get the keys into the hands of those who need to decrypt your messages is a problem. In the process of sending the key, there is a great risk that the key will be intercepted by hackers. The common practice in reality is to asymmetrically encrypt the symmetric encryption key and transmit it to the person who needs it.
(2) Asymmetric Cryptography - Public Key Encryption

In 1976, American scholars Dime and Henman proposed a new key exchange protocol in order to solve the problem of public information transmission and key management, which allows insecure encryption. The two sides of the communication on the medium exchange information and securely agree on the key, which is the "public key system". Compared with the "symmetric encryption algorithm", this method is also called "asymmetric encryption algorithm".
Asymmetric encryption provides a very secure method for data encryption and decryption, which uses a pair of keys, a public key and a private key. The private key can only be kept safely by one party and cannot be leaked, while the public key can be sent to anyone who requests it. Asymmetric encryption uses one of the pair of keys for encryption, while decryption requires the other key. For example, if you request the public key from the bank, the bank sends the public key to you, and you use the public key to encrypt the message, then only the holder of the private key, the bank, can decrypt your message. Unlike symmetric encryption, the bank does not need to send the private key over the network, so the security is greatly improved.
The most commonly used asymmetric encryption algorithm is the RSA algorithm, which was invented by Rivest, Shamir, and Adleman in 1978.
Although asymmetric encryption is very secure, it is very slow compared to symmetric encryption, so we still use symmetric encryption to transmit messages, but the key used in symmetric encryption can be sent through asymmetric encryption. To explain this process, look at the following example:
(1) Alice needs to make a transaction on the bank's website. Her browser first generates a random number as a symmetric key.
(2) Alice's browser requests the public key from the bank's website.
(3) The bank sends the public key to Alice.
(4) Alice's browser encrypts its own symmetric key with the bank's public key.
(5) Alice's browser sends the encrypted symmetric key to the bank.
(6) The bank uses the private key to decrypt to obtain the symmetric key of Alice's browser.
(7) Alice and the bank can use the symmetric key to encrypt and decrypt the communication content.
(3) Summary
(1) Symmetric encryption uses the same key for encryption and decryption, so the speed is fast, but because the key needs to be transmitted over the network, the security is not high.
(2) Asymmetric encryption uses a pair of keys, public key and private key, so the security is high, but the speed of encryption and decryption is slow.
(3) The solution is to encrypt the symmetric encryption key with the asymmetric encryption public key, and then send it out. The receiver uses the private key to decrypt to obtain the symmetric encryption key, and then the two parties can use symmetric encryption to communicate. .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325938947&siteId=291194637