What is SSL encryption?

Source: Internet
Author: User
Tags ssl connection asymmetric encryption
SSL encryption methods keywords: SSL encryption methods with the development of computer network technology, convenient and fast Internet connection makes people gradually get used to sending and receiving e-mail, shopping, and transactions from web pages, at this time, important or sensitive data needs to be transmitted on the web page, such as users' bank accounts and passwords. Therefore, network security has become an urgent problem for modern computer network applications. Currently, large online transaction systems such as online banking and e-commerce generally adopt the combination of HTTP and SSL. The server uses a web server that supports SSL, and the client uses a browser that supports SSL for secure communication. SSL is the abbreviation of Secure Socket Layer (Secure Sockets Layer Protocol). It can provide confidential transmission over the Internet. Netscape released the first web browser and put forward the SSL protocol standard, which currently has version 3.0. SSL uses public key technology. The goal is to ensure the confidentiality and reliability of communications between two applications, and support can be achieved at the same time on the server side and the client side. Currently, the SSL protocol using public key technology has become an industrial standard for secure communication on the Internet. This article focuses on the SSL protocol and SSL program design. The SSL protocol is a preliminary introduction to the Secure Sockets Layer protocol that allows users/server applications to communicate with each other without being eavesdropped by attackers. It also allows users to be authenticated. The SSL protocol must be built on a reliable transport layer protocol (TCP. The advantage of the SSL protocol is that it is independent from the application layer protocol. The High-level application layer protocol (such as HTTP, FTP, and telnet) can be transparently built on the SSL protocol. The SSL protocol has completed encryption algorithms, communication key negotiation, and server authentication before the application layer protocol communication. After that, the data transmitted by the application layer protocol will be encrypted to ensure the privacy of the communication. As described above, the secure channel provided by the SSL protocol has the following three features: 1. data Confidentiality Information Encryption refers to converting plaintext input files into encrypted files using encryption algorithms to achieve data confidentiality. The key is used to encrypt the data before decryption. Without a key, the encrypted data cannot be unlocked. After the data is encrypted, only the key must be transmitted in a safe way. Encrypted data can be publicly transmitted. 2. Data Consistency encryption can also ensure data consistency. For example, the message Verification Code (MAC) can verify the encrypted information provided by the user. the receiver can use Mac to verify the encrypted data to ensure that the data has not been tampered with during transmission. 3. Another purpose of Security Authentication Encryption is to serve as a personal identity, and the user's key can be used as the identity for security authentication. SSL uses public key encryption technology (RSA) as the encrypted communication protocol between the client and the server when transmitting confidential data. Currently, most web servers and browsers support SSL technology extensively. When a browser tries to connect to a server with SSL authentication and encryption, it will wake up an SSL session. The browser checks the authentication and must meet the following three conditions: 1) an authority issues a certificate, of course, you can create self-signed certificates (X509 structure ). 2) The certificate cannot expire. 3) The certificate belongs to the server it is connected. Only when all three conditions are met can the browser successfully complete authentication. With these three conditions, you can confirm that your browser is connected to the correct server, instead of connecting to a false server that wants to steal important information such as user passwords. In today's e-commerce, another widely used security protocol is the SET protocol. The Set (Secure Electronic Transaction, Secure Electronic Transaction) protocol is a specification jointly launched by Visa and MasterCard in May 1997. Set can provide greater trust, more complete transaction information, higher security, and less fraud in electronic transactions. The SET transaction is carried out in three phases: the user makes a purchase to the merchant and confirms the payment; the merchant verifies the payment with the bank; and the bank pays the payment to the merchant. Each stage involves RSA Data Encryption and RSA digital signature. The SET protocol requires multiple encryption and decryption operations in one transaction, which ensures high security. However, the SET protocol is more complex than the SSL protocol, both sellers and banks need to transform their systems for interoperability. In Linux, OpenSSL servers are popular for SSL authentication. The OpenSSL Project is a collaborative project that develops a robust, commercial-grade, complete open-source toolkit and uses powerful encryption algorithms to implement a Secure Socket Layer (Secure Sockets Layer, SSL v2/v3) and Transport Layer Security (Transport Layer Security, TLS v1 ). This project is managed and developed by volunteers around the world OpenSSL Toolkit and related documents. How to configure the OpenSSL server in Linux, first download the openssl-version.tar.gz software package from the OpenSSL homepage (http://www.openssl.org/idea) to compile and install, with the Apache server can establish a web server that supports SSL, you can also use self-signed certificates for authentication. For details about how to compile and install the OpenSSL server, refer to the OpenSSL howto document. The SSL programming preliminary introduction SSL communication model as a standard C/S structure, in addition to the transmission on the TCP layer, there is no obvious difference with general communication. Here, we mainly introduce how to use OpenSSL for secure communication program design. For more information about OpenSSL, see the OpenSSL official homepage http://www.openssl.org. Before using OpenSSL, you must initialize OpenSSL. You can choose one of the following three functions: ssl_library_init (void); openssl_add_ssl_algorithms (); ssleay_add_ssl_algorithms (); in fact, the following two functions are only the macros of the first function. If you want to use OpenSSL error information, use ssl_load_error_strings (void) to initialize the error information. In the future, you can use void err_print_errors_fp (File * FP) to print SSL error messages. For an SSL connection session, you must first apply for an SSL environment. The basic process is as follows: 1. ssl_method * meth = tlsv1_client_method (); The Protocol used to create this session connection. If it is a client, you can use ssl_method * tlsv1_client_method (void); tlsv1.0 protocol ssl_method * sslv2_client_method ); SSLv2 ssl_method * handle (void); SSLv3 ssl_method * sslv23_client_method (void); SSLv2/V3 protocol server also needs to create the protocol used for this session: ssl_method * tlsv1_server_method (void ); ssl_method * sslv2_server_method (void); ssl_method * Sslv3_server_method (void); ssl_method * sslv23_server_method (void); note that the client and server must use the same protocol. 2. The environment for applying for an SSL session CTX uses different protocols for the session. The environment is also different. The OpenSSL function used to apply for an SSL session environment is sslk_ctx * ssl_ctx_new (ssl_method *). The parameter is the SSL communication method we applied for earlier. Returns the pointer to the current SSL connection environment. Then, set the CTX Attribute Based on your needs. Typically, set the SSL handshake certificate authentication method and load your own certificate. Void ssl_ctx_set_verify (ssl_ctx *, Int, int * (INT, x509_store_ctx *) sets the certificate verification method. The first parameter is the current CTX pointer, and the second is the verification method. If you want to verify the other party, use ssl_verify_peer. If not, use ssl_verify_none. Generally, the client needs to verify the other party, but the server does not. The third parameter is the callback function for processing verification. If there is no special need, use a null pointer. Void ssl_ctx_load_verify_locations (ssl_ctx *, const char *, const char *); load the certificate. The first parameter is the same as above. The second parameter is the name of the Certificate file. The third parameter is the path of the Certificate file; int ssl_ctx_use_certificate_file (ssl_ctx * CTX, const char * file, int type); load local certificate; type indicates the structure type of the Certificate file; failure to return-1int ssl_ctx_use_privatekey_file (ssl_ctx * CTX, const char * file, int type); load your own private key; type parameter specifies the structure type of the private key file; failure to return-1 after loading the certificate and file, verify that the private key matches the certificate: bool ssl_ctx_check_private_key (ssl_ctx *); 3. since SSL uses t CP protocol, of course, you need to attach SSL to the connected socket: SSL * ssl_new (ssl_ctx *); apply for an SSL set of characters; int ssl_set_rfd (SSL *); bind the read-only socket int ssl_set_wfd (SSL *); bind the socket int ssl_set_fd (SSL *); bind the read/write socket to succeed. Return 1; return 0 if binding fails; 4. the next step is the SSL handshake action int ssl_connect (SSL *); The Failure Returns-15. after the handshake is successful, you can communicate. Use ssl_read and ss_write SSL sockets instead of the traditional read, writeint ssl_read (SSL * SSL, char * Buf, int num ); int ssl_write (SSL * SSL, char * Buf, int num); if it is a server, use ssl_a Instead of the traditional accept, ccept calls int ssl_accept (SSL * SSL); 6. after the communication ends, you need to release the previously applied SSL resource int ssl_shutdown (SSL * SSL); close the SSL socket; void ssl_free (SSL); release the SSL socket; void ssl_ctx_free (CTX ); release the SSL environment. OpenSSL has been developed to version 0.9.96, but it has very few documents, and even the most basic man function manual has not been completed. Therefore, this article focuses on the framework for Program Design Using OpenSSL. For more detailed information, see the OpenSSL document or the Apache mod_ssl document. Through the above introduction, I think you have some knowledge about the SSL protocol. The author has the opportunity to continue to introduce other aspects of the SSL protocol. SSL principle decryption this article is from: http://noc.cstnet.net.cn/fan Xiaoming rsapublic encryption used in certification and encryption in the computer industry. An RSA public key encryption license that can be obtained from RSA Data Security Inc. Public key encryption is an asymmetric encryption or decryption method. Each pair of passwords consists of a public key and a private key. Public Keys are widely released. The private key is private and not public. Data Encrypted with the public key can only be decrypted by the private key. In turn, data encrypted with the private key can only be decrypted with the public key. This asymmetric feature makes public key encryption very useful. Public key encryption is an authentication process. In the following examples, public key encryption can easily verify the identity of A and B. The symbol {data} key indicates that "data" has been encrypted or decrypted using a password. Assume that a wants to verify B's identity. B has a pair of passwords. One is public and the other is private. The Public Key disclosed by Party B to Party. A generates a random message and sends it to B. A --> B: Random-message B uses its private key to encrypt the message and returns the encrypted message. Party B --> A: {random-message} Party B's private key a receives the message and decrypts it using the public key previously published by Party B. He compares the decrypted message with the original message sent to B. If they are exactly the same, they will know that they are talking to Party B. Any man-in-the-middle does not know the private key of Party B, nor does it properly encrypt random messages of Party A's check. Unless you know your encrypted message clearly. It is not a good idea to encrypt the message with the private key and then send it to others. Because the encryption value may be used against you, it must be noted that only you have a private key, so only you can encrypt the message. Therefore, instead of encrypting the original message sent by a, B creates an information segment and encrypts it. The information segment is taken from the random message and has the following useful features: 1. This information segment is difficult to restore. No one can obtain the original message from the information segment even if it is disguised as B. 2. counterfeits calculate the same information segment value for different messages. 3. use the Information Section to protect yourself. He calculates random information segments sent by a, encrypts the results, and sends encrypted information segments to return. A can calculate the same information segment and decrypt B's Message Authentication B. This technology only depicts digital signatures. The random messages generated by encrypting A have been signed by B in. Therefore, encryption is required for the authentication protocol. Some messages are produced by B: A --> B: Hello, are you B? B --> A: A, I am B {Information Section [a, I am B]} B's private key. When you use this protocol, B knows the message he sent to B, he doesn't mind signing it. He first sent unencrypted information, "a, I am B. ", And then send the message version encrypted by the information segment. A can easily verify that B is B. At the same time, B has not signed the information he does not want. When submitting a public key, how does B submit its public key in a trusted manner? Let's take a look at the authentication protocol as follows: A --> B: Hello B --> A: Hi, I am B, and B's public key a --> B: Prove it B --> A:, I am B {Information Section [a, I am B]} under this Agreement, anyone can become "B ". All you need is the public key and private key. You send a message to Party A saying that you are B, so that your public key replaces the password of Party B. Then, you send a message encrypted with your private key to prove your identity. A cannot find that you are not B. To solve this problem, the standard organization has invented the certificate. A certificate has the following content: * issuer name of the certificate * Organization of the certificate * Public Key of the title * the postmark certificate is encrypted using the issuer's private key. Everyone knows the public key of the certificate issuer (in this way, each certificate issuer has a certificate ). A certificate is a protocol that binds a public key to a name. By using the certificate technology, each person can check the certificate of Party B to determine whether it has been counterfeited. Let us assume that Party B controls his private key and he does get the certificate. These are the revised protocols: A --> B: Hello, B --> A: Hi, I'm B, and B's verification A --> B: Prove it B -->: a, I am B {Information Section [a, I am B]} B's private key now when a receives B's first message, he can check the certificate and signature (as described above, use the information segment and public key for decryption), then check the title (name of B), and confirm that it is B. He can believe that the public key is B's public key and requires B to prove his identity. Through the above process, Party B creates an information segment and replies to Party A with a signature version. A can verify the information segment of B by using the public key obtained from the certificate and check the result. If a hacker is named h a --> H: Hello h --> he cannot create a message from B that he believes. Once a has verified B, he can send a message to B that only B can decrypt and read: A --> B: {secret} the only way to find the password for the public key of Party B is to use the private key of Party B to decode the above information. Password exchange is another effective way to use password encryption. Only Party B can obtain the password even if communication between Party A and Party B is listened on. Using a password as another secret-key enhances network security, but this time it is a symmetric encryption algorithm (such as des, RC4, and ide ). Because a generates a password before sending it to B, A knows the password. B knows the password because B has a private key and can decrypt the information of. But they all know the password. They can initialize a symmetric password algorithm and start to send encrypted information. Here is the final agreement: A --> B: Hello, B --> A: Hi, I'm B, and B's verification A --> B: Prove it B -->: a, I am B {Information Section [a, I am B]} B's private key a --> B: OK B, here is a secret {secret} B's public key B --> A: {some message} secret-key the hacker eavesdroppers. If a malicious hacker H is in the middle of a and B, although the passwords exchanged between Party A and Party B cannot be found, they can interfere with their conversation. He can let go of most of the information and choose to destroy some information (this is very simple because he knows the protocol used for communication between Party A and Party B ). A --> H: Hello h --> B: Hello B --> H: Hi, I'm B. Check h --> A: Hi, I'm B, verification of B. A --> H: Prove ith --> B: Prove it B --> H: A, I'm B {Information Section [, i'm B]} B's private key H --> A: A, I'm B {Information Section [a, I'm B]} B's private key a --> H: OK B, here is a secret {secret} B's public key H --> B: OK B, here is a secret {secret} B's public key B --> H: {some message} secret-Keyh --> A: garble [{some message} secret-key] H ignore some data and do not modify it until a and B exchange passwords. Then, H interferes with the information given to Party. In this regard, Party A believes in Party B, so he may believe that the message has been disturbed and try his best to decrypt it. Note that H does not know the password. All he can do is destroy the data encrypted with the key. Based on the Protocol, h may not produce a valid message. But next time? To prevent such damages, Party A and Party B generate a message authentication code in their protocol ). A verification code message (MAC) is a part of data generated by passwords and some transmitted messages. The above features described by the information segment algorithm are exactly what they use to defend against H: MAC = digest [some message, secret] Because H does not know the password, he cannot get the correct value. Even if H interferes with messages randomly, as long as the data volume is large, there is little chance of success. For example, using hd5 (a good encryption algorithm invented by RSA), A and B can send 128-bit MAC values and their messages. H. I guess the chance of a correct Mac is nearly 1/18, and 446,744,073,709,551,616 is about to be equal to zero. This is another modified protocol: A --> B: Hello, B --> A: Hi, I'm B, and B's verification is a --> B: Prove it B -->: hi, I'm B, B's verification A, I'm B {Information Section [a, I'm B]} B's private key OK B, here is a secret {secret} B's public key {some message, Mac} secret-key. Now H is useless. He interferes with all the messages, but Mac computers can find him. A and B can detect FAKE MAC values and stop talking. H can no longer communicate with B. OpenSSL FAQ

References: http://haifeng168.blogchina.com/haifeng168/5069604.html

To protect the security of sensitive data during transmission, many well-known enterprises around the world adopt the SSL (Security Socket Layer) encryption mechanism. SSL is a security and confidentiality protocol proposed by Netscape, in browsers (such as Internet Explorer, Netscape Navigator) and Web servers (such as Netscape's Netscape
Enterprise Server, ColdFusion Server, and so on) to construct a secure channel for data transmission. SSL runs on the TCP/IP layer and under the application layer to provide encrypted data channels for applications, it uses encryption algorithms such as RC4, MD5, and RSA, and uses a 40-bit key, which is suitable for business information encryption. At the same time, Netscape developed the HTTPS protocol and built it into its browser. HTTPS is actually SSL over HTTP, which uses the default port 443, instead of using port 80 as HTTP to communicate with TCP/IP. The HTTPS protocol uses SSL to encrypt the original data on the sender and then decrypt the data on the receiver. encryption and decryption require the sender and the receiver to exchange a common key. Therefore, the transmitted data is not easily intercepted and decrypted by network hackers.

However, the encryption and decryption process requires a large amount of system overhead, seriously reducing the performance of the machine. the test data shows that the efficiency of data transmission over HTTPS is only one tenth of the efficiency of data transmission over HTTP. If SSL technology is enabled for all web applications of a website for security and confidentiality, and the HTTPS protocol is used for transmission, the performance and efficiency of the website will be greatly reduced, this is not necessary because not all data requires such a high level of security and confidentiality.

References: http://zhidao.baidu.com/question/429602.html

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.