JP4924177B2 - Program obfuscation device and program - Google Patents

Program obfuscation device and program Download PDF

Info

Publication number
JP4924177B2
JP4924177B2 JP2007112928A JP2007112928A JP4924177B2 JP 4924177 B2 JP4924177 B2 JP 4924177B2 JP 2007112928 A JP2007112928 A JP 2007112928A JP 2007112928 A JP2007112928 A JP 2007112928A JP 4924177 B2 JP4924177 B2 JP 4924177B2
Authority
JP
Japan
Prior art keywords
program
conditional
variable
obfuscation
conditional branch
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.)
Expired - Fee Related
Application number
JP2007112928A
Other languages
Japanese (ja)
Other versions
JP2008269398A (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.)
Fujifilm Business Innovation Corp
Original Assignee
Fuji Xerox Co Ltd
Fujifilm Business Innovation Corp
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 Fuji Xerox Co Ltd, Fujifilm Business Innovation Corp filed Critical Fuji Xerox Co Ltd
Priority to JP2007112928A priority Critical patent/JP4924177B2/en
Publication of JP2008269398A publication Critical patent/JP2008269398A/en
Application granted granted Critical
Publication of JP4924177B2 publication Critical patent/JP4924177B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、コンピュータプログラムを冗長化することで難読化する技術に関する。   The present invention relates to a technique for obfuscating a computer program by making it redundant.

プログラムを悪意あるリバースエンジニアリングから守るために、様々なプログラム難読化技術が提案されている。
難読化とは、プログラムを冗長化して複雑に変換することで、プログラムの解析コストを大きくする技術である。
Various program obfuscation techniques have been proposed to protect programs from malicious reverse engineering.
Obfuscation is a technique for increasing the analysis cost of a program by making the program redundant and converting it in a complicated manner.

難読化手法の1つに、不明瞭な条件式(Opaque Predicates)を用いた難読化方法がある(非特許文献1、2参照。)。Opaque Predicatesとは、実行時に恒真/恒偽であることが分かっている、難読化のために用いる条件式のことをいう。
不明瞭な条件式(Opaque Predicates)を用いた難読化とは、Opaque Predicatesを条件式として用いて恒真/恒偽な条件分岐を難読化対象のプログラムに付加することで、当該プログラムを冗長化して難読化する手法である。つまり、プログラムが実現する処理としては意味を持たない恒真/恒偽な条件分岐を付加することで当該プログラムを冗長化してプログラムの解析コストを大きくする。
One obfuscation method is an obfuscation method using an unclear conditional expression (Opaque Predicates) (see Non-Patent Documents 1 and 2). Opaque Predicates are conditional expressions used for obfuscation that are known to be true / false at run time.
Obfuscation using an obscure conditional expression (Opaque Predicates) means adding a true / false conditional branch to an obfuscated program using Opaque Predicates as a conditional expression to make the program redundant. This is an obfuscated technique. That is, by adding a true / false conditional branch that has no meaning as a process realized by the program, the program is made redundant to increase the analysis cost of the program.

図21には難読化の対象とするプログラムの一例を示し、図22には当該難読化対象プログラムにOpaque Predicatesを用いた難読化を適用した一例を示してある。
図22に示す難読化を施したプログラムは、図21に示す元のプログラム中の位置p21にa*(a―1)mod2==1と言う条件式と、++a;という条件節とからなる条件分岐22を加えることで生成されている。
ここでmodとは、例えば7mod2=1といったように、左の整数値を右の整数値で割った時の余りを返す余剰計算による演算である。また、++aはaの値に1加える演算、*は2つの値の積を取る演算である。
FIG. 21 shows an example of a program to be obfuscated, and FIG. 22 shows an example in which obfuscation using Opaque Predicates is applied to the obfuscation target program.
The obfuscated program shown in FIG. 22 has a condition comprising a conditional expression a * (a-1) mod 2 == 1 and a conditional clause ++ a; at position p21 in the original program shown in FIG. It is generated by adding a branch 22.
Here, mod is an operation by a surplus calculation that returns the remainder when the left integer value is divided by the right integer value, for example, 7 mod 2 = 1. Further, ++ a is an operation for adding 1 to the value of a, and * is an operation for taking the product of two values.

条件分岐22では、aがどのような整数値であっても、a*(a―1)は2の倍数であるため、a*(a―1)mod2の値は常に0、つまり、a*(a ―1)mod2==1は恒偽のOpaque Predicateである。そのため、++a;と言う条件節は決して実行されない。
このため、図21と図22のプログラムの意味は変わらない一方で、図22のプログラムには冗長な条件分岐22が含まれている分、図21のプログラムよりも解析コスト、つまりプログラムの意味を理解するコストが大きくなる。
C. Collberg, C. Thomborson, and D. Low, ``Manufacturing Cheap, Resilient, and Stealthy Opaque Constructs,'' Proceedings of the 25th ACM Symposium on Principles of Programming Languages, pp.184--196, 1998 T. Ogiso, Y. Sakabe, M. Soshi and A. Miyaji,``Software obfuscation on a theoretical basis and its implementation,''IEEE Trans. Fundamentals, vol.E86-A, no.1, pp.176--186, January, 2003.
In conditional branch 22, no matter what integer value a is, a * (a-1) is a multiple of 2. Therefore, the value of a * (a-1) mod2 is always 0, that is, a * (a-1) mod2 == 1 is a false Opaque Predicate. Therefore, the conditional clause ++ a; is never executed.
For this reason, while the meaning of the program of FIG. 21 and FIG. 22 does not change, since the program of FIG. 22 includes the redundant conditional branch 22, the analysis cost, that is, the meaning of the program, is greater than that of the program of FIG. The cost of understanding increases.
C. Collberg, C. Thomborson, and D. Low, `` Manufacturing Cheap, Resilient, and Stealthy Opaque Constructs, '' Proceedings of the 25th ACM Symposium on Principles of Programming Languages, pp.184--196, 1998 T. Ogiso, Y. Sakabe, M. Soshi and A. Miyaji, `` Software obfuscation on a theoretical basis and its implementation, '' IEEE Trans. Fundamentals, vol.E86-A, no.1, pp.176-- 186, January, 2003.

従来のOpaque Predicatesを用いた難読化には、プログラムへの入力を変えても、付加したOpaque Predicatesの真偽値が変化しないという問題があった。
そのため、プログラムを悪意をもって解析しようとする攻撃者は、難読化を適用したプログラムに頻度分析を行うことで、Opaque Predicatesを用いた難読化を無効化することができる。
ここで、頻度分析とは、プログラムにランダムに入力を与えたり、また、プログラム内部を書き換えたりした上で実行させることで、出力結果や実行フローの違いを観察する分析方法を言う。
The obfuscation using conventional Opaque Predicates has a problem that even if the input to the program is changed, the truth value of the added Opaque Predicates does not change.
Therefore, an attacker who tries to analyze a program maliciously can invalidate the obfuscation using Opaque Predicates by performing frequency analysis on the program to which obfuscation is applied.
Here, the frequency analysis is an analysis method for observing a difference in output result or execution flow by giving a program a random input or executing the program after rewriting the program.

通常考えられる条件分岐の条件式の場合、プログラムへの入力値を変えればある割合でその真偽値も変化する。しかしながら、Opaque Predicatesの真偽値はどのような入力を与えても変化しない。つまり、Opaque Predicatesを用いた条件分岐の条件節は、どのような入力においても必ず実行されるか、どのような入力においても必ず実行されないかのいずれかである。
したがって、頻度分析において入力値を変えて何度も実行フローを観察するうちに、攻撃者は、必ず実行される/必ず実行されない条件節を特定できる。これにより、Opaque Predicatesを用いた難読化は無効化されてしまう。
In the case of a conditional expression that can be considered normally, if the input value to the program is changed, its true / false value also changes at a certain rate. However, the truth value of Opaque Predicates does not change with any input. That is, the conditional clause of the conditional branch using Opaque Predicates is either always executed at any input or not always executed at any input.
Therefore, while changing the input value in the frequency analysis and observing the execution flow many times, the attacker can specify a conditional clause that is always executed / not always executed. As a result, obfuscation using Opaque Predicates is invalidated.

本発明は、上記従来の事情に鑑みなされたのもであり、従来に比して、頻度分析攻撃に対して耐性が高い難読化をプログラムに適用することを目的としている。   The present invention has been made in view of the above-described conventional circumstances, and an object thereof is to apply obfuscation to a program, which is more resistant to a frequency analysis attack than conventional ones.

請求項1のプログラム難読化装置は、難読化対象のプログラムを入力する入力手段と、前記プログラム中の第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に当該プログラム中の第2の変数の値を変換する条件節を含む第1の条件分岐と、当該第1の条件分岐における前記第1の変数の取り得る値の全範囲で当該第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に前記変換された第2の変数の値を元の値に逆変換する条件節を含む第2の条件分岐と、を生成する生成手段と、前記プログラム中の前記第1及び第2の変数が存在する以降の部分で前記第1の条件分岐と第2の条件分岐を挿入する位置を決定する決定手段と、前記プログラム中の決定された位置に前記第1の条件分岐と第2の条件分岐を挿入する挿入手段と、を有することを特徴とする。   The program obfuscation apparatus according to claim 1 is an input unit for inputting a program to be obfuscated, a conditional expression for dividing a value of a first variable in the program, and a value of the first variable divided for the case. A first conditional branch including a conditional clause that converts the value of the second variable in the program every time, and the first conditional branch in the entire range of possible values of the first variable in the first conditional branch. A second conditional branch including a conditional expression for dividing the value of the variable and a conditional clause for inversely converting the converted second variable value to the original value for each divided first variable value And generating means for generating the first conditional branch and the second conditional branch in a portion after the first and second variables exist in the program, and a determining means for determining a position to insert the first conditional branch and the second conditional branch The first conditional branch at a determined position in the program And inserting means for inserting a second conditional branch, and having a.

請求項2のプログラム難読化装置は、請求項1において、前記第1の条件分岐は複数の条件式からなる第1の条件式和集合を含み、前記第2の条件分岐は複数の条件式からなる第2の条件式和集合を含み、当該第1の条件式和集合と当該第2の条件式和集合とは同値であり、かつ、異なる集合であることを特徴とする。   The program obfuscation device according to claim 2 is the program obfuscation device according to claim 1, wherein the first conditional branch includes a first conditional expression union composed of a plurality of conditional expressions, and the second conditional branch includes a plurality of conditional expressions. The first conditional expression union and the second conditional expression union are the same and different sets.

請求項3のプログラム難読化装置は、請求項1又は請求項2において、前記決定手段は、前記第1の条件分岐を挿入する位置以降で前記第1及び第2の変数が操作されないプログラム部分を隔てた位置を前記第2の条件分岐を挿入する位置に決定することを特徴とする。   The program obfuscation device according to claim 3 is the program obfuscation device according to claim 1 or 2, wherein the determination means includes a program part in which the first and second variables are not operated after the position where the first conditional branch is inserted. The separated position is determined as a position where the second conditional branch is inserted.

請求項4のプログラム難読化装置は、請求項1乃至請求項3のいずれかにおいて、前記難読化対象のプログラム中に既存の複数の条件分岐の相関度を算出する算出手段を有し、前記生成手段は、算出した相関度に近い相関度となるように前記第1及び第2の条件分岐を生成することを特徴とする。   The program obfuscation apparatus according to claim 4 has calculation means for calculating the degree of correlation of a plurality of existing conditional branches in the obfuscation target program according to any one of claims 1 to 3, wherein the generation The means is characterized in that the first and second conditional branches are generated so that the degree of correlation is close to the calculated degree of correlation.

請求項5のプログラム難読化装置は、請求項1乃至請求項4のいずれかにおいて、前記決定手段は、前記第1の条件分岐が含む条件式を、前記難読化対象のプログラム中における前記第1の変数の取り得る値の全範囲で当該第1の変数の値を場合分けする条件式とすることを特徴とする。   The program obfuscation apparatus according to claim 5 is the program obfuscation apparatus according to any one of claims 1 to 4, wherein the determination unit includes the conditional expression included in the first conditional branch in the program to be obfuscated. It is characterized in that it is a conditional expression for dividing the value of the first variable into the whole range of possible values of the variable.

請求項6のプログラム難読化装置は、請求項1乃至請求項4のいずれかにおいて、前記決定手段は、前記第1の条件分岐が含む条件式を、前記難読化対象のプログラム中における前記第1の変数の取り得る値の部分的な範囲で当該第1の変数の値を場合分けする条件式とすることを特徴とする。   A program obfuscation apparatus according to a sixth aspect is the program obfuscation apparatus according to any one of the first to fourth aspects, wherein the determining unit includes the conditional expression included in the first conditional branch in the program to be obfuscated. It is characterized in that it is a conditional expression for dividing the value of the first variable into cases within a partial range of possible values of the variable.

請求項7のプログラム難読化装置は、請求項1乃至請求項6のいずれかにおいて、前記生成手段は、前記難読化対象のプログラムへの入力変数を、前記第1の及び第2の変数として前記第1及び第2の条件分岐を生成することを特徴とする。   The program obfuscation apparatus according to claim 7 is the program obfuscation apparatus according to any one of claims 1 to 6, wherein the generation unit uses the input variables to the obfuscation target program as the first and second variables. First and second conditional branches are generated.

請求項8のプログラム難読化装置は、請求項1乃至請求項7のいずれかにおいて、前記生成手段は、前記第1の変数を余剰計算による場合分けして、前記第1及び第2の条件分岐を生成することを特徴とする。   The program obfuscation device according to claim 8 is the program obfuscation device according to any one of claims 1 to 7, wherein the generation unit divides the first variable into cases according to a surplus calculation, and the first and second conditional branches. Is generated.

