A method, device, electronic device and medium for secure data transmission

Through the combination of hashing algorithm and exclusive OR operation, the problem of high resource consumption and computational complexity of existing encryption solutions is solved, efficient data transmission on resource-constrained devices is achieved, and key security risks are reduced.

CN118890152BActive Publication Date: 2024-12-17CEC CYBERSPACE GREAT WALL
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411377102.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2024-12-17
Estimated Expiration
2044-09-30

AI Technical Summary

Technical Problem

The existing symmetric encryption and asymmetric encryption schemes require additional resources in key management and distribution, and have high computational complexity, making it difficult to apply to devices with resource-constrained resources such as smart cards, embedded devices, etc., and there are key security risks. .

Method used

The hashing algorithm and XOR operation are used to configure the key data and message digest through negotiation information interaction, and perform data segmentation and XOR operation to achieve encryption, reducing the consumption of key management and computing resources.

Benefits of technology

It reduces the computational complexity, improves data transmission efficiency, reduces resource consumption and key security risks, and is suitable for devices with limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118890152B_ABST
    Figure CN118890152B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of secure data transmission, and provides a method, device, electronic device and medium for secure data transmission. In the method, after the first device and the second device mutually configure the negotiation information, a hash algorithm is used to calculate the configured first key data, obtain the message digest of the first key data, and send the two to the second device; after receiving the first encrypted data sequence to be transmitted sent by the second device, the first key data is XORed with each first encrypted sub-data respectively to obtain the corresponding first binary sub-data. Based on the first sub-data to be transmitted corresponding to each first binary sub-data, the first data to be transmitted is obtained. Since the method does not involve additional key management, resource consumption and key security risks are reduced, and the encryption function is realized by XOR operation, the calculation complexity is reduced while the data transmission efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of secure data transmission, and in particular to a method, device, electronic device and medium for secure data transmission. Background Art

[0002] During data transmission, there are many security risks such as man-in-the-middle attacks, data interception, eavesdropping, and data forgery, which seriously affect data confidentiality. The commonly used solution is to encrypt the transmission content to solve the data confidentiality.

[0003] Common encryption schemes include symmetric encryption schemes and asymmetric encryption schemes. In a symmetric encryption scheme, the sender and the receiver negotiate a key, which is shared by both parties and unknown to others. When sending data, the sender uses the key to encrypt the data before transmitting it. After receiving the encrypted data, the receiver uses the key to decrypt the encrypted data. A third party cannot decrypt the encrypted data without the key. In an asymmetric encryption scheme, the sender and the receiver each have their own key pair, including a public key PubKey and a private key PriKey, where their respective public keys PubKey are publicly available. When sending data, the sender obtains the receiver's public key PubKey, and then uses the receiver's PubKey to encrypt the data before sending it. When the receiver receives the data, it decrypts it using its own PriKey. A third party cannot decrypt the encrypted data without the PriKey.

[0004] Although these two encryption schemes are highly secure, they require additional resources in key management and distribution to ensure secure key transmission and management. In addition, symmetric encryption schemes and asymmetric encryption schemes require high computing power of resources, have high computational complexity, and consume large resources. They cannot be applied to resource-constrained devices such as smart cards, embedded devices, and mobile devices. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a method, device, electronic device and medium for secure data transmission. Since no additional key management is involved, resource consumption and key security risks are reduced, and encryption functions are implemented using XOR operations, which reduces computational complexity while improving data transmission efficiency.

[0006] In a first aspect, a method for securely transmitting data is provided, which is applied to a first device that establishes a communication connection with a second device. The method may include:

[0007] Negotiation information for interactive configuration with the second device; the negotiation information includes a preset hash algorithm and a target data length L of the key data;

[0008] Using the hash algorithm, calculate the configured first key data to obtain a message digest of the first key data, and send the first key data and the message digest of the first key data to the second device;

[0009] Receive a first encrypted data sequence to be transmitted sent by a second device; the first encrypted data sequence to be transmitted is obtained by dividing the data length L1 of the stored first data to be transmitted into a first data sequence including a plurality of first sub-data to be transmitted according to a first preset ratio after the hash value calculated by the second device for the received first key data using the hash algorithm is consistent with the message digest of the first key data, and performing an XOR operation on the first binary sub-data corresponding to each of the first sub-data to be transmitted and the first key data respectively; the first data sequence includes a plurality of first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged; the data length of each first sub-data to be transmitted is a target data length L; the first encrypted data sequence to be transmitted includes the first encrypted sub-data corresponding to each first binary sub-data;

[0010] Performing an XOR operation on the first key data and each first encrypted sub-data to obtain corresponding first binary sub-data;

[0011] Based on the first sub-data to be transmitted corresponding to each first binary sub-data, the first data to be transmitted is acquired.

[0012] In one possible implementation, the method further includes:

[0013] receiving the configured second key data and a message digest of the second key data sent by the second device, where the message digest of the second key data is obtained by the second device calculating the configured second key data by using the hash algorithm;

[0014] If the hash value calculated by using the hash algorithm for the received second key data is consistent with the message digest of the second key data, the data length L2 of the second data to be transmitted is divided according to the second preset ratio to obtain a second data sequence, wherein the second data sequence includes a plurality of second sub-data to be transmitted whose data positions corresponding to the second data to be transmitted remain unchanged; and the data length of each second sub-data to be transmitted is the target data length L;

[0015] Performing binary conversion on each of the second sub-data to be transmitted to obtain corresponding second binary sub-data;

[0016] Performing an exclusive OR operation on the second key data and each second binary sub-data respectively to obtain a second encrypted data sequence to be transmitted; the second encrypted data sequence to be transmitted includes the second encrypted sub-data corresponding to each second binary sub-data;

[0017] Send the second encrypted data sequence to be transmitted to the second device.

[0018] In a possible implementation, the configuration process of the first key data includes:

[0019] Perform binary conversion on the target second sub-data to be transmitted in the second data sequence and the preset random number R_A to obtain target second binary sub-data and a second binary random number; the target second sub-data to be transmitted is any second sub-data to be transmitted in the second data sequence; the data length of the random number R_A is the target data length L;

[0020] An XOR operation is performed on the target second binary sub-data and the second binary random number to obtain the first key data.

