A PLC program data protection method, medium and device
By dividing the PLC program data into sub-blocks and using multiple key decryption and time matching mechanisms, the problem of insufficient overall security of the PLC program data is solved, and efficient data protection and timely stop loss are achieved.
Patent Information
- Application Number
- CN202411074227.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-07
AI Technical Summary
The existing technology cannot effectively protect the overall security of PLC program data. After the key is cracked, the data is in plain text and the loss cannot be stopped in time.
Using a multi-key decryption method, the PLC program data is divided into multiple sub-data blocks, and an asymmetric encryption algorithm is used to generate key pairs for encryption and decryption. Security is improved through identity verification and time matching mechanisms to ensure that the data is timely when decryption fails. Delete the remaining blocks and restore the backup.
Through multiple key decryption and time matching mechanisms, the overall security of PLC program data is significantly improved, preventing data leakage and stopping losses in time when decryption fails, ensuring the normal operation of the PLC.
Smart Images

Figure CN118586020B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial control and safety technology, and in particular to a PLC program data protection method. Background Art
[0002] Industrial control systems, or industrial control systems, are an important part of the national industrial system and critical infrastructure. Programmable logic controllers (PLCs) are important basic control devices in industrial control systems, and the security issues they face have also received more and more attention.
[0003] In many cases, PLC program data is a core secret. The confidentiality of PLC program data is an important part of PLC security and industrial control system security protection.
[0004] The current protection for PLC program data generally involves encrypting the entire PLC data program. Once the key is cracked, the entire PLC program data is in plain text, and security cannot be well guaranteed, and users cannot obtain it in a timely manner.
[0005] Based on this, how to develop a method that can enhance the overall security of PLC program data is one of the problems that need to be solved urgently. Summary of the invention
[0006] The purpose of the present invention is to provide a PLC program data protection method, medium and device, which can realize the reading of complete PLC program data through multi-key decryption, thereby improving the overall security of the PLC program data.
[0007] To achieve the above object, the present invention adopts the following technical solutions:
[0008] In a first aspect, the present invention provides a PLC program data protection method, comprising the following steps:
[0009] S1, a number of key pairs generated based on an asymmetric encryption algorithm, each key pair including a one-to-one corresponding public key and private key;
[0010] S2, configuring a data reading unit, wherein the data reading unit has an identity identifier and stores the private key;
[0011] S3, dividing the PLC program data into at least two sub-data blocks;
[0012] S4, using different public keys to encrypt all sub-data blocks one by one and then store them;
[0013] S5, when reading PLC program data, initiate identity verification. If the verification is successful, enter S6, otherwise directly disconnect the connection with the data reading unit;
[0014] S6, transmitting the encrypted sub-data block;
[0015] S7, using the corresponding private key to decrypt the sub-data blocks one by one, and splicing the decrypted sub-data blocks to form complete PLC program data.
[0016] In certain embodiments of the first aspect of the present invention, in S3, the method of dividing the PLC program data into at least two sub-data blocks is as follows:
[0017] S31, pre-setting a number of separators in the PLC program data;
[0018] S32, scanning the PLC program data in a forward-to-backward order until any separator is reached, and cutting the scanned portion from the PLC program data to form a sub-data block;
[0019] S33, cyclically scanning the remaining PLC program data according to the method of S32 until the end of the PLC program data, forming a plurality of sub-data blocks.
[0020] In certain embodiments of the first aspect of the present invention, in S4, after encryption, a corresponding priority is configured for each sub-data block, and the sub-data blocks are encoded and stored in order from low to high priority; and the encrypted sub-data blocks are backed up at specified intervals.
[0021] In certain embodiments of the first aspect of the present invention, in S6, the encrypted sub-data blocks are transmitted in order from low to high priority, and when the first sub-data block is transmitted, the priority order of all sub-data blocks is transmitted together.
[0022] In some embodiments of the first aspect of the present invention, in S7, the method of using the corresponding private key to decrypt the sub-data blocks one by one is as follows:
[0023] S71, obtaining the code of the sub-data block currently received;
[0024] S72, matching the private key corresponding to the encoding of the sub-data block;
[0025] S73, using the private key to decrypt the sub-data block, if the decryption is successful, continue to decrypt the next sub-data block, otherwise issue a decryption failure warning and delete the remaining sub-data blocks;
[0026] S74, after eliminating the risk of data leakage, re-write the encrypted sub-data block of the most recent backup.
[0027] In certain embodiments of the first aspect of the present invention, while encrypting the sub-data blocks, a transmission time is configured for each sub-data block; when the transmission time of any sub-data block does not match the configured transmission time, a decryption failure is prompted, and transmission is restarted from the first sub-data block.
[0028] In some embodiments of the first aspect of the present invention, the transmission time is configured as follows:
[0029] The transmission time of the first sub-data block is configured to be 0, and when the first sub-data block is transmitted, the time of the local timer is initialized to 0;
[0030] The transmission time of the remaining sub-data blocks is:
[0031]
[0032] in, The transmission time configured for the nth sub-block, The time required to decrypt the n-1th and n-1th sub-blocks, is a coefficient greater than 1.
[0033] In certain embodiments of the first aspect of the present invention, when decryption failure occurs for the same PLC program data for multiple consecutive times, a decryption failure warning is issued and the remaining sub-data blocks are deleted.
[0034] In a second aspect, the present invention provides a non-transitory storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the PLC program data protection method as described in the first aspect.
[0035] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the PLC program data protection method as described in the first aspect is implemented.
[0036] Compared with the prior art, the present invention has the following beneficial effects:
[0037] 1. The present invention first divides the PLC program data into multiple sub-data blocks, and encrypts and stores them separately, and adds identity authentication of the data reading unit. During decryption, the sub-data blocks are decrypted one by one and spliced to obtain complete PLC program data, and the overall security of the PLC program data is improved through multi-key decryption.
[0038] 2. The present invention configures the transmission time of each sub-data block, and determines whether the time matches when transmitting each data block. If the match fails multiple times, it is also regarded as a decryption failure. Since the time for multiple attempts to decrypt with a key or other abnormal means is different from the time used for normal decryption, the risk of multiple attempts to decrypt with a key or other abnormal means can be avoided to a certain extent by configuring the transmission time.
[0039] 3. The present invention deletes the remaining sub-data blocks as soon as decryption fails. Even if a small part of the PLC program data is leaked, the remaining part can be protected to achieve the effect of stopping the loss in time; and after eliminating the risk, the most recently backed-up sub-data block is rewritten to ensure the normal operation of the PLC. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic diagram of the overall process of the present invention.
[0041] Figure 2 It is a schematic diagram of the sub-data block segmentation process of the present invention.
[0042] Figure 3 This is a schematic diagram of setting the separator of the present invention.
[0043] Figure 4 It is a schematic diagram of the sub-data block decryption process of the present invention.
[0044] Figure 5 It is an interactive schematic diagram of reading PLC program data of the present invention. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] Embodiment 1:
[0047] This embodiment provides a PLC program data protection method, please refer to Figure 1 , including the following steps:
[0048] S1, a number of key pairs generated based on an asymmetric encryption algorithm, each key pair includes a one-to-one corresponding public key and private key.
[0049] The asymmetric encryption algorithm may adopt RSA or ECC, and RSA encryption is preferred in this embodiment.
[0050] The RSA encryption algorithm can be used through several key pairs [EKey, DKey], where EKey represents the public key and Dkey represents the private key, and the two correspond to each other. That is, the plaintext is encrypted by the public key EKey to obtain the ciphertext, and the ciphertext is decrypted by the private key Dkey to obtain the corresponding plaintext.
[0051] The multiple public keys of this embodiment constitute a public key sequence [EKey1, EKey2, EKey3, ..., EKeyn], which is used to be stored in the PLC.
[0052] Similarly, several private keys constitute a private key sequence [DKey1, DKey2, DKey3, ..., DKeyn].
[0053] The number at the end of the public key / private key represents the serial number of the public key / private key. Public keys and private keys with the same serial number correspond to each other and constitute the same key pair.
[0054] S2, configuring a data reading unit, wherein the data reading unit has an identity ID and stores the private key, specifically a private key sequence [DKey1, DKey2, DKey3, ..., DKeyn].
[0055] It is worth mentioning that the data reading unit is arranged in the external terminal. When the external terminal is electrically connected to the PLC, the data reading unit can interact with the PLC for data.
[0056] S3, dividing the PLC program data into at least two sub-data blocks.
[0057] For details, please refer to Figure 2 , the method of dividing the PLC program data into at least two sub-data blocks is as follows:
[0058] S31, pre-set several separators in the PLC program data, such as Figure 3 As shown, Kt0 represents the entire PLC program data, and the double dashed line represents a separator.
[0059] S32, scanning the PLC program data in order from front to back until any separator, and cutting the scanned part from the PLC program data to form a sub-data block Kt1.
[0060] S33, the remaining PLC program data is scanned cyclically according to the method of S32 until the end of the PLC program data, forming a plurality of sub-data blocks Kt2, sub-data blocks Kt3, and sub-data blocks Kt4.
[0061] Thereby, the whole PLC program data Kt0 is divided into four sub-data blocks, namely sub-data block Kt1, sub-data block Kt2, sub-data block Kt3, and sub-data block Kt4.
[0062] S4, using different public keys to encrypt all sub-data blocks one by one and then store them. Preferably, a storage unit is set in the PLC to store the encrypted sub-data blocks. It is worth mentioning that when the data reading unit is connected to the PLC, the data reading unit is connected to the storage unit, and data interaction can be performed directly.
[0063] It is worth mentioning that in order to read the sub-data blocks one by one in the order expected by the user when reading the PLC program data later, this embodiment configures a corresponding priority for each sub-data block after encryption, and the priority configuration can be performed manually by the user.
[0064] It is worth mentioning that each sub-data block is encrypted one by one using a public key in a specific order, such as using public key EKey1 to encrypt the first sub-data block Kt1, public key EKey2 to encrypt the second sub-data block Kt2, and so on.
[0065] Then, the encrypted sub-data blocks are encoded and stored in order of priority from low to high, and the encrypted sub-data blocks are backed up at specified intervals, preferably, every half an hour.
[0066] In order to realize backup, a backup unit is provided in the PLC, and the backup unit is connected to the storage unit but not directly connected to the data reading unit. Therefore, even when the data reading unit is connected to the PLC, the data reading unit cannot exchange data with the backup unit.
[0067] S5, please refer to Figure 5 When reading PLC program data, an identity verification is initiated. If the verification is successful, S6 is entered. Otherwise, the connection with the data reading unit is directly disconnected to prevent the leakage of PLC program data.
[0068] S6, transmitting the encrypted sub-data block.
[0069] Specifically, the encrypted sub-data blocks are transmitted in order from low to high priority, and when the first sub-data block is transmitted, the priority order of all sub-data blocks is transmitted to the data reading unit.
[0070] Through the encoded priority order, the data reading unit can sort the stored private keys accordingly, thereby achieving decryption of the corresponding sub-data blocks.
[0071] S7, using the corresponding private key to decrypt the sub-data blocks one by one, and splicing the decrypted sub-data blocks to form complete PLC program data.
[0072] Specifically, Figure 4As shown, the method of decrypting the sub-data blocks one by one using the corresponding private key is as follows:
[0073] S71, obtaining the code of the sub-data block currently received;
[0074] S72, matching the private key corresponding to the encoding of the sub-data block;
[0075] S73, using the private key to decrypt the sub-data block, if the decryption is successful, continue to decrypt the next sub-data block, otherwise issue a decryption failure warning and delete the remaining sub-data blocks.
[0076] It is worth mentioning that when the decryption is successful, the data reading unit immediately sends a request to the storage unit to transmit the next sub-data block. After receiving the request, the storage unit immediately sends back the sub-data block of the next priority, records the return time, and the data reading unit performs decryption.
[0077] By deleting the remaining sub-data blocks in the storage unit, even if several sub-data blocks with lower priorities are obtained externally, the remaining sub-data blocks with higher priorities can be protected at the first time, thereby preventing the complete PLC program data from being obtained externally.
[0078] S74, after eliminating the risk of data leakage, re-write the encrypted sub-data block of the most recent backup.
[0079] This embodiment mainly protects the higher priority parts of the PLC program data from being leaked through multi-key decryption, thereby improving the overall security of the PLC program data.
[0080] Embodiment 2:
[0081] In the solution of the first embodiment above, there is still a certain risk of data leakage if the external device decrypts through multiple decryption attempts or other abnormal means.
[0082] Based on this, the second embodiment is improved on the basis of the first embodiment, specifically:
[0083] In the second embodiment, while encrypting the sub-data blocks, a transmission time is configured for each sub-data block; when the actual transmission time of any sub-data block (i.e., the return time described in the first embodiment) does not match the configured transmission time, a decryption failure is prompted, and transmission is restarted from the first sub-data block.
[0084] It is worth mentioning that in this embodiment, the method for determining whether the transmission time of any sub-data block does not match the configured transmission time is as follows:
[0085] When the actual transmission time of the sub-data block is within the configured transmission time If the match is successful within k seconds before and after , k is a redundancy value, which can be 5 or 10. The smaller the value of k, the higher the matching accuracy requirement, but the higher the probability of misjudgment due to network fluctuations. On the contrary, the larger the value of k, the lower the matching accuracy requirement, but the lower the probability of misjudgment due to network fluctuations.
[0086] When decryption failure occurs for multiple times in a row for the same PLC program data, a decryption failure warning is issued and the remaining sub-data blocks are deleted.
[0087] This makes it possible to identify situations where multiple attempts to decrypt the key or other abnormal means are made, and protect the PLC program data in such situations.
[0088] Specifically, the transmission time is configured as follows:
[0089] The first sub-data block is configured with a transmission time of 0, that is, , and when transmitting the first sub-data block, initialize the local timer to 0.
[0090] The remaining sub-data block configuration transmission time can include the following:
[0091] Method 1:
[0092] The transmission time of the remaining sub-data blocks is:
[0093]
[0094] in, The transmission time configured for the nth sub-block, The time required to decrypt the n-1th and n-1th sub-blocks, It is a coefficient greater than 1, preferably 1.1 or 1.2, which is used for the duration of sending a request and data transmission between the data reading unit and the storage unit.
[0095] Method 2:
[0096] The transmission time of the remaining sub-data blocks is:
[0097]
[0098] in, The transmission time configured for the nth sub-block, The time required to decrypt the n-1th and n-1th sub-blocks, It is the duration of sending a request and transmitting data between the data reading unit and the storage unit, which can be obtained by performing multiple tests and taking an average value, and is preferably 3s or 5s.
[0099] Method 3:
[0100] The transmission time of the remaining sub-data blocks is:
[0101]
[0102] in, The transmission time configured for the nth sub-block, The time required to decrypt the n-1th and n-1th sub-blocks, It is the time duration for sending request and data transmission between the data reading unit and the storage unit, which can be obtained by multiple tests and taking the average value; The delay time configured for each sub-data block.
[0103] In this method, it is also required that when the decryption is successful, the data reading unit immediately sends a request to the storage unit to transmit the next sub-data block. After the storage unit receives the request, the delay time Then the sub-data block of the next priority level is sent back, and the time of sending back is recorded, and the data reading unit decrypts it.
[0104] Compared with method one and method two, method three locally matches the delay time that cannot be obtained by an external data reading unit, which can further enhance the safety performance.
[0105] Embodiment three:
[0106] The third embodiment provides a non-transitory storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the PLC program data protection method as described in the first or second embodiment.
[0107] Embodiment 4:
[0108] The fourth embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the PLC program data protection method as described in the first or second embodiment is implemented.
[0109] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0110] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A PLC program data protection method, characterized in that: The following steps are involved: S1, a number of key pairs generated based on an asymmetric encryption algorithm, each key pair including a one-to-one corresponding public key and private key; S2, configuring a data reading unit, wherein the data reading unit has an identity identifier and stores the private key; S3, dividing the PLC program data into at least two sub-data blocks; S4, using different public keys to encrypt all sub-data blocks one by one and then store them, and back up the encrypted sub-data blocks at specified intervals; S5, when reading PLC program data, initiate identity verification. If the verification is successful, enter S6, otherwise directly disconnect the connection with the data reading unit; S6, transmitting the encrypted sub-data block; S7, using the corresponding private key to decrypt the sub-data blocks one by one, and splicing the decrypted sub-data blocks to form complete PLC program data; In S7, the method of using the corresponding private key to decrypt the sub-data blocks one by one is as follows: S71, obtaining the code of the sub-data block currently received; S72, matching the private key corresponding to the encoding of the sub-data block; S73, using the private key to decrypt the sub-data block, if the decryption is successful, continue to decrypt the next sub-data block, otherwise issue a decryption failure warning and delete the remaining sub-data blocks; S74, after eliminating the risk of data leakage, rewriting the encrypted sub-data block of the most recent backup; While encrypting the sub-data blocks, configuring a transmission time for each sub-data block; When the transmission time of any sub-data block does not match the configured transmission time, a decryption failure message is displayed and the transmission is restarted from the first sub-data block. The transmission time is configured as follows: The transmission time of the first sub-data block is configured to be 0, and when the first sub-data block is transmitted, the time of the local timer is initialized to 0; The transmission time of the remaining sub-data blocks is: in, The transmission time configured for the nth sub-block, The time required to decrypt the n-1th and n-1th sub-blocks, The duration of sending request and data transmission between the data reading unit and the storage unit; The delay time configured for each sub-data block; When decryption is successful, the data reading unit immediately sends a request to the storage unit to transmit the next sub-data block. After receiving the request, the storage unit delays for a period of time. Then the next sub-data block is sent back and the time of sending back is recorded, and the data reading unit decrypts it; When decryption failure occurs for multiple times in a row for the same PLC program data, a decryption failure warning is issued and the remaining sub-data blocks are deleted.
2. A PLC program data protection method according to claim 1, characterized in that: In S3, the method of dividing the PLC program data into at least two sub-data blocks is as follows: S31, pre-setting a number of separators in the PLC program data; S32, scanning the PLC program data in a forward-to-backward order until any separator is reached, and cutting the scanned portion from the PLC program data to form a sub-data block; S33, cyclically scanning the remaining PLC program data according to the method of S32 until the end of the PLC program data, forming a plurality of sub-data blocks.
3. A PLC program data protection method according to claim 1, characterized in that: In S4, after encryption, a corresponding priority is assigned to each sub-data block, and the sub-data blocks are encoded and stored in order from low to high priority.
4. A PLC program data protection method according to claim 3, characterized in that: In S6, the encrypted sub-data blocks are transmitted in order from low to high priority, and when the first sub-data block is transmitted, the priority order of all sub-data blocks is transmitted together.
5. A non-transitory storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the PLC program data protection method according to any one of claims 1 to 4.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the PLC program data protection method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Data encrypted transmission method
CN108768930A
