CN100557618C - A kind of method that in computer program, embeds and extract watermark - Google Patents

A kind of method that in computer program, embeds and extract watermark Download PDF

Info

Publication number
CN100557618C
CN100557618C CNB2008101193580A CN200810119358A CN100557618C CN 100557618 C CN100557618 C CN 100557618C CN B2008101193580 A CNB2008101193580 A CN B2008101193580A CN 200810119358 A CN200810119358 A CN 200810119358A CN 100557618 C CN100557618 C CN 100557618C
Authority
CN
China
Prior art keywords
cutpoint
watermark
fundamental block
embedded
mapping relations
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CNB2008101193580A
Other languages
Chinese (zh)
Other versions
CN101350055A (en
Inventor
王建民
张长江
王朝坤
李德毅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tsinghua University
Original Assignee
Tsinghua University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tsinghua University filed Critical Tsinghua University
Priority to CNB2008101193580A priority Critical patent/CN100557618C/en
Publication of CN101350055A publication Critical patent/CN101350055A/en
Application granted granted Critical
Publication of CN100557618C publication Critical patent/CN100557618C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The present invention relates to a kind of method that in computer program, embeds and extract watermark, belong to the software copyright protection technical field.In the inventive method, the process of embed watermark is: watermark and key are separately converted to big integer w and k, and w and k are converted to the integer array W[of dull non-decreasing respectively with n element] and K[], at W[] and K[] each to setting up m mapping relations between the elements corresponding, the method of selection watermark to be embedded from computer program is created the mapping relations code and is embedded into the cutpoint place that controls flow graph with the method for selected watermark to be embedded respectively then; The process of extracting watermark is: read in the cutpoint in each method control flow graph in the computer program successively and judge, if satisfy extraction conditions, then extract the mapping relations code from this cutpoint, extract assisted class according to one of all mapping relations code establishing that extract, read in the extraction key, assisted class is extracted in operation, shows to extract the result.

Description

A kind of method that in computer program, embeds and extract watermark
Technical field
The present invention relates to a kind of method that in computer program, embeds and extract watermark, relate in particular to a kind of method that in the Java binary code program, embeds and extract watermark, belong to the software copyright protection technical field.
Background technology
Development along with the embedded device of computer network, distributed system and networking; platform-neutral and portability to software had had than higher, more urgent in the past requirement; but also brought the problem of secure context; wherein, Software Intellectual Property Rights protection problem is a hot issue always.Research software copyright protection technology all has very important meaning for protection computer software copyright owners' rights and interests, the exploitation of encouragement computer software and the development of application, promotion software industry and IT application in the national economy.
Software watermark is meant the one section information with sign meaning that is embedded in the software not perceivedly, can be used for the intellecture property ownership of certifying software.Under some particular conditions, software watermark also can be used for following the tracks of illegally to be usurped.The software watermark technology belongs to a kind of typical software copyright protection technology.
Summary of the invention
The objective of the invention is to propose a kind of method that embeds and extract watermark in computer program, this method is based on unique point---the semanteme of cutpoint and program of computer program control flow graph.Water mark method different from the past in the method, by set up setting the mapping relations of number between watermark and key, and is embedded in the form of these mapping relations with code and the corresponding fundamental block of programmed control flow graph cutpoint place.
The method that embeds and extract watermark in computer program that the present invention proposes may further comprise the steps:
The process of embed watermark is:
(1) copyright information and the key information with the computer program copyright people is separately converted to an integer digit strings, is designated as w and k respectively, and w and k are big integers;
(2) above-mentioned w and k are converted to the integer array W[of dull non-decreasing respectively with n element] and K[], n is the integer that watermark embedding person sets, 1≤i≤n-1, and concrete transfer process is:
(2-1) set one arbitrarily, obtain and satisfy inequality greater than 1 integer q w ≤ ( q l - 1 ) Σ j = 0 n - 2 q jl Integer l, and satisfy inequality k ≤ ( q p - 1 ) Σ j = 0 n - 2 q jp Integer p;
(2-2) according to equation w = Σ j = 0 n - 2 v j q jl , k = Σ j = 0 n - 2 u j q jp Obtain coefficient v respectively 0, v 1..., v N-2And u 0, u 1..., u N-2, wherein, for 0≤j≤n-2, coefficient v jBe integer and satisfied: 0≤v j<q l, coefficient u jBe integer and satisfied: 0≤u j<q p
(2-3) make W[0]=l-1, K[0]=p-1, to 1≤i≤n-1, obtain W[i]=W[i-1]+v I-1, K[i]=K[i-1]+u I-1
(3) at the above-mentioned copyright information integer array W[that is converted to] and key information integer array K[] each set up m mapping relations between to corresponding element, m is another integer that watermark embedding person sets, and obtains a set with m * n mapping relations;
(4) method of selection watermark to be embedded from computer program, its process is:
(4-1) method of setting up a watermark to be embedded is gathered, and reads in a method from computer program;
(4-1-1) make up the control flow graph of this method of reading in according to the control stream of the method for reading in, and the parent map of controlled flow graph, obtain the set of all cutpoints in this parent map;
(4-1-2) set is judged to cutpoint, if empty set then changes step (4-1-5) over to, if be not empty set, then reads a cutpoint in the above-mentioned cutpoint set;
(4-1-3) cutpoint that reads is judged, if meet: the fundamental block in the control flow graph corresponding with this cutpoint that reads can be split into two fundamental blocks, and between two fundamental blocks, insert after the new fundamental block, two fundamental blocks become adjacent cutpoint in new control flow graph, then but this cutpoint that reads is the cutpoint of embed watermark, but write down entry position with the corresponding fundamental block of cutpoint that is somebody's turn to do embed watermark, and above-mentioned method of reading in is joined in the method set of watermark to be embedded, change step (4-1-5) over to, if do not meet, change step (4-1-4) over to;
(4-1-4) above-mentioned cutpoint set is judged,, then changed over to step (4-1-5) if all cutpoint traversals of this cutpoint set finish, otherwise, read the next cutpoint in this cutpoint set, change step (4-1-3) over to;
(4-1-5), then change step (4-2) over to if the traversal of all methods in the computer program finishes, otherwise, reading in next method in the computer program, repeating step (4-1-1) is to step (4-1-4), all methods in the traversal computer program;
But (4-2) judge the cutpoint number of embed watermark, if be less than m * n, then from computer program, select a not method in the method set of watermark to be embedded arbitrarily, with the corresponding control flow graph of method selected in add new branch, but make the control flow graph that has added new branch contain the cutpoint of embed watermark, but record and entry position owing to the corresponding fundamental block of cutpoint that has added the embed watermark that new branch contains, and amended this method selected is joined in the method set of above-mentioned watermark to be embedded, repeat in this step with top all methods in the method set of watermark to be embedded not in the traversal computer program;
But (4-3) judge the cutpoint number of embed watermark, if still be less than m * n, then from the method set of above-mentioned watermark to be embedded, select a method at random, read in another cutpoint according to the process in the above-mentioned steps (4-1), but find the cutpoint of an embed watermark, but and the entry position of the corresponding fundamental block of cutpoint of record and the embed watermark that finds, but if do not find the cutpoint of embed watermark, then in the method body of selecting at random, add the auxiliary code of the control stream that changes this method of selecting at random, but make the cutpoint that contains new embed watermark in the control flow graph of the method that this is selected at random, but and the entry position of the corresponding fundamental block of cutpoint of record and this new embed watermark, repeat in this step with top, but reach m * n until the cutpoint number of embed watermark;
(5) mapping relations are embedded in the method for selected watermark to be embedded, its process is:
(5-1) from mapping relations set, select mapping relations, from the method set of above-mentioned watermark to be embedded, select the method for a watermark to be embedded, but and read the cutpoint of an embed watermark in the method for watermark to be embedded;
(5-2) increase a plurality of integer local variables for the method for watermark to be embedded, the local variable that makes numbering minimum in the local variable that increases newly is corresponding to the independent variable in the mapping relations, the local variable of numbering maximum is corresponding to the dependent variable in the mapping relations, create local variable initialization directive and the operational order relevant with mapping relations, and operational order is associated with local variable, obtain the mapping relations code;
(5-3) will split into two fundamental block b with the corresponding fundamental block of the cutpoint that from the method for watermark to be embedded, reads 1, b 2, and with the mapping relations code that makes up with a fundamental block b 3Be inserted into b 1And b 2Between, make fundamental block b 1, b 2, b 3Satisfy: fundamental block b 1Jumping is to fundamental block b 2And b 3, fundamental block b 3Jumping is to fundamental block b 2
(5-4) read next mapping relations, but judge the cutpoint whether new embed watermark is arranged in the method for watermark to be embedded,, but then read the cutpoint of next one embed watermark in the method for watermark to be embedded if having, and repeating step (5-2) and step (5-3), finish the embedding of mapping relations code; If do not have, then read the method for next watermark to be embedded, but read the cutpoint of an embed watermark in the method for this next one watermark to be embedded, and repeat above step (5-2) and (5-3), finish the embedding of mapping relations code;
(5-5) repeating step (5-4) is embedded in the computer program until all mapping relations codes;
The process of extracting watermark is:
(6) method of setting up a watermark to be extracted is gathered;
(7) read a method in the computer program, control stream according to the method that reads makes up and the corresponding control flow graph of this method that reads, obtain corresponding parent map, obtain all cutpoints of parent map, obtain a cutpoint set, read the cutpoint in the cutpoint set successively and judge, if with the fundamental block b that reads in the corresponding control flow graph of cutpoint 4Satisfy: b 4Jump target be two fundamental block b 5And b 6, and fundamental block b 5Also be cutpoint b 6Be not cutpoint, while fundamental block b 5Be fundamental block b 6Jump target, or fundamental block b 6Also be cutpoint b 5Be not cutpoint, while fundamental block b 6Be fundamental block b 5Jump target, then to not doing further to judge for the cutpoint fundamental block, if satisfy: this is consistent for local variable number and type in the mapping relations code of the local variable number that contains in the cutpoint fundamental block and type and structure, then from computer program, extract this and be not the operational order that comprises in the cutpoint fundamental block and the initial value of all local variables, and make up a new method according to the initial value of operational order and local variable, concrete building process is as follows: to order numbering by size above-mentioned is not that local variable in the cutpoint fundamental block is again from 0 open numbering, making the minimum local variable of numbering is the input parameter of new method, the value of the local variable that numbering is maximum is the rreturn value of new method, makes the operational order of the operational order of extraction as new method;
(8) said new method is joined in the method set of above-mentioned watermark to be extracted;
(9) repeat above-mentioned steps (7) and (8), all the method traversals in computer program finish;
(10) according to the method set of above-mentioned watermark to be extracted, create and extract assisted class, extract key, and parse copyright information;
(11) use the method identical with (2), user's key information is converted to the integer array g[of dull non-decreasing] with n element with above-mentioned steps (1);
(12) read above-mentioned integer array g[successively] in each integer, and respectively with the input of the integer that reads as each method in the said extracted assisted class, obtain to extract the rreturn value of each method operation in the assisted class, if the number of identical rreturn value is less than m, it is wrong then to extract key, extract failure,, then should identical rreturn value join integer array h[if the number of identical rreturn value is more than or equal to m] in;
(13) judge integer array h[] whether be dull non-decreasing, if not, then show and extract failure, if then make above-mentioned l=h[0]+1, to 0≤j≤n-2, make v j=h[j+1]-h[j], according to formula w = Σ j = 0 n - 2 v j q jl Obtain a big integer w, big integer w as an integer digit strings, is reduced into original character string, show that copyright information also extracts successfully.
The method that embeds and extract watermark in computer program that the present invention proposes has the following advantages:
(1) in the method that the present invention proposes, embed watermark information neither, also embedded key information not, but mapping relations between the two are embedded in the computer program, thereby between watermark and key, set up a kind of dependence of novelty, given key new implication, function and use-pattern in the watermark field;
(2) method of the present invention's proposition is a kind of software watermark process based on the figure theory of novelty, the embedding of code and extraction all are based on feature node---the cutpoint of control flow graph, do not need in the telescopiny code that embeds is carried out painstakingly mark, and extraction efficiency is also very high;
(3) in the method that the present invention proposes, the embedding of mapping relations code participates in the operation of program, thereby the mapping relations code is disguised relatively good, can resist the performance analysis attack; Simultaneously, the information such as title of class, method, field are irrelevant in the embedding of mapping relations code and the computer program, thereby come embed watermark with the method example that the present invention proposes, and can resist morphology and obscure attack;
(4) in the method that the present invention proposes, the embedding of mapping relations code can not cause the significantly increase of program volume, can not cause the obvious decline of program run performance yet, good concealment, and it is convenient to extract, and especially is fit to the copyright protection of large program.
Description of drawings
But Fig. 1 is the FB(flow block) of initial option embed watermark cutpoint in the embed watermark process.
But Fig. 2 is a FB(flow block) of further selecting the embed watermark cutpoint in the embed watermark process.
Fig. 3 is the FB(flow block) that embeds the mapping relations code in the embed watermark process.
Fig. 4 is the synoptic diagram that embeds the mapping relations code at the cutpoint place of method control flow graph.
Fig. 5 does not have the control flow graph of cutpoint to add the synoptic diagram that branch makes it to contain cutpoint to one.
Fig. 6 extracts the FB(flow block) of extracting the mapping relations code in the watermark process.
Fig. 7 extracts the FB(flow block) of resolving copyright information in the watermark process.
Embodiment
In the method that the present invention proposes, but the process of its embed watermark mainly comprises the cutpoint position that splits copyright information and key information, structure mapping relations, selection embed watermark and embeds four steps of mapping relations code.
(1) copyright information and the key information with the computer program copyright people is separately converted to an integer digit strings, is designated as w and k respectively, and w and k are big integers.In the present embodiment, split the process of copyright information and key information, as shown in Figure 1.An at first self-defined digital collection, this set can comprise any one conventional characters, comprises numeral, letter etc.For example, the definition digital collection: 10,11 ..., 36,37,38 ..., 61 ... 90,91 ..., 99}, this digital collection can be represented character set { a respectively, b ..., z, A, B, ..., Z ..., 0,1, ..., each element among the 9}, the element a in the element in the digital collection 10 expression character sets wherein, the element b in the element 11 expression character sets in the digital collection, other are analogized.According to above-mentioned definition, convert copyright information and key information to digit strings respectively then, promptly each character in copyright information and the key information is converted to elements corresponding in the digital collection respectively.For example, copyright information is abc, and key information is 123, after then passing through this conversion, the digit strings of copyright information correspondence is 101112, and the digit strings of key information correspondence is 919293, this digit strings is designated as w and k respectively, i.e. w=101112, k=919293.
(2) above-mentioned w and k are converted to the integer array W[of dull non-decreasing respectively with n element] and K[], n is the round values that watermark embedding person sets here, in order to the number of element in the expression integer array, concrete transfer process is:
(2-1) set arbitrarily q be one greater than 1 integer, obtain and satisfy inequality: w ≤ ( q l - 1 ) Σ j = 0 n - 2 q jl , Promptly satisfy w≤q (n-1) lAn integer l of-1, and obtain and satisfy inequality: k ≤ ( q p - 1 ) Σ j = 0 n - 2 q jp , Promptly satisfy k≤q (n-1) pAn integer p of-1;
(2-2) according to equation w = Σ j = 0 n - 2 v j q jl , k = Σ j = 0 n - 2 u j q jp Obtain coefficient v respectively 0, v 1..., v N-2And u 0, u 1..., u N-2, wherein, for 0≤j≤n-2, coefficient v jBe integer and satisfied: 0≤v j<q l, coefficient u jBe integer and satisfied: 0≤u j<q p
(2-3) make W[0]=l-1, K[0]=p-1; (4) to 1≤i≤n-1, make W[i]=W[i-1]+v I-1, K[i]=K[i-1]+u I-1
In the present embodiment, suppose n=10, q=2, then for w=101112, root root inequality w ≤ Σ j = 0 n - 2 q ( j + 1 ) l Obtain integer l 〉=2, l gets minimum value 2, and makes W[0]=l-1=1, according to equation w = Σ j = 0 n - 2 v j q jl Obtain coefficient and be respectively v 0, v 1..., v 8Be respectively: 0,2,3,3,2,2,0,2,1, owing to, W[i is arranged to 1≤i≤n-1]=W[i-1]+v I-1So, just can obtain the integer array that copyright information is converted to and be: 1,1,3,6,9,11,13,13,15,16}, similarly, the integer array that k=919293 is converted into is: 2,7,14,17,20,20,24,27,27,27}.
(3) at the above-mentioned copyright information integer array W[that is converted to] and key information integer array K[] each set up m mapping relations between to corresponding element, here m is another integer that watermark embedding person sets, whether distorted in order to determining program in watermark extraction process, obtained a set with m * n mapping relations.In the present embodiment, the process that makes up mapping relations is: (3-1) create a mapping relations template base H, H={f (x)=a rx r+ a R-1x R-1+ ...+a 1x 1+ a 0, r ∈ N, a j∈ Z, 0≤j≤r}, wherein, r represents the template base radix set to satisfy r 〉=log 2M gets final product, and template base H has defined the template form of the mapping relations that make up, and in the present embodiment, specifies m=3, and then r=2 can satisfy condition, drawing template establishment storehouse H={f (x)=a 2x 2+ a 1X+a 0, a 2* a 1≠ 0} ∪ { f (x)=a 2x 2+ a 0, a 2≠ 0} ∪ { f (x)=a 1X+a 0, a 1≠ 0} has 3 kinds of templates among the H, represent 3 kinds of different mapping relations respectively; (3-2) for 1≤i≤n, at each to element K[i] and W[i] between m mapping relations of structure, each mapping relations is all taken from different mapping relations templates, the template form of note h (f) expression mapping relationship f, and remember F={f Ij| W[i]=f Ij(K[i]), 1≤i≤n, 1≤j≤m, h (f Ij) ∈ H} represents the set of m * n mapping relations constructing.In the present embodiment, when making up concrete mapping relations, at K[i] and W[i] between m mapping relations of structure take from the individual different template of m in the template base respectively, and the appointment independent variable is K[i], dependent variable is W[i], then with x=K[i] and f (x)=W[i] expression formula of each template in the substitution template base respectively, obtain corresponding coefficient a in each template j, concrete solution procedure is as follows: a r=[f (x)/x] is if a r=0, then make a rGet the random number in the certain limit; To 1≤j≤r-1, a j=[(f (x)-a rx r-a R-1x R-1-...-a J+1x J+1)/x], if a r=0, then make a rGet the random number in the certain limit; a 0=f (x)-a rx r-a R-1x R-1-...-a 1x 1
K[0 for example]=2, W[0]=1, so x=K[0 is arranged], f (x)=W[0], substitution template f (x)=a 1X+a 0, try to achieve a 1=[W[0]/K[0]]=[1/2]=0, the random number that obtains in the certain limit is composed to a 1, suppose a here 1=1, a 0=W[0]-a 1* K[0]=1-1 * 2=-1, so first mapping relations of structure are f 1(x)=and x-1, can obtain f equally 2(x)=x 2-3, f 3(x)=x 2+ x-5, the template form of these three mapping relations is respectively { f (x)=a 1X+b, a 1≠ 0}, { f (x)=a 2x 2+ b, a 2≠ 0}, { f (x)=a 2x 2+ a 1X+b, a 1≠ 0, a 2≠ 0};
But the synoptic diagram of the cutpoint position of selection embed watermark as depicted in figs. 1 and 2.Cutpoint also is articulation point, for the non-directed graph G=that is communicated with (V, E), if there is a different set of node e 1, e 2, e 3Satisfy from e 1To e 3All paths all pass through node e 2, node e so 2The cutpoint that just is called figure G, in other words, if e 2Be cutpoint, from figure G, delete node e so 2After, G will become two or more a plurality of connected component.Whether a node is that cutpoint can be judged by following theorem: suppose that (V E) is undirected connected graph to G=, and (V T) is the depth-first search generation tree of figure G, then node e to S= 2Be the cutpoint of G, and if only if, and following condition is set up: node e 2Be the root node of S and have more than a size child node, perhaps node e 2Be not root node, the root of its certain stalk tree and other node in this subtree all do not point to node e 2The back edge of ancestors' node.
(4) from computer program, select the method for watermark to be embedded, but and obtain the cutpoint of embed watermark in this method control flow graph, concrete process is:
(4-1) from computer program, read in a method;
(4-1-1) make up the control flow graph of this method, and obtain its parent map (ignoring the non-directed graph that the directivity on limit in this control flow graph obtains), obtain the set of all cutpoints in this parent map according to the control of this method stream;
(4-1-2) above-mentioned cutpoint set is judged,, then changed over to step (4-1-5),, then read a cutpoint in the above-mentioned cutpoint set if be not empty if empty;
(4-1-3) the above-mentioned cutpoint that reads is judged, if meet: the fundamental block in the control flow graph corresponding with this cutpoint can be split into two fundamental blocks, and between two fundamental blocks, insert after the new fundamental block, two fundamental blocks become adjacent cutpoint in new control flow graph, then but this cutpoint that reads is the cutpoint of embed watermark, but write down entry position with the corresponding fundamental block of cutpoint that is somebody's turn to do embed watermark, and above-mentioned method of reading in is joined in the method set of watermark to be embedded, change step (4-1-5) over to, if do not meet, change step (4-1-4) over to;
(4-1-4) above-mentioned cutpoint set is judged,, then changed over to step (4-1-5) if all cutpoint traversals of this cutpoint set finish, otherwise, read the next cutpoint in this cutpoint set, change step (4-1-3) over to;
(4-1-5), then change step (4-2) over to if the traversal of all methods in the computer program finishes, otherwise, reading in next method in the computer program, repeating step (4-1-1) is to step (4-1-4), all methods in the traversal computer program;
But (4-2) judge the cutpoint number of the embed watermark of above-mentioned record, if be less than m * n, then from computer program, select a not method in the method set of watermark to be embedded arbitrarily, as shown in Figure 2, then with the corresponding control flow graph of this system of selection in add new branch, but make this control flow graph contain the cutpoint of embed watermark, but write down entry position with the corresponding fundamental block of cutpoint that is somebody's turn to do embed watermark, and this amended system of selection is joined in the method set of above-mentioned watermark to be embedded, repeat above step all methods in the method set of watermark to be embedded not in the traversal computer program;
In the present embodiment, the detailed process of adding new branch as shown in Figure 4.In Fig. 4, at first the fundamental block with node d correspondence splits into two fundamental block d 1And d 2, add two new fundamental block w then 1And w 2, make d 1Jump target be w 1And w 2, w 1And w 2Jump target all be d 2, d 2Jump target be the jump target of the fundamental block of former node d correspondence.Through after such adjustment, node d 1But just become the control flow graph cutpoint of an embed watermark.
But (4-3) judge the cutpoint number of above-mentioned embed watermark, if still be less than m * n, then from the method set of above-mentioned watermark to be embedded, select a method at random, read the cutpoint set in the parent map of this method control flow graph, read a cutpoint that is not recorded as yet in this cutpoint set, this cutpoint is judged, if meet: the fundamental block in the control flow graph corresponding with this cutpoint can be split into two fundamental blocks, and between two fundamental blocks, insert after the new fundamental block, two fundamental blocks become adjacent cutpoint in new control flow graph, then but this cutpoint that reads is the cutpoint of embed watermark, but write down entry position with the corresponding fundamental block of cutpoint that is somebody's turn to do embed watermark, if do not meet, then read the cutpoint that the next one in the cutpoint set is not recorded as yet, and this cutpoint carried out same judgement, but finish until cutpoint that in this cutpoint set, finds a new embed watermark or the cutpoint traversal in the set of this cutpoint, but if when this cutpoint set traversal finishes, do not find the cutpoint of embed watermark yet, then in this method body, add the auxiliary code that can change this method control stream, but make the cutpoint that contains new embed watermark in the control flow graph of this method, but and the entry position of the corresponding fundamental block of cutpoint of record and this new embed watermark, repeat above step, but reach m * n until the cutpoint number of embed watermark;
(5) above-mentioned mapping relations are embedded in the method for above-mentioned selected watermark to be embedded, its process may further comprise the steps as shown in Figure 3:
(5-1) from the set of above-mentioned mapping relations, select mapping relations, from the method set of above-mentioned watermark to be embedded, select a method, but and the cutpoint of an embed watermark in the read method;
(5-2) increase a plurality of integer local variables for above-mentioned system of selection, the local variable that makes numbering minimum in the local variable that increases newly is corresponding to the independent variable in the mapping relations, the local variable of numbering maximum is corresponding to the variable in the mapping relations, create local variable initialization directive and the operational order relevant with mapping relations, and operational order is associated with local variable, thereby obtain the mapping relations code.In the present embodiment, be example with the java applet, suppose that the maximum local variable of current system of selection is numbered n, then for mapping relationship f 1(x)=x-1, need to give this method to increase 4 local variables newly, its reversion is respectively n, n+1, n+2, n+3, the local variable that wherein is numbered n is corresponding to the x in the mapping relations, the local variable that is numbered n+1 is corresponding to the once coefficient 1 in the mapping relations, and the local variable that is numbered n+2 is corresponding to the constant term in the mapping relations-1, and the local variable that is numbered n+3 is corresponding to the f in the mapping relations 1(x), the setup code of creating for these mapping relations is:
iconst_0
istore?n
iconst_1
istore?n+1
iconst_m1
istore?n+2
For the mapping relations code that this mapping relations are created as follows:
iload?n
iload?n+1
imul
iload?n+2
iadd
istore?n+3
(5-3) will split into two fundamental block b with the corresponding fundamental block of the above-mentioned cutpoint that reads 1, b 2, and with the mapping relations code that makes up with a fundamental block b 3Be inserted into b 1And b 2Between, make fundamental block b 1, b 2, b 3Satisfy: fundamental block b 1Jumping is to fundamental block b 2And b 3, fundamental block b 3Jumping is to fundamental block b 2In the present embodiment, after creating local variable initialization directive and mapping relations code, at first above-mentioned setup code is inserted into the head of method body, but read the cutpoint of the embed watermark of an above-mentioned record in this method then, above-mentioned mapping relations code is embedded into this cutpoint place with the form of a fundamental block, the telescopiny of mapping relations code as shown in Figure 5, in Fig. 5, but node f is the cutpoint of embed watermark in this control flow graph, and the fundamental block of cutpoint f correspondence is split into two fundamental block f 1And f 2, and the fundamental block w that will contain the mapping relations code is added between the two, makes f 1Jump target be w and f 2, the jump target of w is f 2, f 2Jump target be the jump target of the fundamental block of cutpoint f correspondence, originally jump target is that the jump target of fundamental block of the fundamental block of cutpoint f correspondence is updated to f 1Method after embedding the mapping relations code is controlled in the flow graph like this, fundamental block f 1And f 2All be cutpoint, and both are adjacent, promptly one of them is another jump target.
(5-4) read next mapping relations, but and judge the cutpoint that whether also has new embed watermark in this method, if having, but then read the cutpoint of next one embed watermark in this method, and repeating step (5-2) and step (5-3), finish the embedding of mapping relations code; If do not have, then read the method for next watermark to be embedded, but read the cutpoint of an embed watermark in this method, and repeating step (5-2) and step (5-3), finish the embedding of mapping relations code.
(5-5) repeating step (5-4) all is embedded in the computer program until all mapping relations.
In the method that the present invention proposes, the process of extracting watermark is the inverse process of embed watermark process, mainly comprises the extraction (as Fig. 6) of mapping relations code and according to extracting two steps of key-parsing copyright information (as Fig. 7).
(6) method of setting up a watermark to be extracted is gathered, read in a method in the computer program, control stream according to this method makes up and the corresponding control flow graph of this method, obtain corresponding parent map, obtain all cutpoints of parent map, obtain the set of cutpoint, read the cutpoint in the cutpoint set successively and judge, if with the fundamental block b that reads in the corresponding control flow graph of cutpoint 4Satisfy: b 4Jump target be two fundamental block b 5And b 6, and fundamental block b 5Also be cutpoint b 6Be not cutpoint, while fundamental block b 5Be fundamental block b 6Jump target, or fundamental block b 6Also be cutpoint b 5Be not cutpoint, while fundamental block b 6Be fundamental block b 5Jump target, then to not doing further to judge for the cutpoint fundamental block, if this does not satisfy for the fundamental block of cutpoint: local variable number that contains in this fundamental block and type are all consistent with local variable number and type in the mapping relations code of above-mentioned structure, then from computer program, extract the operational order that comprises in this fundamental block and the initial value of all local variables, and make up a new method according to the initial value of operational order and local variable, this method can be read in a numeric parameter and be returned a round values, concrete building process is as follows: to the local variable of order numbering by size again from 0 open numbering, making the minimum local variable of numbering is the input parameter of new method, the value of the local variable that numbering is maximum is the rreturn value of new method, and the operational order of extraction is as the operational order of new method;
(7) above-mentioned newly-generated method is added in the method set of watermark to be extracted,
(8) repeat above-mentioned steps (6) and step (7), all the method traversals in computer program finish.
(9) according to the method for above-mentioned watermark to be extracted, extract key, and parse copyright information.In one embodiment of the invention, at first use the extraction assisted class of a sky of bytecode engineering storehouse (hereinafter to be referred as Apache BCEL) establishment of Apache's software foundation issue, then with the method for above-mentioned all watermarks to be extracted all as the method in such, create a main method at last, this main method can be called the method for above-mentioned all watermarks to be extracted.
(10) according to the method for above-mentioned steps (1) and (2), user's extraction key is converted to the integer array g[of dull non-decreasing] with n element.For example, the extraction key of user's input is 123, and then being converted into the integer digit strings according to the method in the step (1) is 919293, regard it as big integer k, i.e. k=919293 is then according to the method in the step (2), k is converted to integer array g[]={ 2,7,14,17,20,20,24,27,27,27}.
(11) read above-mentioned integer array g[successively] in each integer, and respectively with the integer that reads as the input of extracting each method in the assisted class, obtain to extract the rreturn value of each method in the assisted class, if the number of identical rreturn value is less than m, it is wrong then to extract key, extracts failure; If the number of identical rreturn value is more than or equal to m, then should identical rreturn value join integer array h[] in.For example, integer array g[]=2,7,14,17,20,20,24,27,27, during 27},, as the input of extracting each method in the assisted class, then have them at least three mapping relationship f in the mapping relations of Qian Ruing for first element 2 in the array 1(x)=and x-1, f 2(x)=x 2-3, f 3(x)=x 2The method rreturn value of+x-5 correspondence all is 1, so obtain integer array h[] in the value of first element be 1, same method can be asked array h[respectively] in the value of other elements, the integer array that finally obtains is h[]={ 1,1,3,6,9,11,13,13,15,16}.
(12) judge integer array h[] whether be dull non-decreasing, if not, then show and extract failure; If then make l=h[0]+1, to 0≤j≤n-2, make v j=h[j+1]-h[j], and with v 0, v 1..., v N-2Value substitution formula
Figure C20081011935800121
In, calculate the value of big integer w, and regard big integer w as an integer digit strings and be reduced into the result of original character string display reduction and extract successfully.H[for example]={ 1,1,3,6,9,11,13,13,15,16} then obtains v 0, v 1..., v N-2Value be respectively 0,2,3,3,2,2,0,2,1, with v 0, v 1..., v N-2Value substitution formula w = Σ j = 0 n - 2 v j q jl In calculate w=101112, w can be reduced to character string abc according to the digital collection of definition in the step (1), Here it is original copyright information.

