Data transmission method and data transmission device of embedded equipment

By establishing a data encryption transmission session in the embedded device, and using elliptic curve and key agreement algorithm to generate the session key, the security and stability issues of data transmission in the embedded device are solved, and the confidentiality and integrity of the data are guaranteed.

CN118869201AInactive Publication Date: 2024-10-29CHINA ELECTRONICS CORP 6TH RES INST
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410908452.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-10-29
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Embedded devices have security and stability risks during unprotected data transmission. The plain text direct transmission method cannot guarantee the confidentiality and integrity of data, especially in the face of malicious network attacks.

Method used

By establishing a data encryption transmission session between the embedded device and the target transmission device, the session key is generated based on the elliptic curve and key agreement algorithm, and the symmetric encryption algorithm is used for encryption and decryption to ensure the security and stability of data transmission. .

Benefits of technology

It improves the security and stability of data transmission of embedded devices, ensures the confidentiality and integrity of transmitted data, and prevents data theft, tampering and damage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118869201A_ABST
    Figure CN118869201A_ABST
Patent Text Reader

Abstract

The invention provides a data transmission method and a data transmission device for embedded equipment, and the data transmission method comprises the steps: responding to the establishment of a data transmission session which indicates to carry out data encryption transmission between the embedded equipment and target transmission equipment; obtaining first target data sent by the target transmission device through the wireless link and used for the embedded device to process the target task; in response to the received first target data, generating a corresponding session key of the embedded device in the data transmission session by using a preset key negotiation algorithm based on an elliptic curve key pair generated by the embedded device; and based on the session key, sequentially performing encryption processing and decryption processing on the first target data by using a preset symmetric encryption algorithm to obtain second target data used when the embedded device processes the target task. Through the method, the security and the stability of data transmission of the embedded equipment are improved, and the confidentiality and the integrity of the transmitted data are further ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Since some embedded devices are responsible for tasks of high importance, there are risks to the security and stability of data transmission during unprotected data transmission of embedded devices. In addition, during unprotected data transmission, data can be easily read by anyone who intercepts the information, and the confidentiality of the data cannot be guaranteed.

[0003] At present, wireless data transmission for embedded devices generally adopts the plain text direct transmission method. Plain text transmission has the risk of data being stolen, tampered with or damaged during the transmission process. Attackers can easily modify the content of the transmission, which reduces the security and stability of embedded device data transmission when transmitting sensitive or important data. In addition, against malicious network attacks, the plain text direct transmission method cannot guarantee the confidentiality and integrity of the data. Summary of the invention

[0004] In view of this, the purpose of the present application is to provide a data transmission method and a data transmission device for an embedded device, by establishing a data transmission session for data encryption transmission between the embedded device and the target transmission device, for the target data transmitted through the wireless link, a session key corresponding to the data transmission session is generated based on the elliptic curve and using a key agreement algorithm, and then the session key and a symmetric encryption algorithm are used for encryption and decryption to obtain the target data used by the embedded device when processing the target task, thereby improving the security and stability of the data transmission of the embedded device, and further ensuring the confidentiality and integrity of the transmitted data.

[0005] The present invention provides a data transmission method for an embedded device, the data transmission method comprising:

[0006] In response to the establishment of a data transmission session instructing the embedded device to perform encrypted data transmission with the target transmission device, obtaining first target data for the embedded device to process a target task sent by the target transmission device via a wireless link;

[0007] In response to receiving the first target data, based on the elliptic curve key pair generated by the embedded device, using a preset key agreement algorithm, a session key corresponding to the embedded device in the data transmission session is generated;

[0008] Based on the session key, the first target data is encrypted and decrypted in sequence using a preset symmetric encryption algorithm to obtain second target data used by the embedded device when processing the target task.

[0009] Furthermore, the elliptic curve key pair generated based on the embedded device uses a preset key agreement algorithm to generate a session key corresponding to the embedded device in the data transmission session, including:

[0010] Based on a preset elliptic curve, an elliptic curve key pair corresponding to the embedded device is generated using a preset digital signature algorithm;

[0011] Based on the elliptic curve key pair, generating a session shared key corresponding to the data transmission session by exchanging keys with a target transmission device;

[0012] Based on the session shared key, a session key corresponding to the embedded device in the data transmission session is generated.

[0013] Further, the generating a session shared key corresponding to the data transmission session by exchanging keys with a target transmission device based on the elliptic curve key pair includes:

[0014] Exchanging a first curve public key included in the elliptic curve key pair with a corresponding second curve public key in the target transmission device to obtain the second curve public key;

[0015] A session shared key corresponding to the data transmission session is generated based on the second curve public key and the first curve private key included in the elliptic curve key pair.

[0016] Further, the generating, based on the session shared key, a session key corresponding to the embedded device in the data transmission session includes:

[0017] Generate a random string corresponding to the embedded device, and concatenate the random string with an initial vector corresponding to the embedded device to obtain a first concatenated key;

[0018] Encrypting the first splicing key using the session shared key to obtain a first encrypted splicing key;

[0019] Exchanging the first encrypted splicing key with the corresponding second encrypted splicing key in the target transmission device to obtain the second encrypted splicing key;

[0020] Decrypting the second encrypted splicing key using the session shared key to obtain a decrypted splicing key;

[0021] Based on the first splicing key and the decryption splicing key, a session key corresponding to the embedded device in the data transmission session is generated by means of an exclusive OR operation.

[0022] Further, based on the session key, the first target data is encrypted and decrypted in sequence using a preset symmetric encryption algorithm to obtain second target data used by the embedded device when processing the target task, including:

[0023] Generate an initial encryption vector and an initial decryption vector corresponding to a preset symmetric encryption algorithm;

[0024] Based on the session key and the initial encryption vector, encrypting the first target data using an encryption function in the symmetric encryption algorithm to obtain first encrypted target data;

[0025] Based on the session key and the initial decryption vector, the first encrypted target data is decrypted using a decryption function in the symmetric encryption algorithm to obtain second target data used by the embedded device when processing a target task.

[0026] Further, the encrypting the first target data based on the session key and the initial encryption vector using an encryption function in the symmetric encryption algorithm to obtain the first encrypted target data includes:

[0027] Based on the session key, generating an initialization encryption key corresponding to the encryption function in the symmetric encryption algorithm;

[0028] According to the first memory space corresponding to the initial encryption vector, a first temporary buffer area corresponding to the encryption function having a size consistent with the first memory space is divided in the memory of the embedded device;

[0029] Based on the initialization encryption key, the first target data is encrypted using the encryption function in the first temporary buffer area to obtain first encrypted target data.

[0030] Further, the decryption function in the symmetric encryption algorithm is used to decrypt the first encrypted target data based on the session key and the initial decryption vector to obtain the second target data used by the embedded device, including:

[0031] Based on the session key, generating an initialization decryption key corresponding to a decryption function in the symmetric encryption algorithm;

[0032] According to the second memory space corresponding to the initial decryption vector, a second temporary buffer area corresponding to the decryption function having a size consistent with the second memory space is divided in the memory of the embedded device;

[0033] Based on the initialization decryption key, the first encrypted target data is decrypted using the decryption function in the second temporary buffer area to obtain second target data used by the embedded device when processing the target task.

[0034] The present application also provides a data transmission device for an embedded device, the data transmission device comprising:

[0035] A data acquisition module, configured to, in response to the establishment of a data transmission session instructing the embedded device to perform encrypted data transmission between the embedded device and the target transmission device, acquire first target data sent by the target transmission device via a wireless link for the embedded device to process a target task;

[0036] A key generation module, configured to generate, in response to receiving the first target data, a session key corresponding to the embedded device in the data transmission session based on an elliptic curve key pair generated by the embedded device and using a preset key agreement algorithm;

[0037] The data processing module is used to encrypt and decrypt the first target data in sequence based on the session key using a preset symmetric encryption algorithm to obtain second target data used by the embedded device when processing the target task.

[0038] Further, when the key generation module is used to generate a session key corresponding to the embedded device in the data transmission session based on the elliptic curve key pair generated by the embedded device and using a preset key agreement algorithm, the key generation module is used to:

[0039] Based on a preset elliptic curve, an elliptic curve key pair corresponding to the embedded device is generated using a preset digital signature algorithm;

[0040] Based on the elliptic curve key pair, generating a session shared key corresponding to the data transmission session by exchanging keys with a target transmission device;

[0041] Based on the session shared key, a session key corresponding to the embedded device in the data transmission session is generated.

[0042] Further, when the key generation module is used to generate a session shared key corresponding to the data transmission session by exchanging keys with the target transmission device based on the elliptic curve key pair, the key generation module is used to:

[0043] Exchanging a first curve public key included in the elliptic curve key pair with a corresponding second curve public key in the target transmission device to obtain the second curve public key;

[0044] A session shared key corresponding to the data transmission session is generated based on the second curve public key and the first curve private key included in the elliptic curve key pair.

[0045] Further, when the key generation module is used to generate a session key corresponding to the embedded device in the data transmission session based on the session shared key, the key generation module is used to:

[0046] Generate a random string corresponding to the embedded device, and concatenate the random string with an initial vector corresponding to the embedded device to obtain a first concatenated key;

[0047] Encrypting the first splicing key using the session shared key to obtain a first encrypted splicing key;

[0048] Exchanging the first encrypted splicing key with the corresponding second encrypted splicing key in the target transmission device to obtain the second encrypted splicing key;

[0049] Decrypting the second encrypted splicing key using the session shared key to obtain a decrypted splicing key;

[0050] Based on the first splicing key and the decryption splicing key, a session key corresponding to the embedded device in the data transmission session is generated by means of an exclusive OR operation.

[0051] Further, when the data processing module is used to sequentially encrypt and decrypt the first target data using a preset symmetric encryption algorithm based on the session key to obtain the second target data used by the embedded device when processing the target task, the data processing module is used to:

[0052] Generate an initial encryption vector and an initial decryption vector corresponding to a preset symmetric encryption algorithm;

[0053] Based on the session key and the initial encryption vector, encrypting the first target data using an encryption function in the symmetric encryption algorithm to obtain first encrypted target data;

[0054] Based on the session key and the initial decryption vector, the first encrypted target data is decrypted using a decryption function in the symmetric encryption algorithm to obtain second target data used by the embedded device when processing a target task.

[0055] Further, when the data processing module is used to encrypt the first target data based on the session key and the initial encryption vector using the encryption function in the symmetric encryption algorithm to obtain the first encrypted target data, the data processing module is used to:

[0056] Based on the session key, generating an initialization encryption key corresponding to the encryption function in the symmetric encryption algorithm;

[0057] According to the first memory space corresponding to the initial encryption vector, a first temporary buffer area corresponding to the encryption function having a size consistent with the first memory space is divided in the memory of the embedded device;

[0058] Based on the initialization encryption key, the first target data is encrypted using the encryption function in the first temporary buffer area to obtain first encrypted target data.

[0059] Further, when the data processing module is used to decrypt the first encrypted target data based on the session key and the initial decryption vector using the decryption function in the symmetric encryption algorithm to obtain the second target data used by the embedded device, the data processing module is used to:

[0060] Based on the session key, generating an initialization decryption key corresponding to a decryption function in the symmetric encryption algorithm;

[0061] According to the second memory space corresponding to the initial decryption vector, a second temporary buffer area corresponding to the decryption function having a size consistent with the second memory space is divided in the memory of the embedded device;

[0062] Based on the initialization decryption key, the first encrypted target data is decrypted using the decryption function in the second temporary buffer area to obtain second target data used by the embedded device when processing the target task.

[0063] An embodiment of the present application also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of the data transmission method of the embedded device as described above are performed.

[0064] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the data transmission method of the embedded device as described above are executed.

[0065] The embodiment of the present application provides a data transmission method and a data transmission device for an embedded device, and the data transmission method includes: in response to the establishment of a data transmission session indicating data encryption transmission between the embedded device and the target transmission device, obtaining first target data sent by the target transmission device through a wireless link for the embedded device to process a target task; in response to receiving the first target data, based on an elliptic curve key pair generated by the embedded device, using a preset key negotiation algorithm, generating a session key corresponding to the embedded device in the data transmission session; based on the session key, using a preset symmetric encryption algorithm to sequentially encrypt and decrypt the first target data to obtain second target data used by the embedded device when processing the target task.

[0066] Compared with the method of wireless data transmission for embedded devices using plain text direct transmission in the prior art, a data transmission session for encrypted data transmission is established between the embedded device and the target transmission device. For the target data transmitted through the wireless link, a session key corresponding to the data transmission session is generated based on the elliptic curve and using the key negotiation algorithm. The session key and the symmetric encryption algorithm are then used for encryption and decryption to obtain the target data used by the embedded device when processing the target task, thereby improving the security and stability of data transmission of the embedded device, and further ensuring the confidentiality and integrity of the transmitted data.

[0067] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments 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.

[0069] Figure 1 A flowchart of a data transmission method for an embedded device provided in an embodiment of the present application;

[0070] Figure 2 A schematic diagram of the structure of a data transmission device for an embedded device provided in an embodiment of the present application;

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

[0072] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work belongs to the scope of protection of the present application.

[0073] Research has found that in the process of unprotected data transmission to embedded devices, there are risks to the security and stability of data transmission; in addition, in the process of unprotected data transmission, data can be easily read by anyone who intercepts the information, and the confidentiality of the data cannot be guaranteed; wireless data transmission to embedded devices generally adopts the method of direct plaintext transmission, which has the risk of data being stolen, tampered with or damaged during transmission. Attackers can easily modify the content of the transmission, which reduces the security and stability of embedded device data transmission when transmitting sensitive or important data; in addition, against malicious network attacks, the direct plaintext transmission method cannot guarantee the confidentiality and integrity of data.

[0074] Based on this, an embodiment of the present application provides a data transmission method for an embedded device, which establishes a data transmission session for encrypted data transmission between the embedded device and the target transmission device. For the target data transmitted through the wireless link, a session key corresponding to the data transmission session is generated based on an elliptic curve and using a key negotiation algorithm. The session key and a symmetric encryption algorithm are then used for encryption and decryption to obtain the target data used by the embedded device when processing the target task, thereby improving the security and stability of data transmission of the embedded device, and thereby ensuring the confidentiality and integrity of the transmitted data.

[0075] See also Figure 1 , Figure 1 This is a flow chart of a data transmission method for an embedded device provided in an embodiment of the present application. Figure 1 As shown in , the data transmission method of the embedded device provided by the embodiment of the present application includes:

[0076] S101, in response to the establishment of a data transmission session instructing an embedded device to perform encrypted data transmission with a target transmission device, obtaining first target data sent by the target transmission device via a wireless link for the embedded device to process a target task.

[0077] It should be noted that the embedded device is equipped with multiple modules, including a WIFI module, a configuration database, a protocol interaction module, an upgrade guidance unit, a wireless upgrade module, a storage unit and a dynamic monitoring unit, etc.; among them, the embedded device is installed with multiple software, and the embedded device can process target tasks according to the transmitted target data.

[0078] In one possible implementation mode of the present application, the target transmission device is a device used to transmit data to an embedded device, such as a tablet computer, a mobile phone, a host and other devices; before the target transmission device and the embedded device establish a data transmission session, the embedded device and the target transmission device must establish a wireless connection to form a wireless link; wherein the wireless connection includes but is not limited to a WIFI connection and a Bluetooth connection.

[0079] In this step, during the specific implementation, first, in response to the embedded device's processing of the target task, a data transmission session for encrypted data transmission is established between the embedded device and the target transmission device; then, in response to the establishment of the data transmission session, a target transmission device including the first target data is determined from a plurality of transmission devices according to the target task; finally, the first target data sent by the target transmission device via a wireless link for the embedded device to process the target task is obtained.

[0080] The first target data corresponds to the target task and the target transmission device respectively, and the first target data may include any data content used for the embedded device to process the target task, such as upgrade files, log files, maintenance files, and repair scripts.

[0081] S102: In response to receiving the first target data, based on the elliptic curve key pair generated by the embedded device, a session key corresponding to the embedded device in the data transmission session is generated using a preset key agreement algorithm.

[0082] In this step, during the specific implementation, first, in response to receiving the first target data, based on the preset elliptic curve, an elliptic curve key pair corresponding to the embedded device is generated using a preset digital signature algorithm; then, based on the elliptic curve key pair, a session shared key corresponding to the data transmission session is generated by exchanging keys with the target transmission device; finally, based on the session shared key, a session key corresponding to the embedded device in the data transmission session is generated.

[0083] In one implementation of the present application, during specific implementation, step S102 may include:

[0084] S1021. Based on a preset elliptic curve, generate an elliptic curve key pair corresponding to the embedded device using a preset digital signature algorithm.

[0085] In one possible implementation mode of the present application, the preset elliptic curve is the secp256k1 elliptic curve, but is not limited to the secp256k1 elliptic curve, and may be other elliptic curves, which is not further limited in the present application.

[0086] In this step, based on the preset elliptic curve, the embedded device first uses a preset digital signature algorithm to determine the first curve private key in the elliptic curve key pair; then, based on the first curve private key, the first curve public key in the elliptic curve key pair is determined; finally, based on the first curve private key and the first curve public key, the elliptic curve key pair corresponding to the embedded device is determined.

[0087] The preset digital signature algorithm is an ECDSA algorithm, that is, the elliptic curve key pair is an ECDSA key pair.

[0088] Specifically, by defining the "generate_keypair" function, the generation of the elliptic curve key pair is realized; then the statement "sk=SigningKey.generate(curve=SECP256k1)" is used to generate the first curve private key "sk"; after that, based on the first curve private key "sk", the statement "vk=sk.get_verifying_key()" is used to generate the first curve public key "vk", and "(sk, vk)" is determined as the elliptic curve key pair corresponding to the embedded device.

[0089] Furthermore, while the embedded device generates the corresponding elliptic curve key, the target transmission device also generates an elliptic curve key pair corresponding to the target transmission device based on the elliptic curve using the digital signature algorithm; wherein the elliptic curve key pair corresponding to the target transmission device includes a second curve public key and a second curve private key.

[0090] S1022: Generate a session shared key corresponding to the data transmission session by exchanging keys with a target transmission device based on the elliptic curve key pair.

[0091] In this step, the embedded device and the target transmission device exchange the curve public keys in the elliptic curve key pairs generated by each of them, that is, the first curve public key and the second curve public key are exchanged, and the embedded device obtains the second curve public key of the target transmission device.

[0092] In one implementation of the present application, during specific implementation, step S1022 may include:

[0093] S10221. Exchange a first curve public key included in the elliptic curve key pair with a corresponding second curve public key in a target transmission device to obtain the second curve public key.

[0094] In this step, in order to calculate the session shared key corresponding to the data transmission session, the embedded device must exchange the first curve public key included in the elliptic curve key pair corresponding to the embedded device with the corresponding second curve public key in the target transmission device; then, the embedded device obtains the second curve public key.

[0095] Specifically, before calculating the session shared key, the first curve public key and the second curve public key are exchanged before generating the session shared key through the statement “shared_key_a=compute_shared_key(sk_a,vk_b)”.

[0096] S10222. Generate a session shared key corresponding to the data transmission session based on the second curve public key and the first curve private key included in the elliptic curve key pair.

[0097] In this step, the session shared key corresponding to the data transmission session is generated by calling a preset session shared key function on the second curve public key obtained by exchanging and the first curve private key generated by itself.

[0098] Specifically, the session shared key corresponding to the data transmission session is calculated by defining "compute_shared_key(sk,vk)", and includes the second curve public key "vk" obtained by the exchange and the first curve private key "sk" generated by itself; the session shared key is calculated by the statement "shared_key=sk.privkey.secret_multiplier*vk.pubkey.point"; and the session shared key "shared_key_a or shared_key_b" is generated by the statement "return hashlib.sha256(int.to_bytes(shared_key.x(),32,'big')).digest()".

[0099] S1023: Based on the session shared key, generate a session key corresponding to the embedded device in the data transmission session.

[0100] In this step, during the specific implementation, first, the generated random string is concatenated with the initial vector corresponding to the embedded device to obtain a first concatenated key; then, the first encrypted concatenated key obtained by encrypting the first concatenated key using the session shared key is exchanged with the corresponding second encrypted concatenated key in the target transmission device to obtain the second encrypted concatenated key; finally, based on the decrypted concatenated key obtained by decrypting the second encrypted concatenated key using the session shared key and the first encrypted concatenated key, a session key corresponding to the embedded device in the data transmission session is generated by an XOR operation.

[0101] In one implementation of the present application, during specific implementation, step S1023 may include:

[0102] S10231. Generate a random string corresponding to the embedded device, and concatenate the random string with an initial vector corresponding to the embedded device to obtain a first concatenation key.

[0103] In this step, when it is specifically implemented, first, a set of random strings corresponding to the embedded device is generated; then, an initial vector corresponding to the embedded device is determined; finally, the random string is concatenated with the initial vector to obtain a first concatenated key corresponding to the embedded device.

[0104] In one possible implementation of the present application, the size of the random string is 16 bytes; the initial vector is a 16-byte "0x00" vector, that is, the length of the obtained first concatenated key is 32 bytes.

[0105] Specifically, a set of 16-byte random character string "random_data_a" is generated through the statement "random_data_a=os.urandom(16)"; then, the initial vector "iv" corresponding to the embedded device is determined through the statement "iv=b'\x00'*16"; finally, the first splicing key "data_a" is obtained through the statement "data_a=random_data_a+iv".

