Embodiment
For making the object of the embodiment of the present invention, technical scheme and advantage clearly, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
In the existing mode that software is protected; main use encryption lock is protected software; encryption lock is a kind of security product of the software and hardware combining be inserted in parallel port of computer or USB port; general have tens or the nonvolatile storage space of hundreds of byte can for read-write; the partial code in software is preserved in this storage space; software developer can carry out exchanges data by interface function and encryption lock, namely reads and writes the code in encryption lock.But must encryption lock be carried when using software in this way, to make troubles to user and encryption lock is also easily lost.In addition, adopt the cost of hardware encipher lock high, encryption lock causes the size of code of its actual transplanting limited due to limited storage space, and what this reduced encryption lock to a certain extent cracks difficulty.
In order to solve by the problem that use is inconvenient and protection intensity is low that encryption lock brings software protection in prior art, the embodiment of the present invention provides a kind of method for protecting software, and as shown in Figure 1, the method comprises:
101, from the code of application program to be protected, obtain P-code and encrypt for P-code and obtain encrypting P-code.
When protecting the application program of software; do not used by unwarranted user to make the application program of software; needing to transplant in a part of code to encryption lock from the code of application program to protect, only having through authorizing the user of (having encryption lock) just normally can use software by the P-code in encryption lock.But after encryption lock is lost, other users undelegated can be caused to use protected software.In order to overcome above-mentioned defect, the embodiment of the present invention needs to perform step 101 and from the code of application program to be protected, obtains P-code also for P-code encryption obtains encrypting P-code.
102, establishment and application program to be protected carry out mutual driver, and driver is used for enabling decryption of encrypted P-code and performs P-code.
Because the encryption lock cost carrying partial code in application program to be protected is higher and easily lose; and the storage space of encryption lock and operational efficiency limited; the actual size of code transplanted from application program to be protected is very limited, and what this also reduced code to a certain extent cracks difficulty.Therefore, the embodiment of the present invention does not use encryption lock, but needs the establishment of execution step 102 to carry out mutual driver with application program to be protected, and driver is used for enabling decryption of encrypted P-code and performs P-code.Wherein, between described driver and described application program to be protected, create the program of interactive interface; Described driver can be explained encryption P-code and perform P-code under kernel mode i.e. system model.Perform because the partial code in application program to be protected is transplanted in driver by the embodiment of the present invention; and almost exist not used for the debugger cracking driver at present; adding the virtual machine protection (shell being added to code as used VMProtect) of code, making to analyze very difficulty to transplanting code.
103, driver receives the execution P-code request that application program to be protected sends, and performs in P-code request and carries encryption P-code.
From the code of application program to be protected, get P-code in a step 101 due to the embodiment of the present invention and obtained encrypting P-code for P-code encryption, and create in a step 102 and carry out mutual driver with application program to be protected, described driver is for deciphering described encryption P-code and performing described P-code; Therefore, when needs use application program to be protected, need to be sent to driver by the interactive interface between application program to be protected and driver to perform P-code request, request driver performs P-code.Therefore the embodiment of the present invention after step 102, needs to perform the execution P-code request that step 103 driver receives application program to be protected transmission, performs in P-code request and carry encryption P-code.
104, driver is decrypted encryption P-code, determines whether to perform P-code according to decrypted result.
After driver receives the execution P-code request of application program to be protected transmission; driver obtains the encryption P-code carried in this request from the request of execution P-code; and encryption P-code is decrypted, determine whether to perform P-code according to decrypted result.If decrypted result is correct, then performs described P-code by driver, if decrypted result is incorrect, then cannot performs described P-code thus described application program to be protected cannot be used.Driver is when being decrypted encryption P-code, can be decrypted it according to the encryption rule of encryption P-code, described encryption rule can be carried out in advance setting by software developer and can set this encryption rule in driver when creating driver.
The method for protecting software that the embodiment of the present invention provides; can create and carry out mutual driver with application program to be protected; after this driver receives the execution P-code request of application program to be protected transmission, the encryption P-code treated in protection application program is decrypted and performs P-code; determined whether to perform described P-code according to the decrypted result of encryption P-code by driver, thus do not need to treat protection application program (software) by the encryption lock storing P-code of the prior art and protect.Simultaneously; because driver is to the hardware execution efficiency of the operational efficiency of complicated algorithm far above encryption lock itself; and not by the restriction of encryption lock storage space; therefore the code of code logic complexity and the more code of the size of code carried than encryption lock can be protected as P-code to treat protection application program (software) by the present invention, and what considerably increase application program to be protected (software) cracks difficulty.
Understand the method shown in above-mentioned Fig. 1 in order to better, the embodiment of the present invention is described in detail for each step in Fig. 1.
Due in prior art in order to protect the application program of software, the partial code in application program to be protected can be transplanted in encryption lock, authorized use the user of software normally can use software by encryption lock.But the limited storage space due to encryption lock and the operational efficiency to complicated algorithm lower, therefore the code logic great majority transplanting code in encryption lock all relatively simple and in encryption lock the actual size of code transplanted relatively little, what this reduced code to a certain extent cracks difficulty.In order to overcome above-mentioned defect, the mode that the embodiment of the present invention does not re-use encryption lock carrys out the P-code in protection application program, but carries out mutual driver, by performing described P-code in driver by creating with application program to be protected.Due to driver not by storage space restriction and the operational efficiency of driver to complicated algorithm is higher, therefore the embodiment of the present invention can obtain the P-code of code logic complexity and can obtain the larger P-code of size of code from application program to be protected.When the embodiment of the present invention obtains P-code the code of reality from application program to be protected; the obtain manner of dot-dividing type can be adopted from the code of application program to be protected to obtain P-code, and the diverse location namely in the code of application program to be protected obtains multiple P-code.The embodiment of the present invention obtains P-code by dot-dividing type can not only obtain the larger P-code of size of code; but also the code of the different code logic of diverse location in application source code to be protected can be got; by improving the size of code of P-code and the complexity of P-code, thus improve P-code crack difficulty.
Because the P-code obtained in the code from application program to be protected is just stored in encryption lock by prior art; P-code is not encrypted; therefore, after encryption lock is lost, any user getting encryption lock can normally use application program to be protected.Therefore, after the embodiment of the present invention gets P-code in the code from application program to be protected, also need to be encrypted P-code.Owing to embodiments providing a kind of mode adopting dot-dividing type to obtain P-code, entanglement is there will not be in order to make the P-code of acquisition, therefore the P-code of the different code logic obtained by dot-dividing type can be built into code block by the embodiment of the present invention, the P-code of different code logic can be distinguished by code block, thus avoid the P-code of different code logic to occur entanglement.After P-code is built into code block, need to be encrypted code block to obtain encrypting P-code.When being encrypted code block, embodiments providing a kind of optional embodiment, asymmetric encryption can be carried out to described code block and obtaining encrypting P-code.When using asymmet-ric encryption method to be encrypted code block, need use two keys: public-key cryptography and private cipher key.Public-key cryptography and private cipher key are a pair, if use public-key cryptography to be encrypted code block, so only have corresponding private cipher key to decipher; If use private cipher key to be encrypted code block, corresponding public-key cryptography is so only had to decipher.Such as; the embodiment of the present invention can by the public-key cryptography in pair of secret keys to code block be encrypted obtain encrypt P-code; and when creating driver; described encryption rule can be set in driver; therefore when the external world needs to perform application program to be protected; the execution P-code request carrying encryption P-code can be sent to driver; driver, after receiving the request of described execution P-code, needs to use private cipher key to be decrypted encryption P-code according to the encryption rule of setting.Owing to there is interactive interface between application program to be protected and driver; if therefore driver needs to reply enciphered message to application program to be protected; so need driver to use the public-key cryptography in the pair of secret keys of application setting to be protected to be encrypted return information, use private cipher key to be decrypted the enciphered message of replying by application program to be protected.Above by mode just a kind of optional embodiment that asymmetric encryption mode is encrypted code block, certainly other cipher modes can also be used, such as use symmetric cryptography mode to be encrypted code block, namely use same double secret key code block to encrypt and decrypt.Although adopt symmetric cryptography mode can reach encryption and decryption speed faster, but the process due to encryption and decryption adopts same key, the security of enciphered message just cannot be ensured after either party Key Exposure, although therefore adopt symmetric cryptography mode also can play the object of encrypted code block, its cryptographic security is not so good as symmetric cryptography mode.Because the embodiment of the present invention does not use encryption lock to preserve encryption P-code, therefore after being encrypted by code block by each mode above-mentioned and obtaining encryption P-code, encryption P-code can be carried out this locality preservation by the embodiment of the present invention.Preserve in the process of encryption P-code in reality; under encryption P-code can being stored in the catalogue of application program to be protected; so that when using application program to be protected; encryption P-code can be obtained fast from its catalogue, and encryption P-code is carried in execution P-code request and send to driver.Or, also encryption P-code can be stored in other storage spaces of application program place to be protected client.
In order to improve the degree of protection treating protection application program; driver is enable to perform except P-code except being encrypted P-code and realizing a set of code interpretative device in driver; the embodiment of the present invention also needs in driver, realize a set of empowerment management logic; namely arrange the rights of using of application program to be protected, the machine only with rights of using can run described application program to be protected.Concrete when arranging the rights of using of application program to be protected, the embodiment of the present invention can be realized by the mode of digital signature.Its process comprises: the hardware information with the machine of rights of using is generated machine code, such as the hard disk serial number of machine, mainboard information etc. are formed a string sequence number through a series of encryption, hash, described sequence number is exactly can the machine code of unique recognition machine; After acquisition has the machine code of the machine of rights of using, need to carry out Hash operation to described machine code and obtain cryptographic hash, cryptographic hash is used for the unique value of the fixed size representing described machine code.SHA256 algorithm can be adopted to carry out to described machine code the cryptographic hash that Hash operation obtains 256 when reality carries out Hash operation to machine code, other hash algorithms can certainly be adopted to carry out Hash operation to machine code.After obtaining unique cryptographic hash; the embodiment of the present invention also need the private key by presetting to described cryptographic hash be encrypted obtain described in there is the digital signature of the hardware information of the machine of rights of using; namely be encrypted by hardware information summary (carrying out Hash operation to hardware information to obtain) of private key to the machine with rights of using of application program to be protected; and the cryptographic hash (digital signature) of encryption is sent to driver, driver only has could decipher encrypted cryptographic hash (digital signature) with the PKI of application program to be protected.Owing to providing this processing mode of rights of using arranging application program to be protected in the embodiment of the present invention; and when arranging the rights of using of application program to be protected, digital signature process is carried out to the cryptographic hash of the machine hardware information with rights of using; therefore the described driver in the embodiment of the present invention, in the execution P-code request receiving described application program transmission to be protected, has the digital signature of the cryptographic hash of the machine hardware information of rights of using in the request of described execution P-code described in also comprising.
After by the way P-code being encrypted and treat protection application programming rights of using; the embodiment of the present invention not only needs to be decrypted described P-code according to the encryption rule of P-code by driver; but also need to be verified (namely verifying described digital signature) by the authorization privilege of driver to machine, judge its rights of using whether with application program to be protected (namely judging that whether digital signature is legal).Concrete is verified by the digital signature of driver to the machine code of current machine exactly, and determines whether to perform described P-code according to the result.Such as; when using application program to be protected; application program to be protected can send the request of execution P-code by the interactive interface between itself and driver to driver, carries the digital signature of the cryptographic hash of the machine hardware information of encrypting P-code and having rights of using in the request of described execution P-code.After driver receives the request of described execution P-code, can first be verified the digital signature of carrying in the request of described execution P-code by the PKI matched with the private key used when carrying out digital signature process, if certifying digital signature is legal, then illustrate that the transmit leg of the cryptographic hash of machine hardware information is legal, but because the cryptographic hash of the machine hardware information obtained by hash algorithm is irreversible, therefore after certifying digital signature is legal, the embodiment of the present invention also needs to use same hash algorithm to calculate the cryptographic hash of the machine code of current machine, if the cryptographic hash calculated is identical with the cryptographic hash demonstrating digital signature before, then can be decrypted according to the encryption rule of P-code encryption P-code and perform described P-code by driver, thus can normally use application program to be protected, if the cryptographic hash calculated is not identical with the cryptographic hash demonstrating digital signature before, then machine does not have the rights of using of application program to be protected, cannot normally use application program to be protected.
The embodiment of the present invention is by arranging the rights of using of application program to be protected; Hash operation is carried out to the hardware information of authorized machine and carries out digital signature process; the encryption using software developer to preset by driver and the hash signature of verification method to the machine code of current machine are verified; the encryption method that only software developer could be used to preset by driver when signing legal is decrypted encryption P-code and performs described P-code, thus can normally use application program to be protected.The high strength protection treating protection application program is realized by encryption P-code and authorized signature.
As the application to method shown in above-mentioned Fig. 1, embodiments provide a kind of software protecting equipment, as shown in Figure 2, described device comprises: acquiring unit 21, creating unit 22, receiving element 23 and decryption unit 24, wherein,
Acquiring unit 21, obtains encrypting P-code for obtaining P-code in the code from application program to be protected and encrypting for described P-code;
Creating unit 22, carry out mutual driver for creating with described application program to be protected, described driver is for deciphering described encryption P-code and performing described P-code;
Receiving element 23, for receiving the execution P-code request that described application program to be protected sends, carries described encryption P-code in the request of described execution P-code;
Decryption unit 24, for being decrypted described encryption P-code, determines whether to perform described P-code according to decrypted result.
Further, acquiring unit 21 obtains P-code for dot-dividing type in the code from application program to be protected, and described dot-dividing type obtains the P-code that the P-code diverse location be included in the code of application program to be protected obtains different code logic.
Further, as shown in Figure 3, acquiring unit 21 comprises:
Build module 211, for described P-code is built into code block;
Encrypting module 212, obtains encrypting P-code for carrying out asymmetric encryption to described code block;
Preserving module 213, preserving for described encryption P-code being carried out this locality.
Further, as shown in Figure 4, described device also comprises:
Setting unit 25, for arranging the rights of using of application program to be protected.
Further, setting unit 25 comprises:
Generation module 251, the hardware information for the machine by having rights of using generates machine code;
Computing module 252, obtains cryptographic hash for carrying out Hash operation to described machine code;
Signature blocks 253, for the private key by presetting to described cryptographic hash be encrypted obtain described in there is the digital signature of the hardware information of the machine of rights of using.
Further, decryption unit 24 is also verified described digital signature for the PKI that the private key used with preset is corresponding, determines whether to perform described P-code according to the result.
The software protecting equipment that the embodiment of the present invention provides; can create and carry out mutual driver with application program to be protected; after this driver receives the execution P-code request of application program to be protected transmission, the encryption P-code treated in protection application program is decrypted and performs P-code; determined whether to perform described P-code according to the decrypted result of encryption P-code by driver, thus do not need to treat protection application program (software) by the encryption lock storing P-code of the prior art and protect.Simultaneously; because driver is to the hardware execution efficiency of the operational efficiency of complicated algorithm far above encryption lock itself; and not by the restriction of encryption lock storage space; therefore the code of code logic complexity and the more code of the size of code carried than encryption lock can be protected as P-code to treat protection application program (software) by the present invention, and what considerably increase application program to be protected (software) cracks difficulty.
In addition; the software protecting equipment that the embodiment of the present invention provides can by arranging the rights of using of application program to be protected; Hash operation is carried out to the hardware information of authorized machine and carries out digital signature process; the encryption using software developer to preset by driver and the hash signature of verification method to the machine code of current machine are verified; the encryption method that only software developer could be used to preset by driver when signing legal is decrypted encryption P-code and performs described P-code, thus can normally use application program to be protected.The high strength protection treating protection application program is realized by encryption P-code and authorized signature.
It should be noted that for above-mentioned software protecting equipment, the function of the unit module used in every embodiment of the present invention can be realized by hardware processor (hardwareprocessor).
Device embodiment described above is only schematic, the wherein said unit illustrated as separating component or can may not be and physically separates, parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of module wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.Those of ordinary skill in the art, when not paying performing creative labour, are namely appreciated that and implement.
Through the above description of the embodiments, those skilled in the art can be well understood to the mode that each embodiment can add required general hardware platform by software and realize, and can certainly pass through hardware.Based on such understanding, technique scheme can embody with the form of software product the part that prior art contributes in essence in other words, this computer software product can store in a computer-readable storage medium, as ROM/RAM, magnetic disc, CD etc., comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) perform the method described in some part of each embodiment or embodiment.
Last it is noted that above embodiment is only in order to illustrate technical scheme of the present invention, be not intended to limit; Although with reference to previous embodiment to invention has been detailed description, those of ordinary skill in the art is to be understood that: it still can be modified to the technical scheme described in foregoing embodiments, or carries out equivalent replacement to wherein portion of techniques feature; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.