Disclosure of Invention
The invention aims to provide a protection method and a kit for configuration engineering files of an industrial control system, which aim to solve the technical problems that the industrial control system in the prior art is difficult to use an imposition decryption technology and the configuration engineering has a divulgence risk.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
in a first aspect, a method for protecting a configuration engineering file for an industrial control system is provided, including: encrypting and decrypting the well-written configuration engineering file of the industrial control system to obtain a first configuration engineering file of the industrial control system and an encryption and decryption key, wherein the encryption and decryption key comprises a password and a salt value; encrypting and decrypting the password again, storing the password in the first industrial control system configuration project file, and generating a second industrial control system configuration project file; and the manufacturer of the second industrial control system configuration engineering file sent by the user who receives the forgotten password decrypts the password through the private key.
Further, a DES symmetric encryption and decryption mode is adopted to encrypt and decrypt the well-written configuration engineering files of the industrial control system, and the DES symmetric encryption and decryption mode comprises but is not limited to an aes symmetric encryption and decryption algorithm and a DES symmetric encryption and decryption algorithm.
Further, the openssl encryption and decryption component is used for encrypting and decrypting the password again to generate a public key and a private key.
Further, the salt value is a value greater than 8 bits, which is preset or generated by a random algorithm.
In a second aspect, a protective sleeve for an industrial control system configuration engineering file is provided, which includes: the first encryption and decryption module is configured in the configuration software and used for encrypting and decrypting the well-written configuration engineering file of the industrial control system to obtain a first configuration engineering file of the industrial control system and an encryption and decryption key, wherein the encryption and decryption key comprises a password and a salt value; the second encryption and decryption module is configured in the configuration software and used for encrypting and decrypting the password again, storing the password in the first industrial control system configuration project file and generating a second industrial control system configuration project file; and the manufacturer of the second industrial control system configuration engineering file sent by the user who receives the forgotten password decrypts the password through the private key.
Further, the first encryption and decryption module encrypts and decrypts the well-written configuration engineering file of the industrial control system by adopting a DES (data encryption standard) symmetric encryption and decryption mode, wherein the DES symmetric encryption and decryption mode comprises but is not limited to an aes symmetric encryption and decryption algorithm and a DES symmetric encryption and decryption algorithm.
Further, the second encryption and decryption module encrypts and decrypts the password again by using the openssl encryption and decryption component to generate a public key and a private key.
Further, the salt value is a value greater than 8 bits, which is preset or generated by a random algorithm.
Further, the configuration software is configured with a DPAPI interface function and a gcry _ malloc _ secure interface function.
Compared with the prior art, the invention has the following beneficial effects:
(1) the method comprises the steps of encrypting and decrypting a well-written configuration engineering file of the industrial control system to obtain a first configuration engineering file of the industrial control system and an encryption and decryption key, wherein the encryption and decryption key comprises a password and a salt value; encrypting and decrypting the password again, storing the password in the first industrial control system configuration project file, and generating a second industrial control system configuration project file; the manufacturer of the second industrial control system configuration engineering file, which receives the password forgotten user, decrypts the password through the private key; the encryption strength of the configuration engineering file is improved, the conventional brute force attack can be prevented, and the leakage risk of the configuration engineering is reduced;
(2) the invention is purposefully added into the DPAPI interface function in windows and the gcry _ malloc _ secure interface function design in linux, so that the problem that the password is stolen in the memory can be avoided;
(3) in the invention, the password can be found back to a manufacturer after the user forgets the password, the password is encrypted and decrypted by openssl, and the user stores the private key of the public key manufacturer;
(4) according to the invention, by means of encrypting and decrypting the configuration engineering file body, a safe encryption and decryption mode can be realized under the condition that no authentication server exists, and the problems that the industrial control environment is relatively closed, the calculation force of a CPU (central processing unit) and a memory of the industrial control equipment is low, and the forced decryption technology is difficult to use are solved.
Detailed Description
The invention is further described below with reference to the accompanying drawings. The following examples are only for illustrating the technical solutions of the present invention more clearly, and the protection scope of the present invention is not limited thereby.
The first embodiment is as follows:
a protection method for industrial control system configuration engineering files comprises the steps of encrypting and decrypting written industrial control system configuration engineering files to obtain first industrial control system configuration engineering files and encryption and decryption keys, wherein the encryption and decryption keys comprise passwords and salt values; encrypting and decrypting the password again, storing the password in the first industrial control system configuration project file, and generating a second industrial control system configuration project file; and the manufacturer of the second industrial control system configuration engineering file sent by the user who receives the forgotten password decrypts the password through the private key.
In this embodiment, a DES symmetric encryption and decryption manner is adopted to encrypt and decrypt the configuration engineering files of the programmed industrial control system, and the DES symmetric encryption and decryption manner includes, but is not limited to, an aes symmetric encryption and decryption algorithm, a DES symmetric encryption and decryption algorithm, and a customized encryption and decryption suite.
Encrypting and decrypting the password again by adopting an openssl encryption and decryption component to generate a public key and a private key; and a safer salt value is preset, wherein the salt value is a value which is preset or generated by a random algorithm and is larger than 8 bits. The salt value is added to prevent malicious brute force attacks.
The method comprises the steps of encrypting and decrypting a well-written configuration engineering file of the industrial control system to obtain a first configuration engineering file of the industrial control system and an encryption and decryption key, wherein the encryption and decryption key comprises a password and a salt value; encrypting and decrypting the password again, storing the password in the first industrial control system configuration project file, and generating a second industrial control system configuration project file; the manufacturer of the second industrial control system configuration engineering file sent by the user who forgets the password decrypts the password through the private key; the encryption strength of the configuration engineering file is improved, the conventional brute force attack can be prevented, and the leakage risk of the configuration engineering is reduced.
Example two:
as shown in fig. 1 and fig. 2, based on the protection method for the configuration engineering file of the industrial control system according to the first embodiment, the present embodiment provides a protection kit for the configuration engineering file of the industrial control system, including a first encryption and decryption module configured in configuration software, and configured to encrypt and decrypt the written configuration engineering file of the industrial control system to obtain a first configuration engineering file of the industrial control system and an encryption and decryption key, where the encryption and decryption key includes a password and a salt value; the second encryption and decryption module is configured in the configuration software and used for encrypting and decrypting the password again, storing the password in the first industrial control system configuration project file and generating a second industrial control system configuration project file; and the manufacturer of the second industrial control system configuration engineering file sent by the user who receives the forgotten password decrypts the password through the private key.
The specific configuration process of the protective sleeve oriented to the industrial control system configuration engineering file in this embodiment is as follows.
The method comprises the following steps: designing configuration software, adding an encryption and decryption module (a first encryption and decryption module) into the configuration software, and selecting a mature symmetric encryption and decryption mode DES; the symmetric encryption and decryption mode includes but is not limited to known symmetric encryption and decryption algorithms such as aes and des, and also includes a customized encryption and decryption suite.
Step two: an openssl encryption and decryption component (a second encryption and decryption module) is added into the configuration software, and a public key and a private key are generated by adopting openssl. And prefabricate a safer salt value, wherein the salt value is more than 8 bits. Salt values may also be generated using a random algorithm. The salt value is added to prevent malicious brute force attacks.
Step three: adding a DPAPI interface function and a gcry _ malloc _ secure interface function into configuration software; in order to adapt to different types of industrial control terminals, windows CE is protected by a DPAPI interface function, and class linux is protected by a gcry _ malloc _ secure interface function, so that a memory is prevented from being read. Used for protecting the password from being read in the memory.
The configuration engineering file is normally decrypted through the password, the decrypted configuration engineering file starts to execute the programmed program, and the password is left in the memory at the moment. The configuration software can call a DPAPI interface when running in windows and call a gcry _ malloc _ secure interface when running in linux, and then the password in the memory can be protected.
Step four: and encrypting and decrypting the compiled configuration engineering file through DES (data encryption standard) by configuration software to obtain a first industrial control system configuration engineering file and an encryption and decryption key, wherein the encryption and decryption key is (password + salt value). When the DES encrypted and decrypted configuration engineering file is stolen for reverse analysis, the real function code cannot be seen, and the safety of the configuration engineering file body is protected.
Step five: and (4) encrypting and decrypting the password through the openssl component, storing the password in the encrypted and decrypted configuration engineering file (the first industrial control system configuration engineering file) in the step four, and generating a new configuration engineering file (the second industrial control system configuration engineering file).
Step six: and (4) the user forgets the password, the new configuration engineering file is sent to the manufacturer, and the manufacturer decrypts the private key through the openssl component to obtain the password.
The openssl component encryption and decryption is realized by encrypting and decrypting a private key by using a public key, encrypting and decrypting a password by using the public key, and storing the private key in a manufacturer to prevent a user from forgetting the password. After the user forgets the password, the configuration engineering file is sent to a manufacturer, the manufacturer extracts the encrypted and decrypted password, the password is decrypted by using the private key, and the decrypted configuration engineering file is sent to the user.
According to the invention, a DES (password + salt) encryption and decryption mode is adopted for the configuration engineering file, so that the conventional brute force cracking attack can be prevented; the DPAPI interface function in windows and the gcry _ malloc _ secure interface function in linux are added in a targeted mode, and the risk that the password is stolen in a memory can be avoided. In consideration of the fact that the user can find the password back to the manufacturer after forgetting the password, opennssl encryption and decryption is carried out on the password, and the user stores the private key of the public key manufacturer. Because the industrial control environment is relatively closed, and the calculation force of the CPU and the memory of the industrial control equipment is low. The method for encrypting and decrypting the configuration engineering file body can realize a safe encryption and decryption method under the condition that an authentication server is not available.
The specific treatment flow of this embodiment is shown in fig. 2:
defining DES encryption function of DESUTil. Defining DES decryption function of DESULTI, and realizing DES decryption of the configuration file by the function through key;
defining a ReadPrj () function, wherein the function is used for reading the content of the configuration engineering file and storing the read content in a PrjData variable;
inputting a password for encryption, calling a DES encryption suite, DESUTil. The PrjData is the content of the configuration engineering file, and the key is the set password + the prefabricated salt value, namely key = password + salt; obtaining an encrypted configuration file PrjData _ encrypt;
inputting a password to decrypt the configuration engineering file, and calling a DES decryption suite, namely secret. The PrjData is the content of the configuration engineering file, and the key is the set password + the prefabricated salt value, namely key = password + salt; obtaining the decrypted configuration file PrjData;
defining an OPENSL public key encryption function of RSAEncrypt. Defining an OPENSL private key decryption function of RSAEncrypt.decrypt, and decrypting the user password by the generated private key by the function;
after Openssl generates a public key and installs Openssl, generating a public key command Openssl-out rsa _ public _ key.pem 2048 by adopting a standard, and storing the public key in rsa _ public _ key.pem file; generating a private key command openssl-in rsa _ private _ key-term-output rsa _ public _ key-term according to a private key generation public key rsa _ public _ key.term by adopting a standard, wherein the private key is stored in a rsa _ private _ key.term file;
encrypting the password by using RSAEncrypt (password) to obtain the encrypt key; and storing the configuration file into a configuration file encrypted by the DES.
When the user forgets the password, the configuration engineering file is sent to the manufacturer, the manufacturer finds the encrypted and decrypted password stored in the configuration engineering file, and the manufacturer decrypts the password by using RSAEncrypt. After the key is input, the file can be normally decrypted; and sending the decrypted configuration engineering file to the client.
And the user decrypts the configuration engineering file, the correct password is always stored in the memory, and the DPAPI interface or the gcry _ malloc _ secure function is called to protect the password in the memory.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.