Summary of the invention
In order to solve problem present in background technology, the present invention provides software product guard method, the method by improve license file and
The verification mode of license information, can prevent license proving program to be bypassed or be modified, to reach to protect the purpose of software product.
The present invention provides the guard method of a kind of software product, comprises step: generate license file, including step: separate from software product
Go out startup program and main body program, integrate described startup program and license proving program, form bootstrap, merge described bootstrap,
License information, generates described license file;Before running described main body program, verify described license file, be verified,
Then run described main body program.
In a preferred embodiment, when merging the described license file of generation, merge digital certificate and privacy key simultaneously.
In a preferred embodiment, before the described combining step in generating described license file, further include and described bootstrap is added
Close step: be that described bootstrap generates digital digest by the private key of described digital certificate, and is described bootstrap by described privacy key
And the digital digest of described bootstrap is encrypted, the encryption bootstrap obtained after encryption merges described with the digital digest of encryption bootstrap
Step is incorporated in described license file.
In a preferred embodiment, before the described combining step in generating described license file, further include and described license information is entered
The step of row encryption: be that described license information generates digital digest by the private key of described digital certificate, and is described by described privacy key
The digital digest of license information and described license information is encrypted, the encryption license information obtained after encryption and encryption license
The digital digest of information is incorporated in described license file in described combining step.
In a preferred embodiment, after described encrypting step, and before described combining step, further include the step to described secret key encryption:
Being that described privacy key is encrypted by the private key of described digital certificate, the secret encryption key obtained after encryption is merged in described combining step
To described license file.
In a preferred embodiment, the method for described checking described license information includes step: parse described from described license file
Bootstrap and described license information;Perform the described license proving program in described bootstrap, described license information is carried out
Checking;It is verified, then performs the described startup program in described bootstrap, and then run described main body program.
In a preferred embodiment, described license file is stored in mobile memory.
The guard method of the present invention software product by providing, by the startup program of software product being separated with main body program, and will start program
Integrate with license proving program so that license information must be by the checking of license proving program, could properly functioning startup
Program, and then run main body program, say, that if license information cannot pass through the checking of license proving program, or license tests
Card program is bypassed, then the startup program of software product will be unable to properly functioning, so that the main body program of software product cannot add carrying at all
OK, further, in presently preferred embodiments of the present invention, by bootstrap and license information and the encryption of privacy key, and
Improvement to license file verification method, improve license file cracks difficulty, it is thus possible to preferably protect software product.
Detailed description of the invention
For making technical scheme and advantage thereof definitely and in detail, illustrate hereinafter with reference to diagram.
Refer to Fig. 1, Fig. 1 and illustrate the guard method flow chart of the software product that a preferred embodiment of the present invention is provided.As it is shown in figure 1, software
The guard method of product comprises step: generate license file;Checking license file, if being verified, then runs the main body of software product
Program, if checking is not passed through, the most out of service.
Specifically, refer to Fig. 2, Fig. 2 and illustrate the license document generating method flow chart provided in a preferred embodiment of the present invention.As
Shown in Fig. 2, the method generating license file comprises the steps of:
S1, isolates startup program and main body program from software product.The startup program of software product refers in the main body program running software product
The Bootloader before having to carry out, such as, the main body program for software product carries running environment, carries out the main body program of software product
Loading, say, that if the startup program of software product cannot normally perform, the main body program of software product will be unable to start.Software produces
The main body program of product refer to realize the program of various concrete business function, be software product chief value embody.In this step, separate and start journey
Sequence is by the way of code dehind with the mode of main body program, and the code of startup program Yu main body program is separated from each other independence.The enforcement of the present invention
In example, the development language that software product uses is java language.
S2, integrates startup program and license proving program, forms bootstrap.In this step, program will be started by the way of integrating code
Integrate with license proving program.
S3, merges bootstrap, license information, generates license file.In this step, by designing self-defined byte code files rule,
Bootstrap, license information are written in same file according to self-defined byte code files rule, thus generate license file.This
In inventive embodiment, license information is software product authorization information, comprises: manufacturer, name of product, authorization message, effect duration,
MAC binding etc..
According in the license file that above-mentioned steps is generated, i.e. contain the license information of software product, contain again opening of software product
Dynamic program and license proving program, by the startup program of software product being separated with main body program, and enter license starting integration procedure
In file, add software product cracks difficulty, has reached to protect the purpose of software product.
In order to further promote the protection to software product, in other preferred embodiments of the present invention can by bootstrap or
License information is encrypted, and increase license file cracks difficulty.By Fig. 3 to Fig. 5, those preferred embodiments will be entered respectively below
Row describes in detail.
Refer to Fig. 3, Fig. 3 and illustrate the license document generating method flow chart provided in a preferred embodiment of the present invention.As it is shown on figure 3,
The present embodiment is with the difference of embodiment illustrated in fig. 2, further includes step S203, after being positioned at step S2, before step S3.Step S203
It it is the step that bootstrap is encrypted.In the present embodiment, encryption bootstrap method is to be realized by the means of digital certificate and privacy key
, specifically, including by the private key of digital certificate be bootstrap generate digital digest, and by privacy key be bootstrap and guiding journey
The digital digest of sequence is encrypted, and obtains the digital digest encrypting bootstrap with encryption bootstrap.It is understood that what the present embodiment provided
In license document generating method, step S3 is when merging generation license file, and merging is encryption bootstrap and encryption bootstrap
Digital digest, from license document generating method shown in Fig. 2 step S3 merge content different, but merge method the most identical,
Therefore do not repeating at this.The license file generated by the method in the present embodiment, owing to having done digital digest, and to two to bootstrap
Person is encrypted, if it is desired to crack license file, the most not only it should be understood that self-defined byte code files is regular, in addition it is also necessary to complete
To bootstrap and the correct deciphering of digital digest thereof, and by the checking of bootstrap digital digest, it can be seen that, carried by the present embodiment
The license document generating method of confession, can promote the difficulty that cracks of license file greatly, thus provide more solid to software product
Protection.
Refer to Fig. 4, Fig. 4 and illustrate the license document generating method flow chart provided in a preferred embodiment of the present invention.As shown in Figure 4,
The present embodiment is with the difference of embodiment illustrated in fig. 3, further includes step S213, before being positioned at step S3.Step S213 is to believe license
The step that breath is encrypted.In the present embodiment, the method for encryption license information is to be realized by the means of digital certificate and privacy key,
Specifically, including by the private key of digital certificate be license information generate digital digest, and by privacy key be license information and
The digital digest of license information is encrypted, and obtains the digital digest encrypting license information with encryption license information.May be appreciated
It is that, in the license document generating method that the present embodiment provides, step S3 is when merging generation license file, and merging is encryption license
Information and the digital digest of encryption license information, different from the content that step S3 in license document generating method shown in Fig. 3 merges,
But the method merged is the most identical, therefore is not repeating at this.Being not difficult to find out, the present embodiment is improvement, phase further based on embodiment illustrated in fig. 3
For the embodiment shown in Fig. 2, not only bootstrap is encrypted, also license information is encrypted too, thus may be used
See, the license file generated by the method for the present embodiment not only possess the license file of Fig. 2 and embodiment illustrated in fig. 3 generation
Feature, also by the encryption to license information so that license file to crack step more complicated, thus further improve license
File crack difficulty.It is understood that step S213 in the present embodiment is independent with step S203 each other, say, that
In other embodiments of the present invention, in the method generating license file, it is also possible to according to actual demand, only comprise and license information is added
Close step S213, and do not comprise step S203 that bootstrap is encrypted, therefore this embodiment, also should belong to the model that the present invention is protected
Farmland.
Refer to Fig. 5, Fig. 5 and illustrate the license document generating method flow chart provided in a preferred embodiment of the present invention.As it is shown in figure 5,
The present embodiment is with the difference of embodiment illustrated in fig. 4, further includes step S223, after being positioned at step S203 and S213, before step S3.
Step S223 is the step being encrypted privacy key.In the present embodiment, the method for secret encryption key is to be secret by the private key of digital certificate
Decryption key is encrypted, and obtains secret encryption key.It is understood that in the license document generating method of the present embodiment offer, compared to
For embodiment illustrated in fig. 4, step S3 merge generate license file time, not only incorporate encryption bootstrap and encryption digital digest,
Encryption license information and encryption digital digest, still further incorporate secret encryption key, same, the method for merging is the most identical,
Therefore do not repeating at this.
It should be noted that Fig. 3 in the embodiment shown in 5, in newly-increased step S203, S213 or S223, the cryptographic means of use is all
Be the private key by digital certificate and privacy key, owing to license file is during normal use, need to be decrypted and verify, and decipher and
The PKI of the digital certificate needed for checking and privacy key the most all comprise respectively in digital certificate files and privacy key file, it is to be understood that
In the embodiment shown in Fig. 3 to Fig. 5, the file merged in step S3 has further included digital certificate and privacy key (or secret encryption key).
By above-mentioned diagram and description, the method for the generation license file in the method for protecting software of the present invention is described in detail, below
In conjunction with diagram, the method for the license file verification in embodiment illustrated in fig. 1 will be described in detail.
Refer to Fig. 6, Fig. 6 and illustrate the license file verification method flow diagram that a preferred embodiment of the present invention is provided.Testing in the present embodiment
Card method, is the verification method of the license file generated for embodiment illustrated in fig. 2, as shown in Figure 6, license file verification method bag
Include following steps:
A1, parses bootstrap and license information from license file.Specifically, when software product starts, owing to starting journey
Sequence is separated and is merged and is written in License file, cannot be completed the normal startup of software product by normal approach, so Java must be passed through
The bottom ClassLoader extension mechanism that virtual machine provides, extension realizes self-defining ClassLoader, self-defined ClassLoader takes over
Java Virtual Machine is to starting loading and the process of execution of program, by the rewriting to findclass method, according to self-defined byte code files rule,
License file is resolved, restores bootstrap, perform bootstrap.
A2, performs the license proving program in bootstrap, verifies license information.After bootstrap is resolved and restores
Then can perform bootstrap, in embodiments of the invention, after bootstrap is performed, begin to be taken over whole start-up course by bootstrap.Draw
License information is the most first resolved reduction from license file by helical pitch sequence, then by internal license proving program pair
License information is verified.Wherein, in embodiments of the invention, license proving program can by the way of validity verification or effectively
License information is verified by the mode of phase and marc address binding, but the present invention is not limited to this, it is also possible to entered by other verification modes
Row checking.
By license proving program, license information is verified, according to the result, select follow-up processing mode, if being verified,
Then perform the startup program in bootstrap, and then run main body program, to complete the normal startup of software product;If checking is not passed through, the most directly
The execution of escape leading program, software product will be unable to start.
License file verification method provided in the embodiment of the present invention, need to first call self defined class loader, according to generating license file
Time the self-defined byte code files rule that used license file carries out resolving reduction, then performed license proving program by bootstrap,
To complete the checking of license information.Obtaining before license information authentication results, either the startup program of software product or main body journey
Sequence, all without there being any action, thus the checking avoiding license information is bypassed, and software product is provided protection.
In verification method for the license file generated in Fig. 3 to embodiment illustrated in fig. 5, further include the numeral card in license file
Book and privacy key (or secret encryption key) resolve, and are decrypted bootstrap, license information and corresponding digital digest
Process with checking, it can be seen that, the verification method of license file is different, further by the difference along with license document generating method
Improve the difficulty that license proving program is cracked or walks around.
In sum, by the improvement to license file in method for protecting software provided by the present invention, and strictly license file is tested
Card process carries out management and control, improves license file and cracks difficulty, and the difficulty that software product is modified.For instance, if it is desired to crack figure
The license file generated in 5 illustrated embodiments, it is necessary first to the self-defined bytecode structure of correct understanding license file, the most complete
Parse all modules, forge PKI, private key, privacy key, License information, and according to the regular and self-defined byte of encryption logic
Code document convention regenerates License file or decompiling restores bootstrap, extracts the startup-program code in bootstrap, translates main body
Program, joins startup code in software agent, thus walks around License checking procedure, it can be seen that, cracking programs is extremely complex, difficulty
The highest.
More further, in order to more preferably provide protection to software product, license file can be written in the mobile memories such as USBKey,
And in the findclass method of self defined class loader ClassLoader, perform to read the step of License file from USBKey, thus
Complete to guide and proof procedure.