A test method, device and terminal for transport layer security protocol
By calculating and decrypting the key used in the handshake connection, and performing structural testing of the decrypted messages, combined with fuzzy testing, the shortcomings of the TLS protocol stack handshake process testing in the existing technology are solved, and the comprehensiveness of the TLS1.3 protocol is achieved Testing improves testing efficiency and accuracy.
Patent Information
- Application Number
- CN202110824935.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-21
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2041-07-21
AI Technical Summary
The testing tools for the TLS protocol in the prior art mainly test for secure configurations and unencrypted packets, and cannot deeply test whether the entire handshake process of the transport layer security protocol stack is implemented correctly, and do not support the TLS1.3 protocol.
By establishing a handshake connection with the target test end, the key used for the encrypted message is calculated, and after decrypting it, the decrypted message is tested in structure, and fuzzy testing is performed to detect the robustness of the target test end.
It realizes a comprehensive test of the entire handshake process of the transport layer security protocol stack, improves testing efficiency and accuracy, can test the correctness of the TLS1.3 protocol, and solves the problems of difficulty in testing implementation and single test points in the existing technology.
Smart Images

Figure CN115701026B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet of Things, and in particular to a test method, device and terminal for a transport layer security protocol. Background Art
[0002] With the popularization of the Internet of Things, there are more and more security incidents in the Internet of Things, and the importance of network security is becoming more and more apparent. The most widely used communication security protocol is the Secure Sockets Layer protocol SSL (Secure Sockets Layer), also known as the Transport Layer Security protocol TLS (Transport Layer Security), which is later unified as TLS. The TLS protocol uses cryptographic technology to provide security functions such as identity authentication, data encryption and integrity verification for both parties in communication.
[0003] In the prior art, there are no testing tools or methods for different SSL / TLS protocol stacks for testing the TLS protocol, and manual testing is the only option. At the same time, the testing tools for the TLS protocol mainly test security configurations and unencrypted messages, but do not support the TLS1.3 protocol, and cannot deeply test whether the entire handshake process of the TLS protocol stack is implemented correctly. Summary of the invention
[0004] The purpose of the present invention is to provide a test method, device and terminal for a transport layer security protocol, so as to solve the problem that the test tools for the transport layer security protocol in the prior art mainly test security configurations and unencrypted messages, but cannot deeply test whether the implementation of the entire handshake process of the transport layer security protocol stack is correct.
[0005] To achieve the above object, an embodiment of the present invention provides a method for testing a transport layer security protocol, comprising:
[0006] Establishing a handshake connection with the target test end, and calculating the key used to encrypt messages during the handshake connection process;
[0007] Decrypting the encrypted message using the encryption algorithm in the handshake connection process according to the key;
[0008] After the encrypted message is successfully decrypted, a message structure test is performed on the decrypted encrypted message.
[0009] Furthermore, the target test end includes a client and a server.
[0010] Furthermore, the method further comprises:
[0011] Testing the calculation method of the key and the encryption algorithm to obtain a first test result;
[0012] Output the first detection result to a test report.
[0013] Further, the performing a message structure test on the decrypted encrypted message includes:
[0014] Detecting whether the fields of the decrypted encrypted message meet the preset message structure requirements to obtain a second detection result;
[0015] Output the second detection result to a test report.
[0016] Furthermore, the method further comprises: performing a fuzzy test on the target test end;
[0017] The performing fuzz testing on the target test end includes:
[0018] Construct a malformed message and send it to the target test end.
[0019] Furthermore, the performing fuzz testing on the target test end further includes:
[0020] If the alarm information fed back by the target test end is received, the alarm information is parsed to obtain an error code, and the error code is detected to obtain a third detection result;
[0021] Output the third detection result to a test report.
[0022] To achieve the above object, an embodiment of the present invention further provides a test device for a transport layer security protocol, comprising:
[0023] A calculation module, used to establish a handshake connection with the target test end, and calculate the key used to encrypt the message during the handshake connection;
[0024] A decryption module, used to decrypt the encrypted message according to the key through the encryption algorithm in the handshake connection process;
[0025] The first testing module is used to perform a message structure test on the decrypted encrypted message after the encrypted message is successfully decrypted.
[0026] Furthermore, the device also includes:
[0027] A second testing module, used for performing fuzz testing on the target testing end;
[0028] The performing fuzz testing on the target test end includes:
[0029] The construction module is used to construct a malformed message and send it to the target test end.
[0030] To achieve the above-mentioned purpose, an embodiment of the present invention also provides a terminal, including a transceiver, a processor, a memory, and a program or instruction stored in the memory and executable on the processor; when the processor executes the program or instruction, the test method of the transport layer security protocol as described above is implemented.
[0031] To achieve the above objectives, an embodiment of the present invention further provides a readable storage medium having a program or instruction stored thereon, wherein the program or instruction, when executed by a processor, implements the steps in the test method of the transport layer security protocol as described above.
[0032] The beneficial effects of the above technical solution of the present invention are as follows:
[0033] The test method of the transport layer security protocol of the embodiment of the present invention calculates the key used for encrypting the message during the handshake connection process, decrypts the encrypted message through the encryption algorithm in the handshake connection process, and performs a message structure test on the encrypted message after successful decryption. The test method of the transport layer security protocol of the embodiment of the present invention automatically tests after decrypting the encrypted information in the transport layer security protocol stack, which solves the problems of difficulty in implementing the test and single test method and test point in the prior art, and can test the correctness of the entire handshake process of the transport layer security protocol stack, with more comprehensive test content and improved test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A schematic diagram of a flow chart of a method for testing a transport layer security protocol according to an embodiment of the present invention;
[0035] Figure 2 A schematic diagram of a transport layer security protocol according to an embodiment of the present invention performing a handshake through an (EC)DHE negotiation handshake mode;
[0036] Figure 3 A schematic diagram of decrypting a message using an encryption algorithm in a handshake process according to an embodiment of the present invention;
[0037] Figure 4 A schematic diagram of a test device for a transport layer security protocol according to an embodiment of the present invention;
[0038] Figure 5 Schematic diagram of the structure of a terminal according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0040] It should be understood that the references to "one embodiment" or "an embodiment" throughout the specification mean that the specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present invention. Therefore, the references to "in one embodiment" or "in an embodiment" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0041] In various embodiments of the present invention, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0042] Additionally, the terms "system" and "network" are often used interchangeably herein.
[0043] In the embodiments provided in the present application, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined according to A. However, it should also be understood that determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.
[0044] like Figure 1 As shown, a method for testing a transport layer security protocol according to an embodiment of the present invention includes:
[0045] Step 101, establishing a handshake connection with a target test end, and calculating a key used to encrypt messages during the handshake connection process;
[0046] Step 102, decrypting the encrypted message according to the key using the encryption algorithm in the handshake connection process;
[0047] Step 103: After the encrypted message is successfully decrypted, a message structure test is performed on the decrypted encrypted message.
[0048] The test method of the transport layer security protocol of the embodiment of the present invention calculates the key used for encrypting the message during the handshake connection process, decrypts the encrypted message through the encryption algorithm in the handshake connection process, and performs a message structure test on the encrypted message after successful decryption. The test method of the transport layer security protocol of the embodiment of the present invention automatically tests after decrypting the encrypted information in the transport layer security protocol stack, which solves the problems of difficulty in implementing the test and single test method and test point in the prior art, and can test the correctness of the entire handshake process of the transport layer security protocol stack, with more comprehensive test content and improved test efficiency.
[0049] Optionally, the target test end includes a client and a server.
[0050] Start the corresponding transport layer security protocol test service function according to the type of the target test end. If the target test end is a TLS1.3 client, start the corresponding TLS server function; if the target test end is a TLS1.3 server, start the corresponding TLS client function.
[0051] The testing method of the transport layer security protocol in the embodiment of the present invention provides the ability to test the client and server of TLS1.3 at the same time, and can test the correctness of the entire handshake process of the transport layer security protocol stack. The test content is more comprehensive and the test efficiency is improved.
[0052] Optionally, the method further comprises:
[0053] Testing the calculation method of the key and the encryption algorithm to obtain a first test result;
[0054] Output the first detection result to a test report.
[0055] One embodiment of the present invention, as Figure 2 As shown in the figure, during the handshake process with the target test end, the messages after the client hello message ClientHello and the server hello message ServerHello are all encrypted. There are two main types of keys: handshake key handshake_secret and application key application_secret. First test the unencrypted message, and then test the encrypted message. Here, the key used for encryption must be calculated to decrypt the message, and it is also verified whether the key calculation method meets the specification RFC8446. The messages defined by the TLS1.3 protocol and the corresponding Base Key are shown in Table 1.
[0056] Table 1
[0057] Message Type Base Key ClientHello Unencrypted ServerHello Unencrypted EndOfEarlyData client_early_traffic_secret EncryptedExtensions [sender]_handshake_traffic_secret CertificateRequest [sender]_handshake_traffic_secret Certificate [sender]_handshake_traffic_secret CertificateVerify [sender]_handshake_traffic_secret Finished [sender]_handshake_traffic_secret NewSessionTicket [sender]_application_traffic_secret KeyUpdate [sender]_application_traffic_secret
[0058] like Figure 3 Step s6 calculates the client's handshake key handshake_secret, step s8 calculates the client's application key application_secret, step s2 calculates the server's handshake key handshake_secret, and step s3 calculates the server's application key application_secret.
[0059] Taking the TLS handshake negotiated by (EC)DHE as an example, the key calculation formula is as follows:
[0060] Handshake Secret=HMAC-Hash(0,(EC)DHE)
[0061] sender_handshake_traffic_secret=HKDF-Expand(Handshake Secret,"c hstraffic",ClientHello...ServerHello)
[0062] Master Secret=HMAC-Hash(HKDF-Expand(Handshake Secret,"derived",""),0)
[0063] sender_application_traffic_secret=HKDF-Expand(Master Secret,"c hstraffic",ClientHello...ServerHello)
[0064] HKDF: Key derivation function.
[0065] (EC)DHE: The curve group negotiated between the client and the server.
[0066] ClientHello...ServerHello: The hash length of the ClientHello message to the ServerHello message.
[0067] The calculation formula of the key used for final encryption is:
[0068] handshake_key=HKDF-Expand-Label([sender]_handshake_traffic_secret,"key",key_length)
[0069] application_key=HKDF-Expand-Label(sender_application_traffic_secret,"key",key_length)
[0070] After calculating the key, use the encryption algorithm in the handshake process to decrypt the message. If the decryption fails, the test fails, indicating that the key calculation method of the target test end does not comply with the specification RFC8446; if the decryption succeeds, the test succeeds and the test result is output to the test report. In addition to the TLS handshake method negotiated by (EC)DHE, there is also a TLS1.3 and a shared key PSK handshake method, and the key calculation formula is the same as the TLS handshake method negotiated by (EC)DHE. It should be noted that different messages use different keys, but they are all derived from sender_handshake_traffic_secret or sender_application_traffic_secret.
[0071] The test method of the transport layer security protocol in the embodiment of the present invention decrypts the encrypted message through the encryption algorithm in the handshake connection process, and can check whether the key algorithm usage and key calculation involved in the TLS1.3 handshake process meet the specification RFC8446. The test method of the transport layer security protocol in the embodiment of the present invention ensures the accuracy and reliability of the test by verifying the key algorithm usage and key calculation involved in the handshake process.
[0072] Optionally, the performing a message structure test on the decrypted encrypted message includes:
[0073] Detecting whether the fields of the decrypted encrypted message meet the preset message structure requirements to obtain a second detection result;
[0074] Output the second detection result to a test report.
[0075] In the message test, the main comparison is whether the fields in the message meet the requirements of the message structure defined in the specification RFC8446. Table 2 shows some test items of an embodiment of the present invention.
[0076] Table 2
[0077]
[0078]
[0079] The test method of the transport layer security protocol of the embodiment of the present invention ensures the accuracy and reliability of the test by performing a message structure test on the encrypted message after decryption.
[0080] Optionally, the method further comprises: performing a fuzzy test on the target test end;
[0081] The performing fuzz testing on the target test end includes:
[0082] Construct a malformed message and send it to the target test end.
[0083] In one embodiment of the present invention, Fuzz fuzz testing does not require a complete TLS connection. It performs an attack test on the target test end by sending a constructed malformed message to the target test end, parses the alarm information received from the target test end, and detects the parsed error code, the format, size, length, transmission mode and transmission rate of the test information.
[0084] The received alarm information is parsed to obtain an error code and the error code is detected, wherein the test content includes the test items shown in Table 3.
[0085] Table 3
[0086]
[0087]
[0088]
[0089] The test method of the transport layer security protocol of the embodiment of the present invention conducts an attack test on the target test end by constructing a malformed message, and detects that the information fed back by the target test end for the malformed message meets the alarm requirements in the standard. The test method of the transport layer security protocol of the embodiment of the present invention can test the correctness of the entire handshake process of the transport layer security protocol stack, the test content is more comprehensive, and the test efficiency is improved.
[0090] Optionally, the performing fuzz testing on the target test end further includes:
[0091] If the alarm information fed back by the target test end is received, the alarm information is parsed to obtain an error code, and the error code is detected to obtain a third detection result;
[0092] Output the third detection result to a test report.
[0093] In one embodiment of the present invention, after the fuzzy test, the robustness of the transport layer security protocol is also tested.
[0094] The test method of the transport layer security protocol of the embodiment of the present invention conducts an attack test on the target test end by constructing a malformed message, and detects that the information fed back by the target test end for the malformed message meets the alarm requirements in the standard. The test method of the transport layer security protocol of the embodiment of the present invention can test the correctness of the entire handshake process of the transport layer security protocol stack, the test content is more comprehensive, and the test efficiency is improved.
[0095] like Figure 4As shown, the embodiment of the present invention further provides a test device 400 for a transport layer security protocol, comprising:
[0096] The calculation module 401 is used to establish a handshake connection with the target test end and calculate the key used for encrypting messages during the handshake connection process;
[0097] A decryption module 402, configured to decrypt the encrypted message according to the key using an encryption algorithm in the handshake connection process;
[0098] The first test module 403 is used to perform a message structure test on the decrypted encrypted message after the encrypted message is successfully decrypted.
[0099] The test device for the transport layer security protocol of the embodiment of the present invention calculates the key used for encrypting the message during the handshake connection process, decrypts the encrypted message through the encryption algorithm during the handshake connection process, and performs a message structure test on the encrypted message after successful decryption. The test device for the transport layer security protocol of the embodiment of the present invention automatically tests the encrypted information in the transport layer security protocol stack after decryption, and can test the correctness of the entire handshake process of the transport layer security protocol stack. The test content is more comprehensive and the test efficiency is improved.
[0100] Optionally, the device further comprises:
[0101] A second testing module, used for performing fuzz testing on the target testing end;
[0102] The performing fuzz testing on the target test end includes:
[0103] The construction module is used to construct a malformed message and send it to the target test end.
[0104] The test device of the transport layer security protocol of the embodiment of the present invention conducts an attack test on the target test end by constructing a malformed message, and detects that the information fed back by the target test end for the malformed message meets the alarm requirements in the standard. The test method of the transport layer security protocol of the embodiment of the present invention can test the correctness of the entire handshake process of the transport layer security protocol stack, the test content is more comprehensive, and the test efficiency is improved.
[0105] A terminal according to another embodiment of the present invention, such as Figure 5 As shown, it includes a transceiver 510, a processor 500, a memory 520, and a program or instruction stored in the memory 520 and executable on the processor 500; when the processor 500 executes the program or instruction, the above-mentioned test method applied to the transport layer security protocol is implemented.
[0106] The transceiver 510 is used to receive and send data under the control of the processor 500 .
[0107] Among them, Figure 5 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically one or more processors represented by processor 500 and various circuits of memory represented by memory 520 are linked together. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 510 may be a plurality of components, namely, a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. For different user devices, the user interface 530 may also be an interface capable of externally and internally connecting required devices, and the connected devices include but are not limited to a keypad, a display, a speaker, a microphone, a joystick, and the like.
[0108] The processor 500 is responsible for managing the bus architecture and general processing, and the memory 520 can store data used by the processor 500 when performing operations.
[0109] A readable storage medium according to an embodiment of the present invention stores a program or instruction thereon. When the program or instruction is executed by a processor, the steps in the test method of the transport layer security protocol as described above are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0110] The processor is the processor in the test method of the transport layer security protocol described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0111] It should be further explained that the terminals described in this specification include but are not limited to smart phones, tablet computers, etc., and many of the functional components described are called modules in order to more particularly emphasize the independence of their implementation methods.
[0112] In the embodiment of the present invention, module can be implemented with software so that it can be executed by various types of processors. For example, an executable code module of an identification can include one or more physical or logical blocks of computer instructions, for example, it can be constructed as an object, process or function. Nevertheless, the executable code of the identified module does not need to be physically located together, but can include different instructions stored in different positions, and when these instructions are logically combined together, it constitutes a module and realizes the specified purpose of the module.
[0113] In fact, executable code module can be a single instruction or many instructions, and can even be distributed on a plurality of different code segments, distributed among different programs, and distributed across a plurality of memory devices. Similarly, operating data can be identified in the module, and can be implemented and organized in the data structure of any appropriate type according to any appropriate form. The operating data can be collected as a single data set, or can be distributed in different locations (including on different storage devices), and can only be present on a system or network as an electronic signal at least in part.
[0114] When a module can be implemented by software, considering the level of existing hardware technology, a person skilled in the art can build a corresponding hardware circuit to implement the corresponding function of the module that can be implemented by software without considering the cost. The hardware circuit includes a conventional very large scale integration (VLSI) circuit or gate array and existing semiconductors such as logic chips, transistors, or other discrete components. The module can also be implemented by a programmable hardware device, such as a field programmable gate array, a programmable array logic, a programmable logic device, etc.
[0115] The above exemplary embodiments are described with reference to the accompanying drawings, and many different forms and embodiments are feasible without departing from the spirit and teachings of the present invention. Therefore, the present invention should not be constructed as a limitation of the exemplary embodiments proposed herein. More specifically, these exemplary embodiments are provided so that the present invention will be perfect and complete, and the scope of the present invention will be conveyed to those who are familiar with the technology. In these figures, the component sizes and relative sizes may be exaggerated for clarity. The terms used here are only based on the purpose of describing specific exemplary embodiments and are not intended to be limiting. As used herein, unless the text clearly indicates otherwise, the singular forms "one", "an" and "the" are intended to include these multiple forms. It will be further understood that the terms "including" and / or "comprising" when used in this specification indicate the presence of the features, integers, steps, operations, components and / or components, but do not exclude the presence or increase of one or more other features, integers, steps, operations, components, components and / or their groups. Unless otherwise indicated, when stated, a range of values includes the upper and lower limits of that range and any subranges therebetween.
[0116] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for testing a transport layer security protocol, characterized in that: include: Establishing a handshake connection with the target test end, and calculating the key used to encrypt messages during the handshake connection process; Decrypting the encrypted message using the encryption algorithm in the handshake connection process according to the key; Testing the calculation method of the key and the encryption algorithm to obtain a first test result; Outputting the first detection result to a test report; After the encrypted message is successfully decrypted, a message structure test is performed on the decrypted encrypted message; Constructing a deformed message and sending it to the target test end, and performing a fuzzy test on the target test end; If the alarm information fed back by the target test end is received, the alarm information is parsed to obtain an error code, and the error code is detected to obtain a third detection result; Outputting the third test result to a test report; The performing a message structure test on the decrypted encrypted message comprises: Detecting whether the fields of the decrypted encrypted message meet the preset message structure requirements to obtain a second detection result; Output the second detection result to a test report.
2. The method for testing the transport layer security protocol according to claim 1, characterized in that: The target test end includes a client and a server.
3. A test device for a transport layer security protocol, characterized in that: include: A calculation module, used to establish a handshake connection with the target test end, and calculate the key used to encrypt the message during the handshake connection; A decryption module, used to decrypt the encrypted message according to the key through the encryption algorithm in the handshake connection process; A first testing module is used to perform a message structure test on the decrypted encrypted message after the encrypted message is successfully decrypted; The second test module is used to construct a malformed message and send it to the target test end, and perform a fuzzy test on the target test end; The calculation module is further used to: detect the calculation method of the key and the encryption algorithm to obtain a first detection result; Outputting the first detection result to a test report; The first test module is further used to: detect whether the field of the decrypted encrypted message meets the preset message structure requirements to obtain a second test result; Output the second detection result to a test report.
4. A terminal, comprising: A transceiver, a processor, a memory, and a program or instruction stored in the memory and executable on the processor; characterized in that when the processor executes the program or instruction, the test method for the transport layer security protocol as described in any one of claims 1-2 is implemented.
5. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by the processor, the steps in the test method of the transport layer security protocol as described in any one of claims 1-2 are implemented.