[0021] In a possible implementation, the second key data is obtained by the second device performing binary conversion on the target first sub-data to be transmitted in the first data sequence and a preset random number R_B, obtaining the target first binary sub-data and the first binary random number, and then performing an XOR operation on the target first binary sub-data and the first binary random number, wherein the target first sub-data to be transmitted is any first sub-data to be transmitted in the first data sequence; and the data length of the random number R_B is the target data length L.

[0022] In a possible implementation, the negotiation information further includes a preset filling rule; and the method further includes:

[0023] If the data length of the last cut data obtained by splitting the data length L1 of the second data to be transmitted is not the target data length L, then the last cut data is padded according to the preset filling rule to obtain the last second sub-data to be transmitted with a data length of the target data length L, and the last second sub-data to be transmitted and the corresponding other second sub-data to be transmitted are combined to generate a second data sequence.

[0024] In a possible implementation, obtaining the first data to be transmitted based on the first sub-data to be transmitted corresponding to each first binary sub-data includes:

[0025] If the last first sub-data to be transmitted in the first data sequence is obtained by the second device using a preset filling rule, after obtaining the first sub-data to be transmitted corresponding to each first binary sub-data, de-filling the last first sub-data to be transmitted using the preset filling rule to obtain new last first sub-data to be transmitted; and splicing the new last first sub-data to be transmitted and other first sub-data to be transmitted according to data positions to obtain first data to be transmitted;

[0026] If the last first sub-data to be transmitted in the first data sequence is not obtained by the second device using a preset filling rule, the first sub-data to be transmitted are spliced ​​according to the data position to obtain the first data to be transmitted.

[0027] In one possible implementation, the method further includes:

[0028] If the hash value calculated by using the hash algorithm for the received first key data is inconsistent with the message digest of the first key data, a data retransmission request is sent to the second device, and the execution step is returned: using the hash algorithm to calculate the configured first key data to obtain the message digest of the first key data.

[0029] In a second aspect, a secure data transmission device is provided, which is applied to a first device that establishes a communication connection with a second device, and the device may include:

[0030] An interaction unit, configured to exchange negotiation information with the second device; the negotiation information includes a preset hash algorithm and a target data length L of the key data;

[0031] a computing unit, configured to use the hash algorithm to compute the configured first key data, obtain a message digest of the first key data, and send the first key data and the message digest of the first key data to the second device;

[0032] A receiving unit, used for receiving a first encrypted data sequence to be transmitted sent by a second device; the first encrypted data sequence to be transmitted is obtained by dividing the data length L1 of the stored first data to be transmitted according to a first preset ratio to obtain a first data sequence including a plurality of first sub-data to be transmitted, after a hash value calculated by the second device using the hash algorithm for the received first key data is consistent with the message digest of the first key data, and performing an XOR operation on the first binary sub-data corresponding to each of the first sub-data to be transmitted and the first key data respectively; the first data sequence includes a plurality of first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged; the data length of each first sub-data to be transmitted is a target data length L; the first encrypted data sequence to be transmitted includes the first encrypted sub-data corresponding to each first binary sub-data;

[0033] The calculation unit is further used to perform an XOR operation on the first key data and each first encrypted sub-data to obtain corresponding first binary sub-data;

[0034] The acquiring unit is used to acquire the first data to be transmitted based on the first sub-data to be transmitted corresponding to each first binary sub-data.

[0035] In a third aspect, an electronic device is provided, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0036] Memory, used to store computer programs;

[0037] The processor is used to implement any method step described in the first aspect when executing the program stored in the memory.

[0038] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.

[0039] In the secure data transmission method provided by the present application, after the first device and the second device mutually exchange the configured negotiation information, a hash algorithm is used to calculate the configured first key data to obtain the message digest of the first key data, and the first key data and the message digest of the first key data are sent to the second device; the negotiation information includes a preset hash algorithm and a target data length of the key data; a first encrypted data sequence to be transmitted sent by the second device is received; the first encrypted data sequence to be transmitted is the first preset ratio of the stored data of the first data to be transmitted after the hash value calculated by the second device using the hash algorithm for the received first key data is consistent with the message digest of the first key data After the first data sequence including multiple first sub-data to be transmitted is obtained by dividing the first data sequence by length, the first binary sub-data corresponding to each first sub-data to be transmitted is obtained by performing an XOR operation with the first key data respectively; the first data sequence includes multiple first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged; the data length of each first sub-data to be transmitted is the target data length; the first encrypted data sequence to be transmitted includes the first encrypted sub-data corresponding to each first binary sub-data; the first key data is XORed with each first encrypted sub-data respectively to obtain the corresponding first binary sub-data, and the first data to be transmitted is obtained based on the first sub-data to be transmitted corresponding to each first binary sub-data. This method reduces resource consumption and key security risks, reduces computational complexity and improves data transmission efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1A schematic diagram of a system architecture of a method for securely transmitting applicable data provided in an embodiment of the present application;

[0042] Figure 2 A schematic diagram of a flow chart of a method for securely transmitting data provided in an embodiment of the present application;

[0043] Figure 3 A schematic diagram of the structure of a secure data transmission device provided in an embodiment of the present application;

[0044] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application. Unless otherwise defined, the technical terms or scientific terms used in this application should be the common meanings understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Including" or "including" and other similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connected", "coupled" or "connected" and other similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0046] Compared with the existing symmetric encryption schemes and asymmetric encryption schemes to ensure data security during data exchange, this application proposes a secure data transmission, which is a lightweight data encryption scheme. It uses hardware acceleration technology to complete the XOR operation through dedicated XOR logic gates or configure specific XOR operation logic units in FPGA, DSP, ASIC and other devices to ensure data confidentiality. The basic technical principles of XOR operation are explained below:

[0047] The mathematical symbol of Exclusive OR (XOR) is ⊕, which is a basic logical operation applied to two binary operands. Its result is true only when one of the two binary operands is true (usually represented as 1) and the other binary operand is false (represented as 0). In the XOR operation, if the two input values ​​(i.e. binary operands) are the same, the output is 0; if the two input values ​​are different, the output is 1. Its truth table is as follows Figure 1 As shown:

[0048]

[0049] The XOR operation follows the following operation rules:

[0050] Identity law: A ⊕ 0 = A;

[0051] Zeroing law: A ⊕ A = 0;

[0052] Commutative law: A ⊕ B = B ⊕ A;

[0053] Associative law: A ⊕ (B ⊕ C) = (A ⊕ B) ⊕ C;

[0054] Reflexivity: A ⊕ B ⊕ B = A;

[0055] In hardware implementation, the XOR gate is a basic digital logic gate and is often used to build more complex logic circuits. This application uses hardware acceleration to implement XOR operations. In specific implementations, XOR operations can be accelerated by dedicated XOR logic gates or by configuring specific XOR operation logic units in devices such as FPGAs, DSPs, and ASICs.

[0056] The data security transmission method provided by this application can be applied in Figure 1 In the system architecture shown, the system may include: a hardware acceleration module, a random number generation module, a data conversion module, a data storage module, a data segmentation and reorganization module, a data filling module, a data encryption and decryption module, and a data integrity module;

[0057] Hardware acceleration module: It has corresponding hardware support, provides specific interfaces, and supports program calls. After the call, the calculation is handed over to the hardware to improve computing performance and efficiency. In this application, the hardware acceleration module supports the random number generation module and the encryption and decryption module, and can complete fast XOR operations. In the specific implementation, it can be achieved through dedicated XOR logic gates or by configuring specific XOR operation logic units in devices such as FPGA, DSP, and ASIC.

[0058] Random number generation module: Generates a random number of a specified length based on the configured key seed for encryption and decryption. Different devices can generate the same random number or different random numbers, which is not limited in this application.

[0059] Data conversion module: responsible for converting data formats. For example, it is used to complete the conversion between the data format of stored user data (or "data to be transmitted") and the binary data format.

[0060] Data storage module: securely stores random numbers, user data, message digests, etc.

[0061] Data cutting and reorganization module: completes the cutting of user data and the reorganization and restoration of cut data. When cutting user data, the user data is cut according to the specified length (or "target data length L") and cut into data of the specified length (or "sub-data to be transmitted"). For data less than the specified length, the data filling module needs to be called to fill it to form cut data of the specified length for efficient calculation. When reorganizing data, the cut data is reorganized to restore the user data.

[0062] Data filling module: fills the data according to the preset filling principle to form data of a specified length. It should be noted that if the data length of each cutting data is the specified length, the data filling module is not required to fill the cutting data.

[0063] Data encryption and decryption module: completes the data encryption and decryption process based on XOR operation.

[0064] Data integrity module: used to generate and verify data integrity proof (message digest) to ensure that data has not been tampered with during transmission or storage.

[0065] The data security transmission method provided in the present application can be applied to the data security transmission between two devices, and can also be applied to the data security transmission between two devices among multiple devices.

[0066] In terms of specific process design, the present invention introduces a hardware acceleration module, which can be called for the XOR operation process to be completed by the corresponding hardware, greatly improving the computing performance. The data cutting and reorganization module completes the cutting of large files and solves the problem of slow acceleration of large files. In addition, in terms of process design, the present invention cleverly uses the data of other participants. The data of a participant is XORed with its own random number and sent to other participants as a key. Other participants use the key to complete the XOR operation with their own data, and then send the data to other participants other than themselves. Each participant then cleverly uses the XOR operation to obtain the data of other participants.

[0067] The present invention does not involve additional key management, reducing resource consumption and potential security risks caused by key transmission and management. The present invention uses hardware acceleration to implement XOR operations through dedicated XOR logic gates or by configuring specific XOR operation logic units in devices such as FPGA, DSP, and ASIC, and the XOR operation has low computational complexity, thereby improving computing performance and efficiency. The algorithm of the present invention is a lightweight algorithm with little reliance on resources, and can be effectively applied in scenarios with limited resources, with a wider range of applications.

[0068] It should be noted that in actual applications, the functional modules of the system are not limited to the system functional modules proposed in the invention, and the data interaction process is not limited to the interaction process described in the invention. In addition, the final form of the present invention is not limited to the software form, but can also be a hardware device equipped with the system.

[0069] The preferred embodiments of the present application are described below in conjunction with the drawings of the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application can be combined with each other if there is no conflict. The specific implementation process of the present application is introduced below by taking the data transmission between the first device and the second device as an example.

[0070] Figure 2 The following is a flow chart of a method for securely transmitting data provided in an embodiment of the present application. Figure 2 As shown, the method may include:

[0071] Step 201: Negotiation information of mutual configuration between a first device and a second device.

[0072] In a specific implementation, after completing identity authentication and establishing a communication connection between the first device and the second device, the first device and the second device communicate and interact, and each obtains negotiation information, which may include a preset hash algorithm, a target data length L of the key data, a preset padding rule, etc.

[0073] The first device stores the second data to be transmitted, such as DATA_A, whose data length is L1, such as L_DATA_A, and the second device stores the first data to be transmitted, such as DATA_B, whose data length is L2, such as L_DATA_B. L1 or L2 is greater than the target data length L.

[0074] Step 202: The first device uses a hash algorithm to calculate the configured first key data to obtain a message digest of the first key data, and sends the first key data and the corresponding message digest to the second device.

[0075] Specifically, the first device calls the data integrity module, uses the negotiated hash algorithm, calculates the message digest of the configured first key data, and sends the first key data and the message digest of the first key data to the second device.

[0076] Step 203: The second device uses a hash algorithm to calculate the configured second key data to obtain a message digest of the second key data, and sends the second key data and the corresponding message digest to the first device.

[0077] Specifically, the second device calls the data integrity module, uses the negotiated hash algorithm, calculates the message digest of the configured second key data, and sends the second key data and the message digest of the second key data to the first device.

[0078] It should be noted that the serial numbers in step 202 and step 203 do not represent the order in which the steps are executed, that is, the steps of step 202 and step 203 can be executed simultaneously or one after another.

[0079] Step 204: After the hash value calculated by the second device using the hash algorithm for the received first key data is consistent with the message digest of the first key data, the second device divides the data length L1 of the stored first data to be transmitted according to the first preset ratio to obtain a first data sequence.

[0080] Since packet loss may occur during the transmission process, it is necessary to verify the integrity of the transmitted data.

[0081] Specifically, the second device uses a hash algorithm to calculate the currently received first key data to obtain a corresponding hash value;

[0082] (1) If the hash value is consistent with the message digest of the currently received first key data, it indicates that the transmitted data is complete. At this time, the second device divides the data length L1 of the stored first data to be transmitted according to the first preset ratio to obtain multiple first sub-data to be transmitted;

[0083] A first data sequence consisting of a plurality of first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged is obtained, wherein the data positions remain unchanged means that the positions of the segmented data in the first data to be transmitted are not changed according to the segmentation sequence.

[0084] The first preset ratio is the ratio of the data length L1 to the target data length L, so that the data length of each first sub-data to be transmitted is the target data length L.

[0085] In one example, the second device calls the data cutting and reassembly module to cut DATA_B into N parts, which are respectively recorded as DATA_B_1, DATA_B_2, ..., DATA_B_N. N = [L_DATA_B / L]. [L_DATA_B / L] means rounding up the result of L_DATA_B / L. If the result of L_DATA_B / L is a decimal, the smallest integer greater than the result is taken; if the result is an integer, it remains unchanged. The data cut from the i-th part is recorded as DATA_B_i, i∈[1, N], N=[L_DATA_B / L], and the data storage module is called to store it.

[0086] (2) If the hash value is inconsistent with the message digest of the currently received first key data, it indicates that the transmitted data is incomplete, and the second device sends a data retransmission request to the first device;

[0087] Based on the data retransmission request, the first device returns to the execution step: using the hash algorithm to calculate the configured first key data to obtain a message digest of the first key data until a preset end condition is met.

[0088] If the attempt fails after a specific number of times, the connection is terminated and the data exchange process ends.

[0089] Step 205: The second device performs binary conversion on each first sub-data to be transmitted in the first data sequence to obtain corresponding first binary sub-data, and performs an XOR operation on each first binary sub-data and the first key data to obtain a first encrypted data sequence to be transmitted.

[0090] The second device calls the data conversion module to perform binary conversion on each first sub-data to be transmitted in the first data sequence to obtain corresponding first binary sub-data in binary form; for example, DATA_B_1, DATA_B_2, ....., DATA_B_N are converted into binary form in sequence, recorded as R_DATA_B_1, R_DATA_B_2, ..., R_DATA_A_N.

[0091] The second device performs an XOR operation on the first key data received from the first device and each first binary sub-data to obtain first encrypted sub-data corresponding to each first binary sub-data; for example, the first key data is XORed with R_DATA_B_1, R_DATA_B_2, ..., R_DATA_B_N to generate corresponding new data: Y1, Y2, ..., YN. Where Yi = C_DATA_A_1 ⊕ R_DATA_B_i, i∈[1, N].

[0092] The second device obtains a first encrypted data sequence to be transmitted (Y1, Y2, . . . , YN) composed of the first encrypted sub-data.

[0093] Step 206: The second device sends a first encrypted data sequence to be transmitted to the first device.

[0094] Step 207: The first device performs an XOR operation on the first key data and each first encrypted sub-data in the first encrypted data sequence to be transmitted, to obtain corresponding first binary sub-data.

[0095] The first device uses the data encryption and decryption module to perform an XOR operation on the first key data with Y1, Y2, Y3, ..., YN, respectively, to obtain the first binary sub-data corresponding to each first encrypted sub-data: R_DATA_B_1, R_DATA_B_2, R_DATA_B_3, ..., R_DATA_B_N. Because Yi = first key data ⊕ R_DATA_B_i, i∈[1, N], the first key data ⊕ Yi = first key data ⊕ [first key data ⊕ R_DATA_B_i] = R_DATA_B_i, i∈[1, N].

[0096] Step 208: The first device obtains the first data to be transmitted based on the first sub-data to be transmitted corresponding to each first binary sub-data.

[0097] The first device calls a data conversion module to convert the data form of the first binary sub-data: R_DATA_B_1, R_DATA_B_2, R_DATA_B_3, ..., R_DATA_B_N into the data form of user data: DATA_B_1, DATA_B_2, DATA_B_3, ..., DATA_B_N.

[0098] Afterwards, the first device calls the data segmentation and reassembly module to reassemble R_DATA_B_1, R_DATA_B_2, R_DATA_B_3, ..., R_DATA_B_N to obtain DATA_B, i.e., the first data to be transmitted. In this way, the first device obtains the first data to be transmitted of the second device.

[0099] Further, after the first device executes step 203 and receives the configured second key data and the message digest of the second key data sent by the second device, the method may further include:

[0100] Step 209: The first device uses a hash algorithm to calculate a hash value for the received second key data that is consistent with the message digest of the second key data, and divides the data length L2 of the second data to be transmitted according to a second preset ratio to obtain a second data sequence.

[0101] The second data sequence may include a plurality of second sub-data to be transmitted whose data positions corresponding to the second data to be transmitted remain unchanged; the second preset ratio is a ratio of the data length L2 to the target data length L, so that the data length of each second sub-data to be transmitted is the target data length L;

[0102] This specific implementation is similar to step 204 and will not be described in detail here.

[0103] In one example, the first device calls the data cutting and reassembly module to cut DATA_A into M parts, and the entire data set is represented as (DATA_A_1, DATA_A_2, ......., DATA_A_M). The data cut from the i-th part is recorded as DATA_A_i, i∈[1, M], M=[L_DATA_A / L], and [L_DATA_A / L] represents rounding up the result of L_DATA_A / L. If the result of L_DATA_A / L is a decimal, take the smallest integer larger than the result; if the result is an integer, keep it unchanged.

[0104] Step 210: The first device performs binary conversion on each second sub-data to be transmitted in the second data sequence to obtain corresponding second binary sub-data, and performs an XOR operation on the second key data and each second binary sub-data to obtain a second encrypted data sequence to be transmitted.

[0105] The second encrypted data sequence to be transmitted may include second encrypted sub-data corresponding to each second binary sub-data.

[0106] This specific implementation is similar to step 205 and will not be described in detail here.

[0107] Step 211: The first device sends a second encrypted data sequence to be transmitted to the second device.

[0108] Step 212: The second device performs an XOR operation on the second key data and each second encrypted sub-data in the second encrypted data sequence to be transmitted, to obtain corresponding second binary sub-data.

[0109] The second device uses the data encryption and decryption module to perform an XOR operation on the second key data with X1, X2, ..., XM respectively, to obtain the second binary sub-data corresponding to each second encrypted sub-data: R_DATA_A_1, R_DATA_A_2, ..., R_DATA_A_M. Because Xi = second key data ⊕ R_DATA_A_i, i∈[1, M], the second key data ⊕Xi = second key data ⊕[second key data ⊕ R_DATA_A_i] = R_DATA_A_i, i∈[1, M].

[0110] Step 213: The second device obtains the second data to be transmitted based on the second first sub-data to be transmitted corresponding to each second binary sub-data.

[0111] The second device calls the data conversion module to convert the data form of the second binary sub-data: R_DATA_A_1, R_DATA_A_2, R_DATA_A_3, ..., R_DATA_A_M into the data form of user data: DATA_A_1, DATA_A_2, DATA_A_3, ..., DATA_A_M.

[0112] In some embodiments, the first key data of the first device may be pre-configured key data, or may be configured in the following manners, including:

[0113] The first device may call the hardware acceleration module to generate a random number R_A whose data length is the target data length L;

[0114] Perform binary conversion on the target second sub-data to be transmitted in the second data sequence and the preset random number R_A to obtain the target second binary sub-data and the second binary random number, and perform an XOR operation on the target second binary sub-data and the second binary random number to obtain the first key data;

[0115] The target second sub-data to be transmitted may be any second sub-data to be transmitted in the second data sequence.

[0116] Accordingly, the second key data of the second device may be pre-configured key data, or may be configured in the following manners, including:

[0117] The second device may call the hardware acceleration module to generate a random number R_B whose data length is the target data length L;

[0118] The target first sub-data to be transmitted in the first data sequence is converted into binary form with a preset random number R_B to obtain the target first binary sub-data and the first binary random number; and the target first binary sub-data is XORed with the first binary random number to obtain the second key data. The target first sub-data to be transmitted is any first sub-data to be transmitted in the first data sequence.

[0119] In some embodiments, for the last cut data after cutting the second data to be transmitted or the first data to be transmitted, if the data length of the cut data is not the target data length L, the last cut data is filled with data according to a preset filling rule to obtain a new last cut data with a data length of the target data length L, that is, the last sub-data to be transmitted; then, the last sub-data to be transmitted and other sub-data to be transmitted with the corresponding target data length L are used to generate a corresponding data sequence, that is, a second data sequence corresponding to the second data to be transmitted, or a first data sequence corresponding to the first data to be transmitted.

[0120] Specifically, if the data length of the last cut data obtained by splitting the data length L1 of the second data to be transmitted is not the target data length L, then the last cut data is filled with data according to the preset filling rule to obtain the last second sub-data to be transmitted with a data length of the target data length L, and the last second sub-data to be transmitted and the corresponding other second sub-data to be transmitted are combined to generate a second data sequence.

[0121] Correspondingly, the last first sub-data to be transmitted in the second data sequence generated by the second device may also be obtained by using a preset filling rule.

[0122] Here, take DATA_A as an example, cutting DATA_A into M parts, and the entire data set is represented as (DATA_A_1, DATA_A_2, ......., DATA_A_M). The preset filling rule can be to fill at least one identical target character after the last character / before the first character of DATA_A_M, so that the filled L_DATA_A_M is the target data length L; or, the set filling rule can be to fill consecutive numbers (such as 1, 2, 3...) after the last character / before the first character of DATA_A_M, so that the filled L_DATA_A_M is the target data length L, which is not limited in this application.

[0123] Further, in the case where the last first sub-data to be transmitted in the first data sequence is obtained by the second device using a preset filling rule, step 208 performed by the first device may specifically include:

[0124] After obtaining the first sub-data to be transmitted corresponding to each first binary sub-data, the first device de-fills the last first sub-data to be transmitted using a preset filling rule to obtain a new last first sub-data to be transmitted; and splices the new last first sub-data to be transmitted and other first sub-data to be transmitted according to the data position to obtain the first data to be transmitted.

[0125] In a specific example, it is assumed that the two parties involved in data exchange are a first device A and a second device B. The data of the first device A is marked as DATA_A, and the data of the second device B is marked as DATA_B.

[0126] 1. Complete the initialization configuration and define the length L of the random number. You can also use the default value. This length is also used as the length basis for data cutting.

[0127] 2. A and B complete identity authentication and establish a connection.

[0128] 3. A and B negotiate a hash algorithm, recorded as HASH_METHOD.

[0129] 4. A calls the hardware acceleration module to generate a random number R_A of length L, where R stands for the abbreviation of random number Random.

[0130] 5. A calls the data storage module to store R_A.

[0131] 6. A reads DATA_A and calculates its length L_DATA_A.

[0132] 7. A calls the data cutting and reorganization module to cut DATA_A into M parts. The entire data set is represented as (DATA_A_1, DATA_A_2, ..., DATA_A_M). The i-th piece of data is denoted as DATA_A_i, i∈[1,M].

[0133] 8. A calls the data storage module to store DATA_A_1, DATA_A_2, ......., DATA_A_M respectively.

[0134] 9. A calls the data filling module to fill DATA_A_M with a filling length of L-L_DATA_A_M.

[0135] 10. A calls the data conversion module to convert DATA_A_1 and R_A into binary form for XOR operation. The converted binary data are recorded as B_DATA_A_1 and B_R_A respectively.

[0136] 11. A calls the data encryption and decryption module to encrypt B_DATA_A_1. The encrypted ciphertext data is recorded as C_DATA_A_1.

[0137] Among them, C_DATA_A_1=B_DATA_A_1⊕B_R_A. C stands for the abbreviation of Cipher. The encryption process can call the hardware acceleration module to accelerate the calculation.

[0138] 12. A calls the data integrity module and uses the agreed hash algorithm HASH_METHOD to calculate the message digest (hash value) of the ciphertext data C_DATA_A_1, expressed as HASH_METHOD (C_DATA_A_1). The calculation result is recorded as H_C_DATA_A_1. H stands for message digest Hash.

[0139] 13. A sends C_DATA_A_1 and its corresponding message digest H_C_DATA_A_1 to B. The format is (C_DATA_A_1, H_C_DATA_A_1).

[0140] 14. B calls the data storage module to store the received data. The received data is recorded as (C_DATA_A_1*, H_C_DATA_A_1*).

[0141] 15. B uses HASH_METHOD to calculate the hash value of C_DATA_A_1* and compares it with H_C_DATA_A_1*. If the results are consistent, it means that the data is complete during the transmission process, and proceed to the next step. If the results are inconsistent, it means that the data transmission process may be damaged. B deletes the locally stored (C_DATA_A_1*, H_C_DATA_A_1*) and requests A to resend the data.

[0142] 16. A queries the stored data DATA_A_1, recalculates the ciphertext data and message digest of the data, and resends the data to B. The format is (C_DATA_A_1, H_C_DATA_A_1).

[0143] 17. After receiving the data, B calls the data storage module to store the data.

[0144] 18. B verifies whether the received data is complete, and the process is the same as described in 15. If the attempt fails after a specific number of attempts, the connection is terminated, ending the data exchange process.

[0145] 19. B calls the hardware acceleration module to generate a random number R_B of length L.

[0146] 20. B calls the data storage module to store R_B.

[0147] 21. B reads DATA_B and calculates its length L_DATA_B.

[0148] 22. B calls the data cutting and reassembly module to cut DATA_B into N parts, which are respectively recorded as DATA_B_1, DATA_B_2, ..., DATA_B_N. The i-th part of the data is recorded as DATA_B_i, i∈[1,N], N=[L_DATA_B / L].

[0149] 23. B calls the data storage module to store DATA_B_1, DATA_B_2, ..., DATA_B_N.

[0150] 24. B calls the data filling module to fill DATA_B_N with a filling length of L-L_DATA_B_N.

[0151] 25. B calls the data conversion module to convert DATA_B_1 and R_B into binary form. The converted binary data are recorded as B_DATA_B_1 and B_R_B respectively.

[0152] 26. B calls the data encryption and decryption module to perform encryption operations on B_DATA_B_1 respectively. The encrypted ciphertext data is recorded as C_DATA_B_1.

[0153] Among them, C_DATA_B_1=B_DATA_B_1⊕B_R_B.

[0154] 27. B calls the data integrity module and uses the agreed hash algorithm HASH_METHOD to calculate the message digest (hash value) of the ciphertext data C_DATA_B_1. It is recorded as H_C_DATA_B_1. H_C_DATA_B_1=HASH_METHOD(C_DATA_B_1).

[0155] 28. B sends the encrypted data C_DATA_B_1 and its corresponding message digest H_C_DATA_B_1 to A. The format is (C_DATA_B_1, H_C_DATA_B_1).

[0156] 29. The data received by A is recorded as (C_DATA_B_1#, H_C_DATA_B_1#). A calls the data storage module to store (C_DATA_B_1#, H_C_DATA_B_1#).

[0157] 30. A uses HASH_METHOD to calculate the hash value of C_DATA_B_1# and compares it with H_C_DATA_B_1#. If the results are consistent, it means that the data is complete during the transmission process, and proceed to the next step. If the results are inconsistent, it means that the data transmission process may be damaged, and A requests B to resend the data.

[0158] 31. B queries the stored data, recalculates the ciphertext data and message digest of the damaged data, and resends the damaged data to A. The format is (C_DATA_B_1, H_C_DATA_B_1).

[0159] 32. After receiving the data, A calls the data storage module to store the data.

[0160] 33. A verifies whether the received data is complete, and the process is the same as described in 30. If the attempt fails after a specific number of attempts, the connection is terminated, ending the data exchange process.

[0161] 34. A calls the data conversion module to convert DATA_A_1, DATA_A_2, ..., DATA_A_M into binary form in sequence, denoted as R_DATA_A_1, R_DATA_A_2, ..., R_DATA_A_M.

[0162] 35. B calls the data conversion module to convert DATA_B_1, DATA_B_2, ..., DATA_B_N into binary form in sequence, denoted as R_DATA_B_1, R_DATA_B_2, ..., R_DATA_A_N.

[0163] 36. A uses the received ciphertext data C_DATA_B_1 from B and A's M binary data (R_DATA_A_1, R_DATA_A_2, ..., R_DATA_A_M) to perform XOR operations to generate new data (X1, X2, ..., XM).

[0164] Among them, Xi=C_DATA_B_1⊕R_DATA_A_i, i∈[1,M].

[0165] 37. B uses the received ciphertext data C_DATA_A_1 of A and N copies of B’s data (R_DATA_B_1, R_DATA_B_2, ..., R_DATA_B_N) to perform XOR operations respectively to generate new data (Y1, Y2, ..., YN). Among them, Yi = C_DATA_A_1 ⊕ R_DATA_B_i, i∈[1, N].

[0166] 38. A sends new data (X1, X2, ..., XM) to B.

[0167] 39. B sends new data (Y1, Y2, Y3..., YN) to A.

[0168] 40. B uses the data encryption and decryption module to calculate the XOR operation between C_DATA_B_1 and X1, X2, ..., XM, and obtains R_DATA_A_1, R_DATA_A_2, ..., R_DATA_A_M. Because Xi = C_DATA_B_1 ⊕ R_DATA_A_i, i∈[1, M], then:

[0169] C_DATA_B_1⊕Xi=C_DATA_B_1⊕[C_DATA_B_1⊕R_DATA_A_i]=R_DATA_A_i, i∈[1, M].

[0170] 41. A uses the data encryption and decryption module to calculate the XOR operation between C_DATA_A_1 and Y1, Y2, Y3...YN, and obtains R_DATA_B_1, R_DATA_B_2, R_DATA_B_3,..., R_DATA_B_N. Because Yi=C_DATA_A_1⊕R_DATA_B_i(37), i∈[1,N], therefore:

[0171] C_DATA_A_1⊕Yi=C_DATA_A_1⊕[C_DATA_A_1⊕R_DATA_B_i]=R_DATA_B_i, i∈[1, N].

[0172] 42. B calls the data conversion module to convert R_DATA_A_1, R_DATA_A_2, ..., R_DATA_A_M into DATA_A_1, DATA_A_2, ....., DATA_A_M.

[0173] 43. A calls the data conversion module to convert R_DATA_B_1, R_DATA_B_2, R_DATA_B_3, ..., R_DATA_B_N into DATA_B_1, DATA_B_2, DATA_B_3, ..., DATA_B_N.

[0174] 44. B calls the data filling module to fill DATA_A_M.

[0175] 45. A calls the data filling module to fill DATA_B_N.

[0176] 46. ​​B calls the data segmentation and reassembly module to reassemble DATA_A_1, DATA_A_2, ..., DATA_A_M to obtain DATA_B. In this way, B obtains A's data.

[0177] 47. A calls the data segmentation and reassembly module to reassemble R_DATA_B_1, R_DATA_B_2, R_DATA_B_3, ..., R_DATA_B_N to obtain DATA_B. In this way, A obtains B's data.

[0178] 48. At this point, A has obtained B's data, and B has obtained A's data, that is, the data exchange process between A and B has been completed.

[0179] In some embodiments, in order to further improve the security of data transmission, the encryption algorithm can be updated regularly, and the new encryption algorithm is updated based on the currently applied encryption algorithm, thereby continuously increasing the algorithm logic of the encryption algorithm.

[0180] For example, the encryption algorithm based on XOR operation is updated to the encryption algorithm based on XOR-NON operation. The encryption algorithm based on XOR-NON operation (i.e., the logic operation combining XOR logic gate and NOT logic gate) means that the data is XORed and then the calculated value is inverted, thereby encrypting the data and avoiding security risks caused by outdated algorithms.

[0181] In other embodiments, in order to further improve the security of data transmission, corresponding key data can be generated based on different cutting data each time the device transmits data, that is, new key data is generated each time data is transmitted, and the interaction of key data between devices is realized.

[0182] For example, taking the cut binary data: B_DATA_A_1 and B_DATA_A_2 as an example, the first transmission data is XORed with B_DATA_A_1 and B_R_A, that is, encrypted to obtain the current key data of the first transmission data; the second transmission data is XORed with B_DATA_A_2 and B_R_A to obtain the current key data of the second transmission data.

[0183] Alternatively, in order to further improve the security of data transmission, data transmission can also be performed in a manner that combines periodic updating of the encryption algorithm and generation of new key data each time data is transmitted, which is not limited in this application.

[0184] Corresponding to the above method, the embodiment of the present application also provides a secure data transmission device, such as Figure 3 As shown, the device comprises:

[0185] An interaction unit 310 is used to exchange configuration negotiation information with a second device; the negotiation information includes a preset hash algorithm and a target data length L of the key data;

[0186] a calculation unit 320, configured to calculate the configured first key data by using the hash algorithm to obtain a message digest of the first key data, and send the first key data and the message digest of the first key data to the second device;

[0187] The receiving unit 330 is used to receive a first encrypted data sequence to be transmitted sent by a second device; the first encrypted data sequence to be transmitted is obtained by dividing the data length L1 of the stored first data to be transmitted according to a first preset ratio to obtain a first data sequence including a plurality of first sub-data to be transmitted, and then performing an XOR operation on the first binary sub-data corresponding to each of the first sub-data to be transmitted and the first key data respectively after the hash value calculated by the second device for the received first key data using the hash algorithm is consistent with the message digest of the first key data; the first data sequence includes a plurality of first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged; the data length of each first sub-data to be transmitted is the target data length L; the first encrypted data sequence to be transmitted includes the first encrypted sub-data corresponding to each first binary sub-data;

[0188] The calculation unit 320 is further used to perform an XOR operation on the first key data and each first encrypted sub-data to obtain corresponding first binary sub-data;

[0189] The acquisition unit 340 is configured to acquire the first data to be transmitted based on the first sub-data to be transmitted corresponding to each first binary sub-data.

[0190] The functions of each functional unit of the data security transmission device provided in the above-mentioned embodiments of the present application can be realized through the above-mentioned method steps. Therefore, the specific working process and beneficial effects of each unit in the data security transmission device provided in the embodiments of the present application will not be repeated here.

[0191] The present application also provides an electronic device, such as Figure 4 As shown, it includes a processor 410 , a communication interface 420 , a memory 430 and a communication bus 440 , wherein the processor 410 , the communication interface 420 , and the memory 430 communicate with each other via the communication bus 440 .

[0192] Memory 430, for storing computer programs;

[0193] The processor 410 is used to execute the program stored in the memory 430 to implement the following steps:

[0194] Negotiation information for interactive configuration with the second device; the negotiation information includes a preset hash algorithm and a target data length L of the key data;

[0195] Using the hash algorithm, calculate the configured first key data to obtain a message digest of the first key data, and send the first key data and the message digest of the first key data to the second device;

[0196] Receive a first encrypted data sequence to be transmitted sent by a second device; the first encrypted data sequence to be transmitted is obtained by dividing the data length L1 of the stored first data to be transmitted into a first data sequence including a plurality of first sub-data to be transmitted according to a first preset ratio after the hash value calculated by the second device for the received first key data using the hash algorithm is consistent with the message digest of the first key data, and performing an XOR operation on the first binary sub-data corresponding to each of the first sub-data to be transmitted and the first key data respectively; the first data sequence includes a plurality of first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged; the data length of each first sub-data to be transmitted is a target data length L; the first encrypted data sequence to be transmitted includes the first encrypted sub-data corresponding to each first binary sub-data;

[0197] Performing an XOR operation on the first key data and each first encrypted sub-data to obtain corresponding first binary sub-data;

[0198] Based on the first sub-data to be transmitted corresponding to each first binary sub-data, the first data to be transmitted is acquired.

[0199] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0200] The communication interface is used for communication between the above electronic device and other devices.

[0201] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0202] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0203] The implementation methods and beneficial effects of the components of the electronic device in the above embodiments to solve the problems can be found in Figure 2 The various steps in the illustrated embodiment are implemented, therefore, the specific working process and beneficial effects of the electronic device provided by the embodiment of the present application are not repeated here.

[0204] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer executes the method for securely transmitting data described in any of the above embodiments.

[0205] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the method for secure data transmission described in any one of the above embodiments.

[0206] Those skilled in the art will appreciate that the embodiments in the present application can be provided as methods, systems, or computer program products. Therefore, the embodiments in the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments in the present application can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0207] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0208] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0209] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0210] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present application.

[0211] Obviously, those skilled in the art can make various changes and modifications to the embodiments in the present application without departing from the spirit and scope of the embodiments in the present application. Thus, if these modifications and variations of the embodiments in the present application fall within the scope of the claims and their equivalents in the embodiments of the present application, the embodiments of the present application are also intended to include these modifications and variations.

Claims

1. A method for secure data transmission, characterized in that: Applied in a first device establishing a communication connection with a second device, the method includes: Negotiation information for interactive configuration with the second device; the negotiation information includes a preset hash algorithm and a target data length of the key data; Using the hash algorithm, calculate the configured first key data to obtain a message digest of the first key data, and send the first key data and the message digest of the first key data to the second device; Receive a first encrypted data sequence to be transmitted sent by a second device; the first encrypted data sequence to be transmitted is obtained by dividing the data length L1 of the stored first data to be transmitted into a first data sequence including a plurality of first sub-data to be transmitted according to a first preset ratio after the hash value calculated by the second device for the received first key data using the hash algorithm is consistent with the message digest of the first key data, and performing an exclusive OR operation on the first binary sub-data corresponding to each of the first sub-data to be transmitted and the first key data respectively; the first data sequence includes a plurality of first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged; the data length of each first sub-data to be transmitted is the target data length; the first encrypted data sequence to be transmitted includes the first encrypted sub-data corresponding to each first binary sub-data; Performing an XOR operation on the first key data and each first encrypted sub-data to obtain corresponding first binary sub-data; Based on the first sub-data to be transmitted corresponding to each first binary sub-data, the first data to be transmitted is acquired.

2. The method according to claim 1, characterized in that The method further comprises: receiving the configured second key data and a message digest of the second key data sent by the second device, where the message digest of the second key data is obtained by the second device calculating the configured second key data by using the hash algorithm; If the hash value calculated by using the hash algorithm for the received second key data is consistent with the message digest of the second key data, the data length L2 of the second data to be transmitted is divided according to the second preset ratio to obtain a second data sequence, wherein the second data sequence includes a plurality of second sub-data to be transmitted whose data positions corresponding to the second data to be transmitted remain unchanged; and the data length of each second sub-data to be transmitted is the target data length; Performing binary conversion on each of the second sub-data to be transmitted to obtain corresponding second binary sub-data; Performing an exclusive OR operation on the second key data and each second binary sub-data respectively to obtain a second encrypted data sequence to be transmitted; the second encrypted data sequence to be transmitted includes the second encrypted sub-data corresponding to each second binary sub-data; Send the second encrypted data sequence to be transmitted to the second device.

3. The method according to claim 2, characterized in that The configuration process of the first key data includes: Perform binary conversion on the target second sub-data to be transmitted in the second data sequence and the preset random number R_A to obtain the target second binary sub-data and the second binary random number; the target second sub-data to be transmitted is any second sub-data to be transmitted in the second data sequence; the data length of the random number R_A is the target data length; An XOR operation is performed on the target second binary sub-data and the second binary random number to obtain the first key data.

4. The method according to claim 2, characterized in that The second key data is obtained by the second device performing binary conversion on the target first sub-data to be transmitted in the first data sequence and a preset random number R_B, obtaining the target first binary sub-data and the first binary random number, and then performing an XOR operation on the target first binary sub-data and the first binary random number. The target first sub-data to be transmitted is any first sub-data to be transmitted in the first data sequence; the data length of the random number R_B is the target data length.

5. The method according to claim 1, characterized in that The negotiation information also includes a preset filling rule; and the method further includes: If the data length of the last cut data obtained by splitting the data length L1 of the second data to be transmitted is not the target data length, then data padding is performed on the last cut data according to the preset padding rule to obtain the last second sub-data to be transmitted with a data length equal to the target data length, and the last second sub-data to be transmitted and the corresponding other second sub-data to be transmitted are combined to generate a second data sequence.

6. The method according to claim 5, characterized in that Acquiring the first data to be transmitted based on the first sub-data to be transmitted corresponding to each first binary sub-data includes: If the last first sub-data to be transmitted in the first data sequence is obtained by the second device using a preset filling rule, after obtaining the first sub-data to be transmitted corresponding to each first binary sub-data, de-filling the last first sub-data to be transmitted using the preset filling rule to obtain new last first sub-data to be transmitted; and splicing the new last first sub-data to be transmitted and other first sub-data to be transmitted according to data positions to obtain first data to be transmitted; If the last first sub-data to be transmitted in the first data sequence is not obtained by the second device using a preset filling rule, the first sub-data to be transmitted are spliced ​​according to the data position to obtain the first data to be transmitted.

7. The method according to claim 2, characterized in that The method further comprises: If the hash value calculated by using the hash algorithm for the received first key data is inconsistent with the message digest of the first key data, a data retransmission request is sent to the second device, and the execution step is returned: using the hash algorithm to calculate the configured first key data to obtain the message digest of the first key data.

8. A secure data transmission device, characterized in that: In a first device for establishing a communication connection with a second device, the apparatus includes: An interaction unit, configured to interact with a second device to exchange negotiation information configured therewith; the negotiation information comprising a preset hash algorithm and a target data length of the key data; a computing unit, configured to use the hash algorithm to compute the configured first key data, obtain a message digest of the first key data, and send the first key data and the message digest of the first key data to the second device; A receiving unit, used for receiving a first encrypted data sequence to be transmitted sent by a second device; the first encrypted data sequence to be transmitted is obtained by dividing the data length L1 of the stored first data to be transmitted according to a first preset ratio to obtain a first data sequence including a plurality of first sub-data to be transmitted, after the hash value calculated by the second device using the hash algorithm for the received first key data is consistent with the message digest of the first key data, and performing an exclusive OR operation on the first binary sub-data corresponding to each of the first sub-data to be transmitted and the first key data respectively; the first data sequence includes a plurality of first sub-data to be transmitted whose data positions corresponding to the first data to be transmitted remain unchanged; the data length of each first sub-data to be transmitted is a target data length; the first encrypted data sequence to be transmitted includes the first encrypted sub-data corresponding to each first binary sub-data; The calculation unit is further used to perform an XOR operation on the first key data and each first encrypted sub-data to obtain corresponding first binary sub-data; The acquisition unit is used to acquire the first data to be transmitted based on the first sub-data to be transmitted corresponding to each first binary sub-data.

9. An electronic device, characterized in that: The electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-7 when executing a program stored in a memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.