A kind of method for protecting software and device
Technical field
The present invention relates to the software protection field, particularly relate to a kind of method and device by proof procedure protection software.
Background technology
Along with the development of infotech, software industry also more and more is subject to people's attention, and various system softwares and application software emerge in an endless stream.Usually, the software developer need drop into the research and development that huge manpower and materials are carried out software.But in case the software development success, the bootlegger only need spend a spot of energy just can copy also sale at a low price, greatly hits the development that people are engaged in the enthusiasm and the serious obstruction software industry of software development.
Pirate to protect the intellectual property in order to contain, industry has been released a series of Software Protection Technique.Wherein, when software startup, carrying out the rights of using checking according to the sign of user profile, product ID, digital signature and/or running software carrier is method for protecting software commonly used at present, if the verification passes, then allows to carry out the operation of software; If checking can't pass, then return information, do not allow to move the limited operation that described software or masked segment function only allow software.
Seeing also Fig. 1, is a kind of flow process of method for protecting software of prior art.
When protected software initialization, will trigger authentication unit and start proof procedure: at first, obtain the information such as sign of user profile, product ID, digital signature and/or running software carrier; Secondly, the rreturn value generation unit is verified according to the sign of user profile, product ID, digital signature and/or running software carrier, generates rreturn value; Whether subsequently, comparing unit compares according to described rreturn value, pass through to judge checking, if then allow the described software of operation to carry out business processing; If not, then carry out authentication failed and handle, as return information, do not allow to move the limited operation that described software or masked segment function only allow software.
The method for protecting software of described prior art has some defectives: owing to only handle when software initialization; and directly judge by comparing unit usually according to rreturn value; if the assailant follows the tracks of the proof procedure of software; just can be by revising the rreturn value of these proof procedures; perhaps change some compare operation; make and always return checking in the proof procedure and pass through, thereby cause the assailant can thoroughly walk around proof procedure, and need not to pay close attention to other verification operation details.
Summary of the invention
The technical matters that the present invention solves is to provide a kind of increasing to attack difficulty to improve the method for protecting software and the device of security.
For this reason, the technical scheme of technical solution problem of the present invention is: a kind of method for protecting software is provided, chooses scrambler storage unit as a result, this method may further comprise the steps:
1) generate validation value when described software startup, generate the scrambler result according to described validation value, described scrambler result is stored in described scrambler as a result in the storage unit;
2) judge that whether validation value is whether predetermined value or checking scrambler result be correct, in this way, then enters step 3); As not, then carry out the limited operation of described software or do not allow to move described software;
3) move described software, and start timer;
4) judge whether aforementioned timer arrives predetermined period, in this way, then enter step 5); As not, then do not operate;
5) aforementioned scrambler result is carried out verification, judge whether verification is passed through, in this way, then return step 4); As not, then withdraw from the operation of described software or carry out the limited operation of described software.
Wherein, in the described step 1), generate the scrambler result and specifically comprise:
11) generate pseudo random number;
12) utilize described pseudo random number that validation value is carried out conversion, generate first transformation results.
Wherein, described step 12) specifically comprises pseudo random number and validation value addition; Addition result is carried out hash conversion.
Wherein, be character string with the hash conversion result as character string or with hash conversion result's value transform, described character string i.e. first transformation results.
Wherein, described step 5) specifically comprises:
51) the scrambler result is carried out map function, generate second transformation results;
52) obtain check results according to aforementioned first transformation results and second transformation results;
53) judge whether check results is predetermined value.
Wherein, map function is a hash conversion described step 51); Described step 52) in first transformation results and second transformation results are carried out the step-by-step XOR.
The present invention also provides a kind of software protecting equipment that is used to realize the described method for protecting software of claim 1, comprising: the validation value generation unit is used for generating validation value when described software startup; Comparing unit, whether be used for the comparatively validate value is predetermined value; Also comprise: scrambler is generation unit as a result, is used for generating the scrambler result according to the aforementioned authentication value; Scrambler is storage unit as a result, is used to store described scrambler result; Timer is used for triggering verification unit when described running software; Verification unit is used for when software startup or timer arrival predetermined period aforementioned scrambler result being carried out verification.
Wherein, described validation value generation unit and comparing unit become one.
With respect to prior art; the invention has the beneficial effects as follows: at first; because carrying out scrambler to the validation value that returns, the present invention handles; generate the scrambler result; and timer is set when running software, when timer arrives predetermined period, the scrambler result is carried out verification, promptly regularly the scrambler result is carried out verification; carry out difficulty of attacking and improve security at the validation value that returns thereby increase the assailant, realize software protection.Secondly, because the present invention carries out timing verification to the scrambler result, rather than regenerate validation value and validation value is judged the speed of timing verification is higher.Secondly, in an embodiment of the invention, when software startup the scrambler result is carried out verification, prior art is verified rreturn value when software startup relatively, has increased at the rreturn value difficulty of attacking.
Description of drawings
Fig. 1 is a kind of process flow diagram of method for protecting software of prior art;
Fig. 2 is the theory diagram of software protecting equipment of the present invention;
Fig. 3 is the process flow diagram of method for protecting software of the present invention;
Fig. 4 is the process flow diagram of method for protecting software embodiment of the present invention;
Fig. 5 is the process flow diagram that scrambler is handled in the flow process shown in Figure 4;
Fig. 6 is the process flow diagram of scrambler verification as a result in the flow process shown in Figure 4.
Embodiment
Method for protecting software of the present invention and device be by carrying out scrambler and handle and the scrambler result is carried out timing verification to the validation value that returns, the effectively attack carried out at rreturn value of defensive attack person, thus realization is to the protection of software.
Seeing also Fig. 2, is the theory diagram of using the software protecting equipment of method for protecting software of the present invention.Described software protecting equipment comprises validation value generation unit 110, comparing unit 120, scrambler generation unit 130, timer 140 and verification unit 150 as a result; Described validation value generation unit 110 is used for obtaining information and generating validation value from data handling system 200 when protected software startup; Whether described comparing unit 120 is used for the comparatively validate value is predetermined value and the operation that influences data handling system 200; Described scrambler generation unit 130 as a result is used for generating the scrambler result according to the aforementioned authentication value; Described timer 140 is used for triggering verification unit 150 when described running software; Described verification unit 150 is used for when software startup or timer arrival predetermined period aforementioned scrambler result being carried out verification, and influences the operation of data handling system 200.
Need to prove that described validation value generation unit 110 and comparing unit 120 can integrate.
Seeing also Fig. 3, is the process flow diagram of method for protecting software of the present invention.
At first, implementation step S1, validation value generation unit 110 generate validation value when described software startup, and scrambler as a result generation unit 130 generate the scrambler result according to described validation value;
Step S2 judges that whether checking is passed through, and in this way, then enters step S3; As not, then do not allow the data handling system 200 described softwares of operation or carry out the limited operation of described software;
Step S3 allows the described software of operation, and starts timer 140;
Step S4 judges whether aforementioned timer 140 arrives predetermined period, in this way, then enters step S5, as not, does not then operate;
Step S5,150 couples of aforementioned scrambler results of verification unit carry out verification, judge whether verification is passed through, and in this way, then return step S4; As not, then data handling system 200 withdraws from the operation of described software or carries out the limited operation of described software.
Need to prove, among the described step S2, judge when whether checking is passed through, can adopt 120 pairs of validation values of comparing unit to compare, also can adopt 150 couples of scrambler results of verification unit to carry out verification.
For the ease of the understanding of the present invention, the present invention is described in further detail below in conjunction with embodiment.
See also Fig. 4, when protected software initialization, at first execution in step S11 selectes scrambler storage unit as a result, and described scrambler storage unit as a result comprises first memory block and second memory block.
Subsequently, among the step S12, the validation value generation unit generates validation value rtValue according to the sign of user profile, product ID, digital signature and/or running software carrier.
Consult Fig. 5 in the lump, scrambler generation unit as a result produces a length and the first memory block width consistent (as 32 s') pseudo random number rtResult.ulData1, and it is kept at first memory block; Utilize described pseudo random number rtResult.ulData1 that validation value rtValue is carried out conversion, generate the first transformation results rtResult.ulData2, the described first transformation results rtResult.ulData2 is kept at second memory block.The described pseudo random number rtResult.ulData1 and the first transformation results rtResult.ulData2 form scrambler rtResult as a result.
In the present embodiment, H (rtResult.ulData1+rtValue) _ 32 is adopted in described map function, be about to pseudo random number rtResult.ulData1 and validation value rtValue addition, its result carried out the HASH conversion, get at last HASH result preceding 32 as a signless integer.
Be understandable that two kinds of processing modes to be arranged for the raw data of HASH conversion: one, with 32 integer rtResult.ulData1+rtValue as one 4 byte long character string; Its two, be a character string with the value transform of 32 integer rtResult.ulData1+rtValue.
Step S13, comparing unit compares validation value rtValue, judges whether validation value rtValue is predetermined value, and in this way, then execution in step S14 is passed through in the expression checking; As not, represent then to verify and do not pass through that will carry out authentication failed and handle, the partial function that withdraws from running software or shielding software carries out the limited operation of software.
Step S14 allows running software to carry out business processing, starts timer.The cycle of timer can be selected voluntarily according to the characteristics of software runtime environment.
Step S15 judges whether timer arrives predetermined period, in this way, then enters step S16; As not, then do not carry out any operation, do not influence the normal operation of software.
Consult Fig. 6 in the lump, step S16 when timer arrives predetermined period, carries out verification to the scrambler result.Concrete checking procedure comprises: at first, from scrambler as a result storage unit read the scrambler result; Carry out map function, generate the second transformation results H (rtResult.ulData1+1) _ 32, be about to pseudo random number rtResult.ulData1 and add 1, its result is carried out the HASH conversion, get at last HASH result preceding 32 as a signless integer; Then the second transformation results H (rtResult.ulData1+1) _ 32 and the first transformation results rtResult.ulData2 are carried out " step-by-step XOR ", generate check results H (rtResult.ulData1+1) _ 32^rtResult.ulData2; At last, judge that whether check results is predetermined value, judges whether verification is passed through, and in this way, then returns step S15; As not, then withdraw from the operation of described software or carry out the limited operation of described software.
In the present embodiment, set and have only when protected validation value rtValue is 1, scrambler verification does not as a result pass through.Therefore,, represent that then protected validation value is 1, just mean that also the scrambler check results do not pass through if last check results is 0.
The above only is a preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.