Claims (1)

1, a kind of method that embeds and extract watermark in computer program is characterized in that this method may further comprise the steps:
The process of embed watermark is:
(1) copyright information and the key information with the computer program copyright people is separately converted to an integer digit strings, is designated as w and k respectively, and w and k are big integers;
(2) above-mentioned w and k are converted to the integer array W[of dull non-decreasing respectively with n element] and K[], n is the integer that watermark embedding person sets, 1≤i≤n-1, and concrete transfer process is:
(2-1) set one arbitrarily, obtain and satisfy inequality greater than 1 integer q w ≤ ( q l - 1 ) Σ j = 0 n - 2 q jl Integer l, and satisfy inequality k ≤ ( q p - 1 ) Σ j = 0 n - 2 q jp Integer p;
(2-2) according to equation w = Σ j = 0 n - 2 v j q jl , k = Σ j = 0 n - 1 u j q jp Obtain coefficient v respectively 0, v 1..., v N-2And u 0, u 1..., u N-2, wherein, for 0≤j≤n-2, coefficient v jBe integer and satisfied: 0≤v j<q l, coefficient u jBe integer and satisfied: 0≤u j<q p
(2-3) make W[0]=l-1, K[0]=p-1, to 1≤i≤n-1, obtain W[i]=W[i-1]+v I-1, K[i]=K[i-1]+u I-1
(3) at the above-mentioned copyright information integer array W[that is converted to] and key information integer array K[] each set up m mapping relations between to corresponding element, m is another integer that watermark embedding person sets, and obtains a set with m * n mapping relations;
(4) method of selection watermark to be embedded from computer program, its process is:
(4-1) method of setting up a watermark to be embedded is gathered, and reads in a method from computer program;
(4-1-1) make up the control flow graph of this method of reading in according to the control stream of the method for reading in, and the parent map of controlled flow graph, obtain the set of all cutpoints in this parent map;
(4-1-2) set is judged to cutpoint, if empty set then changes step (4-1-5) over to, if be not empty set, then reads a cutpoint in the above-mentioned cutpoint set;
(4-1-3) cutpoint that reads is judged, if meet: the fundamental block in the control flow graph corresponding with this cutpoint that reads can be split into two fundamental blocks, and between two fundamental blocks, insert after the new fundamental block, two fundamental blocks become adjacent cutpoint in new control flow graph, then but this cutpoint that reads is the cutpoint of embed watermark, but write down entry position with the corresponding fundamental block of cutpoint that is somebody's turn to do embed watermark, and above-mentioned method of reading in is joined in the method set of watermark to be embedded, change step (4-1-5) over to, if do not meet, change step (4-1-4) over to;
(4-1-4) above-mentioned cutpoint set is judged,, then changed over to step (4-1-5) if all cutpoint traversals of this cutpoint set finish, otherwise, read the next cutpoint in this cutpoint set, change step (4-1-3) over to;
(4-1-5), then change step (4-2) over to if the traversal of all methods in the computer program finishes, otherwise, reading in next method in the computer program, repeating step (4-1-1) is to step (4-1-4), all methods in the traversal computer program;
But (4-2) judge the cutpoint number of embed watermark, if be less than m * n, then from computer program, select a not method in the method set of watermark to be embedded arbitrarily, with the corresponding control flow graph of method selected in add new branch, but make the control flow graph that has added new branch contain the cutpoint of embed watermark, but record and entry position owing to the corresponding fundamental block of cutpoint that has added the embed watermark that new branch contains, and amended this method selected is joined in the method set of above-mentioned watermark to be embedded, repeat in this step with top all methods in the method set of watermark to be embedded not in the traversal computer program;
But (4-3) judge the cutpoint number of embed watermark, if still be less than m * n, then from the method set of above-mentioned watermark to be embedded, select a method at random, read in another cutpoint according to the process in the above-mentioned steps (4-1), but find the cutpoint of an embed watermark, but and the entry position of the corresponding fundamental block of cutpoint of record and the embed watermark that finds, but if do not find the cutpoint of embed watermark, then in the method body of selecting at random, add the auxiliary code of the control stream that changes this method of selecting at random, but make the cutpoint that contains new embed watermark in the control flow graph of the method that this is selected at random, but and the entry position of the corresponding fundamental block of cutpoint of record and this new embed watermark, repeat in this step with top, but reach m * n until the cutpoint number of embed watermark;
(5) mapping relations are embedded in the method for selected watermark to be embedded, its process is:
(5-1) from mapping relations set, select mapping relations, from the method set of above-mentioned watermark to be embedded, select the method for a watermark to be embedded, but and read the cutpoint of an embed watermark in the method for watermark to be embedded;
(5-2) increase a plurality of integer local variables for the method for watermark to be embedded, the local variable that makes numbering minimum in the local variable that increases newly is corresponding to the independent variable in the mapping relations, the local variable of numbering maximum is corresponding to the dependent variable in the mapping relations, create local variable initialization directive and the operational order relevant with mapping relations, and operational order is associated with local variable, obtain the mapping relations code;
(5-3) will split into two fundamental block b with the corresponding fundamental block of the cutpoint that from the method for watermark to be embedded, reads 1, b 2, and with the mapping relations code that makes up with a fundamental block b 3Be inserted into b 1And b 2Between, make fundamental block b 1, b 2, b 3Satisfy: fundamental block b 1Jumping is to fundamental block b 2And b 3, fundamental block b 3Jumping is to fundamental block b 2
(5-4) read next mapping relations, but judge the cutpoint whether new embed watermark is arranged in the method for watermark to be embedded,, but then read the cutpoint of next one embed watermark in the method for watermark to be embedded if having, and repeating step (5-2) and step (5-3), finish the embedding of mapping relations code; If do not have, then read the method for next watermark to be embedded, but read the cutpoint of an embed watermark in the method for this next one watermark to be embedded, and repeat above step (5-2) and (5-3), finish the embedding of mapping relations code;
(5-5) repeating step (5-4) is embedded in the computer program until all mapping relations codes;
The process of extracting watermark is:
(6) method of setting up a watermark to be extracted is gathered;
(7) read a method in the computer program, control stream according to the method that reads makes up and the corresponding control flow graph of this method that reads, obtain corresponding parent map, obtain all cutpoints of parent map, obtain a cutpoint set, read the cutpoint in the cutpoint set successively and judge, if with the fundamental block b that reads in the corresponding control flow graph of cutpoint 4Satisfy: b 4Jump target be two fundamental block b 5And b 6, and fundamental block b 5Also be cutpoint b 6Be not cutpoint, while fundamental block b 5Be fundamental block b 6Jump target, or fundamental block b 6Also be cutpoint b 5Be not cutpoint, while fundamental block b 6Be fundamental block b 5Jump target, then to not doing further to judge for the cutpoint fundamental block, if satisfy: this is consistent for local variable number and type in the mapping relations code of the local variable number that contains in the cutpoint fundamental block and type and structure, then from computer program, extract this and be not the operational order that comprises in the cutpoint fundamental block and the initial value of all local variables, and make up a new method according to the initial value of operational order and local variable, concrete building process is as follows: to order numbering by size above-mentioned is not that local variable in the cutpoint fundamental block is again from 0 open numbering, making the minimum local variable of numbering is the input parameter of new method, the value of the local variable that numbering is maximum is the rreturn value of new method, makes the operational order of the operational order of extraction as new method;
(8) said new method is joined in the method set of above-mentioned watermark to be extracted;
(9) repeat above-mentioned steps (7) and (8), all the method traversals in computer program finish;
(10) according to the method set of above-mentioned watermark to be extracted, create and extract assisted class, extract key, and parse copyright information;
(11) use the method identical with (2), user's key information is converted to the integer array g[of dull non-decreasing] with n element with above-mentioned steps (1);
(12) read above-mentioned integer array g[successively] in each integer, and respectively with the input of the integer that reads as each method in the said extracted assisted class, obtain to extract the rreturn value of each method operation in the assisted class, if the number of identical rreturn value is less than m, it is wrong then to extract key, extract failure,, then should identical rreturn value join integer array h[if the number of identical rreturn value is more than or equal to m] in;
(13) judge integer array h[] whether be dull non-decreasing, if not, then show and extract failure, if then make above-mentioned l=h[0]+1, to 0≤j≤n-2, make v j=h[j+1]-h[j], according to formula w = Σ j = 0 n - 2 v j q j 1 Obtain a big integer w, big integer w as an integer digit strings, is reduced into original character string, show that copyright information also extracts successfully.
CNB2008101193580A 2008-09-05 2008-09-05 A kind of method that in computer program, embeds and extract watermark Active CN100557618C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2008101193580A CN100557618C (en) 2008-09-05 2008-09-05 A kind of method that in computer program, embeds and extract watermark

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2008101193580A CN100557618C (en) 2008-09-05 2008-09-05 A kind of method that in computer program, embeds and extract watermark

Publications (2)

Publication Number Publication Date
CN101350055A CN101350055A (en) 2009-01-21
CN100557618C true CN100557618C (en) 2009-11-04

Family

ID=40268842

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2008101193580A Active CN100557618C (en) 2008-09-05 2008-09-05 A kind of method that in computer program, embeds and extract watermark

Country Status (1)

Country Link
CN (1) CN100557618C (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8812855B2 (en) * 2009-03-02 2014-08-19 Nxp B.V. Software protection
CN101866410A (en) * 2010-04-30 2010-10-20 湖南大学 Methods for embedding watermarks in Java software and extracting watermarks from Java software
CN102971735B (en) * 2010-06-30 2017-07-14 皇家飞利浦电子股份有限公司 Interactive image analysis
CN102122335B (en) * 2010-12-24 2012-11-14 清华大学 Method for restricting illegal JAVA software operation by using software watermarks
CN102867286A (en) * 2011-07-08 2013-01-09 索尼公司 Method and device for generating, embedding and detecting digital watermarks
CN103093155B (en) * 2012-12-07 2016-04-27 中北大学 Based on the information concealing method of Codes Revised
WO2014153679A1 (en) * 2013-03-27 2014-10-02 Irdeto B.V. Watermarking executable files
CN103530536B (en) * 2013-09-30 2017-01-25 南通大学 Method for embedding Java software watermark
CN112465088A (en) * 2020-12-07 2021-03-09 合肥维天运通信息科技股份有限公司 Two-dimensional code position generation method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于内容的英文文本数字水印算法设计与实现. 肖湘蓉,孙星明.计算机工程,第31卷第22期. 2005 *

Also Published As

Publication number Publication date
CN101350055A (en) 2009-01-21

Similar Documents

Publication Publication Date Title
CN100557618C (en) A kind of method that in computer program, embeds and extract watermark
CN101458810B (en) Vector map watermark method based on object property characteristic
CN101944094B (en) Webpage information extraction method and device thereof
Collberg et al. Software watermarking: Models and dynamic embeddings
CN110765753A (en) Method, system, computer device and storage medium for generating file
CN101452570A (en) Vector space data digital watermarking method based on grid
CN102867049A (en) Chinese PINYIN quick word segmentation method based on word search tree
CN111460452B (en) Android malicious software detection method based on frequency fingerprint extraction
CN110475039A (en) Lines, Artss draw method, equipment and the storage medium hidden and restored
CN102375847A (en) Method and device for forming merge tree for generating document template
CN101639828A (en) Method for hiding and extracting watermark based on XML electronic document
US11429819B2 (en) Packer classification apparatus and method using PE section information
CN110609936A (en) Intelligent classification method for fuzzy address data
CN115292791B (en) Method for converting JSL-route expert design data into universal data format
CN100461214C (en) Image authentication method based on feedback chaos system and neighborhood assistance
CN115082281A (en) Form text anti-counterfeiting watermark generation method, system and computer storage medium
Chroni et al. Encoding watermark numbers as reducible permutation graphs using self-inverting permutations
Deguchi et al. Lightweight parameterized suffix array construction
Hong et al. An efficient algorithm of frequent connected subgraph extraction
Kim et al. An efficient index data structure with the capabilities of suffix trees and suffix arrays for alphabets of non-negligible size
Chroni et al. Encoding numbers into reducible permutation graphs using heap-ordered trees
CN100521765C (en) Video frequency digital water mark enciphering marking and detecting method
CN106296024A (en) A kind of simulation of water resources system and regulation and administration method
Daage et al. Climate change impacts on precipitation extremes, flows and flash floods in Mediterranean mesoscale catchments
Vielhauer et al. Image annotation watermarking: nested object embedding using hypergraph model

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant