Disclosure of Invention
In order to solve the technical problems, the invention provides a method, a system and a device for external data security protection and bidirectional authentication of a sensor, which are used for solving the problems that the confidentiality of data is not guaranteed when the sensor is used for data transmission, the authenticity and the integrity of the data cannot be authenticated by a background subsystem, and the sensor does not have the capability of authenticating instructions sent by the background subsystem.
The invention provides a method, a system and a device for protecting and bidirectionally identifying external data of a sensor, which comprise the following steps:
calculating and encrypting uplink data output by the sensor;
after receiving the current task, verifying the uplink data and signing the uplink data;
verifying downlink data received by a sensor;
wherein, the calculating and encrypting the uplink data output by the sensor comprises:
encrypting the uplink data to obtain a ciphertext;
calculating the uplink data to obtain a standard hash value;
after receiving the current task, verifying the uplink data and signing the uplink data comprises the following steps:
decrypting the ciphertext to obtain a plaintext, and calculating an actual hash value of the plaintext;
comparing the actual hash value with the standard hash value;
the actual hash value that is passed the comparison is signed.
Preferably, before calculating and encrypting the upstream data output by the sensor, the method further comprises: and carrying out an initialization operation.
Preferably, the upstream data includes sensor data and a unique identifier.
Preferably, the encryption processing of the uplink data is performed, and the encryption mode in the obtained secret is a symmetric cryptographic algorithm.
Preferably, the standard hash value and the actual hash value are calculated by a cryptographic hash algorithm.
The external data security protection and two-way authentication system of the sensor comprises a data processing subsystem and a background subsystem;
the data processing subsystem is used for calculating and encrypting the uplink data output by the sensor and verifying the downlink data received by the sensor;
the background subsystem is used for verifying uplink data and signing the uplink data after receiving the current task:
an information channel is arranged between the data processing subsystem and the background subsystem;
the calculating and encrypting the uplink data output by the sensor specifically includes: encrypting the uplink data to obtain a ciphertext;
calculating the uplink data to obtain a standard hash value;
after receiving the current task, verifying the uplink data and signing the uplink data specifically comprises the following steps: decrypting the ciphertext to obtain a plaintext, and calculating an actual hash value of the plaintext;
comparing the actual hash value with the standard hash value;
the actual hash value that is passed the comparison is signed.
An external data security protection and two-way authentication device of a sensor, comprising:
the data security protection module is used for calculating and encrypting the uplink data output by the sensor and verifying the downlink data received by the sensor;
the data verification signature module is used for verifying uplink data and signing the uplink data after receiving the current task;
the data security protection module calculates and encrypts uplink data output by the sensor and verifies downlink data received by the sensor, and specifically includes: encrypting the uplink data to obtain a ciphertext;
calculating the uplink data to obtain a standard hash value;
after receiving the current task, the data verification signature module verifies uplink data and signs the uplink data specifically comprises: decrypting the ciphertext to obtain a plaintext, and calculating an actual hash value of the plaintext;
comparing the actual hash value with the standard hash value;
the actual hash value that is passed the comparison is signed.
Compared with the related art, the external data security protection and bidirectional authentication method, system and device for the sensor provided by the invention have the following beneficial effects:
under the condition that the sensor is not changed, the sensor is bound with the external device in one-to-one correspondence, and the key management is adopted, so that the sensor is identified, confidentiality, authenticity and integrity of data transmitted by the sensor are protected, meanwhile, the background subsystem can identify uplink data, and the sensor can identify downlink data after receiving the background data, so that the authenticity, the integrity and the non-repudiation of the data are judged.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
For ease of understanding by those skilled in the art, referring to fig. 1, an external data security protection and two-way authentication system for a sensor includes: the system comprises a data processing subsystem and a background subsystem, wherein an information channel is arranged between the data processing subsystem and the background subsystem and comprises an uplink channel and a downlink channel;
the invention provides a method for protecting the safety and identifying the external data of a sensor in two directions, which is applied to the sensor, and is shown by referring to the attached figure 2, and comprises the following steps:
step S100: the data processing subsystem calculates and encrypts uplink data output by the sensor.
The specific implementation process of the step is shown in fig. 3:
step S101: encrypting the uplink data output by the sensor by using a symmetric cryptographic algorithm to obtain a ciphertext;
the method comprises the steps of encrypting data by adopting a symmetric cryptographic algorithm after receiving the data transmitted by a sensor to obtain a ciphertext, and transmitting the ciphertext to a background subsystem through a data transmitting module;
the symmetric cryptographic algorithm belongs to the prior art for those skilled in the art who know all the technical knowledge of the technical field of the invention before the application date or priority date and can know all the prior art in the field, and the specific working principle is not repeated here;
in this embodiment, as shown in fig. 5, step S102: calculating the uplink data by using a password hash algorithm to obtain a standard hash value;
specific: for the received first group of data, calculating the unique identifier of the data and the device by adopting a password hash algorithm to obtain a standard hash value, storing the standard hash value, and simultaneously transmitting the standard hash value to a background subsystem through a data transmission module; and for the data after the first group, a standard hash value of the data and the previous group of data is calculated by adopting a password hash algorithm to obtain the standard hash value, the standard hash value is also stored, and the standard hash value is sent to a background subsystem through a data sending module.
Similarly, the cryptographic hash algorithm belongs to the prior art, and the specific working principle is not described herein, for those skilled in the art who know all the technical knowledge of the present invention prior to the filing date or priority date and can know all the prior art in the field.
Step S200: after receiving the current task, the uplink data is verified and signed.
The specific implementation process of the step is shown in fig. 4:
step 201: decrypting the ciphertext by using the key to obtain a plaintext, and calculating an actual hash value of the plaintext by using a password hash algorithm;
specific: after receiving the ciphertext, the background subsystem decrypts the ciphertext by adopting a secret key received in the device initialization stage to obtain plaintext data; for the first group of data, the background subsystem calculates the plaintext data and the unique identifier of the device by adopting a cryptographic hash algorithm to obtain an actual hash value;
step 202: comparing the actual hash value with the standard hash value;
specific: comparing the actual hash value with the standard hash value received by the background subsystem, and if the actual hash value is consistent with the standard hash value, passing the verification; otherwise, an error is prompted. For the first group of later data, the background subsystem adopts a password hash algorithm to calculate the actual hash value of the last group of data to obtain the actual hash value, compares the actual hash value with the received standard hash value, and if the actual hash value is consistent with the received standard hash value, passes verification; otherwise, an error is prompted.
In this embodiment, as shown in fig. 6, step 203: signing the actual hash value which passes the comparison by using the private key;
specifically, the background subsystem sets the time for signing the actual hash value, and for the first signature, the background subsystem calculates the hash value of the hash value, the device state, the signature sequence and the like passing verification in the time period by adopting a password hash algorithm, and signs the hash value by utilizing a private key to obtain a signature value; for the signatures after the first time, the background subsystem adopts a password hash algorithm to calculate hash values passing verification, last signature values, device states, signature sequences and the like in the time period, and signs the hash values by using a private key.
Step S300: verifying downlink data received by a sensor;
specifically, the background subsystem encrypts the issued data by adopting a secret key of a symmetric cryptographic algorithm of the device, signs the issued data by adopting a private key, and then issues the data and the signature value to the data processing subsystem, wherein the data processing subsystem is used for processing the issued data. The data that is delivered includes, but is not limited to: instruction data, device configuration, key exchange, etc.
The data processing subsystem adopts the public key to verify the signature value, and if the verification is passed, the data processing subsystem operates according to the data; otherwise, an error is prompted.
In the invention, the background subsystem can check the data generated by each device, authenticate the data by verifying the hash value and/or the signature value corresponding to the required authentication data, and if the data passes the authentication;
similarly, the data processing subsystem authenticates the data issued by the background subsystem through the hash value and/or the signature value corresponding to the authentication data, and the authenticity and the integrity of the data are ensured.
In this embodiment, before use, an initialization operation is further required, which specifically includes: sensor, data processing subsystem and background subsystem pre-preparation: the sensor information including but not limited to name, manufacturer, type, unique identification, data verification mode, etc. is entered into the background subsystem;
inputting information of the data processing subsystem, including but not limited to name, manufacturer, type, unique identifier, etc., into the background subsystem;
the cryptographic algorithm supported by the data processing subsystem is imported by the background subsystem and comprises a symmetric cryptographic algorithm, a public key cryptographic algorithm and a cryptographic hash algorithm;
the background subsystem adopts a random number generator to produce random numbers, and the random numbers are imported into the device.
The sensor, the data processing subsystem and the background subsystem are connected, and specifically comprise: and selecting a corresponding interface according to the butted sensor data transmission interface, realizing one-to-one correspondence between the sensor and the data processing subsystem, and inputting the corresponding sensor unique identifier and the device unique identifier into the background subsystem.
After the sensor is successfully connected with the data processing subsystem, the specified data is sent to the background subsystem, the background subsystem locks the one-to-one correspondence relationship between the sensor and the data processing subsystem, and the data processing subsystem is activated and can be used.
The background subsystem adopts a cryptographic hash algorithm to calculate a hash value of the content formed by the unique identifier of the sensor and the unique identifier of the data processing subsystem, and the hash value is reserved.
The data processing subsystem needs to be initialized after being activated, and specifically includes:
automatically generating a key and a security parameter of a preset cryptographic algorithm while the data processing subsystem is activated;
calculating hash values of information such as unique identification of the data processing subsystem, activation time, position (available space) of the device during activation, automatically generated secret key and security parameter, corresponding relation between the data processing subsystem and the sensor and the like by using a password hash algorithm;
encrypting information such as unique identification of the data processing subsystem, activation time, position (available space) of the device during activation, automatically generated secret key and security parameter, corresponding relation between the data processing subsystem and the sensor and the like by using a symmetric cryptographic algorithm to obtain ciphertext;
encrypting the data such as the ciphertext and the secret key of the symmetric cryptographic algorithm by using a preset public key cryptographic algorithm to obtain the ciphertext, and sending the ciphertext and the hash value to a background subsystem;
the background subsystem uses a private key corresponding to a preset public key cryptographic algorithm to decrypt, so as to obtain the unique identification of the data processing subsystem, the activation time, the position of the data processing subsystem during activation, the automatically generated secret key and security parameter, the ciphertext of the information such as the corresponding relation with the sensor, and the secret key of the symmetric cryptographic algorithm.
The background subsystem decrypts the unique identifier of the data processing subsystem, the activation time, the position of the activation time, the automatically generated key and the security parameter, the ciphertext of the information such as the corresponding relation with the sensor and the like by using the key of the symmetric cryptographic algorithm, and obtains the unique identifier of the data processing subsystem, the activation time, the position of the activation time, the automatically generated key and the security parameter and the corresponding relation with the sensor.
The background subsystem calculates the unique identification of the data processing subsystem, the activation time, the position of the data processing subsystem when the data processing subsystem is activated, the automatically generated key, the automatically generated security parameter, the corresponding relation with the sensor and other information hash values by using the key and the security parameter of the hash algorithm obtained after decryption, compares the value (namely the actual hash value) with the received hash value (namely the standard hash value), and if the value is consistent, passes verification; otherwise, an error is prompted.
The background subsystem compares the received corresponding relation between the data processing subsystem and the sensor with the stored corresponding relation, and if the corresponding relation is consistent, the verification is passed; otherwise, an error is prompted.
The comparison mode which can be added comprises the position of the data processing subsystem when in activation;
after the background subsystem passes the verification, the data activated by the data processing subsystem is signed by adopting a private key, and the activated data and a signature value are returned to the data;
after receiving the data and the signature value, the data processing subsystem verifies the signature value by adopting a public key, and enters a normal working state after verification; otherwise, an error is prompted.
In this embodiment, the method further includes checking the data processing subsystem, specifically including: if the connection with the sensor is disconnected, the data processing subsystem records and sends disconnection information to the background subsystem;
the data processing subsystem performs self-checking regularly and sends self-checking information to the background subsystem.
The background subsystem receives the abnormal state signal of the data processing subsystem or can not receive the signal of the data processing subsystem and checks the abnormal state signal;
the background subsystem monitors the data quantity sent by all the data processing subsystems, counts the usual data quantity, sets a boundary value, and automatically reminds the device to carry out abnormality detection after the data quantity exceeds the boundary value.
And monitoring the data processing subsystem according to the power consumption of the data processing subsystem, and automatically reminding to check when the power consumption is abnormal.
The invention also provides a sensor external data security protection and bidirectional authentication device, as shown in figure 7, which comprises a data receiving module, a data security protection module, a data sending module, a data verification signature module, a data management module, a power supply and an information channel between the modules;
the data receiving module and the data transmitting module are formed by all modularized interfaces, including but not limited to RJ45 interfaces, RS485 interfaces, RS232 interfaces, WIFI interfaces, GPRS interfaces, USB interfaces, 4G interfaces, 5G interfaces and NB-IOT interfaces; the data security protection module comprises a password module, a memory card, a driver and a firmware which meet the GB/T37092 information security technology password module security requirements, realizes data encryption protection and digital signature on received data sent by the sensor, authenticates the data sent by the background, and sends the data to the sensor after the authentication is passed; the data verification signature module and the data management module comprise the functions of key generation, distribution and other management, equipment management, data processing and storage, data authentication and the like.
In the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the directions or positional relationships shown in the drawings, are merely for convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention.
The foregoing description is only illustrative of the present invention and is not intended to limit the scope of the invention, and all equivalent structures or equivalent processes or direct or indirect application in other related technical fields are included in the scope of the present invention.