請求項9のプログラム難読化装置は、請求項1乃至請求項7のいずれかにおいて、前記生成手段は、前記第1の変数をハッシュ関数による場合分けして、前記第1及び第2の条件分岐を生成することを特徴とする。   The program obfuscation device according to claim 9 is the program obfuscation device according to any one of claims 1 to 7, wherein the generation unit divides the first variable into cases according to a hash function, and the first and second conditional branches. Is generated.

請求項10のプログラム難読化装置は、請求項1乃至請求項9のいずれかにおいて、前記第1の条件分岐と第2の条件分岐を挿入されたプログラムを出力する手段を有することを特徴とする。   A program obfuscation device according to claim 10 is characterized in that in any one of claims 1 to 9, the program obfuscation device has means for outputting a program in which the first conditional branch and the second conditional branch are inserted. .

請求項11の難読化プログラムは、難読化対象のプログラムを入力する入力手段と、前記プログラム中の第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に当該プログラム中の第2の変数の値を変換する条件節を含む第1の条件分岐と、当該第1の条件分岐における前記第1の変数の取り得る値の全範囲で当該第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に前記変換された第2の変数の値を元の値に逆変換する条件節を含む第2の条件分岐と、を生成する生成手段と、前記プログラム中の前記第1及び第2の変数が存在する以降の部分で前記第1の条件分岐と第2の条件分岐を挿入する位置を決定する決定手段と、前記プログラム中の決定された位置に前記第1の条件分岐と第2の条件分岐を挿入する挿入手段と、をコンピュータに実現することを特徴とする。   The obfuscation program according to claim 11 includes an input means for inputting a program to be obfuscated, a conditional expression for dividing a value of the first variable in the program, and a value of the first variable divided for each case. A first conditional branch including a conditional clause for converting the value of the second variable in the program, and the first variable in the entire range of possible values of the first variable in the first conditional branch. A second conditional branch including a conditional expression for dividing the value of the first variable and a conditional clause for inversely converting the value of the converted second variable into the original value for each value of the first variable divided according to the case; Generating means for generating the first conditional branch and the second conditional branch in a part after the first and second variables exist in the program; The first conditional branch at a determined position in the program; Characterized in that to realize an insertion means for inserting a second conditional branch, to the computer.

請求項1のプログラム難読化装置によると、第1の条件分岐と第2の条件分岐とを難読化対象のプログラムに挿入するようにしたため、従来に比して、頻度分析攻撃に対して耐性が高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 1, since the first conditional branch and the second conditional branch are inserted into the obfuscated program, it is more resistant to frequency analysis attacks than in the past. High obfuscation can be applied to the program.

請求項2のプログラム難読化装置によると、第1の条件分岐と第2の条件分岐との条件式を和集合として難読化対象のプログラム中に挿入するようにしたため、頻度分析攻撃に対して耐性がより高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 2, the conditional expressions of the first conditional branch and the second conditional branch are inserted into the program to be obfuscated as a union, so that they are resistant to frequency analysis attacks. Higher obfuscation can be applied to the program.

請求項3のプログラム難読化装置によると、第1の条件分岐と第2の条件分岐とを難読化対象のプログラム中の離間した位置に挿入するようにしたため、頻度分析攻撃に対して耐性がより高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 3, since the first conditional branch and the second conditional branch are inserted at positions in the program to be obfuscated, they are more resistant to frequency analysis attacks. High obfuscation can be applied to the program.

請求項4のプログラム難読化装置によると、第1及び第2の条件分岐を難読化対象のプログラム中に既存の複数の条件分岐に近い相関度となるようにしたため、頻度分析攻撃に対して耐性がより高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 4, since the first and second conditional branches have a degree of correlation close to a plurality of existing conditional branches in the obfuscated program, they are resistant to frequency analysis attacks. Higher obfuscation can be applied to the program.

請求項5のプログラム難読化装置によると、第1の条件分岐が含む条件式を難読化対象のプログラム中における第1の変数の取り得る値の全範囲で場合分けするようにしたため、第1及び第2の条件分岐がプログラムを実行すると必ず実行され、第1の変数の値にかかわらずプログラムが冗長となって、耐性がより高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 5, the conditional expression included in the first conditional branch is classified in the entire range of possible values of the first variable in the obfuscated program. The second conditional branch is executed whenever the program is executed, and the program becomes redundant regardless of the value of the first variable, and obfuscation with higher tolerance can be applied to the program.

請求項6のプログラム難読化装置によると、第1の条件分岐が含む条件式を難読化対象のプログラム中における第1の変数の取り得る値の部分的な範囲で当該第1の変数の値を場合分けするようにしたため、第1の変数の値によっては第1及び第2の条件分岐がプログラムを実行しても実行されない場合が生じ、第1及び第2の条件分岐の挿入意図をかえって隠すことができ、頻度分析攻撃に対して耐性がより高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 6, the conditional expression included in the first conditional branch is set to the value of the first variable within a partial range of values that can be taken by the first variable in the program to be obfuscated. Since the cases are divided, depending on the value of the first variable, the first and second conditional branches may not be executed even if the program is executed, and the intention to insert the first and second conditional branches is hidden instead. And obfuscation that is more resistant to frequency analysis attacks can be applied to the program.

請求項7のプログラム難読化装置によると、難読化対象のプログラムへの入力変数を第1及び第2の変数として第1及び第2の条件分岐を生成するようにしたため、従来に比して、頻度分析攻撃に対して耐性が高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 7, since the first and second conditional branches are generated with the input variables to the obfuscation target program as the first and second variables, Obfuscation that is highly resistant to frequency analysis attacks can be applied to the program.

請求項8のプログラム難読化装置によると、第1の変数を余剰計算による場合分けして第1及び第2の条件分岐を生成するようにしたため、従来に比して、頻度分析攻撃に対して耐性が高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 8, the first variable is divided into cases according to the surplus calculation and the first and second conditional branches are generated. Obfuscation with high tolerance can be applied to the program.

請求項9のプログラム難読化装置によると、第1の変数をハッシュ関数による場合分して第1及び第2の条件分岐を生成するようにしたため、従来に比して、頻度分析攻撃に対して耐性が高い難読化をプログラムに適用することができる。   According to the program obfuscation apparatus of claim 9, since the first variable is generated by dividing the first variable according to the hash function, compared to the conventional case, the frequency obfuscation attack is prevented. Obfuscation with high tolerance can be applied to the program.

請求項10のプログラム難読化装置によると、第1の条件分岐と第2の条件分岐を挿入された頻度分析攻撃に対して耐性が高いプログラムプログラムを出力することができる。   According to the program obfuscation apparatus of the tenth aspect, it is possible to output a program program that is highly resistant to a frequency analysis attack in which the first conditional branch and the second conditional branch are inserted.

請求項11の難読化プログラムによると、コンピュータハードウエアを利用して、従来に比して頻度分析攻撃に対して耐性が高い難読化をプログラムに適用することができるプログラム難読化装置を実現することができる。   According to the obfuscation program of claim 11, a computer obfuscation apparatus that can apply obfuscation to a program that is more resistant to a frequency analysis attack than before is realized using computer hardware. Can do.

まず、本発明に係るプログラム難読化装置の利用形態の一例を、図3及び図4を参照して説明する。
図3に示すように、本発明に係る難読化装置1はプログラムの開発者によって利用され、開発者は、開発したプログラムを難読化装置に入力として与える。難読化装置1は、入力されたプログラムに対して本発明に係る難読化処理を施して、難読化済プログラムを出力する。
First, an example of a usage pattern of the program obfuscation apparatus according to the present invention will be described with reference to FIGS.
As shown in FIG. 3, the obfuscation apparatus 1 according to the present invention is used by a program developer, and the developer gives the developed program as an input to the obfuscation apparatus. The obfuscation apparatus 1 performs an obfuscation process according to the present invention on the input program and outputs an obfuscated program.

難読化装置は入力された元のプログラムを難読化する際にプログラム自体の意味を変えないので、入力された元のプログラムと難読化済プログラムの動作は同じである。
ただし、難読化済プログラムには冗長な条件分岐が追加されているので、元のプログラムよりも解析コストが大きい。
開発者は、物理的に離れたところにいるユーザに対して、難読化済プログラムを渡す。この渡す手段としては、インターネットを介して提供する方法が考えられ、また別の方法として、CD−ROM等の記憶メディアにデータとして格納して渡す方法も考えられる。
Since the obfuscation device does not change the meaning of the program itself when obfuscating the input original program, the operation of the input original program and the obfuscated program is the same.
However, since a redundant conditional branch is added to the obfuscated program, the analysis cost is higher than that of the original program.
The developer gives the obfuscated program to users who are physically separated. As a means for delivering, a method of providing via the Internet is conceivable, and another method is conceivable in which data is stored and delivered as data in a storage medium such as a CD-ROM.

図4に示すように、難読化済プログラムがユーザに渡された後、開発者は元のプログラムと難読化済プログラムとを所持しており、ユーザは難読化済プログラムのみを所持している。
元のプログラムと難読化済プログラムの機能は同じなので、ユーザは難読化済プログラムにより元のプログラムと同じ機能を利用できる。
一方、ユーザは元のプログラムを所持していないので、元のプログラムの持つ機密情報(例えば、ライセンスに関する情報など)を得るためには、難読化済プログラムを解析しなければならない。しかしながら、 難読化済プログラムの解析コストは元のプログラムの解析コストよりも大きいので、元のプログラムをユーザに手渡す状況と比較すると、プログラムの機密情報が暴かれる機会はより小さい。
As shown in FIG. 4, after the obfuscated program is delivered to the user, the developer possesses the original program and the obfuscated program, and the user possesses only the obfuscated program.
Since the functions of the original program and the obfuscated program are the same, the user can use the same function as the original program by the obfuscated program.
On the other hand, since the user does not have the original program, the obfuscated program must be analyzed in order to obtain confidential information (for example, information related to the license) of the original program. However, since the analysis cost of the obfuscated program is higher than the analysis cost of the original program, there is less chance of exposing the confidential information of the program as compared to the situation of handing the original program to the user.

図1には、本発明の一実施例に係るプログラム難読化装置1の構成を示してある。
本例の難読化装置1は、難読化対象のプログラムを入力する入力手段2と、入力したプログラムを難読化するための処理を行う難読化処理手段3と、難読化されたプログラムを出力する出力手段4と、を有している。更に、難読化処理手段3は、入力したプログラムを難読化するための解析を行う解析手段5と、入力したプログラムを難読化するための条件分岐を生成する条件分岐生成手段6と、入力したプログラムに条件分岐を挿入して難読化する挿入手段7と、を有している。
FIG. 1 shows a configuration of a program obfuscation apparatus 1 according to an embodiment of the present invention.
The obfuscation apparatus 1 of this example includes an input unit 2 that inputs a program to be obfuscated, an obfuscation processing unit 3 that performs processing for obfuscating the input program, and an output that outputs the obfuscated program. And means 4. Further, the obfuscation processing means 3 includes an analysis means 5 for analyzing the input program for obfuscation, a conditional branch generation means 6 for generating a conditional branch for obfuscating the input program, and the input program. And an insertion means 7 for obfuscating by inserting a conditional branch.

入力手段2は、例えば、CDROM等のメディア記憶媒体に記憶された難読化対象のプログラムを読取る手段、通信回線を介して難読化対象のプログラムを受信する手段など難読化対象のプログラムを難読化装置1に取り込むことができる種々な手段を用いることができる。
なお、開発者が操作するコンピュータに本発明に係る難読化プログラムをインストールして難読化装置を構成することもでき、この場合には、入力手段2は作成したプログラムをコンピュータ内部でプログラム作成部から難読化装置部へ受け渡す手段であってもよい。
The input unit 2 is an obfuscation device for an obfuscation target program, such as a unit for reading an obfuscation target program stored in a media storage medium such as a CDROM, or a unit for receiving the obfuscation target program via a communication line. Various means that can be incorporated into 1 can be used.
The obfuscation program according to the present invention can be installed in a computer operated by the developer to configure the obfuscation apparatus. In this case, the input unit 2 sends the created program from the program creation unit inside the computer. It may be a means for delivering to the obfuscation apparatus unit.

出力手段4は、例えば、CDROM等のメディア記憶媒体に難読化したプログラムを書き込む手段、通信回線を介して難読化したプログラムを送信する手段など難読化したプログラムを難読化装置1から出力することができる種々な手段を用いることができる。
解析手段5は、難読化対象のプログラムを解析して、難読化のための条件分岐を挿入するプログラム中の位置を決定する。具体的には、解析手段5は、難読化対象プログラム中の、条件分岐に用いられる第1の変数(以下の例では、a)と第2の変数(以下の例では、b)が存在する以降の部分で条件分岐を挿入する位置を決定する。
The output means 4 can output the obfuscated program from the obfuscation apparatus 1 such as a means for writing an obfuscated program to a media storage medium such as a CDROM, or a means for transmitting an obfuscated program via a communication line. Various means that can be used can be used.
The analysis means 5 analyzes the program to be obfuscated and determines the position in the program where the conditional branch for obfuscation is inserted. Specifically, the analysis means 5 has a first variable (a in the following example) and a second variable (b in the following example) used for conditional branching in the obfuscation target program. The position where the conditional branch is inserted is determined in the following part.

ここで、以下の例では、第1と第2の条件分岐(それぞれ条件分岐の集合)を生成して難読化対象プログラムに挿入するが、第1の条件分岐を挿入する位置以降で第1及び第2の変数が操作されないプログラム部分を隔てた位置を第2の条件分岐を挿入する位置に決定するのが好ましい。すなわち、攻撃者による解析を困難化するために、第1の条件分岐と第2の条件分岐とを、第1及び第2の変数が操作されないプログラム部分を挟んで振り分けてプログラム中に位置させるのが好ましい。
なお、本発明では、このように振り分け配置せずとも、第1の条件分岐と第2の条件分岐とをプログラム中に並べて位置させるようにしてもよく、これによっても、プログラム中に条件分岐を挿入することによる冗長化(難読化)の目的は達成される。
Here, in the following example, the first and second conditional branches (each set of conditional branches) are generated and inserted into the obfuscation target program, but the first and second conditional branches are inserted after the position where the first conditional branch is inserted. It is preferable to determine the position where the second conditional branch is inserted as a position separating program parts where the second variable is not operated. In other words, in order to make analysis by an attacker difficult, the first conditional branch and the second conditional branch are distributed in the program part where the first and second variables are not manipulated and placed in the program. Is preferred.
In the present invention, the first conditional branch and the second conditional branch may be arranged side by side in the program without being distributed and arranged in this way. The purpose of redundancy (obfuscation) by insertion is achieved.

条件分岐生成手段6は、難読化対象プログラム中の第1の変数(以下の例では、a)の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に当該難読化対象プログラム中の第2の変数(以下の例では、b)の値を変換する条件節を含む第1の条件分岐と、当該第1の条件分岐における第1の変数の取り得る値の全範囲で当該第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に前記変換された第2の変数の値を元の値に逆変換する条件節を含む第2の条件分岐と、を生成する。
すなわち、第1の条件分岐は、第1の変数のとり得る値を場合分けして、場合分け毎に第2の変数の値を変換するものであり、難読化対象プログラム中の第1の条件分岐より後部に挿入される第2の条件分岐は、第1の条件分岐で場合分けした第1の変数値の全範囲で当該第1の変数(a)の値を場合分けして、場合分け毎に第1の条件分岐で変換された第2の変数値を元の値に逆変換するものである。
The conditional branch generation unit 6 performs the obfuscation for each conditional expression that separates the value of the first variable (a in the following example) in the obfuscation target program and the value of the first variable that is divided in each case. The first conditional branch including a conditional clause for converting the value of the second variable (b in the following example) in the target program, and the entire range of possible values of the first variable in the first conditional branch And a conditional expression that separates the value of the first variable in each case and a conditional clause that reversely converts the converted value of the second variable into the original value for each case-separated value of the first variable. A second conditional branch is generated.
That is, in the first conditional branch, possible values of the first variable are divided into cases, and the value of the second variable is converted for each case. The first condition in the obfuscation target program The second conditional branch inserted after the branch is divided into cases in which the value of the first variable (a) is divided in the entire range of the first variable values divided in the first conditional branch. Each time the second variable value converted in the first conditional branch is converted back to the original value.

ここで、第1の条件分岐における場合分けは、第1の変数が取り得る値の全範囲であっても、又は、第1の変数が取り得る値の部分範囲であってもよい。例えば、第1の変数が取り得る値が1〜12である場合、この1〜12の値の範囲を4分する場合分けであっても、又は、第1の変数が取り得る値の範囲の内の3〜10の値の範囲を4分する場合分けであってもよい。
このように、第1の条件分岐における第1の変数をその取り得る値の部分範囲で場合分けすると、プログラムの実行において、第1の変数値が場合分けした範囲外のときは、第1の条件分岐及びその後の第2の条件分岐は実行されずにパスされることとなるが、このように第1の変数値によって条件分岐が実行されない場合が生じても、プログラム中に条件分岐を挿入することによる冗長化(難読化)の目的は達成される。
Here, the case division in the first conditional branch may be the entire range of values that the first variable can take, or a partial range of values that the first variable can take. For example, when the value that the first variable can take is 1 to 12, even if the range of the value of 1 to 12 is divided into four cases, or the range of the value that the first variable can take The case of dividing the range of the values of 3 to 10 into 4 may be used.
As described above, when the first variable in the first conditional branch is classified by the partial range of the possible values, when the first variable value is outside the divided range in the execution of the program, the first variable The conditional branch and the subsequent second conditional branch will be passed without being executed, but even if the conditional branch is not executed due to the first variable value in this way, the conditional branch is inserted into the program. By doing so, the purpose of redundancy (obfuscation) is achieved.

なお、第2の条件分岐における場合分けは、第1の条件分岐における第1の変数の取り得る値の全範囲である必要がある。すなわち、この場合分けが部分範囲であると、第1の条件分岐において場合分け毎に変換された第2の変数を元に戻すことができなくなる場合が生じてしまい、条件分岐の挿入によって難読化したプログラムの意味を変更してしまう場合が生じてしまう。   Note that the case division in the second conditional branch needs to be the entire range of possible values of the first variable in the first conditional branch. That is, if the division is a partial range, the second variable converted for each case division in the first conditional branch may not be restored, and obfuscation is caused by the insertion of the conditional branch. The meaning of the selected program may be changed.

ここで、以下の例では、第1の変数及び第2の変数を難読化対象プログラムへの入力変数としているが、本発明では、第1の条件分岐より前にプログラム中に存在するいずれの変数を用いて第1及び第2の条件分岐を生成してもよい。
また、本例の解析手段5は、難読化対象プログラム中に既存の複数の条件分岐の相関度を算出する機能を有しており、本例の生成手段6は算出した相関度に近い相関度となるようにプログラムに挿入する第1及び第2の条件分岐を生成する。
Here, in the following example, the first variable and the second variable are input variables to the obfuscation target program. However, in the present invention, any variable existing in the program before the first conditional branch is used. May be used to generate the first and second conditional branches.
Further, the analysis unit 5 of this example has a function of calculating the degree of correlation of a plurality of existing conditional branches in the obfuscation target program, and the generation unit 6 of this example has a degree of correlation close to the calculated degree of correlation. First and second conditional branches to be inserted into the program are generated so that

本例の難読化装置1は、図2に示すように、プロセッサ(CPU)11、基本的な制御プログラムを記憶したROM12、本発明に係るプログラムを処理する作業領域となるRAM13、外部との入出力を行うためのインタフェース(I/O)14等を有するコンピュータで構成されており、当該コンピュータによって本発明に係る難読化プログラムを実行することで、上記各機能手段2〜7が実現されている。
なお、本発明では、各機能手段2〜7を専用のハードウエアモジュールで実現してもよい。
As shown in FIG. 2, the obfuscation apparatus 1 of this example includes a processor (CPU) 11, a ROM 12 storing a basic control program, a RAM 13 serving as a work area for processing the program according to the present invention, and an external input. Each of the functional units 2 to 7 is realized by a computer having an interface (I / O) 14 or the like for performing output, and the computer executing the obfuscation program according to the present invention. .
In the present invention, each of the functional units 2 to 7 may be realized by a dedicated hardware module.

図5には、図21に示したプログラムを難読化対象として、本発明に係る難読化装置1で難読化した例を示してある。
この例では、生成手段6が、第1と第2の変数を難読化対象プログラムの入力変数aとbとして、第1の条件分岐Sと第2の条件分岐Tとを生成し、挿入手段7が、第1の条件分岐Sと第2の条件分岐Tとを、図21に示すように、難読化対象プログラム中の変数a、bを操作しないプログラム部分ppを隔てた位置にp20、p21に挿入している。
FIG. 5 shows an example in which the program shown in FIG. 21 is obfuscated by the obfuscation apparatus 1 according to the present invention.
In this example, the generating means 6 generates the first conditional branch S and the second conditional branch T using the first and second variables as the input variables a and b of the obfuscation target program, and the inserting means 7 However, as shown in FIG. 21, the first conditional branch S and the second conditional branch T are moved to positions p20 and p21 at positions separated from the program part pp that does not operate the variables a and b in the obfuscation target program. Inserting.

この第1の条件分岐Sは、変数aを余剰計算により場合分けする条件式if(a mod 2 ==0)と、変数bの可逆変換関数である条件節(b=2*b+3)を含んでいる。また、第2の条件分岐は、変数aを余剰計算により場合分けする2つの条件式if(a mod 4==0)とif(a mod 4==2)と、これら場合毎に変数bを元の値に戻す逆変換関数である2つの条件節(b=(b―3)/2)と(b=(b―3)/2)とを含んでいる。
ここで、この例では、第1の条件分岐における条件式は変数aを1つに場合分けしていることに相当する。なお、変数aを複数に場合分けする時には、図5に示す第2の条件分岐Tのように、条件分岐は、複数の条件式からなる和集合と、それぞれの条件式に対応する条件節とを含むものとなる。
The first conditional branch S includes a conditional expression if (a mod 2 == 0) for dividing the variable a by a surplus calculation and a conditional clause (b = 2 * b + 3) which is a reversible transformation function of the variable b. It is out. Further, the second conditional branch includes two conditional expressions if (a mod 4 == 0) and if (a mod 4 == 2) for dividing the variable a by surplus calculation, and the variable b for each of these cases. It includes two conditional clauses (b = (b−3) / 2) and (b = (b−3) / 2), which are inverse transformation functions for restoring the original values.
Here, in this example, the conditional expression in the first conditional branch corresponds to dividing the variable a into one case. When the variable a is divided into a plurality of cases, as in the second conditional branch T shown in FIG. 5, the conditional branch is a union consisting of a plurality of conditional expressions and conditional clauses corresponding to the respective conditional expressions. Will be included.

図5に示す難読化したプログラムでは、明らかに、第1の条件分岐による条件節(b=2*b+3)が実行されれば、必ず、変数bを操作しないプログラム部分ppを隔てた第2の条件分岐における条件節(b=(b―3)/2)も実行される。
したがって、第1と第2の条件分岐を挿入しても、変数bの値は元のプログラムにおいて使用される元の値に戻され、これら第1と第2の条件分岐はプログラムの意味を変更しない。
Obviously, in the obfuscated program shown in FIG. 5, if the conditional clause (b = 2 * b + 3) by the first conditional branch is executed, the second program part pp that does not operate the variable b is always separated. The conditional clause (b = (b−3) / 2) in the conditional branch is also executed.
Therefore, even if the first and second conditional branches are inserted, the value of the variable b is returned to the original value used in the original program, and these first and second conditional branches change the meaning of the program. do not do.

図6及び図7を参照して、図21に示すプログラムを難読化対象として、本例の難読化装置1で実施される処理の第1実施例を説明する。
本実施例の特徴は、条件分岐生成手段6が、第1の条件分岐Sと第2の条件分岐Tにそれぞれ含まれる条件式を生成するために、剰余演算を用いた条件式から成る、互いに和集合として同値であり、かつ、集合としては異なる条件式の和集合S’、T’を生成することである。
この実施例での難読化装置1は、図6に示すような手順S61〜S66に従って処理を行う。
With reference to FIG. 6 and FIG. 7, a first example of processing executed by the obfuscation apparatus 1 of this example will be described with the program shown in FIG. 21 as an obfuscation target.
The feature of the present embodiment is that the conditional branch generation means 6 is composed of conditional expressions using a remainder calculation in order to generate conditional expressions respectively included in the first conditional branch S and the second conditional branch T. It is to generate union sets S ′ and T ′ having the same value as the union set and different conditional expressions as the set.
The obfuscation apparatus 1 in this embodiment performs processing according to procedures S61 to S66 as shown in FIG.

入力手段22で難読化対象のプログラムを入力として受け取り、解析手段5及び条件分岐生成手段6が難読化対象関数を決める(S61)。
具体的には、条件分岐生成手段6が、難読化対象関数の入力変数aを適当に選び、更に、2以上の整数nを適当に選び、このaとnを用いて、次の定める条件式の和集合S’、T’を生成する(S62)。
S’={a mod 2==0、a mod 2==1}。
T’={a mod 2*n==0、a mod 2*n==1、・・a mod 2*n==2*n―2、a mod 2*n==2*n―1 }。
The input unit 22 receives the obfuscation target program as input, and the analysis unit 5 and conditional branch generation unit 6 determine the obfuscation target function (S61).
Specifically, the conditional branch generation means 6 appropriately selects the input variable a of the obfuscation target function, further appropriately selects an integer n of 2 or more, and uses this a and n to define the following conditional expression: A union set S ′, T ′ is generated (S62).
S ′ = {a mod 2 == 0, a mod 2 == 1}.
T ′ = {a mod 2 * n == 0, a mod 2 * n == 1, a mod 2 * n == 2 * n−2, a mod 2 * n == 2 * n−1} .

そして、条件分岐生成手段6が、2つの可逆関数g1、g2を生成する(S63)。具体的には、難読化対象関数中から、g1、g2による操作対象の変数bを適当に選び、更に、解析手段5が、難読化対象プログラム中の挿入位置(図21のp20、p21参照)を決定する。ただし、p20とp21の間で変数bは使われないとする(S64)。   Then, the conditional branch generation means 6 generates two reversible functions g1 and g2 (S63). Specifically, the variable b to be manipulated by g1 and g2 is appropriately selected from the obfuscation target functions, and the analysis unit 5 further inserts the obfuscation target program in the obfuscation target program (see p20 and p21 in FIG. 21). To decide. However, it is assumed that the variable b is not used between p20 and p21 (S64).

そして、挿入手段7が、位置p20とp21に次のように条件分岐を挿入する(S65)。
第1の条件分岐の集合Sとして、(a mod 2== 0)を条件式、変数bを関数g1によって変更する文を条件節とした条件分岐{if( a mod 2 ==0) b=g1(b)}と、(a mod 2 == 1)を条件式、変数bを関数g2によって変更する文を条件節とした条件分岐{if(a mod 2==1) b=g2(b)}とを位置p1に挿入する。
Then, the insertion means 7 inserts a conditional branch at the positions p20 and p21 as follows (S65).
As a set S of first conditional branches, a conditional branch {if (a mod 2 == 0) where (a mod 2 == 0) is a conditional expression, and a sentence in which the variable b is changed by the function g1 is a conditional clause {if (a mod 2 == 0) b = g1 (b)}, conditional branch {if (a mod 2 == 1) b = g2 (b) where (a mod 2 == 1) is a conditional expression and a statement that changes the variable b by the function g2 is a conditional clause )} At position p1.

また、第2の条件分岐の集合Tとして、(a mod2*n==0)、(a mod 2*n==2)、 …、(a mod 2*n==2*n ―2)を条件式、変数bをg1の逆関数g1‘によって変更する文を条件節としたn個の条件分岐{if(a mod 2*n==0) b = g1’(b)}、{if(a mod 2*n==2 ) b=g1‘(b)}、…、{if(a mod 2*n==2*n―2) b=g1’(b)}と、(a mod 2*n==1)、(a mod 2*n==3)、…、(a mod 2*n==2*n―1)を条件式、変数bをg2の逆関数g2‘によって変更する文を条件節としたn個の条件分岐{if(a mod 2*n==1) b=g2’(b)}、{if(a mod 2*n==3 ) b=g2‘(b)}、… 、{if(a mod 2*n==2*n―1) b=g2’(b)}を位置p2に挿入して、出力手段4が難読化したプログラムを出力する(S66)。   Further, as a set T of second conditional branches, (a mod 2 * n == 0), (a mod 2 * n == 2),..., (A mod 2 * n == 2 * n−2) are used. N conditional branches {if (a mod 2 * n == 0) b = g1 ′ (b)}, {if () where a conditional expression is a sentence that changes the variable b by the inverse function g1 ′ of g1. a mod 2 * n == 2) b = g1 ′ (b)},... {if (a mod 2 * n == 2 * n−2) b = g1 ′ (b)} and (a mod 2 * N == 1), (a mod 2 * n == 3),..., (A mod 2 * n == 2 * n−1) is changed by a conditional expression, and variable b is changed by an inverse function g2 ′ of g2. N conditional branches with a sentence as a conditional clause {if (a mod 2 * n == 1) b = g2 ′ (b)}, {if (a mod 2 * n == 3) b = g2 ′ (b )}, , {If (a mod 2 * n == 2 * n-1) b = g2 '(b)} to be inserted at the position p2, the output unit 4 outputs a program obfuscation (S66).

図7には、本実施例によって難読化されたプログラムを例示してある。
図7のプログラムは、図21の関数f00に難読化を適用した例であり、上の手順S61〜S66を行う際に、手順S62、S63、S64でそれぞれ次のようにパラメーターを定めている。
手順S62において、難読化対象関数の入力変数aとしてf00の入力変数aを、2以上の整数nとして2を選ぶ。
手順S63において、可逆関数g1、g2としてg1(x)=2*x+3、g2(x)=4*x―5を生成する。
手順S64において、g1、g2による操作対象として、f00の変数bを選び、難読化対象関数(プログラム)中の位置として、f00中のp20、p21を選ぶ。
FIG. 7 illustrates a program obfuscated by this embodiment.
The program in FIG. 7 is an example in which obfuscation is applied to the function f00 in FIG. 21. When performing the above steps S61 to S66, parameters are defined in steps S62, S63, and S64 as follows.
In step S62, the input variable a of f00 is selected as the input variable a of the obfuscation target function, and 2 is selected as the integer n of 2 or more.
In step S63, g1 (x) = 2 * x + 3 and g2 (x) = 4 * x-5 are generated as the reversible functions g1 and g2.
In step S64, the variable b of f00 is selected as an operation target by g1 and g2, and p20 and p21 in f00 are selected as positions in the obfuscation target function (program).

図7の難読化されたプログラムの動作について説明する。
変数aの値は2の倍数であるか否かによって、第1の条件分岐集合Sの2つの条件節(b=2*b+3)、(b=4*b―5)のいずれか一方が実行される。
変数aが2の倍数であったと仮定すると、この時、1つ目の条件節が実行されるので、変数bの値は2*b+3に変化する。
そして、実行が第2の条件分岐集合Tに進むと、変数aは2の倍数だと仮定しているので、 条件式(a mod 4==0)、(a mod 4==1)、(a mod 4==2)、(a mod 4==3)のうち、(a mod 4==0)、(a mod 4==2)のいずれか一方が必ず真になり、(a mod 4==1)、(a mod 4==3)はいずれも偽になる。
The operation of the obfuscated program in FIG. 7 will be described.
Depending on whether the value of the variable a is a multiple of 2, one of the two conditional clauses (b = 2 * b + 3) and (b = 4 * b-5) of the first conditional branch set S is executed. Is done.
Assuming that the variable a is a multiple of 2, at this time, since the first conditional clause is executed, the value of the variable b changes to 2 * b + 3.
Then, when execution proceeds to the second conditional branch set T, it is assumed that the variable a is a multiple of 2. Therefore, the conditional expressions (a mod 4 == 0), (a mod 4 == 1), ( Of (a mod 4 == 2) and (a mod 4 == 3), either (a mod 4 == 0) or (a mod 4 == 2) is always true, and (a mod 4 == 1) and (a mod 4 == 3) are both false.

(a mod 4==0)と(a mod 4==2)のいずれが真になった場合も、条件節として(b=(b―3)/2)が実行されるので、変数bの値は(b―3)/2に変化し、変数bの値は元に戻る。
実行は{return a + b;}文に到達するが、変数bの値は元に戻っているので、このときに返す値は図21の難読化前のプログラムのケースと同一である。
なお、変数aが2の倍数でない場合も、同様に、変数bの値は元に戻るので、返す値は図21の難読化前のプログラムのケースと同一である。
Regardless of whether (a mod 4 == 0) or (a mod 4 == 2) is true, (b = (b−3) / 2) is executed as a conditional clause. The value changes to (b-3) / 2, and the value of variable b returns to the original value.
Execution reaches the {return a + b;} statement, but since the value of the variable b has been restored, the value returned at this time is the same as the case of the program before obfuscation in FIG.
Even when the variable a is not a multiple of 2, similarly, the value of the variable b returns to the original value, so the value to be returned is the same as the case of the program before obfuscation in FIG.

なお、手順S62において条件分岐を生成する際に、難読化対象のプログラムに元々含まれる任意の2つの条件節間の相関度に基づいてもよい。具体的には、後に示す手順1、2に従ってnを選んでもよい。
ここで、手順1、2を示す前に、条件節間の相関度について説明する。プログラムにおいて、同じブロック構造に2つの条件分岐 {if(s1)h1}と{if(s2)h2}があるとする(図12、図13参照)。この時、2つの条件節h1、h2が同時に実行される度合いを、h1、h2の相関度と定める。頻度分析において、十分な回数、プログラムに適当な入力を与えて実行をトレースすることで、h1、h2間の相関度を計算できる。例えば、図14のプログラムの条件分岐{if(0<a<=100)h1}と{if(0<a<=50)h2}に関して、頻度分析において変数aをランダムに変えて実行トレースを何度もとることで、h1とh21の相関度として0.5に十分近い値が得られる。
Note that when generating a conditional branch in step S62, it may be based on the degree of correlation between any two conditional clauses originally included in the obfuscated program. Specifically, n may be selected according to procedures 1 and 2 described later.
Here, before showing procedure 1 and 2, the correlation degree between conditional clauses is demonstrated. In the program, it is assumed that there are two conditional branches {if (s1) h1} and {if (s2) h2} in the same block structure (see FIGS. 12 and 13). At this time, the degree to which the two conditional clauses h1 and h2 are simultaneously executed is defined as the correlation degree between h1 and h2. In the frequency analysis, the degree of correlation between h1 and h2 can be calculated by tracing the execution by giving an appropriate input to the program a sufficient number of times. For example, regarding the conditional branches {if (0 <a <= 100) h1} and {if (0 <a <= 50) h2} of the program of FIG. 14, what is the execution trace by changing the variable a randomly in the frequency analysis? As a result, a value sufficiently close to 0.5 is obtained as the degree of correlation between h1 and h21.

手順1、2を次に示す。
手順1:プログラムに元々含まれる任意の2つの条件節について相関度を求め、相関度の平均値Qを計算する。プログラムの実行時間と実行トレースを取る回数をともに定数とすると、この操作の計算量オーダーは高々O(k^2)である(kは難読化対象関数に含まれる条件節の数)。
手順2:そして、1/n<=Qを満たすnを選ぶ。
Procedures 1 and 2 are as follows.
Procedure 1: The correlation is obtained for any two conditional clauses originally included in the program, and the average value Q of the correlation is calculated. If the execution time of the program and the number of execution traces are both constants, the computational complexity order of this operation is at most O (k ^ 2) (k is the number of conditional clauses included in the obfuscated function).
Procedure 2: Then, select n satisfying 1 / n <= Q.

図8〜図14を参照して、本例の難読化装置1で実施される処理の第2実施例を説明する。
本実施例の特徴は、条件分岐生成手段6が、第1の条件分岐Sと第2の条件分岐Tにそれぞれ含まれる条件式を生成するために、ハッシュ関数を用いた条件式から成る、互いに和集合として同値であり、かつ、集合として異なる条件式の和集合S’、T’を生成することである。
本実施例での難読化装置1は、図8に示すように手順S81〜S86に従って処理を行う。なお、実施例1と異なる手順はS82とS85である。
With reference to FIGS. 8-14, the 2nd Example of the process implemented with the obfuscation apparatus 1 of this example is described.
The feature of this embodiment is that the conditional branch generation means 6 includes conditional expressions using hash functions for generating conditional expressions respectively included in the first conditional branch S and the second conditional branch T. It is to generate union sets S ′ and T ′ having the same value as the union and different conditional expressions as the set.
The obfuscation apparatus 1 in this embodiment performs processing according to steps S81 to S86 as shown in FIG. The steps different from those in the first embodiment are S82 and S85.

本実施例では、ハッシュ関数hashを用いており、hashの返り値は120bitとしている。
入力手段2で難読化対象のプログラムを入力として受け取り、解析手段5及び条件分岐生成手段6で難読化対象関数を決める(S81)。具体的には、難読化対象関数の入力変数aを適当に選び、更に、2以上の整数nを適当に選び、このaとnを用いて、次の定める条件式の和集合S’、T’を生成する(S82)。ただし、以下では、N=2^(120―n)とする。
In this embodiment, a hash function hash is used, and the return value of hash is 120 bits.
The input means 2 receives the obfuscation target program as input, and the analysis means 5 and conditional branch generation means 6 determine the obfuscation target function (S81). Specifically, the input variable a of the obfuscation target function is appropriately selected, and an integer n of 2 or more is appropriately selected. 'Is generated (S82). However, in the following, it is assumed that N = 2 ^ (120−n).

S’={0<=hash(a)<(2^120)/2、(2^120)/2<=hash(a)<2^120}。
T’={0<=hash(a)<1*N、1*N<=hash(a)<2*N、…、(2^n―2)*N<=hash(a)<(2^n―1)*N、(2^n―1)*N <=hash(a)<2^n*N}。
S ′ = {0 <= hash (a) <(2 ^ 120) / 2, (2 ^ 120) / 2 <= hash (a) <2 ^ 120}.
T ′ = {0 <= hash (a) <1 * N, 1 * N <= hash (a) <2 * N,..., (2 ^ n−2) * N <= hash (a) <(2 ^ N-1) * N, (2 ^ n-1) * N <= hash (a) <2 ^ n * N}.

そして、2つの可逆関数g1、g2を生成する(S83)。難読化対象関数中から、g1、g2による操作対象の変数bを適当に選び、更に、難読化対象関数中の位置p1、p2を決定する。ただし、位置p1とp2の間のプログラム部分ppでは変数bは使われないとする(S84)。
そして、挿入手段7が、位置p1、p2に、次のような条件分岐S、Tをそれぞれ挿入し(S85)、難読化したプログラムを出力手段4が出力する(S86)。
Then, two reversible functions g1 and g2 are generated (S83). The variable b to be manipulated by g1 and g2 is appropriately selected from the obfuscation target functions, and the positions p1 and p2 in the obfuscation target function are determined. However, it is assumed that the variable b is not used in the program part pp between the positions p1 and p2 (S84).
Then, the insertion means 7 inserts the following conditional branches S and T at the positions p1 and p2 (S85), respectively, and the output means 4 outputs the obfuscated program (S86).

条件分岐Sとして、条件式和集合S’の0<=hash(a)<(2^120)/2を条件式、 bをg1によって変更する文を条件節とした条件分岐if(0<=hash(a)<(2^120)/2=g1(b)=g1(b)をp1に挿入する。
また、条件分岐Sとして、条件式和集合S’の(2^120)/2<=hash(a)<2^120を条件式、bをg2によって変更する文を条件節とした条件分岐if((2^120)/2<=hash(a)<(2^120)b=g2(b)をp1に挿入する。
Conditional branch if (0 <= hash (a) <(2 ^ 120) / 2 of conditional expression union set S ′) is used as conditional branch S, and conditional sentence is a statement that changes b by g1. Hash (a) <(2 ^ 120) / 2 = g1 (b) = g1 (b) is inserted into p1.
Also, as conditional branch S, conditional branch if with (2 ^ 120) / 2 <= hash (a) <2 ^ 120 of conditional expression union S ′ as a conditional expression and a sentence that changes b by g2 as a conditional clause. ((2 ^ 120) / 2 <= hash (a) <(2 ^ 120) b = g2 (b) is inserted into p1.

条件分岐Tとして、条件式和集合T’の0<=hash(a)<1*N、1*N<=hash(a)<2*N、…、(2^(n―1))*N<=hash(a)<(2^(n―1)+1)*Nを条件式、bをg1の逆関数g1‘によって変更する文を条件節としたn個の条件分岐if(0<=hash(a)<1*N)b=g1’(b)、if(1*N<=hash(a)<2*N)b=g1‘(b)、…、if((2^(n―1))*N<=hash(a)<(2^(n―1)+ 1)*N )b=g1’(b)をp2に挿入する。
条件式Tとして、条件式和集合T’の(2^(n―1)+1)*N<=hash(a)<(2^(n―1)+2)*N、(2^(n―1)+2)*N<=hash(a)<(2^(n―1)+ 3)*N、…、(2^n ― 1)*N<=hash(a)<(2^n)*Nを条件式、bをg2の逆関数g2‘によって変更する文を条件節としたn個の条件分岐if((2^(n―1)+1)*N<=hash(a)<(2^(n―1)+ 2)*N)b=g2’(b)、if((2^(n―1)+2)*N<=hash(a)<(2^(n―1)+3)*N)b=g2‘(b)、… 、if((2^n ― 1)*N<=hash(a)<(2^n)*N)b=g2’(b)をp2に挿入する。
As conditional branch T, 0 <= hash (a) <1 * N, 1 * N <= hash (a) <2 * N,..., (2 ^ (n−1)) * of conditional expression union T ′ N conditional branches if (0 <0) where N <= hash (a) <(2 ^ (n−1) +1) * N is a conditional expression, and b is a conditional clause that is changed by an inverse function g1 ′ of g1. = Hash (a) <1 * N) b = g1 ′ (b), if (1 * N <= hash (a) <2 * N) b = g1 ′ (b),..., If ((2 ^ ( n-1)) * N <= hash (a) <(2 ^ (n-1) +1) * N) b = g1 '(b) is inserted into p2.
As the conditional expression T, (2 ^ (n−1) +1) * N <= hash (a) <(2 ^ (n−1) +2) * N of the conditional expression union T ′, (2 ^ (n− 1) +2) * N <= hash (a) <(2 ^ (n-1) +3) * N, ..., (2 ^ n-1) * N <= hash (a) <(2 ^ n) * N conditional branches if ((2 ^ (n-1) +1) * N <= hash (a) <() where N is a conditional expression and b is a conditional clause that is changed by an inverse function g2 ′ of g2. 2 ^ (n-1) +2) * N) b = g2 '(b), if ((2 ^ (n-1) +2) * N <= hash (a) <(2 ^ (n-1) +3) * N) b = g2 ′ (b),..., If ((2 ^ n−1) * N <= hash (a) <(2 ^ n) * N) b = g2 ′ (b) is p2 Insert into.

図9には、本実施例によって難読化されたプログラムの例を示してある。図9のプログラムは、図21の関数f00に難読化を適用した例である。
なお、図12〜図14には、2つの条件分岐を挿入した他の例を示してある。
FIG. 9 shows an example of a program obfuscated by this embodiment. The program in FIG. 9 is an example in which obfuscation is applied to the function f00 in FIG.
12 to 14 show other examples in which two conditional branches are inserted.

上記の手順S81〜S86を行う際に、手順S82、S83、S84でそれぞれ次のようにパラメーターを定めている。
手順S82において、難読化対象関数の入力変数aとしてf00の入力変数aを、2以上の整数nとして2を選ぶ。
手順S83において、可逆関数g1、g2としてg1(x)=2*x+3、g2(x)=4*x―5を生成する。
手順S84において、g1、g2による操作対象として、f00の変数bを選び、難読化対象関数中の位置p1、p2として、f00中のp20、p21を選ぶ。
このプログラムも図7のプログラムと同様、図21と同じ動作をする。
When performing the above steps S81 to S86, parameters are determined as follows in steps S82, S83, and S84, respectively.
In step S82, the input variable a of f00 is selected as the input variable a of the obfuscation target function, and 2 is selected as the integer n of 2 or more.
In step S83, g1 (x) = 2 * x + 3 and g2 (x) = 4 * x-5 are generated as the reversible functions g1 and g2.
In step S84, the variable b of f00 is selected as the operation target by g1 and g2, and p20 and p21 in f00 are selected as the positions p1 and p2 in the obfuscation target function.
Similar to the program of FIG. 7, this program operates in the same manner as FIG.

第2実施例でも、第1実施例と同様に、手順S82においてnを選ぶ際に、次の手順1、2に従ってもよい。なお、この手順は、第1実施例で示した手順1、2と同じである。
手順1:プログラムに元々含まれる任意の2つの条件節について相関度を求め、相関度の平均値Qを計算する。プログラムの実行時間と実行トレースを取る回数をともに定数とすると、この操作の計算量オーダーは高々O(k^2)である(kは難読化対象関数に含まれる条件節の数)。
手順2:1/n<=Qを満たすnを選ぶ。
In the second embodiment, as in the first embodiment, when n is selected in step S82, the following steps 1 and 2 may be followed. This procedure is the same as the procedures 1 and 2 shown in the first embodiment.
Procedure 1: The correlation is obtained for any two conditional clauses originally included in the program, and the average value Q of the correlation is calculated. If the program execution time and the number of execution traces are both constants, the computational complexity order of this operation is at most O (k ^ 2) (k is the number of conditional clauses included in the obfuscated function).
Procedure 2: Select n satisfying 1 / n <= Q.

ここで、上記の第1及び第2実施例では第1の条件分岐Sが含む条件式を難読化対象のプログラム中における第1の変数aの取り得る値の全範囲で当該第1の変数aの値を場合分けする条件式としているが、本発明では、第1の変数aの取り得る値の部分的な範囲で当該第1の変数aの値を場合分けする条件式としてもよい。   Here, in the first and second embodiments, the conditional expression included in the first conditional branch S is the first variable a in the entire range of possible values of the first variable a in the obfuscated program. However, in the present invention, the value of the first variable a may be divided into a partial range of possible values of the first variable a.

具体的には、第2実施例では、第1の条件分岐Sで図10(a)に示すように変数aの取り得る値の範囲2^120を2等分したAの範囲とBの範囲とに場合分けし、第2の条件分岐Tで図10(b)に示すように変数aの取り得る値の範囲2^120を4等分したC〜Fの範囲に場合分けしている。
これとは異なり、本発明では、第1の条件分岐Sで図11に示すように変数aの取り得る値の範囲の一部(XとYを除いた部分)場合分けし、この場合分けした範囲の変数aの値を第2の条件分岐Tで場合分けしてもよい。この場合、プログラムの実行において変数aの値が第1の条件分岐による場合分けから外れた範囲(Xの範囲とYの範囲)であるときには、挿入した第1と第2の条件分岐をパスすることとなるが、これによっても、プログラムの冗長化による難読化効果が得られる。
Specifically, in the second embodiment, as shown in FIG. 10A in the first conditional branch S, the range of values A 2 and the range B of which the value range 2 ^ 120 that the variable a can take is equally divided. In the second conditional branch T, as shown in FIG. 10B, the range of values 2 ^ 120 that the variable a can take is divided into C to F divided into four equal parts.
In contrast, in the present invention, in the first conditional branch S, as shown in FIG. 11, a part of the range of values that can be taken by the variable a (part excluding X and Y) is divided, and this case is divided. The value of the variable a in the range may be divided according to the second conditional branch T. In this case, when the value of the variable a is in a range (X range and Y range) that is not classified by the first conditional branch in the execution of the program, the inserted first and second conditional branches are passed. However, this also provides the obfuscation effect by making the program redundant.

図15、図16を参照して、本例の難読化装置1で実施される処理の第3実施例を説明する。
本実施例での難読化装置1は、図15に示すように手順S151〜S156に従って処理を行う。
本実施例の特徴は、手順S152において入力変数aを用いて生成する条件式の和集合S’、T’が変数aの取り得る全ての条件を網羅していない点と、手順S155において関数g1の逆関数g1‘によって変数bのg1による変更を戻す文を挿入する際に、b=g1’(b)と構文は異なるが意味的には等価な文を挿入する点である。
With reference to FIG. 15 and FIG. 16, a third embodiment of the process performed in the obfuscation apparatus 1 of this example will be described.
The obfuscation apparatus 1 in this embodiment performs processing according to steps S151 to S156 as shown in FIG.
The feature of this embodiment is that the union S ′, T ′ of the conditional expressions generated using the input variable a in step S152 does not cover all the conditions that the variable a can take, and the function g1 in step S155. When a sentence that returns the change of the variable b by g1 is inserted by the inverse function g1 ′, a sentence that is syntactically different from b = g1 ′ (b) but semantically equivalent is inserted.

入力手段2で難読化対象のプログラムを入力として受け取り、解析手段5及び条件分岐生成手段6で、難読化対象関数を決め(S151)、難読化対象関数の入力変数aを適当に選び、更に、2以上の整数nを適当に選び、このaとnを用いて、次の定める条件式の和集合S’、T’を生成する(S152)。
S’=[a mod 2==0]
T’= [a mod 2*n==0、…、a mod 2*n==2*n ― 2]
The input unit 2 receives the obfuscation target program as input, the analysis unit 5 and the conditional branch generation unit 6 determine the obfuscation target function (S151), appropriately select the input variable a of the obfuscation target function, An integer n of 2 or more is appropriately selected, and the unions S ′ and T ′ of conditional expressions defined below are generated using a and n (S152).
S ′ = [a mod 2 == 0]
T ′ = [a mod 2 * n == 0,..., A mod 2 * n == 2 * n−2]

そして、解析手段5及び条件分岐生成手段6で、可逆関数g1を生成する(S153)。難読化対象関数中から、g1による操作対象の変数bを適当に選び、更に、難読化対象関数中の位置p1、p2を決定する。ただし、p1とp2の間でa、bは使われないとする(S154)。
そして、挿入手段7が位置p1、p2に、次のような条件分岐を挿入し(S155)、出力手段4が難読化したプログラムを出力する(S156)。
And the reversible function g1 is produced | generated by the analysis means 5 and the conditional branch production | generation means 6 (S153). The variable b to be manipulated by g1 is appropriately selected from the obfuscation target functions, and the positions p1 and p2 in the obfuscation target function are determined. However, a and b are not used between p1 and p2 (S154).
Then, the insertion unit 7 inserts the following conditional branch at the positions p1 and p2 (S155), and the output unit 4 outputs the obfuscated program (S156).

具体的には、第1の条件分岐集合Sとして、条件式和集合S’のa mod 2==0を条件式、bを関数g1によって変更する文を条件節とした条件分岐if(a mod 2==0)、b=g1(b)をp1に挿入する。
第2の条件分岐集合Tとして、条件式和集合T’のa mod 2*n==0、a mod 2*n==2、…、a mod 2*n==2*n―2を条件式、bをg1の逆関数g1‘によって変更する文と等価な文z1、 …、znを条件節としたn個の条件分岐if(a mod 2*n==0)z1、if(a mod 2*n==2)z2、…、if(a mod 2*n==2*n―2)znをp2に挿入する。
Specifically, as the first conditional branch set S, a conditional branch if (a mod) in which a mod 2 == 0 of the conditional expression union S ′ is a conditional expression, and a sentence in which b is changed by the function g1 is a conditional clause. 2 == 0) and b = g1 (b) are inserted into p1.
As a second conditional branch set T, a mod 2 * n == 0, a mod 2 * n == 2,..., A mod 2 * n == 2 * n-2 of the conditional expression union T ′ A statement z1, equivalent to a statement that changes the expression b by the inverse function g1 ′ of g1,..., N conditional branches if (a mod 2 * n == 0) z1, if (a mod 2 * n == 2) z2,..., If (a mod 2 * n == 2 * n-2) zn is inserted into p2.

図16に、本実施例によって難読化されたプログラムの例を示してある。なお、図16のプログラムは、図21の関数f00に難読化を適用した例である。
上記の手順S151〜S156を行う際に、手順S152、S153、S154、S155でそれぞれ次のようにパラメーターを定めている。
手順S152において、難読化対象関数の入力変数aとしてf00の入力変数aを、2以上の整数nとして2を選ぶ。
手順S153において、可逆関数g1としてg1(x)=8*x+2を生成する。
FIG. 16 shows an example of a program obfuscated by this embodiment. Note that the program in FIG. 16 is an example in which obfuscation is applied to the function f00 in FIG.
When performing the above steps S151 to S156, parameters are determined as follows in steps S152, S153, S154, and S155, respectively.
In step S152, the input variable a of f00 is selected as the input variable a of the obfuscation target function, and 2 is selected as the integer n of 2 or more.
In step S153, g1 (x) = 8 * x + 2 is generated as the reversible function g1.

手順S154において、g1による操作対象として、f00の変数bを選び、難読化対象関数中の位置p1、p2としてf00中のp2020p21を選ぶ。
手順S1555において、bをg1の逆関数g1‘によって変更する文と等価な文z1、z2を以下のように選ぶ。
z1={b=b―2;b=b/8;}
z2={b=b―3;b=b+1;b=b/8;}
In step S154, the variable b of f00 is selected as the operation target by g1, and p2020p21 in f00 is selected as the positions p1 and p2 in the obfuscation target function.
In step S1555, sentences z1 and z2 equivalent to a sentence in which b is changed by the inverse function g1 ′ of g1 are selected as follows.
z1 = {b = b-2; b = b / 8;}
z2 = {b = b-3; b = b + 1; b = b / 8;}

図16のプログラムも図7のプログラムと同様、図21と同じ動作をする。
また、本実施例でも、第1実施例と同様に、手順S152においてnを選ぶ際に次の手順1、2に従ってもよい。この手順は、第1実施例で示した手順1、2と同じである。
手順1:プログラムに元々含まれる任意の2つの条件節について相関度を求め、相関度の平均値Qを計算する。プログラムの実行時間と実行トレースを取る回数をともに定数とすると、この操作の計算量オーダーは高々O(k^2)である(kは難読化対象関数に含まれる条件節の数)。
手順2:1/n <=Qを満たすnを選ぶ。
The program of FIG. 16 performs the same operation as that of FIG.
Also in this embodiment, similarly to the first embodiment, when n is selected in step S152, the following steps 1 and 2 may be followed. This procedure is the same as the procedures 1 and 2 shown in the first embodiment.
Procedure 1: The correlation is obtained for any two conditional clauses originally included in the program, and the average value Q of the correlation is calculated. If the execution time of the program and the number of execution traces are both constants, the computational complexity order of this operation is at most O (k ^ 2) (k is the number of conditional clauses included in the obfuscated function).
Procedure 2: Select n satisfying 1 / n <= Q.

図17、図18を参照して、本例の難読化装置1で実施される処理の第4実施例を説明する。
本実施例での難読化装置1は、図17に示すように手順S171〜S176に従って処理を行う。
本実施例の特徴は、挿入する条件節において複数の変数を操作する点である。具体的には、手順S173において生成する可逆変数g1、g2はそれぞれ2つの入力と出力を持ち、更に、手順S174においては操作対象の変数を2つ(b、c)選ぶ。
With reference to FIGS. 17 and 18, a fourth embodiment of the process performed by the obfuscation apparatus 1 of this example will be described.
The obfuscation apparatus 1 in the present embodiment performs processing according to steps S171 to S176 as shown in FIG.
The feature of this embodiment is that a plurality of variables are manipulated in the conditional clause to be inserted. Specifically, the reversible variables g1 and g2 generated in step S173 each have two inputs and outputs, and in step S174, two variables (b, c) to be operated are selected.

入力手段2でプログラムを入力として受け取り、解析手段5及び条件分岐生成手段6で難読化対象関数の入力変数a適当に選び、2上の整数n適当に選び、このaとnを用いて、次の定める条件式の和集合S’、T’を生成する(S172)。
S’=[a mod 2==0、a mod 2==1]。
T’=[a mod 2*n==0、a mod 2*n==1、…、a mod 2*n==2*n―2、a mod 2*n==2*n ― 1]。
The input means 2 receives the program as input, the analysis means 5 and the conditional branch generation means 6 appropriately select the input variable a of the obfuscation target function, appropriately select the integer n above 2, and use this a and n to A union set S ′ and T ′ of the conditional expressions defined by is generated (S172).
S ′ = [a mod 2 == 0, a mod 2 == 1].
T ′ = [a mod 2 * n == 0, a mod 2 * n == 1, ... a mod 2 * n == 2 * n-2, a mod 2 * n == 2 * n-1] .

そして、解析手段5及び条件分岐生成手段6で、2つの入力をもつ可逆関数g1、g2を生成し(S173)、難読化対象関数中からg1、g2による操作対象の変数b、cを適当に選び、更に、難読化対象関数中の位置p1、p2を決定する。ただし、p1とp2の間でa、b、cは使われないとする(S174)。
そして、挿入手段7が位置p1、p2に、次のような条件分岐を挿入して(S175)、出力手段4が難読化したプログラムを出力する(S176)。
Then, the analyzing means 5 and the conditional branch generating means 6 generate reversible functions g1 and g2 having two inputs (S173), and appropriately select variables b and c to be manipulated by g1 and g2 from the obfuscated functions. Further, positions p1 and p2 in the obfuscation target function are determined. However, a, b, and c are not used between p1 and p2 (S174).
Then, the insertion unit 7 inserts the following conditional branch at the positions p1 and p2 (S175), and the output unit 4 outputs the obfuscated program (S176).

第1の条件分岐集合Sとして、条件式和集合S’のa mod 2==0を条件式、b、cを関数g1によって変更する文を条件節とした条件分岐if(a mod 2==0)(b、c)=g1(b、c);をp1に挿入する。
また、第1の条件分岐集合Sとして、条件式和集合S’のa mod 2==1を条件式、b、cをg2によって変更する文を条件節とした条件分岐 if(a mod 2==0)(b、c)=g2(b、c);をp1に挿入する。
As a first conditional branch set S, a conditional branch if (a mod 2 ==) where a mod 2 == 0 of the conditional expression union S ′ is a conditional expression, and a statement that changes b and c by the function g1 is a conditional clause. 0) (b, c) = g1 (b, c); is inserted into p1.
Further, as the first conditional branch set S, a conditional branch if (a mod 2 =) in which conditional expression is a mod 2 == 1 of the conditional expression union set S ′, and a conditional clause is a sentence in which b and c are changed by g2. = 0) (b, c) = g2 (b, c);

更に、第2の条件分岐集合Tとして、条件式和集合T’のa mod 2*n==0、a mod 2*n==2、 …、 a mod 2*n==2*n―2を条件式、b、cをg1の逆関数g1‘によって変更する文を条件節としたn個の条件分岐if(a mod 2*n==0)(b、c)=g1’(b、c);、if(a mod 2*n==2 )(b、c)=g1‘(b、c);、…、if(a mod 2*n==2*n―2)(b、c)=g1’(b、c);をp2に挿入する。
また、第2の条件分岐集合Tとして、条件式和集合T’のa mod 2*n==1、a mod 2*n==3、…、a mod 2*n==2*n―1を条件式、b、cをg2の逆関数g2‘によって変更する文を条件節としたn個の条件分岐if(a mod 2*n==1 )(b、c)=g2‘(b、c);、if(a mod 2*n==3)(b、c)=g2‘(b、c);、…、if(a mod 2*n==2*n―1)(b、c)=g2‘(b、c);をp2に挿入する。
Further, as the second conditional branch set T, a mod 2 * n == 0, a mod 2 * n == 2, ..., a mod 2 * n == 2 * n-2 of the conditional expression union T ′ Is a conditional expression, and b and c are conditional branches if (a mod 2 * n == 0) (b, c) = g1 ′ (b, c) ;, if (a mod 2 * n == 2) (b, c) = g1 '(b, c) ;, ..., if (a mod 2 * n == 2 * n-2) (b, c) = g1 ′ (b, c); is inserted into p2.
In addition, as the second conditional branch set T, a mod 2 * n == 1, a mod 2 * n == 3,..., A mod 2 * n == 2 * n−1 of the conditional expression union T ′. Is a conditional expression, and b, c are conditional statements if (a mod 2 * n == 1) (b, c) = g2 ′ (b, c) ;, if (a mod 2 * n == 3) (b, c) = g2 ′ (b, c);, ..., if (a mod 2 * n == 2 * n−1) (b, c) = g2 ′ (b, c); is inserted into p2.

図18に、本実施例によって難読化されたプログラムの例を示す。図18のプログラムは、図21の関数f00に難読化を適用した例である。
上記の手順S171〜S176を行う際に、手順S172、S173、S174でそれぞれ次のようにパラメーターを定めている。
手順S172において、難読化対象関数の入力変数aとしてf00の入力変数aを、2以上の整数nとして2を選ぶ。
手順S173において、複数の入力を持つ可逆関数g1、g2としてg1(x、y)=(2*x+3、5*y+4)、g2(x、y)=(4*x―5、6*y+7)を生成する。
手順S174において、g1、g2による操作対象として、f00の変数b、cを選び、難読化対象関数中の位置p1、p2として、f00中のp20、p21を選ぶ。
FIG. 18 shows an example of a program obfuscated by this embodiment. The program in FIG. 18 is an example in which obfuscation is applied to the function f00 in FIG.
When performing the above steps S171 to S176, the parameters are determined as follows in steps S172, S173, and S174, respectively.
In step S172, the input variable a of f00 is selected as the input variable a of the obfuscation target function, and 2 is selected as the integer n of 2 or more.
In step S173, reversible functions g1 and g2 having a plurality of inputs, g1 (x, y) = (2 * x + 3, 5 * y + 4), g2 (x, y) = (4 * x−5, 6 * y + 7) Is generated.
In step S174, variables b and c of f00 are selected as the operation targets by g1 and g2, and p20 and p21 in f00 are selected as positions p1 and p2 in the obfuscation target function.

図18のプログラムも図7のプログラムと同様、図21と同じ動作をする。
本実施例でも、第1実施例と同様に、手順S172においてnを選ぶ際に次の手順1,2に従ってもよい。この手順は、第1実施例で示した手順1、2と同じである。
手順1:プログラムに元々含まれる任意の2つの条件節について相関度を求め、相関度の平均値Qを計算する。プログラムの実行時間と実行トレースを取る回数をともに定数とすると、この操作の計算量オーダーは高々O(k^2)である(kは難読化対象関数に含まれる条件節の数)。
手順2:1/n<=Qを満たすnを選ぶ。
The program of FIG. 18 performs the same operation as that of FIG. 21 in the same manner as the program of FIG.
In the present embodiment, similarly to the first embodiment, the following procedures 1 and 2 may be performed when selecting n in step S172. This procedure is the same as the procedures 1 and 2 shown in the first embodiment.
Procedure 1: The correlation is obtained for any two conditional clauses originally included in the program, and the average value Q of the correlation is calculated. If the program execution time and the number of execution traces are both constants, the computational complexity order of this operation is O (k ^ 2) at most (k is the number of conditional clauses included in the obfuscated function).
Procedure 2: Select n satisfying 1 / n <= Q.

図19、図20を参照して、本例の難読化装置1で実施される処理の第5実施例を説明する。
本実施例での難読化装置1は、図19に示すように手順S191〜S196に従って処理を行う。
上記の各実施例では、複数の条件式からなる条件式和集合S’と、条件式和集合S’に同値であるが条件式和集合S’に含まれる条件式とは異なる条件式の条件式和集合T’と、複数の可逆な関数と、を用いているが、本実施例の特徴は、これに加えて条件式和集合S’(と条件式和集合T’)に同値であるが条件式和集合S’に含まれる条件式とも条件式和集合T’に含まれる条件式とも異なる条件式の条件式和集合U’を用いる点である。
本実施例での難読化装置1は、図19に示すような手順S191〜S196に従って処理を行う。
With reference to FIG. 19 and FIG. 20, a fifth example of the process performed by the obfuscation apparatus 1 of this example will be described.
The obfuscation apparatus 1 in the present embodiment performs processing according to steps S191 to S196 as shown in FIG.
In each of the above-described embodiments, a conditional expression union S ′ composed of a plurality of conditional expressions and a conditional expression condition that is equivalent to the conditional expression union S ′ but different from the conditional expressions included in the conditional expression union S ′. The expression union T ′ and a plurality of reversible functions are used. In addition to this, the feature of this embodiment is equivalent to the conditional expression union S ′ (and the conditional expression union T ′). Is that a conditional expression union U ′ having different conditional expressions from the conditional expressions included in the conditional expression union S ′ and the conditional expressions included in the conditional expression union T ′ is used.
The obfuscation apparatus 1 in this embodiment performs processing according to procedures S191 to S196 as shown in FIG.

入力手段2でプログラムを入力として受け取り、解析手段5及び条件分岐生成手段6で、難読化対象関数を決め(S191)、難読化対象関数の入力変数aを適当に選び、2以上の整数k、nを適当に選び、このaとk、nを用いて、次の定める条件式の和集合S’、T’、U’を生成する(S192)。
S’=[a mod 2 ==0、a mod 2==1]。
T’=[a mod 2*k==0、a mod 2*k==1、…、a mod 2*k==2*k―2、a mod 2*k==2*k―1]。
U’=[a mod 2*n==0、a mod 2*n==1、…、a mod 2*n==2*n―2、a mod 2*n==2*n―1]。
The input unit 2 receives a program as input, the analysis unit 5 and the conditional branch generation unit 6 determine an obfuscation target function (S191), appropriately select an input variable a of the obfuscation target function, an integer k of 2 or more, n is appropriately selected, and a set S ′, T ′, U ′ of the following conditional expressions is generated by using a, k, n (S192).
S ′ = [a mod 2 == 0, a mod 2 == 1].
T ′ = [a mod 2 * k == 0, a mod 2 * k == 1, ..., a mod 2 * k == 2 * k-2, a mod 2 * k == 2 * k-1] .
U ′ = [a mod 2 * n == 0, a mod 2 * n == 1,..., A mod 2 * n == 2 * n-2, a mod 2 * n == 2 * n−1] .

そして、解析手段5及び条件分岐生成手段6で、可逆関数g1、g2を生成し(S193)、難読化対象関数中からg1、g2による操作対象の変数bを適当に選び、難読化対象関数中の位置p1、p2、p3を決定する(S194)。ただし、位置p1、p2、p3の3つの位置のいずれの間でも変数a、bは使われないとする。
そして、挿入手段7が次のような条件分岐集合S、T、Uを位置p1、p2、p3に挿入し(S195)、出力手段4が難読化されたプログラムを出力する(S196)。
Then, the analysis means 5 and the conditional branch generation means 6 generate reversible functions g1 and g2 (S193), and appropriately select the variable b to be manipulated by g1 and g2 from the obfuscation target functions. Positions p1, p2, and p3 are determined (S194). However, it is assumed that the variables a and b are not used between any of the three positions p1, p2, and p3.
Then, the insertion means 7 inserts the following conditional branch sets S, T, U into the positions p1, p2, p3 (S195), and the output means 4 outputs the obfuscated program (S196).

なお、以下の説明で、g11‘、g12’は、g1‘(x)=g12’(g11‘(x))を満たす関数とする(g1’はg1の逆関数)。また、g21‘、g22’は、g2‘(x)=g22’(g21‘(x))を満たす関数とする(g2’はg2の逆関数)。   In the following description, g11 ′ and g12 ′ are functions satisfying g1 ′ (x) = g12 ′ (g11 ′ (x)) (g1 ′ is an inverse function of g1). Further, g21 ′ and g22 ′ are functions satisfying g2 ′ (x) = g22 ′ (g21 ′ (x)) (g2 ′ is an inverse function of g2).

第1の条件分岐集合Sとして、条件式和集合S’のa mod 2==0を条件式、bをg1によって変更する文を条件節とした条件分岐if(a mod 2==0)、b=g1(b);を位置p1に挿入する。
第1の条件分岐集合Sとして、条件式和集合S’のa mod 2==1を条件式、bをg2によって変更する文を条件節とした条件分岐if(a mod 2==0)、b=g2(b);を位置p1に挿入する。
As a first conditional branch set S, a conditional branch if (a mod 2 == 0) in which a mod 2 == 0 of the conditional expression union S ′ is a conditional expression, and a sentence in which b is changed by g1 is a conditional clause, b = g1 (b); is inserted into position p1.
As the first conditional branch set S, a conditional branch if (a mod 2 == 0) in which a mod 2 == 1 of the conditional expression union set S ′ is a conditional expression, and a sentence in which b is changed by g2 is a conditional clause, b = g2 (b); is inserted at position p1.

第2の条件分岐集合Tとして、条件式和集合T’のa mod 2*k==0、a mod 2*k==2、…、a mod 2*k==2*k―2を条件式、bを関数g11‘によって変更する文を条件節としたk個の条件分岐if(a mod 2*k==0)、b=g11’(b); if(a mod 2*k==2)、b=g11‘(b);、…、if(a mod 2*k==2*k―2)、b=g11’(b); を位置p2に挿入する。
第2の条件分岐集合Tとして、条件式和集合T’のa mod 2*k==1、a mod 2*k==3、…、a mod 2*k==2*k―1を条件式、bを関数g21‘によって変更する文を条件節としたk個の条件分岐if(a mod 2*k==1)、b=g21’(b);if(a mod 2*k== 3)、b=g21‘(b);、…、if(a mod 2*k==2*k―1)、b=g21’(b);を位置p2に挿入する。
As the second conditional branch set T, a mod 2 * k == 0, a mod 2 * k == 2,..., A mod 2 * k == 2 * k−2 of the conditional expression union T ′ If (a mod 2 * k == 0), b = g11 ′ (b); if (a mod 2 * k ==), where the conditional expression is a statement that changes b by function g11 ′. 2), b = g11 ′ (b);..., If (a mod 2 * k == 2 * k−2), b = g11 ′ (b);
As a second conditional branch set T, a mod 2 * k == 1, a mod 2 * k == 3,..., A mod 2 * k == 2 * k−1 of the conditional expression union T ′ K conditional branches if (a mod 2 * k == 1), b = g21 ′ (b); if (a mod 2 * k ==), where a conditional clause is a sentence in which b is changed by the function g21 ′. 3), b = g21 ′ (b);.., If (a mod 2 * k == 2 * k−1), b = g21 ′ (b); are inserted at position p2.

第3の条件分岐集合Uとして、条件式和集合U’のa mod 2*n==0、a mod 2*n==2、…、a mod 2*n==2*n―2を条件式、bを関数g11‘によって変更する文を条件節としたn個の条件分岐if(a mod 2*n==0 )、b=g12’(b);、if(a mod 2*n==2)、b=g12‘(b);、…、if(a mod 2*n==2*n―2)、b=g12’(b);を位置p3に挿入する。
第3の条件分岐集合Uとして、条件式和集合U’のa mod 2*n==1、a mod 2*n==3、…、a mod 2*n==2*n―1を条件式、bを関数g22‘によって変更する文を条件節としたn個の条件分岐if(a mod 2*n==1)、b=g22’(b);、if(a mod 2*n==3)、b=g22‘(b);、…、if(a mod 2*n==2*n―1)、b=g22’(b);を位置p3に挿入する。
As a third conditional branch set U, a mod 2 * n == 0, a mod 2 * n == 2,..., A mod 2 * n == 2 * n−2 of the conditional expression union set U ′ N conditional branches if (a mod 2 * n == 0), b = g12 ′ (b) ;, if (a mod 2 * n = = 2), b = g12 ′ (b);..., If (a mod 2 * n == 2 * n−2), b = g12 ′ (b);
As a third conditional branch set U, a mod 2 * n == 1, a mod 2 * n == 3,..., A mod 2 * n == 2 * n−1 of the conditional expression union set U ′ N conditional branches if (a mod 2 * n == 1), b = g22 ′ (b) ;, if (a mod 2 * n = = 3), b = g22 ′ (b);..., If (a mod 2 * n == 2 * n−1), b = g22 ′ (b);

図20に、本実施例によって難読化されたプログラムの例を示す。図20のプログラムは、図21の関数f00に難読化を適用した例である。
上記の手順S191〜S196を行う際に、手順S192、S193、S194、S195でそれぞれ次のようにパラメーターを定めている。
FIG. 20 shows an example of a program obfuscated by this embodiment. The program in FIG. 20 is an example in which obfuscation is applied to the function f00 in FIG.
When performing the above steps S191 to S196, parameters are determined as follows in steps S192, S193, S194, and S195, respectively.

手順S192において、難読化対象関数の入力変数aとしてf00の入力変数aを、2以上の以上の整数k、nとしてk=2、n=3を選ぶ。
手順S193において、可逆関数g1、g2としてg1(x)=2*x+3、g2(x)=4*x―5を生成する。
手順S194において、g1、g2による操作対象として、f00の変数bを選ぶ。難読化対象関数中の位置Pp1、p2、p3として、図21に示すf00中のp20、p21を選ぶ(なお、本例では、p2とp3は同じ位置p21として、条件分岐和集合T、Uを順に並べて挿入している)。
手順S195において、g11‘、g12’、g21‘、g22’を以下のように取る。
g11‘(x)=x―3、g12’(x)=x/2、g21‘(x)=x+5、g22’(x)=x/4、(但し、g11‘、g12’、g21‘、g22’は、g1‘(x)=g12’(g11‘(x))とg2’(x)=g22‘(g21’(x))を満たす)
In step S192, an input variable a of f00 is selected as the input variable a of the obfuscation target function, an integer k of 2 or more, and k = 2 and n = 3 are selected as n.
In step S193, g1 (x) = 2 * x + 3 and g2 (x) = 4 * x-5 are generated as the reversible functions g1 and g2.
In step S194, the variable b of f00 is selected as the operation target by g1 and g2. As the positions Pp1, p2, and p3 in the obfuscation target function, p20 and p21 in f00 shown in FIG. 21 are selected (in this example, p2 and p3 are the same position p21, and the conditional branch sum sets T and U are Are inserted in order).
In step S195, g11 ′, g12 ′, g21 ′, and g22 ′ are taken as follows.
g11 ′ (x) = x−3, g12 ′ (x) = x / 2, g21 ′ (x) = x + 5, g22 ′ (x) = x / 4, (where g11 ′, g12 ′, g21 ′, g22 ′ satisfies g1 ′ (x) = g12 ′ (g11 ′ (x)) and g2 ′ (x) = g22 ′ (g21 ′ (x)))

本発明に係る難読化は、頻度分析攻撃に対して理論的に安全である。この理由として、第1実施例において、難読化のために加えた条件分岐を頻度分析により特定するのは困難であることを以下に説明する。   Obfuscation according to the present invention is theoretically safe against frequency analysis attacks. As a reason for this, it will be described below that it is difficult to specify the conditional branch added for obfuscation by frequency analysis in the first embodiment.

まず、難読化対象プログラム(実施例では関数f00)に挿入するg1(g2)によって変数を変換する条件節(eとおく)とg1‘(g2’)によって元に戻す条件節(n個の条件節をそれぞれd1、…、dnとおく)の間の相関度を考える。eが実行されれば、d1、…、dnのいずれかが必ず実行され、更に、そのときd1、…、dnの実行される確率はそれぞれ1/nである。このことから頻度分析において、eとd1、…、dnの間の相関度はそれぞれ1/nと計算される。   First, a conditional clause (denoted as e) for converting a variable by g1 (g2) inserted into an obfuscated program (function f00 in the embodiment) and a conditional clause (n conditions) to be restored by g1 ′ (g2 ′) Let us consider the degree of correlation between the nodes (d1,..., Dn). When e is executed, one of d1,..., dn is always executed, and at that time, the probability of executing d1,. From this, in the frequency analysis, the correlation between e and d1,..., Dn is calculated as 1 / n.

ところで、上記のように手順1、2に従うことで、1/n<=Qなるnを選択することができる(Qは、プログラムに元々含まれる任意の2つの条件節間の相関度の平均)。つまり、手順1、2に従うと、挿入する条件節e,di間の相関度(iは集合[1、…、n]に含まれる)は、プログラムに元々含まれていた条件分岐の間の相関度Qと比べて大きくならない。このことは、eとdiが(変数の可逆操作のペアであるという意味で)関連を持っていることを識別するのは、頻度分析では困難であることを意味する。
このように、本発明によると、頻度分析攻撃に対して理論的に安全な難読化を実施することが可能である。
By following the procedures 1 and 2 as described above, n satisfying 1 / n <= Q can be selected (Q is an average of the degree of correlation between any two conditional clauses originally included in the program). . That is, according to procedures 1 and 2, the degree of correlation between the conditional clauses e and di to be inserted (i is included in the set [1,..., N]) is the correlation between the conditional branches originally included in the program. It will not be larger than degree Q. This means that it is difficult for frequency analysis to identify that e and di are related (in the sense of being a reversible pair of variables).
As described above, according to the present invention, it is possible to implement obfuscation that is theoretically safe against frequency analysis attacks.

更に説明すると、手順1、2に対する攻撃手法として、条件節の集合間の相関度を計算する方法が考えられる。ここで、2つの条件節の集合H=(h1、…、hm)、G=(g1、…、gn)の間の相関度を、H中のいずれかの条件節とG中のいずれかの条件節が同時に実行される度合いとして定める。
例えば、{e}と{d1、…、dn}の間の相関度としては、頻度分析により何度も実行トレースを取ることで、1に近い値が得られる。なぜなら、eが実行されたときは必ずd1、…、dnのいずれかが実行されるからである。このように、相関度の高い2つの条件節集合を発見することで、難読化対象プログラム中に追加した条件分岐を特定するという攻撃が想定される。
More specifically, as an attack method for the procedures 1 and 2, a method of calculating the degree of correlation between sets of conditional clauses can be considered. Here, the correlation between two sets of conditional clauses H = (h1,..., Hm), G = (g1,..., Gn) is expressed as any conditional clause in H and any one in G. This is defined as the degree to which conditional clauses are executed simultaneously.
For example, as the degree of correlation between {e} and {d1,..., Dn}, a value close to 1 can be obtained by taking an execution trace many times by frequency analysis. This is because any one of d1,..., Dn is executed whenever e is executed. In this way, an attack that identifies a conditional branch added to the obfuscation target program by finding two sets of conditional clauses having a high degree of correlation is assumed.

しかしながら、上記のような条件節の集合間の相関度を計算する方法は、計算量的に困難である。今、条件節がs個含まれているプログラムに、上記の本発明に係るいずれかの実施例によって難読化を適用したとする。この時、2+2n個の条件節が挿入されるので、難読化適用済プログラムにはs+2+2n個の条件節が含まれることになる。この難読化済プログラムの難読化を無効化するには{e}と{d1、…、dn}の間の相関度が高いことを特定する必要がある。
ところが、s+2+2n個の条件節から要素数が1、nの集合のペアを抽出する場合の数は、s>>nのとき、s^n=exp(n*logs)に比例する。つまり、条件式集合のペアの場合の数は、nに関して指数関数的に増加する。このため、nが十分大きい場合、{e}と{d1、…、dn}が相関度の高い相関度を持つと特定することは計算量的に困難である。
However, the method for calculating the degree of correlation between sets of conditional clauses as described above is difficult in terms of computational complexity. Now, assume that obfuscation is applied to a program containing s conditional clauses according to any of the embodiments according to the present invention. At this time, since 2 + 2n conditional clauses are inserted, the obfuscated application program includes s + 2 + 2n conditional clauses. In order to invalidate the obfuscation of the obfuscated program, it is necessary to specify that the degree of correlation between {e} and {d1, ..., dn} is high.
However, the number in the case of extracting a set pair of 1 and n elements from s + 2 + 2n conditional clauses is proportional to s ^ n = exp (n * logs) when s >> n. In other words, the number of conditional expression pairs increases exponentially with respect to n. For this reason, when n is sufficiently large, it is difficult to specify that {e} and {d1,..., Dn} have a high degree of correlation.

本発明の一実施例に係るプログラム難読化装置の構成図である。It is a block diagram of the program obfuscation apparatus which concerns on one Example of this invention. 本発明の一実施例に係るプログラム難読化装置のハードウエア構成図である。It is a hardware block diagram of the program obfuscation apparatus which concerns on one Example of this invention. 本発明の一実施例に係るプログラム難読化装置の利用形態の一例を説明する図である。It is a figure explaining an example of the utilization form of the program obfuscation apparatus which concerns on one Example of this invention. 本発明の一実施例に係るプログラム難読化装置の利用形態の一例を説明する図である。It is a figure explaining an example of the utilization form of the program obfuscation apparatus which concerns on one Example of this invention. 本発明により難読化したプログラムの一例を説明する図である。It is a figure explaining an example of the program obfuscated by this invention. 本発明の第1実施例に係る処理手順を説明する図である。It is a figure explaining the process sequence which concerns on 1st Example of this invention. 本発明の第1実施例により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by 1st Example of this invention. 本発明の第2実施例に係る処理手順を説明する図である。It is a figure explaining the process sequence which concerns on 2nd Example of this invention. 本発明の第2実施例により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by 2nd Example of this invention. 場合分けの範囲を説明する図である。It is a figure explaining the range of case division. 場合分けの範囲を説明する図である。It is a figure explaining the range of case division. 本発明により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by this invention. 本発明により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by this invention. 本発明により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by this invention. 本発明の第3実施例に係る処理手順を説明する図である。It is a figure explaining the process sequence which concerns on 3rd Example of this invention. 本発明の第3実施例により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by 3rd Example of this invention. 本発明の第4実施例に係る処理手順を説明する図である。It is a figure explaining the process sequence which concerns on 4th Example of this invention. 本発明の第4実施例により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by 4th Example of this invention. 本発明の第5実施例に係る処理手順を説明する図である。It is a figure explaining the process sequence which concerns on 5th Example of this invention. 本発明の第5実施例により難読化したプログラム例を説明する図である。It is a figure explaining the example of a program obfuscated by 5th Example of this invention. プログラムの一例を説明する図である。It is a figure explaining an example of a program. 難読化したプログラムの従来例を説明する図である。It is a figure explaining the prior art example of the obfuscated program.

符号の説明Explanation of symbols

1:プログラム難読化装置、 2:入力手段、
3:難読化処理手段、 4:出力手段、
5:解析手段(位置決定手段、相関度算出手段)、 6:条件分岐生成手段、
7:挿入手段、 S:第1の条件分岐和集合、
T:第2の条件分岐和集合、 pp:プログラム部分、
p1、p2、p20、p21:挿入位置、 a:第1の変数、
b:第2の変数、
1: Program obfuscation device 2: Input means
3: Obfuscation processing means, 4: Output means,
5: analysis means (position determination means, correlation degree calculation means), 6: conditional branch generation means,
7: insertion means, S: first conditional branch union,
T: second conditional branch union, pp: program part,
p1, p2, p20, p21: insertion position, a: first variable,
b: second variable,

Claims (11)

難読化対象のプログラムを入力する入力手段と、
前記プログラム中の第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に当該プログラム中の第2の変数の値を変換する条件節を含む第1の条件分岐と、当該第1の条件分岐における前記第1の変数の取り得る値の全範囲で当該第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に前記変換された第2の変数の値を元の値に逆変換する条件節を含む第2の条件分岐と、を生成する生成手段と、
前記プログラム中の前記第1及び第2の変数が存在する以降の部分で前記第1の条件分岐と第2の条件分岐を挿入する位置を決定する決定手段と、
前記プログラム中の決定された位置に前記第1の条件分岐と第2の条件分岐を挿入する挿入手段と、
を有することを特徴とするプログラム難読化装置。
An input means for inputting an obfuscated program;
A first conditional expression that includes a conditional expression that separates the value of the first variable in the program and a conditional clause that converts the value of the second variable in the program for each case-divided value of the first variable. Conditional branch, conditional expression for dividing the value of the first variable in the entire range of possible values of the first variable in the first conditional branch, and each value of the divided first variable Generating means for generating a second conditional branch including a conditional clause for inversely converting the value of the converted second variable into an original value;
Determining means for determining a position at which the first conditional branch and the second conditional branch are inserted in a portion after the first and second variables exist in the program;
Inserting means for inserting the first conditional branch and the second conditional branch at a determined position in the program;
A program obfuscation apparatus comprising:
前記第1の条件分岐は複数の条件式からなる第1の条件式和集合を含み、前記第2の条件分岐は複数の条件式からなる第2の条件式和集合を含み、
当該第1の条件式和集合と当該第2の条件式和集合とは同値であり、かつ、異なる集合であることを特徴とする請求項1に記載のプログラム難読化装置。
The first conditional branch includes a first conditional expression union composed of a plurality of conditional expressions, and the second conditional branch includes a second conditional expression union composed of a plurality of conditional expressions,
The program obfuscation apparatus according to claim 1, wherein the first conditional expression union and the second conditional expression union are equivalent and different sets.
前記決定手段は、前記第1の条件分岐を挿入する位置以降で前記第1及び第2の変数が操作されないプログラム部分を隔てた位置を前記第2の条件分岐を挿入する位置に決定することを特徴とする請求項1又は請求項2に記載のプログラム難読化装置。   The deciding means decides, after the position where the first conditional branch is inserted, a position separating the program part where the first and second variables are not operated as a position where the second conditional branch is inserted. The program obfuscation apparatus according to claim 1, wherein the obfuscation apparatus is a program obfuscation apparatus. 前記難読化対象のプログラム中に既存の複数の条件分岐の相関度を算出する算出手段を有し、
前記生成手段は、算出した相関度に近い相関度となるように前記第1及び第2の条件分岐を生成することを特徴とする請求項1乃至請求項3のいずれか1項に記載のプログラム難読化装置。
A calculation means for calculating a degree of correlation of a plurality of existing conditional branches in the obfuscated program;
4. The program according to claim 1, wherein the generation unit generates the first and second conditional branches so that the correlation degree is close to the calculated correlation degree. 5. Obfuscation device.
前記決定手段は、前記第1の条件分岐が含む条件式を、前記難読化対象のプログラム中における前記第1の変数の取り得る値の全範囲で当該第1の変数の値を場合分けする条件式とすることを特徴とする請求項1乃至請求項4のいずれか1項に記載のプログラム難読化装置。   The determining means is a condition for dividing the conditional expression included in the first conditional branch into cases where the value of the first variable is classified in the entire range of possible values of the first variable in the obfuscated program. The program obfuscation apparatus according to claim 1, wherein the program obfuscation apparatus is an expression. 前記決定手段は、前記第1の条件分岐が含む条件式を、前記難読化対象のプログラム中における前記第1の変数の取り得る値の部分的な範囲で当該第1の変数の値を場合分けする条件式とすることを特徴とする請求項1乃至請求項4のいずれか1項に記載のプログラム難読化装置。   The determining means classifies the conditional expression included in the first conditional branch into a value of the first variable in a partial range of values that can be taken by the first variable in the obfuscated program. The program obfuscation apparatus according to claim 1, wherein the conditional expression is a conditional expression. 前記生成手段は、前記難読化対象のプログラムへの入力変数を、前記第1及び第2の変数として前記第1及び第2の条件分岐を生成することを特徴とする請求項1乃至請求項6のいずれか1項に記載のプログラム難読化装置。   7. The generation unit according to claim 1, wherein the generation unit generates the first and second conditional branches using an input variable to the obfuscation target program as the first and second variables. The program obfuscation apparatus according to any one of the above. 前記生成手段は、前記第1の変数を余剰計算による場合分けして、前記第1及び第2の条件分岐を生成することを特徴とする請求項1乃至請求項7のいずれか1項に記載のプログラム難読化装置。   The said production | generation means produces | generates the said 1st and 2nd conditional branch by classifying the said 1st variable by the case by a surplus calculation, The any one of Claim 1 thru | or 7 characterized by the above-mentioned. Program obfuscation device. 前記生成手段は、前記第1の変数をハッシュ関数による場合分けして、前記第1及び第2の条件分岐を生成することを特徴とする請求項1乃至請求項7のいずれか1項に記載のプログラム難読化装置。   8. The generation unit according to claim 1, wherein the generation unit generates the first and second conditional branches by classifying the first variable according to a hash function. Program obfuscation device. 前記第1の条件分岐と第2の条件分岐を挿入されたプログラムを出力する手段を有することを特徴とする請求項1乃至請求項9のいずれか1項に記載のプログラム難読化装置。   10. The program obfuscation apparatus according to claim 1, further comprising means for outputting a program in which the first conditional branch and the second conditional branch are inserted. 難読化対象のプログラムを入力する入力手段と、
前記プログラム中の第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に当該プログラム中の第2の変数の値を変換する条件節を含む第1の条件分岐と、当該第1の条件分岐における前記第1の変数の取り得る値の全範囲で当該第1の変数の値を場合分けする条件式及び場合分けされた当該第1の変数の値毎に前記変換された第2の変数の値を元の値に逆変換する条件節を含む第2の条件分岐と、を生成する生成手段と、
前記プログラム中の前記第1及び第2の変数が存在する以降の部分で前記第1の条件分岐と第2の条件分岐を挿入する位置を決定する決定手段と、
前記プログラム中の決定された位置に前記第1の条件分岐と第2の条件分岐を挿入する挿入手段と、
をコンピュータに実現することを特徴とする難読化プログラム。
An input means for inputting an obfuscated program;
A first conditional expression that includes a conditional expression that separates the value of the first variable in the program and a conditional clause that converts the value of the second variable in the program for each case-divided value of the first variable. Conditional branch, conditional expression for dividing the value of the first variable in the entire range of possible values of the first variable in the first conditional branch, and each value of the divided first variable Generating means for generating a second conditional branch including a conditional clause for inversely converting the value of the converted second variable into an original value;
Determining means for determining a position at which the first conditional branch and the second conditional branch are inserted in a portion after the first and second variables exist in the program;
Inserting means for inserting the first conditional branch and the second conditional branch at a determined position in the program;
An obfuscation program characterized by realizing the above on a computer.
JP2007112928A 2007-04-23 2007-04-23 Program obfuscation device and program Expired - Fee Related JP4924177B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2007112928A JP4924177B2 (en) 2007-04-23 2007-04-23 Program obfuscation device and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2007112928A JP4924177B2 (en) 2007-04-23 2007-04-23 Program obfuscation device and program

Publications (2)

Publication Number Publication Date
JP2008269398A JP2008269398A (en) 2008-11-06
JP4924177B2 true JP4924177B2 (en) 2012-04-25

Family

ID=40048787

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2007112928A Expired - Fee Related JP4924177B2 (en) 2007-04-23 2007-04-23 Program obfuscation device and program

Country Status (1)

Country Link
JP (1) JP4924177B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4905480B2 (en) * 2009-02-20 2012-03-28 富士ゼロックス株式会社 Program obfuscation program and program obfuscation device
EP3238113B1 (en) * 2014-12-22 2018-09-26 Koninklijke Philips N.V. Hiding of a program execution

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2293650C (en) * 1997-06-09 2012-09-25 Christian Sven Collberg Obfuscation techniques for enhancing software security
JP2003337629A (en) * 2002-05-18 2003-11-28 Mitsuko Miyaji Program obfuscation method and device

Also Published As

Publication number Publication date
JP2008269398A (en) 2008-11-06

Similar Documents

Publication Publication Date Title
KR20200044103A (en) High-precision privacy protection real-time function evaluation
Das et al. Anonymizing weighted social network graphs
Balabanov et al. Unified QBF certification and its applications
US8185749B2 (en) System and method for revising boolean and arithmetic operations
Huda et al. A hybrid-multi filter-wrapper framework to identify run-time behaviour for fast malware detection
CN105453481B (en) Calculating equipment including table network
Günther et al. More efficient universal circuit constructions
Won et al. Non-profiled side-channel attack based on deep learning using picture trace
Kiesl et al. Super-blocked clauses
Kakisim et al. Sequential opcode embedding-based malware detection method
RU2680761C1 (en) Secure data transformations
Weissbart et al. Systematic side-channel analysis of curve25519 with machine learning
De León et al. Incorporating negative information to process discovery of complex systems
Hamza et al. A survey and taxonomy of program analysis for IoT platforms
CN112639774A (en) Compiler apparatus with masking function
JP4924177B2 (en) Program obfuscation device and program
Perl et al. Privacy/performance trade-off in private search on bio-medical data
Martínez et al. Efficient model similarity estimation with robust hashing
JP6585846B2 (en) Secret calculation system, secret calculation device, secret calculation method, and program
JP6337133B2 (en) Non-decreasing sequence determination device, non-decreasing sequence determination method, and program
JP2017509942A (en) How to protect secret data when used in cryptographic algorithms
WO2016056503A1 (en) Partial character string position detection device, partial character string position detection method, and program
Kim et al. Attention-Based Cross-Modal CNN Using Non-Disassembled Files for Malware Classification
Coniglio Combining program synthesis and symbolic execution to deobfuscate binary code
Logofatu et al. Efficient evolutionary approaches for the data ordering problem with inversion

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20100312

RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20101118

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20110505

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20111214

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20120110

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20120123

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150217

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Ref document number: 4924177

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees