Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Https (SSL / TLS) Detailed principles     - C ++ 11 feature: decltype keywords (Programming)

- iscsiadm command usage (Linux)

- Linux (Ubuntu) How iptables port mapping (Server)

- Nginx installation configuration Zabbix (Server)

- Configuring the PXE server in Ubuntu 14.04 (Server)

- A simple shell script for monitoring in Linux (Linux)

- Java multi-threaded communications pipeline flow (Programming)

- C ++ inheritance and derived (induction principle) (Programming)

- How to Debian Linux the default Python version switch to alternative version (Linux)

- Apache Kafka: the next generation of distributed messaging system (Server)

- CentOS install expect (Linux)

- Python2 ---- function using dictionaries (Programming)

- VirtualBox 4.3 Can not open a new task for a virtual computer solution (Linux)

- Ubuntu 14.04.02 LTS startup items erroneous writing / dev / sda1 (win 7 loader) Repair (Linux)

- Memcached installation, configuration and monitoring (Server)

- How to upgrade Docker 1.6 on Fedora / CentOS (Server)

- Transfer MySQL database to MariaDB (Database)

- Using monitoring tool dsniff (Linux)

- Linux iptables: basic principles and rules (Linux)

- How to manage Vim plugin (Linux)

 
         
  Https (SSL / TLS) Detailed principles
     
  Add Date : 2018-11-21      
         
       
         
  Recently started work Https networking, spend time learning under Https, SSL / TLS-related content. For me Https, SSL / TLS understanding to share with you, the way to bury a foreshadowing, even after the time is ripe to share with you "encryption basics" because SSL / TLS encryption and decryption have a lot of knowledge areas. On the technical side, I am my own requirements went, we must better understand. For the understanding is not thorough or incorrect place, welcome to participate in the discussion.

Outline

Https (Hyper Text Transfer Protocol over Secure Socket Layer), is based on SSL / TLS for Http, all data is http over SSL / TLS protocol encapsulation transmission. Http Https agreement on the basis of the agreement, adding SSL / TLS handshake and encrypted data transmission, also belong to the application layer protocol. Therefore, the study Https principle agreement, in fact, is to study the final SSL / TLS protocol.

SSL protocol is a secure transmission protocol, originally issued by Netscape in 1996, due to some security reasons SSL v1.0 and SSL v2.0 are not open until 1996 SSL v3.0. TLS SSL v3.0 is an upgraded version of the current market for all Https you are using TLS, instead of SSL. This paper analyzes and explains TLS.

TLS handshake

TLS handshake phase occurs after the TCP handshake. Handshake is actually a process of negotiation, agreement on some of the parameters necessary for consultations.

Client Hello

Because the client (such as a browser) encryption algorithm for some degree of support is not the same, but you must use the same set of encryption algorithms to ensure data TLS protocol transmission to normal encryption and decryption. In the TLS handshake, the client must first inform the service side, which support its own encryption algorithms, so the client will need local support cipher suite (Cipher Suite) list sent to the server. In addition, the client also generates a random number, the random number on the one hand needs to be saved on the client, on the other hand need to send to the server, the client random number random number with the needs of server-side generated combined to produce later to mentioned Master Secret.

Server Hello

The figure above, from the Server Hello to Server Done, to achieve some of each server is sent separately, there is the server implementation is sent to merge together. Sever Hello and Server Done are not only the first data content.

After receiving the server to the client Client Hello, the server needs to send its own certificate to the client. This certificate is for an authentication server. For example, the client received a call themselves www.alipay.com from the data, but how to prove that the other party is legally alipay Alipay it? This is the role of the certificate, the certificate Alipay can prove that it is alipay, instead TenPay. A certificate is required to apply by dedicated digital certificate authority (CA) after the adoption of an electronic certificate issued very strict review. The certificates will also generate a private key and public key. Save yourself from the server private key, can not leak. The public key is included with the certificate information can be disclosed. Certificate itself also comes with a certificate of electronic signature, the signature to verify the integrity and authenticity of the certificate, the certificate can be prevented from being falsification. In addition, there is a valid certificate.

Did not provide enough information in the certificate sent by the server to the client in time, you can also send a Server Key Exchange to clients.

In addition, a very important confidential data, the server needs to authenticate the client to ensure that the data is transferred to the safety of a legitimate client. The server can issue Cerficate Request message to the client, the client sends the requested certificate to verify the legitimacy of the client.

Like with the client, the server also need to generate a random number to the client. Clients and servers need to use these two random numbers to generate Master Secret.

Finally, the server sends a Server Hello Done message to the client indicating Server Hello message over.

Client Key Exchange

If, after the server needs to authenticate the client, the server receives Server Hello message in the client, you first need to send the client certificate to the server, allowing the server to verify the client's legitimacy.

All TLS handshake before this information is transmitted in plain text. After receiving the certificate server and other information, the client will use some encryption algorithms (for example: RSA, Diffie-Hellman) generates a 48-byte Key, this Key called PreMaster Secret, many materials are also known as PreMaster Key , the resulting session secret by Master secret, session secret is used for application data encryption and decryption. PreMaster secret belonging to a secret Key, random number plaintext transmission intercepted PreMaster secret before long, you can pass the final calculation of the session secret, so PreMaster secret use RSA asymmetric encryption method, using the server's public key to encrypt transmission over and then passed to the server.

Next, the client needs the server certificate of inspection, as well as the integrity of the certificate with domain name server checks whether the certificate match.

ChangeCipherSpec is an independent agreement is reflected in one byte of data in the packet, for informing service, the client has been switched to the negotiated cipher suite before the state negotiated cipher suite to encrypt data and until ready to use transferred.

After ChangecipherSpec transfer is completed before the client uses the negotiated cipher suite and good data transfer session secret encryption section Finish to end the service, this data is in order before the formal transfer application data on just a handshake set up encryption for authentication channel .

Server Finish

After receiving the server to the client PreMaster pass over the encrypted data using the private key to decrypt the encrypted data on this, and to verify the data is also used to generate session secret with a client in the same way, after all the good, the client will send a ChangeCipherSpec, inform the client has switched to the negotiated cipher suite, ready to use cipher suite and the session secret encrypted data. Thereafter, the server will be used for a period Finish message sent to the client after the session secret encryption, set up to verify before handshake channel encryption and decryption is successful.

According to information before the handshake, if the client and server can be normal to Finish message encryption and decryption and the message right is verified, then the handshake channel has been successfully established, then, the two sides can use the session secret data generated above the encrypted transmission.

Secret Keys

Analyze and explain the above is mainly to highlight the handshake process, so PreMaster secret, Master secret, session secret generation is over, but for Https, SSL / TLS-depth understanding and grasp these Secret Keys are a very important part. So, ready to come out of these Secret Keys separate analysis and explanation.

PreMaster secret

PreMaster secret is in the client using RSA or Diffie-Hellman encryption algorithms such as generated. It will be used with the random number server and client Hello phase produced together generate Master secret. Sent to the server after the client uses the services of a single public key to encrypt PreMaster secret, the server uses a private key to decrypt get PreMaster secret. This means that the server and the client has a copy of the same PreMaster secret and the random number.

PreMaster secret before the two bytes TLS version number, which is a relatively important to check the version number of handshake because Client Hello stage, the client will send a list of cipher suites currently supported and SSL / TLS the version number to the server, and is transmitted in plain text, if after the handshake packets is compromised, the attacker is likely to falsification of data packets, choose a less secure encryption suite and version to the server, thereby data crack. Therefore, the server needs to decrypt ciphertext out PreMaster version number with the previous version of the Client Hello phase comparison, if the version number is low, then the string is changed, then immediately stop sending any messages.

Calculation of PreMaster Secret (Key), refer to "Htttps SSL / TLS PreMaster / Master Secret (Key) calculation."

Master secret

As mentioned above, due to the service and the client has a copy of the same PreMaster secret and the random number, the random number seed generated as Master secret behind the combination PreMaster secret, the client and server will be calculated the same Master secret .

Master secret hash value is composed of the series, it will serve as data encryption and decryption of secret related to the Key Material.

Wherein, write MAC key, that session secret or a session key. Client write MAC key client send data session secret, Server write MAC secret service sends data session key. MAC (Message Authentication Code), a digital signature is used to verify the integrity of the data, can detect whether or not the data is falsification. See works on MAC MAC.

Calculation of Session Secret (Key), refer to "Htttps SSL / TLS Session Secret (Key) calculation."

Application data transmission

After all the handshake stage is completed, you can start a data transfer application. Application data prior to transmission, the first to attach the MAC secret, and then use this data packet write encryption key for encryption. After the server receives the ciphertext using Client write encryption key to decrypt the client after receiving the data server using Server write encryption key to decrypt, and then use their own write MAC key for data integrity including whether falsification authenticating.

to sum up

Talking about this, Https principle is actually SSL / TLS explain the principles are finished, I can only say that TLS is not only a secure transmission protocol, and is a work of art.
     
         
       
         
  More:      
 
- Enterprise-class GitHub warehousing environment build (Server)
- Ubuntu resolve sudo: source: command not found error (Linux)
- Linux5.8 installed phpMyAdmin was unable to issue related php-mcrypt (Database)
- WinSCP to transfer text files will automatically convert the format (Linux)
- Linux System Administrator common interview questions and answers 30 (Linux)
- DM9000 bare Driver Design (Programming)
- Classical sorting algorithm - Selection Sort (Linux)
- Intrusion analysis and prevention tools Knark under Linux platform (Linux)
- To install and deploy PHP environment under the CentOS (Server)
- Ubuntu installed racing game Speed Dreams 2.1 (Linux)
- PostgreSQL export table structure information (Database)
- Oracle PLS-00231 error analysis (Database)
- Ubuntu root user profiles (Programming)
- Android Studio 1.0.2 set the memory size (Linux)
- ORA-04031 error appears in the solution 11.2.0.4 run utlrp.sql (Database)
- Kitematic how seamless and DockerFILE (Server)
- Installation salt-minion on RHEL5 (Linux)
- Ubuntu 14.10 splash screen brightness settings (Linux)
- KVM installation under CentOS 5.5 (Linux)
- Ubuntu deployed under regular tasks with crontab (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.