Performance test method for encryption interface

Through the classification setting of interface security policies and encryption methods, the actual application scenarios and data security of the encryption interface are realized in the interface performance test, and the problem that interface performance test cannot take into account both security in the existing technology is provided. A method to evaluate the impact of encryption algorithms is achieved to balance data security and system performance.

CN118939537APending Publication Date: 2024-11-12四川启睿克科技有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410965910.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

The prior art cannot truly simulate the actual application scenarios of the encryption interface in interface performance testing, and it is difficult to take into account the security of transmitting data. It is usually necessary to turn off the interface encryption service for testing.

Method used

Set flag bits through the classification of interface security policies and encryption methods, use Python to implement interface encryption and signature processes, and generate encryption parameters based on the flag bits in performance tests, and add them to the performance test policy to execute, ensuring that Safety and authenticity of the test.

Benefits of technology

It realizes the practical application scenario of truly simulating the encryption interface in interface performance testing, while taking into account the security of the interface's data transmission, and can evaluate the impact of different encryption algorithms on interface performance, helping developers find between data security and system performance. balance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939537A_ABST
    Figure CN118939537A_ABST
Patent Text Reader

Abstract

The invention discloses a method for testing the performance of an encryption interface. The method comprises the following steps: classifying an interface security policy and an encryption method and setting flag bits; packaging an interface security policy and an encryption method according to the flag bit so as to realize an interface encryption method; acquiring key information according to the tested interface, and constructing a performance test strategy according to the key information; judging a corresponding flag bit according to the security policy of the tested interface and the classification of the encryption method; according to the judged flag bit, calling a corresponding encapsulation encryption method to obtain an encryption parameter; and adding the encryption parameters into the constructed performance test strategy for execution, and completing the performance test of the encryption interface. According to the method, the actual application scene of the encryption interface can be simulated by calling the method according to specific conditions, so that proper encryption algorithms and parameters can be selected according to actual requirements and security levels, and the relationship between the data security and the system performance can be balanced, so that the balance between the data security and the system performance can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of encryption interface and performance testing, in particular to a performance testing method for an encryption interface. Background Art

[0002] With the development of Internet technology, service security and data security have become increasingly important. Systems that provide interface services often apply various encryption technologies to ensure the safe calling of interfaces. In order to prevent the leakage of sensitive information and protect user privacy, developers encrypt the interfaces when implementing them, or use digital signatures to prevent request parameters from being tampered with during transmission.

[0003] While interface encryption and signatures increase security, they also pose a challenge to interface performance testing. In the prior art, performance testing of encrypted interfaces generally involves shutting down interface encryption services, which cannot truly simulate an online environment and cannot guarantee interface security.

[0004] In view of the deficiencies in the prior art, the present invention proposes a performance testing method for an encryption interface, which can not only truly simulate the actual application scenario of the encryption interface, but also take into account the security of transmitted data in the interface performance test. Summary of the invention

[0005] In view of the above problems, the purpose of the present invention is to provide a performance testing method for an encryption interface, the key point of which is: setting a flag bit by classifying the interface security strategy and the encryption method, and implementing the interface encryption method based on the flag bit based on Python, including the implementation process of interface encryption and interface signature, in the performance testing process, calling the corresponding interface encryption method according to the flag bit to generate encryption parameters, and adding the encryption parameters to the performance testing strategy to complete the encryption interface performance testing process. This method can not only truly simulate the actual application scenario of the encryption interface in the performance testing of the encryption interface, but also take into account the security of the interface.

[0006] The present invention solves the above problems through the following technical solutions:

[0007] A performance testing method for an encryption interface, comprising:

[0008] Classify interface security policies and encryption methods, and set classification flags for each;

[0009] Implement the interface security policy and the encryption method encapsulation according to the flag bit to implement the interface encryption method;

[0010] Obtain key information based on the interface under test and construct a performance test strategy based on the key information;

[0011] Determine the corresponding flag bit according to the security policy and encryption method classification of the tested interface;

[0012] According to the judged flag bit, the corresponding encapsulated encryption method is called to obtain the encryption parameters;

[0013] Add the encryption parameters to the constructed performance test strategy and execute it to complete the performance test of the encryption interface.

[0014] As a further improvement, the interface security policy and encryption method are classified and the classification flags are set respectively, including:

[0015] The first flag flag1 is set according to the classification of the security policy;

[0016] The second flag flag2 is set according to the classification of the encryption method.

[0017] As a further improvement, the security policy at least includes interface encryption and interface signature;

[0018] The encryption method at least includes one-way encryption, symmetric encryption and asymmetric encryption.

[0019] As a further improvement, the interface encryption means that before initiating the interface request, the client encrypts the request parameters, uses the same encryption method and encryption process as the server to encrypt and encode the interface plaintext, and initiates an encryption request based on the encrypted ciphertext, and sends the encrypted message to the server.

[0020] As a further improvement, the interface signature refers to the client using a key to generate a signature for request parameters. When the interface transmits data, the signature is used as one of the parameters to request the interface from the server.

[0021] As a further improvement, the signature refers to verifying whether the caller has the authority to call the interface by matching the keys of the client and the server;

[0022] The signature implementation steps are:

[0023] Arrange all request parameters except signature in ascending or descending alphabetical order by parameter name;

[0024] Use the key-value pair format to concatenate into string stringA;

[0025] stringA is concatenated with the key apikey to obtain the string stringSign;

[0026] Perform encryption operation on stringSign to obtain the signature value;

[0027] Put the sign in the URL request parameter to request the interface.

[0028] As a further improvement, all the request parameters include system parameters and business parameters, wherein the system parameters refer to parameters unrelated to the business, including signature sign, timestamp timestamp and request random string noncestr; business parameters, i.e. application parameters, are parameters related to the interface, and different interfaces require different parameters.

[0029] As a further improvement, key information is obtained according to the interface under test, and a performance test strategy is constructed based on the key information.

[0030] The key information includes the transmitted request data, the interface encryption strategy and method, the encryption key, and the key character string that needs to be encrypted or encoded.

[0031] As a further improvement, the request data refers to all data of the interface under test, including the request method, request header, request address, and request parameters; by adding the request data to the Jmeter tool and setting the number of threads and running time in the performance parameters, a performance test strategy is constructed.

[0032] As a further improvement, according to the flag bit determined, the corresponding encapsulated encryption method is called to obtain the encryption parameters.

[0033] Before initiating an interface request, the interface plaintext data is preprocessed. In the interface implementation of Jmeter, the interface plaintext is encrypted and encoded using the same encryption method and encryption process as the server, and an encryption request is initiated based on the encrypted ciphertext.

[0034] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0035] The present invention realizes the process of encrypting the interface using different encryption algorithms, and can call methods to simulate the actual application scenarios of the encryption interface according to specific circumstances. On the one hand, the security of the transmitted data is taken into account during the performance test, solving the problem of taking into account the security of the interface transmission data in the interface performance test; on the other hand, under the same performance test strategy, the impact of different encryption algorithms on the interface performance can be evaluated, providing data reference for developers, selecting appropriate encryption algorithms and parameters according to actual needs and security levels, and weighing the relationship between data security and system performance when implementing interface encryption, so as to achieve a balance between data security and system performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A schematic diagram of a performance testing method for an encryption interface in the present invention;

[0037] Figure 2 The figure is a flowchart of calling an encryption method according to a determined flag bit to obtain encryption parameters. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be described in more detail below in conjunction with the drawings in the preferred embodiments of the present application. In the drawings, the same or similar reference numerals throughout represent the same or similar parts or parts with the same or similar functions. The described embodiments are part of the embodiments of the present application, not all of the embodiments. The embodiments described below with reference to the drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limitations on the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0039] The present invention aims to take into account interface security when encrypting interface performance testing, and proposes a performance testing method for an encrypted interface. In the following embodiments, the programming language uses Python and the performance tool uses Jmeter. The specific implementation is as follows:

[0040] See attached Figure 1 , a performance testing method for an encryption interface, the specific steps comprising:

[0041] Step 1: Classify the interface security policies and encryption methods, and set the classification flags respectively;

[0042] like Figure 1 As shown, in step 1, the interface security policy and encryption method are classified and a flag is set; specifically, the following steps are included:

[0043] Security policies are divided into two categories: interface encryption and interface signature. The first flag flag1 is set according to the classification of the security policy. The value is 0 or 1. 0 represents interface encryption and 1 represents interface signature.

[0044] Encryption methods are divided into one-way encryption, symmetric encryption, and asymmetric encryption. Among them, one-way encryption technologies include MD5, SHA1, etc.; symmetric encryption technologies include Base64 encryption algorithm, AES encryption algorithm, DES encryption algorithm, etc.; asymmetric encryption technologies include RSA encryption algorithm, etc. The second flag flag2 is set according to the classification of the encryption method, with a value of 1 to 6, 1 represents MD5, 2 represents SHA1, 3 represents Base64 encryption algorithm, 4 represents AES encryption algorithm, 5 represents DES encryption algorithm, and 6 represents RSA encryption algorithm.

[0045] Furthermore, the interface encryption refers to the client encrypting the request parameters before initiating the interface request, encrypting and encoding the interface plaintext using the same encryption method and encryption process as the server, initiating an encryption request based on the encrypted ciphertext, and sending the encrypted message to the server.

[0046] Interface encryption implementation steps:

[0047] 1.11) Obtaining keys, request messages that need to be encrypted, etc.;

[0048] 1.12) Obtain the implemented encryption method;

[0049] 1.13) Encrypt the request message according to the encryption method to obtain the encrypted request message.

[0050] The interface signature refers to the client using the key to generate a signature for the request parameters. When the interface transmits data, the signature is used as one of the parameters to request the interface from the server.

[0051] Signature means verifying whether the caller has the authority to call the interface by matching the keys of the client and the server. Generally, the parameters and keys are used to generate an encrypted string, which is used as the signature. If any parameter is changed, the signature verification will fail, thus preventing the risk of data tampering. For example, the interface parameters after adding the signature are:

[0052] http: / / 127.0.0.1:8000 / sign / ?a=1&b=2&sign=03b6917cce4c6bd1198ead358910f0ff.

[0053] Interface signature implementation steps:

[0054] 1.21) Arrange all request parameters except signature in ascending or descending alphabetical order according to parameter name;

[0055] 1.22) Use the URL key-value pair format (i.e. key1=value1&key2=value2…) to concatenate into string A;

[0056] 1.23) stringA is concatenated with the key apikey to obtain the string stringSign;

[0057] 1.24) Perform encryption operation on stringSign to obtain the signature value sign;

[0058] 1.25) Put the sign in the url request parameter to request the interface.

[0059] In 1.21), all request parameters include system parameters and business parameters. System parameters refer to parameters that are not related to the business, including signature sign, timestamp timestamp, request random string noncestr, etc. Business parameters, i.e. application parameters, are parameters related to the interface, and different interfaces require different parameters.

[0060] Step 2: Implement the interface security policy and the encapsulation of the encryption method according to the flag bit to implement the interface encryption method;

[0061] In step 2, the interface security policy and the encapsulation of the encryption method are implemented according to the flag bit, including: encapsulating the process of the security policy according to the first flag bit flag1 based on python, including the encapsulation of the interface encryption process and the interface signature process: wherein flag1 takes the value of 0, representing the interface encryption process; flag1 takes the value of 1, representing the interface signature process. Encryption technology is used in both the interface encryption and interface signature processes, and the encryption method can be distinguished according to the value of flag2.

[0062] Common encryption methods are encapsulated according to the second flag bit flag2. When flag2 takes the value 1, it represents interface MD5 encryption; when flag2 takes the value 2, it represents interface SHA1 encryption; when flag2 takes the value 3, it represents interface Base64 encryption; when flag2 takes the value 4, it represents interface AES encryption; when flag2 takes the value 5, it represents interface DES encryption; when flag2 takes the value 6, it represents interface RSA encryption.

[0063] Step 3: Obtain key information based on the interface under test and construct a performance test strategy based on the key information;

[0064] In step 3, the key information includes the transmitted request data, the interface encryption strategy and method, the encryption key, and the key character string that needs to be encrypted or encoded.

[0065] Request data refers to all data of the interface under test, including request method, request header, request address, and request parameters, etc. Request parameters include system parameters and business parameters. System parameters refer to signatures, timestamps, request random strings, etc. that are not related to the business; business parameters refer to application parameters related to the interface business, such as request Body.

[0066] Add the request method, request header, request address, request parameters, etc. to the Jmeter tool, and set performance parameters such as the number of threads and running time to construct a performance testing strategy.

[0067] Step 4: Determine the corresponding flag bit according to the security policy and encryption method classification of the tested interface;

[0068] In step 4, the corresponding flag bit is determined according to the classification of the security policy and encryption method of the tested interface, specifically including:

[0069] Determine whether the interface security policy belongs to interface encryption or interface signature, that is, the value of flag1, which is 0 or 1;

[0070] Determine the encryption method involved in the interface security policy, that is, the value of flag2, which can be any value from 0 to 6.

[0071] Step 5: According to the judged flag bit, call the corresponding encapsulated encryption method to obtain encryption parameters;

[0072] In step 5, according to the judged flag bit, the corresponding encapsulated encryption method is called to obtain encryption parameters; including:

[0073] According to the first flag flag1 and the second flag flag2, the corresponding encryption method is called to obtain the encryption parameters, such as Figure 2 As shown:

[0074] When the first flag flag1 is 0, the encryption type is interface encryption, and then the encryption method is determined to obtain the second flag flag2, and the request parameters are encrypted according to the encryption algorithm in the second flag calling method to generate encryption parameters;

[0075] When the first flag flag1 is 1, the encryption type is interface signature, and then the encryption method is determined to obtain the second flag flag2, and the key string is encrypted according to the key, signature rules, and the encryption algorithm in the second flag calling method to generate encryption parameters (ie, signature sign).

[0076] Before initiating an interface request, the interface plaintext data is preprocessed. In the interface implementation of Jmeter, the interface plaintext is encrypted and encoded using the same encryption method and encryption process as the server, and an encryption request is initiated based on the encrypted ciphertext.

[0077] In this embodiment, it is achieved by calling the method api_security(flag1, flag2, apikey, data):

[0078] 5.1) Example 1:

[0079] flag1=0, flag2=2, apikey=”123@456”, data={'username':'Admin', 'password':'A123456', 'mail':'123@qq.com'}, the encryption parameters obtained by calling api_security(flag1, flag2, apikey, data) are facb30776e77b25d71b19f22741e758051d08e3e.

[0080] 5.2) Example 2:

[0081] flag1=1,flag2=1,apikey="123@456",data={'username':'Admin','password':

[0082] 'A123456','mail':'123@qq.com'}, call api_security(flag1,flag2,apikey,data) to get the encryption parameter, that is, sign is c73271f4828c7633566cd95bf9724ac8.

[0083] Step 6: Add the encryption parameters to the constructed performance test strategy to complete the performance test of the encryption interface.

[0084] In the step 6, specifically, the encryption parameters are added to the position that needs to be encrypted in the performance test, and then the test is performed according to the performance test strategy.

[0085] The present invention realizes the process of encrypting the interface using different encryption algorithms, and can call methods to simulate the actual application scenarios of the encryption interface according to specific circumstances. On the one hand, the security of the transmitted data is taken into account during the performance test, solving the problem of taking into account the security of the interface transmission data in the interface performance test; on the other hand, under the same performance test strategy, the impact of different encryption algorithms on the interface performance can be evaluated, providing data reference for developers, selecting appropriate encryption algorithms and parameters according to actual needs and security levels, and weighing the relationship between data security and system performance when implementing interface encryption, so as to achieve a balance between data security and system performance.

[0086] Although the present invention is described herein with reference to the illustrative embodiments of the present invention, the above embodiments are only preferred embodiments of the present invention, and the embodiments of the present invention are not limited to the above embodiments. It should be understood that those skilled in the art can design many other modifications and embodiments, which will fall within the scope and spirit of the principles disclosed in this application.

Claims

1. A performance testing method for an encryption interface, characterized in that: include: Classify interface security policies and encryption methods, and set classification flags for each; Implement interface security policy and encryption method encapsulation according to the flag bit to implement interface encryption method; Obtain key information based on the interface under test and construct a performance test strategy based on the key information; Determine the corresponding flag bit according to the security policy and encryption method classification of the tested interface; According to the judged flag bit, the corresponding encapsulated encryption method is called to obtain the encryption parameters; Add the encryption parameters to the constructed performance test strategy and execute it to complete the performance test of the encryption interface.

2. A performance testing method for an encryption interface according to claim 1, characterized in that: The interface security policies and encryption methods are classified and the classification flags are set respectively, including: The first flag flag1 is set according to the classification of the security policy; The second flag flag2 is set according to the classification of the encryption method.

3. A performance testing method for an encryption interface according to claim 2, characterized in that: The security policy includes at least interface encryption and interface signature; The encryption method at least includes one-way encryption, symmetric encryption and asymmetric encryption.

4. A performance testing method for an encryption interface according to claim 3, characterized in that: The interface encryption means that before initiating the interface request, the client encrypts the request parameters, encrypts and encodes the interface plaintext using the same encryption method and encryption process as the server, initiates an encryption request based on the encrypted ciphertext, and sends the encrypted message to the server.

5. The performance testing method of an encryption interface according to claim 3, characterized in that: The interface signature refers to the client using the key to generate a signature for the request parameters. When the interface transmits data, the signature is used as one of the parameters to request the interface from the server.

6. A performance testing method for an encryption interface according to claim 5, characterized in that: The signature refers to verifying whether the caller has the authority to call the interface by matching the keys of the client and the server; The signature implementation steps are: Arrange all request parameters except signature in ascending or descending alphabetical order by parameter name; Use the key-value pair format to concatenate into string stringA; stringA is concatenated with the key apikey to obtain the string stringSign; Perform encryption operation on stringSign to obtain the signature value; Put the sign in the URL request parameter to request the interface.

7. A performance testing method for an encryption interface according to claim 5, characterized in that: All the request parameters include system parameters and business parameters, where system parameters refer to parameters that are not related to the business, including signature sign, timestamp timestamp and request random string noncestr; business parameters, i.e. application parameters, are parameters related to the interface, and different interfaces require different parameters.

8. The performance testing method of an encryption interface according to claim 1, characterized in that: Obtain key information based on the interface being tested, and construct a performance test strategy based on the key information. The key information includes the transmitted request data, the interface encryption strategy and method, the encryption key, and the key character string that needs to be encrypted or encoded.

9. A performance testing method for an encryption interface according to claim 8, characterized in that: The request data refers to all data of the interface under test, including the request method, request header, request address, and request parameters; a performance test strategy is constructed by adding the request data to the Jmeter tool and setting the number of threads and running time in the performance parameters.

10. The performance testing method of an encryption interface according to claim 1, characterized in that: According to the flag bit judged, the corresponding encapsulated encryption method is called to obtain the encryption parameters. Before initiating an interface request, the interface plaintext data is preprocessed. In the interface implementation of Jmeter, the interface plaintext is encrypted and encoded using the same encryption method and encryption process as the server, and an encryption request is initiated based on the encrypted ciphertext.

Citation Information

Cited By

  • Method and device for enhancing security of original interface based on confusion interface and medium

    CN120017413A