[0106] Furthermore, the target transmission device also generates a set of random character strings corresponding to the target transmission device, and concatenates the random character strings with the initial vector corresponding to the target transmission device, thereby obtaining a second concatenated key in the target transmission device corresponding to the first concatenated key.

[0107] S10232: Use the session shared key to encrypt the first splicing key to obtain a first encrypted splicing key.

[0108] In this step, the session shared key is used to encrypt the first concatenated key corresponding to the embedded device obtained by concatenating the random character string and the initial vector, so as to obtain the first encrypted concatenated key corresponding to the embedded device.

[0109] Specifically, based on the session shared key "shared_key_a" and the first concatenated key "data_a", the first encrypted concatenated key "encrypted_data_a" corresponding to the embedded device is obtained through the statement "encrypted_data_a=xor_encrypt_decrypt(data_a, shared_key_a)".

[0110] Furthermore, the target transmission device also encrypts the second splicing key using the session shared key to obtain a second encrypted splicing key.

[0111] S10233. Exchange the first encrypted splicing key with the corresponding second encrypted splicing key in the target transmission device to obtain the second encrypted splicing key.

[0112] In this step, the embedded device exchanges the first encrypted splicing key obtained by itself with the corresponding second encrypted splicing key in the target transmission device to obtain the second encrypted splicing key corresponding to the target transmission device.

[0113] S10234. Decrypt the second encrypted splicing key using the session shared key to obtain a decrypted splicing key.

[0114] In this step, the embedded device uses the session shared key to decrypt the second encrypted splicing key through a decryption method of an XOR operation to obtain a decrypted splicing key corresponding to the embedded device.

[0115] Specifically, the embedded device obtains the decrypted splicing key "decrypted_data_a" corresponding to the embedded device through the statement "decrypted_data_a=xor_encrypt_decrypt(encrypted_data_b, shared_key_a)" based on the session shared key "shared_key_a" and the second encrypted splicing key "encrypted_data_b".

[0116] S10235: Based on the first splicing key and the decryption splicing key, generate a session key corresponding to the embedded device in the data transmission session by means of an exclusive OR operation.

[0117] In this step, an XOR operation is performed on the first splicing key and the decryption splicing key to generate a session key corresponding to the embedded device in the data transmission session, which is used for subsequent data processing of encryption and decryption of the first target data.

[0118] In one possible implementation of the present application, the first splicing key and the decrypted splicing key obtained after decryption are both 32 bytes, that is, the corresponding session key of the embedded device in the data transmission session generated by the XOR operation is 32 bytes.

[0119] Specifically, based on the first splicing key "data_a" and the decrypted splicing key "decrypted_data_a" of the embedded device, an XOR operation is performed through the statement "final_key_a=bytes([a^b for a,b in zip(data_a,decrypted_data_a)])" to generate the session key "final_key_a" corresponding to the embedded device in the data transmission session.

[0120] In this way, through the above key negotiation algorithm, the embedded device and the target transmission device generate a consistent session key in the data transmission session through negotiation.

[0121] S103: Based on the session key, encrypt and decrypt the first target data in sequence using a preset symmetric encryption algorithm to obtain second target data used by the embedded device when processing the target task.

[0122] In this step, during the specific implementation, first, an initial encryption vector and an initial decryption vector corresponding to a preset symmetric encryption algorithm are generated respectively; then, based on the session key and the initial encryption vector, the first target data is encrypted using an encryption function in the symmetric encryption algorithm to obtain first encrypted target data; finally, based on the session key and the initial decryption vector, the first encrypted target data is decrypted using a decryption function in the symmetric encryption algorithm to obtain second target data used by the embedded device when processing a target task.

[0123] In one implementation of the present application, during specific implementation, step S103 may include:

[0124] S1031. Generate an initial encryption vector and an initial decryption vector corresponding to a preset symmetric encryption algorithm.

[0125] It should be noted that, in one possible implementation of the present application, the preset symmetric encryption algorithm is an AES-128 encryption algorithm; wherein, the encryption mode used by the AES-128 encryption algorithm is the ciphertext block chaining mode (CBC mode).

[0126] In this step, an initial vector corresponding to the symmetric encryption algorithm is generated according to the ciphertext group linking mode used in the preset symmetric encryption algorithm.

[0127] Here, the initial vector has different vector labels in the encryption function and the decryption function in the symmetric encryption algorithm. Specifically, the initial vector in the encryption function is the initial encryption vector; and the initial vector in the decryption function is the initial decryption vector.

[0128] S1032. Based on the session key and the initial encryption vector, encrypt the first target data using an encryption function in the symmetric encryption algorithm to obtain first encrypted target data.

[0129] In this step, during the specific implementation, first, based on the generated session key, an initialization encryption key corresponding to the encryption function in the symmetric encryption algorithm is generated; then, a first temporary cache area corresponding to the encryption function having a size consistent with the first memory space corresponding to the initial encryption vector is divided out in the memory of the embedded device; finally, based on the initialization encryption key, in the first temporary cache area, the first target data is encrypted using the encryption function to obtain the first encrypted target data.

[0130] In one implementation of the present application, during specific implementation, step S1032 may include:

[0131] S10311. Based on the session key, generate an initialization encryption key corresponding to the encryption function in the symmetric encryption algorithm.

[0132] In this step, key encryption is performed by a preset AES encryptor. After the AES encryptor is initialized, an initialization encryption key corresponding to an encryption function in a symmetric encryption algorithm is generated by the AES encryptor based on the session key.

[0133] Specifically, the initialization encryption key "aes_key" is generated through the statement "AES_KEY aes_key; AES_set_encrypt_key(key,128,&aes_key)", wherein the key length of the initialization encryption key "aes_key" is 128 bits.

[0134] S10312. According to the first memory space corresponding to the initial encryption vector, a first temporary cache area corresponding to the encryption function having a size consistent with the first memory space is divided in the memory of the embedded device.

[0135] In this step, after determining the first memory space corresponding to the initial encryption vector, a first temporary cache area corresponding to the encryption function and having the same size as the first memory space is divided in the memory of the embedded device according to the first memory space; and then the initial encryption vector is copied to the first temporary cache area.

[0136] Specifically, through the statement "unsigned char*temp=malloc(AES_BLOCK_SIZE)", a first temporary buffer area with the same size as the first memory space is allocated in the memory of the embedded device; then, through the statement "memcpy(temp,iv,AES_BLOCK_SIZE)", the initial encryption vector is copied to the first temporary buffer area.

[0137] S10313. Based on the initialized encryption key, encrypt the first target data using the encryption function in the first temporary buffer area to obtain first encrypted target data.

[0138] In this step, based on the initialization encryption key and the first target data, the first target data is encrypted by a function encryption operation of an encryption function in a first temporary buffer area to obtain first encrypted target data.

[0139] Specifically, the encryption operation of the encryption function is as follows: "AES_cbc_encrypt(plaintext,ciphertext,strlen(plaintext)+AES_BLOCK_SIZE,&aes_key,temp,AES_ENCRYPT)"; then, the encryption function call is performed on the initialized encryption key and the first target data as function variables through the statement "encrypt_data(plaintext,key,iv,ciphertext)"; finally, the first encrypted target data "ciphertext" is obtained through the statement "printf("Encrypted:%s\n",ciphertext)"; wherein the data size space of the first encrypted target data "ciphertext" is set to 1024 bytes so that the encrypted data can be accommodated in a data space large enough.

[0140] S1033. Based on the session key and the initial decryption vector, the first encrypted target data is decrypted using a decryption function in the symmetric encryption algorithm to obtain second target data used by the embedded device when processing a target task.

[0141] In this step, when it is implemented specifically, first, based on the generated session key, an initialization decryption key corresponding to the decryption function in the symmetric encryption algorithm is generated; then, a second temporary cache area corresponding to the decryption function with the same size as the second memory space corresponding to the initial decryption vector is divided in the memory of the embedded device; finally, based on the initialization decryption key, in the second temporary cache area, the first encrypted target data is decrypted using the decryption function to obtain the second target data used by the embedded device when processing the target task.

[0142] In one implementation of the present application, during specific implementation, step S1033 may include:

[0143] S10331. Based on the session key, generate an initialization decryption key corresponding to the decryption function in the symmetric encryption algorithm.

[0144] In this step, the key is decrypted by a preset AES decryptor. After the AES decryptor is initialized, an initialization decryption key corresponding to the decryption function in the symmetric encryption algorithm is generated by the AES decryptor based on the session key.

[0145] S10332. According to the second memory space corresponding to the initial decryption vector, a second temporary cache area corresponding to the decryption function having a size consistent with the second memory space is divided in the memory of the embedded device.

[0146] In this step, after determining the second memory space corresponding to the initial decryption vector, a second temporary cache area corresponding to the decryption function and having the same size as the second memory space is divided in the memory of the embedded device according to the second memory space; and then the initial encryption vector is copied to the second temporary cache area.

[0147] S10333. Based on the initialization decryption key, decrypt the first encrypted target data using the decryption function in the second temporary buffer area to obtain second target data used by the embedded device when processing the target task.

[0148] In this step, based on the initialization encryption key and the first encrypted target data, the first encrypted target data is decrypted in the second temporary cache through the function decryption operation of the decryption function to obtain the second target data used by the embedded device when processing the target task.

[0149] Specifically, the decryption operation of the decryption function is as follows: "AES_cbc_encrypt(ciphertext,plaintext,strlen(ciphertext)+AES_BLOCK_SIZE,&aes_key,temp,AES_DECRYPT)"; then, the decryption function call is performed on the initialization encryption key and the first encrypted target data as function variables through the statement "decrypt_data(ciphertext,key,iv,plaintext)"; finally, the second target data "plaintext" is obtained through the statement "printf("Decrypted:%s\n",plaintext)" to provide it to the embedded device for use when processing the target task.

[0150] The data transmission method for an embedded device provided in an embodiment of the present application establishes a data transmission session for encrypted data transmission between the embedded device and the target transmission device. For the target data transmitted through the wireless link, a session key corresponding to the data transmission session is generated based on an elliptic curve and using a key negotiation algorithm. The session key and a symmetric encryption algorithm are then used for encryption and decryption to obtain the target data used by the embedded device when processing the target task, thereby improving the security and stability of the data transmission of the embedded device, and further ensuring the confidentiality and integrity of the transmitted data.

[0151] See also Figure 2 , Figure 2 This is a schematic diagram of the structure of a data transmission device for an embedded device provided in an embodiment of the present application. Figure 2 As shown in , the data transmission device 200 includes:

[0152] The data acquisition module 210 is used to acquire first target data for the embedded device to process a target task sent by the target transmission device through a wireless link in response to the establishment of a data transmission session indicating data encryption transmission between the embedded device and the target transmission device;

[0153] A key generation module 220, configured to generate, in response to receiving the first target data, a session key corresponding to the embedded device in the data transmission session based on an elliptic curve key pair generated by the embedded device and using a preset key agreement algorithm;

[0154] The data processing module 230 is used to encrypt and decrypt the first target data in sequence based on the session key using a preset symmetric encryption algorithm to obtain second target data used by the embedded device when processing the target task.

[0155] Further, when the key generation module 220 is used to generate a session key corresponding to the embedded device in the data transmission session based on the elliptic curve key pair generated by the embedded device and using a preset key agreement algorithm, the key generation module 220 is used to:

[0156] Based on a preset elliptic curve, an elliptic curve key pair corresponding to the embedded device is generated using a preset digital signature algorithm;

[0157] Based on the elliptic curve key pair, generating a session shared key corresponding to the data transmission session by exchanging keys with a target transmission device;

[0158] Based on the session shared key, a session key corresponding to the embedded device in the data transmission session is generated.

[0159] Further, when the key generation module 220 is used to generate a session shared key corresponding to the data transmission session by exchanging keys with the target transmission device based on the elliptic curve key pair, the key generation module 220 is used to:

[0160] Exchanging a first curve public key included in the elliptic curve key pair with a corresponding second curve public key in the target transmission device to obtain the second curve public key;

[0161] A session shared key corresponding to the data transmission session is generated based on the second curve public key and the first curve private key included in the elliptic curve key pair.

[0162] Further, when the key generation module 220 is used to generate a session key corresponding to the embedded device in the data transmission session based on the session shared key, the key generation module 220 is used to:

[0163] Generate a random string corresponding to the embedded device, and concatenate the random string with an initial vector corresponding to the embedded device to obtain a first concatenated key;

[0164] Encrypting the first splicing key using the session shared key to obtain a first encrypted splicing key;

[0165] Exchanging the first encrypted splicing key with the corresponding second encrypted splicing key in the target transmission device to obtain the second encrypted splicing key;

[0166] Decrypting the second encrypted splicing key using the session shared key to obtain a decrypted splicing key;

[0167] Based on the first splicing key and the decryption splicing key, a session key corresponding to the embedded device in the data transmission session is generated by means of an exclusive OR operation.

[0168] Further, when the data processing module 230 is used to sequentially encrypt and decrypt the first target data using a preset symmetric encryption algorithm based on the session key to obtain the second target data used by the embedded device when processing the target task, the data processing module 230 is used to:

[0169] Generate an initial encryption vector and an initial decryption vector corresponding to a preset symmetric encryption algorithm;

[0170] Based on the session key and the initial encryption vector, encrypting the first target data using an encryption function in the symmetric encryption algorithm to obtain first encrypted target data;

[0171] Based on the session key and the initial decryption vector, the first encrypted target data is decrypted using a decryption function in the symmetric encryption algorithm to obtain second target data used by the embedded device when processing a target task.

[0172] Further, when the data processing module 230 is used to encrypt the first target data based on the session key and the initial encryption vector using the encryption function in the symmetric encryption algorithm to obtain the first encrypted target data, the data processing module 230 is used to:

[0173] Based on the session key, generating an initialization encryption key corresponding to the encryption function in the symmetric encryption algorithm;

[0174] According to the first memory space corresponding to the initial encryption vector, a first temporary buffer area corresponding to the encryption function having a size consistent with the first memory space is divided in the memory of the embedded device;

[0175] Based on the initialization encryption key, the first target data is encrypted using the encryption function in the first temporary buffer area to obtain first encrypted target data.

[0176] Further, when the data processing module 230 is used to decrypt the first encrypted target data based on the session key and the initial decryption vector using the decryption function in the symmetric encryption algorithm to obtain the second target data used by the embedded device, the data processing module 230 is used to:

[0177] Based on the session key, generating an initialization decryption key corresponding to a decryption function in the symmetric encryption algorithm;

[0178] According to the second memory space corresponding to the initial decryption vector, a second temporary buffer area corresponding to the decryption function having a size consistent with the second memory space is divided in the memory of the embedded device;

[0179] Based on the initialization decryption key, the first encrypted target data is decrypted using the decryption function in the second temporary buffer area to obtain second target data used by the embedded device when processing the target task.

[0180] The data transmission device for an embedded device provided in an embodiment of the present application establishes a data transmission session for encrypted data transmission between the embedded device and a target transmission device, generates a session key corresponding to the data transmission session based on an elliptic curve and using a key agreement algorithm for target data transmitted via a wireless link, and then uses the session key and a symmetric encryption algorithm to perform encryption and decryption processing to obtain the target data used by the embedded device when processing the target task, thereby improving the security and stability of data transmission of the embedded device, and further ensuring the confidentiality and integrity of the transmitted data.

[0181] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 3 As shown in , the electronic device 300 includes a processor 310 , a memory 320 and a bus 330 .

[0182] The memory 320 stores machine-readable instructions executable by the processor 310. When the electronic device 300 is running, the processor 310 communicates with the memory 320 via the bus 330. When the machine-readable instructions are executed by the processor 310, the above-mentioned Figure 1 The steps of the data transmission method for the embedded device in the method embodiment shown in the figure, and the specific implementation manner can be referred to the method embodiment, which will not be repeated here.

[0183] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 The steps of the data transmission method for the embedded device in the method embodiment shown in the figure, and the specific implementation manner can be referred to the method embodiment, which will not be described in detail here.

[0184] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0185] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0186] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0187] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0188] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0189] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A data transmission method for an embedded device, characterized in that: The data transmission method comprises: In response to the establishment of a data transmission session instructing the embedded device to perform encrypted data transmission with the target transmission device, obtaining first target data for the embedded device to process a target task sent by the target transmission device via a wireless link; In response to receiving the first target data, based on the elliptic curve key pair generated by the embedded device, using a preset key agreement algorithm, a session key corresponding to the embedded device in the data transmission session is generated; Based on the session key, the first target data is encrypted and decrypted in sequence using a preset symmetric encryption algorithm to obtain second target data used by the embedded device when processing the target task.

2. The method according to claim 1, characterized in that The method of generating a session key corresponding to the embedded device in the data transmission session based on the elliptic curve key pair generated by the embedded device using a preset key agreement algorithm includes: Based on a preset elliptic curve, an elliptic curve key pair corresponding to the embedded device is generated using a preset digital signature algorithm; Based on the elliptic curve key pair, generating a session shared key corresponding to the data transmission session by exchanging keys with a target transmission device; Based on the session shared key, a session key corresponding to the embedded device in the data transmission session is generated.

3. The method according to claim 2, characterized in that The generating a session shared key corresponding to the data transmission session by exchanging keys with a target transmission device based on the elliptic curve key pair includes: Exchanging a first curve public key included in the elliptic curve key pair with a corresponding second curve public key in the target transmission device to obtain the second curve public key; A session shared key corresponding to the data transmission session is generated based on the second curve public key and the first curve private key included in the elliptic curve key pair.

4. The method according to claim 3, characterized in that The step of generating a session key corresponding to the embedded device in the data transmission session based on the session shared key includes: Generate a random string corresponding to the embedded device, and concatenate the random string with an initial vector corresponding to the embedded device to obtain a first concatenated key; Encrypting the first splicing key using the session shared key to obtain a first encrypted splicing key; Exchanging the first encrypted splicing key with the corresponding second encrypted splicing key in the target transmission device to obtain the second encrypted splicing key; Decrypting the second encrypted splicing key using the session shared key to obtain a decrypted splicing key; Based on the first splicing key and the decryption splicing key, a session key corresponding to the embedded device in the data transmission session is generated by means of an exclusive OR operation.

5. The method according to claim 1, characterized in that The method of sequentially encrypting and decrypting the first target data using a preset symmetric encryption algorithm based on the session key to obtain second target data used by the embedded device when processing the target task includes: Generate an initial encryption vector and an initial decryption vector corresponding to a preset symmetric encryption algorithm; Based on the session key and the initial encryption vector, encrypting the first target data using an encryption function in the symmetric encryption algorithm to obtain first encrypted target data; Based on the session key and the initial decryption vector, the first encrypted target data is decrypted using a decryption function in the symmetric encryption algorithm to obtain second target data used by the embedded device when processing a target task.

6. The method according to claim 5, characterized in that The step of encrypting the first target data based on the session key and the initial encryption vector using an encryption function in the symmetric encryption algorithm to obtain first encrypted target data includes: Based on the session key, generating an initialization encryption key corresponding to the encryption function in the symmetric encryption algorithm; According to the first memory space corresponding to the initial encryption vector, a first temporary buffer area corresponding to the encryption function having a size consistent with the first memory space is divided in the memory of the embedded device; Based on the initialization encryption key, the first target data is encrypted using the encryption function in the first temporary buffer area to obtain first encrypted target data.

7. The method according to claim 5, characterized in that The method of decrypting the first encrypted target data based on the session key and the initial decryption vector using a decryption function in the symmetric encryption algorithm to obtain second target data for data use by the embedded device includes: Based on the session key, generating an initialization decryption key corresponding to a decryption function in the symmetric encryption algorithm; According to the second memory space corresponding to the initial decryption vector, a second temporary buffer area corresponding to the decryption function having a size consistent with the second memory space is divided in the memory of the embedded device; Based on the initialization decryption key, the first encrypted target data is decrypted using the decryption function in the second temporary buffer area to obtain second target data used by the embedded device when processing the target task.

8. A data transmission device for an embedded device, characterized in that: The data transmission device comprises: A data acquisition module, configured to, in response to the establishment of a data transmission session instructing the embedded device to perform encrypted data transmission between the embedded device and the target transmission device, acquire first target data sent by the target transmission device via a wireless link for the embedded device to process a target task; A key generation module, configured to generate, in response to receiving the first target data, a session key corresponding to the embedded device in the data transmission session based on an elliptic curve key pair generated by the embedded device and using a preset key agreement algorithm; The data processing module is used to encrypt and decrypt the first target data in sequence based on the session key using a preset symmetric encryption algorithm to obtain second target data used by the embedded device when processing the target task.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor when running to execute the steps of the data transmission method for an embedded device as described in any one of claims 1 to 7.

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 steps of the data transmission method for an embedded device as claimed in any one of claims 1 to 7 are executed.

Citation Information

Patent Citations

  • Data transmission method and electronic equipment

    CN112187832A

  • Data transmission method and device, equipment and storage medium

    CN114785527A

  • Internet of vehicles information encryption method and device, computer equipment and storage medium

    CN115766244A

  • Cross-domain security interconnection method and device of industrial control system

    CN115883183A

  • Intelligent card secure communication method

    WO2014114191A1