Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP5477994B2 - Self-rewriting processing device, self-rewriting processing method, and program - Google Patents
[go: Go Back, main page]

JP5477994B2 - Self-rewriting processing device, self-rewriting processing method, and program - Google Patents

Self-rewriting processing device, self-rewriting processing method, and program Download PDF

Info

Publication number
JP5477994B2
JP5477994B2 JP2010092497A JP2010092497A JP5477994B2 JP 5477994 B2 JP5477994 B2 JP 5477994B2 JP 2010092497 A JP2010092497 A JP 2010092497A JP 2010092497 A JP2010092497 A JP 2010092497A JP 5477994 B2 JP5477994 B2 JP 5477994B2
Authority
JP
Japan
Prior art keywords
instruction
key
target program
protection target
dummy
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
JP2010092497A
Other languages
Japanese (ja)
Other versions
JP2011221922A (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.)
KDDI Corp
Original Assignee
KDDI 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 KDDI Corp filed Critical KDDI Corp
Priority to JP2010092497A priority Critical patent/JP5477994B2/en
Publication of JP2011221922A publication Critical patent/JP2011221922A/en
Application granted granted Critical
Publication of JP5477994B2 publication Critical patent/JP5477994B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Storage Device Security (AREA)

Description

本発明は、自己書き換え処理装置、自己書き換え処理方法、およびプログラムに関する。   The present invention relates to a self-rewriting processing device, a self-rewriting processing method, and a program.

従来より、保護対象プログラムの解析および改ざんを困難にする手法が提案されている(例えば、特許文献1参照)。特許文献1には、保護対象プログラムの解析および改ざんを困難にする手法として、自己書き換えの手法が示されている。   Conventionally, a method for making it difficult to analyze and falsify a protection target program has been proposed (see, for example, Patent Document 1). Patent Document 1 discloses a self-rewriting technique as a technique for making it difficult to analyze and falsify a program to be protected.

特許文献1の自己書き換えでは、まず、保護対象プログラムに記述されている命令を偽の命令で偽装する。次に、偽の命令の前方に、この偽の命令を元の命令に置換する第1の処理を挿入するとともに、偽の命令の後方に、第1の処理の実行により置換された元の命令を偽の命令に置換する第2の処理を挿入する。   In the self-rewriting of Patent Document 1, first, an instruction described in a protection target program is disguised with a fake instruction. Next, a first process for replacing the fake instruction with the original instruction is inserted in front of the fake instruction, and the original instruction replaced by the execution of the first process is inserted behind the fake instruction. Insert a second process that replaces with a fake instruction.

このため、特許文献1の自己書き換えを行った保護対象プログラムを実行すると、偽の命令が実行されるより前に、第1の処理が実行される。このため、偽の命令が元に戻った状態で実行されることとなる。また、偽の命令が元に戻った状態で実行された後に、第2の処理が実行される。このため、元に戻った命令が再度偽装されることとなる。したがって、偽装した命令は、実行前後の所定の期間でのみ元の命令に戻り、他の期間では偽装された状態となるので、保護対象プログラムの解析および改ざんが困難となる。   For this reason, when the protection target program that has been self-rewritten in Patent Document 1 is executed, the first process is executed before the fake instruction is executed. For this reason, it is executed in a state where the fake instruction is restored. In addition, the second process is executed after the fake instruction is executed in a state in which it is restored. For this reason, the instruction which returned to the original will be camouflaged again. Therefore, the camouflaged instruction returns to the original instruction only in a predetermined period before and after execution, and is in a camouflaged state in other periods, so that it is difficult to analyze and falsify the protection target program.

特開2004−192068号公報Japanese Patent Laid-Open No. 2004-192068

特許文献1の自己書き換えを行った保護対象プログラムでは、第1の処理を実行するために、元の命令が保護対象プログラムに記述される。このため、どのような置換が行われるのかが容易に推測できてしまい、保護対象プログラムの解析および改ざんの困難性を向上できなかった。   In the protection target program in which self-rewriting is performed in Patent Document 1, the original instruction is described in the protection target program in order to execute the first process. For this reason, it is easy to guess what kind of replacement will be performed, and the difficulty of analyzing and falsifying the protection target program cannot be improved.

そこで、保護対象プログラムに記述される元の命令を予め暗号化しておき、偽装した偽の命令を元に戻す際に復号する手法が考えられる。ところが、この暗号化する手法では、暗号化の際に用いる鍵を保護対象プログラムに記述を記述しなくてはならない。このため、鍵が容易に漏洩してしまい、保護対象プログラムの解析および改ざんの困難性を向上できなかった。   Therefore, a method is conceivable in which the original instruction described in the protection target program is encrypted in advance and decrypted when the fake fake instruction is restored. However, in this encryption method, it is necessary to describe the description of the key used for encryption in the protection target program. For this reason, the key is easily leaked, and the difficulty of analyzing and falsifying the program to be protected cannot be improved.

そこで、本発明は、上述の課題に鑑みてなされたものであり、保護対象プログラムの解析および改ざんの困難性を向上させることができる自己書き換え処理装置、自己書き換え処理方法、およびプログラムを提供することを目的とする。   Therefore, the present invention has been made in view of the above-described problems, and provides a self-rewriting processing device, a self-rewriting processing method, and a program capable of improving the difficulty of analyzing and falsifying a protection target program. With the goal.

本発明は、上記の課題を解決するために、以下の事項を提案している。   The present invention proposes the following matters in order to solve the above problems.

(1) 本発明は、保護対象プログラムを記憶する記憶手段(例えば、図1のキャッシュ20に相当)と、前記保護対象プログラムに記述されている命令を少なくとも1つ選択する選択手段(例えば、図1のCPU10に相当)と、前記選択手段により選択された命令を、鍵を用いて暗号化する命令暗号化手段(例えば、図1のCPU10に相当)と、前記命令暗号化手段により用いられた鍵を、ダミーの鍵に置換する鍵偽装手段(例えば、図1のCPU10に相当)と、前記鍵偽装手段により置換されたダミーの鍵を元の鍵に置換する鍵復元処理(例えば、図5の鍵復元処理55に相当)を、前記保護対象プログラムに挿入する鍵復元処理挿入手段(例えば、図1のCPU10に相当)と、前記命令暗号化手段により暗号化された命令を、前記鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理(例えば、図5の命令復号処理52Aに相当)を、前記保護対象プログラムに挿入する命令復号処理挿入手段(例えば、図1のCPU10に相当)と、前記鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理(例えば、図5の鍵偽装処理56に相当)を、前記保護対象プログラムに挿入する鍵偽装処理挿入手段(例えば、図1のCPU10に相当)と、前記選択手段により選択された命令をダミーの命令に置換する命令偽装手段(例えば、図1のCPU10に相当)と、前記命令偽装手段により置換されたダミーの命令を、前記命令復号処理の実行により復号された元の命令に置換する命令復元処理(例えば、図5の命令復元処理53に相当)を、前記保護対象プログラムに挿入する命令復元処理挿入手段(例えば、図1のCPU10に相当)と、前記命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理(例えば、図5の命令偽装処理54に相当)を、前記保護対象プログラムに挿入する命令偽装処理挿入手段(例えば、図1のCPU10に相当)と、を備えることを特徴とする自己書き換え処理装置を提案している。   (1) The present invention provides a storage means for storing a protection target program (for example, equivalent to the cache 20 in FIG. 1) and a selection means for selecting at least one instruction described in the protection target program (for example, FIG. 1), an instruction encryption means for encrypting the instruction selected by the selection means using a key (for example, equivalent to the CPU 10 in FIG. 1), and the instruction encryption means. Key disguising means (for example, equivalent to the CPU 10 in FIG. 1) for replacing the key with a dummy key, and key restoration processing (for example, FIG. 5) for replacing the dummy key replaced by the key disguising means with the original key. A key restoration process insertion unit (e.g., equivalent to the CPU 10 in FIG. 1) and a command encrypted by the command encryption unit. Instruction decryption process insertion means (for example, instruction decryption process insertion means (for example, equivalent to the instruction decryption process 52A in FIG. 5) for decrypting using the original key replaced by execution of the key recording restoration process (for example, equivalent to the instruction decryption process 52A in FIG. 5) 1) and a key impersonation process (for example, equivalent to the key impersonation process 56 of FIG. 5) for replacing the original key replaced by the execution of the key recovery process with a dummy key. Key impersonation processing insertion means (for example, equivalent to the CPU 10 in FIG. 1) to be inserted into the target program, and instruction impersonation means (for example, equivalent to the CPU 10 in FIG. 1) for replacing the instruction selected by the selection means with a dummy instruction And an instruction restoration process (for example, the instruction restoration process 53 in FIG. 5) which replaces the dummy instruction replaced by the instruction disguising means with the original instruction decoded by the execution of the instruction decoding process. Instruction restoration processing insertion means (for example, equivalent to the CPU 10 in FIG. 1) for inserting the above into the protection target program, and an instruction disguise for replacing the original instruction replaced by execution of the instruction restoration processing with a dummy instruction A self-rewriting process comprising: an instruction impersonation process insertion means (for example, equivalent to the CPU 10 of FIG. 1) for inserting a process (for example, equivalent to the instruction impersonation process 54 of FIG. 5) into the protection target program A device is proposed.

この発明によれば、自己書き換え処理装置に、記憶手段、選択手段、命令暗号化手段、鍵偽装手段、鍵復元処理挿入手段、命令復号処理挿入手段、鍵偽装処理挿入手段、命令偽装手段、命令復元処理挿入手段、および命令偽装処理挿入手段を設けた。そして、記憶手段により、保護対象プログラムを記憶することとした。また、選択手段により、保護対象プログラムに記述されている命令を少なくとも1つ選択することとした。また、命令暗号化手段により、選択手段により選択された命令を、鍵を用いて暗号化することとした。また、鍵偽装手段により、命令暗号化手段により用いられた鍵を、ダミーの鍵に置換することとした。また、鍵復元処理挿入手段により、鍵復元処理を保護対象プログラムに挿入することとした。ここで、鍵復元処理とは、鍵偽装手段により置換されたダミーの鍵を元の鍵に置換する処理のことである。また、命令復号処理挿入手段により、命令復号処理を保護対象プログラムに挿入することとした。ここで、命令復号処理とは、命令暗号化手段により暗号化された命令を、鍵復元処理の実行により置換された元の鍵を用いて復号する処理のことである。また、鍵偽装処理挿入手段により、鍵偽装処理を保護対象プログラムに挿入することとした。ここで、鍵偽装処理とは、鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する処理のことである。また、命令偽装手段により、選択手段により選択された命令をダミーの命令に置換することとした。また、命令復元処理挿入手段により、命令復元処理を保護対象プログラムに挿入することとした。ここで、命令復元処理とは、命令偽装手段により置換されたダミーの命令を、命令復号処理の実行により復号された元の命令に置換する処理のことである。また、命令偽装処理挿入手段により、命令偽装処理を保護対象プログラムに挿入することとした。ここで、命令偽装処理とは、命令復元処理の実行により置換された元の命令をダミーの命令に置換する処理のことである。   According to this invention, the self-rewriting processing device includes a storage means, a selection means, an instruction encryption means, a key impersonation means, a key restoration process insertion means, an instruction decryption process insertion means, a key impersonation processing insertion means, an instruction impersonation means, an instruction A restoration processing insertion means and an instruction spoofing processing insertion means are provided. Then, the storage target program is stored by the storage means. Further, at least one instruction described in the protection target program is selected by the selection means. In addition, the instruction encryption means encrypts the instruction selected by the selection means using a key. In addition, the key used by the instruction encryption unit is replaced with a dummy key by the key disguise unit. In addition, the key restoration processing insertion means inserts the key restoration processing into the protection target program. Here, the key restoration process is a process of replacing the dummy key replaced by the key disguising unit with the original key. Further, the instruction decoding process insertion means inserts the instruction decoding process into the protection target program. Here, the instruction decryption process is a process of decrypting the instruction encrypted by the instruction encryption unit using the original key replaced by the execution of the key recovery process. Further, the key impersonation process insertion means inserts the key impersonation process into the protection target program. Here, the key impersonation process is a process of replacing the original key replaced by the execution of the key restoration process with a dummy key. Further, the instruction disguised means replaces the instruction selected by the selecting means with a dummy instruction. Further, the instruction restoration processing insertion means inserts the instruction restoration processing into the protection target program. Here, the instruction restoration process is a process of replacing the dummy instruction replaced by the instruction disguising unit with the original instruction decoded by executing the instruction decoding process. Further, the instruction impersonation process insertion means inserts the instruction impersonation process into the protection target program. Here, the instruction disguise process is a process of replacing the original instruction replaced by the execution of the instruction restoration process with a dummy instruction.

このため、自己書き換え処理装置は、命令偽装手段により、保護対象プログラムに記述されている命令をダミーの命令に置換するとともに、命令暗号化手段により、元の命令を暗号化する。これによれば、ダミーに偽装された命令の元の命令は、暗号化された状態となる。   For this reason, the self-rewrite processing device replaces the instruction described in the protection target program with a dummy instruction by the instruction disguise means, and encrypts the original instruction by the instruction encryption means. According to this, the original instruction of the instruction disguised as a dummy is in an encrypted state.

また、自己書き換え処理装置は、鍵偽装処理により、命令暗号化手段により命令を暗号化する際に用いる鍵を、鍵偽装手段によりダミーの鍵に予め偽装する。   Further, the self-rewriting processing apparatus pre-disguises the key used when encrypting the instruction by the instruction encrypting means into a dummy key by the key disguising means by the key disguise process.

以上によれば、自己書き換え処理装置は、ダミーに偽装した命令の元の命令を暗号化するとともに、暗号化に用いる鍵を偽装するため、保護対象プログラムの解析および改ざんの困難性を向上させることができる。   According to the above, the self-rewriting processing device encrypts the original instruction of the dummy disguised instruction and impersonates the key used for encryption, thereby improving the difficulty of analyzing and falsifying the protection target program Can do.

(2) 本発明は、(1)の自己書き換え処理装置について、前記命令復号処理挿入手段は、前記命令復号処理を、前記保護対象プログラムのうち、前記命令偽装手段により置換されたダミーの命令(例えば、図5のダミーの第1命令セット51Aに相当)より前方に挿入し、前記命令復元処理挿入手段は、前記命令復元処理を、前記保護対象プログラムのうち、前記命令復号処理(例えば、図5の命令復号処理52Aに相当)と、前記命令偽装手段により置換されたダミーの命令(例えば、図5のダミーの第1命令セット51Aに相当)と、の間に挿入し、前記命令偽装処理挿入手段は、前記命令偽装処理を、前記保護対象プログラムのうち、前記命令偽装手段により置換されたダミーの命令(例えば、図5のダミーの第1命令セット51Aに相当)の後方に挿入し、前記鍵復元処理挿入手段は、前記鍵復元処理を、前記保護対象プログラムのうち前記命令復号処理(例えば、図5の命令復号処理52Aに相当)より前方に挿入し、前記鍵偽装処理挿入手段は、前記鍵偽装処理を、前記保護対象プログラムのうち前記命令復号処理(例えば、図5の命令復号処理52Aに相当)より後方に挿入することを特徴とする自己書き換え処理装置を提案している。   (2) The present invention relates to the self-rewriting processing device according to (1), wherein the instruction decoding process inserting means replaces the instruction decoding process with a dummy instruction (replaced by the instruction impersonating means in the protection target program). For example, the instruction restoration processing insertion means inserts the instruction restoration processing into the instruction decoding processing (for example, FIG. 5) of the protection target program. 5 and the dummy instruction replaced by the instruction disguising means (for example, equivalent to the dummy first instruction set 51A of FIG. 5), and the instruction disguising process The inserting unit replaces the instruction impersonation process with a dummy instruction (for example, the dummy first instruction set 51 of FIG. 5) replaced by the instruction impersonating unit in the protection target program. The key restoration processing inserting means inserts the key restoration processing ahead of the instruction decoding processing (for example, equivalent to the instruction decoding processing 52A in FIG. 5) in the protection target program. The key impersonation process insertion means inserts the key impersonation process behind the instruction decryption process (for example, equivalent to the instruction decryption process 52A in FIG. 5) in the protection target program. A rewrite processing device is proposed.

この発明によれば、(1)の自己書き換え処理装置において、命令復号処理挿入手段は、命令復号処理を、保護対象プログラムのうち、命令偽装手段により置換されたダミーの命令より前方に挿入することとした。また、命令復元処理挿入手段は、命令復元処理を、保護対象プログラムのうち、命令復号処理と、命令偽装手段により置換されたダミーの命令と、の間に挿入することとした。また、命令偽装処理挿入手段は、命令偽装処理を、保護対象プログラムのうち、命令偽装手段により置換されたダミーの命令の後方に挿入することとした。また、鍵復元処理挿入手段は、鍵復元処理を、保護対象プログラムのうち命令復号処理より前方に挿入することとした。また、鍵偽装処理挿入手段は、鍵偽装処理を、保護対象プログラムのうち命令復号処理より後方に挿入することとした。   According to the present invention, in the self-rewriting processing device of (1), the instruction decoding process inserting means inserts the instruction decoding process ahead of the dummy instruction replaced by the instruction disguise means in the protection target program. It was. Further, the instruction restoration processing insertion means inserts the instruction restoration processing between the instruction decoding process and the dummy instruction replaced by the instruction disguise means in the protection target program. Further, the instruction impersonation process insertion means inserts the instruction impersonation process behind the dummy instruction replaced by the instruction impersonation means in the protection target program. Further, the key restoration processing insertion means inserts the key restoration processing ahead of the instruction decryption processing in the protection target program. Further, the key impersonation process insertion means inserts the key impersonation process behind the instruction decryption process in the protection target program.

このため、自己書き換え処理装置により上述の各処理が行われた後の保護対象プログラムを実行すると、まず、鍵復元処理が実行され、偽装されていた鍵が元に戻ることになる。次に、命令復号処理が実行され、元に戻った鍵を用いて命令が復号されることになる。次に、鍵偽装処理が実行され、復号に用いた鍵が再度偽装されるとともに、命令復元処理が実行され、偽装されていた命令が復号した命令に戻ることになる。次に、この命令が実行された後に、命令偽装処理が実行され、この命令が再度偽装されることになる。これによれば、上述した効果と同様の効果を奏することができる。   For this reason, when the protection target program after the above-described processing is performed by the self-rewriting processing device is executed, first, the key restoration processing is executed, and the forged key is restored. Next, an instruction decryption process is executed, and the instruction is decrypted using the restored key. Next, the key impersonation process is executed, the key used for decryption is impersonated again, and the instruction restoration process is executed, so that the instruction that has been impersonated returns to the decrypted instruction. Next, after this instruction is executed, an instruction impersonation process is executed, and this instruction is impersonated again. According to this, an effect similar to the effect mentioned above can be produced.

(3) 本発明は、(1)または(2)の自己書き換え処理装置について、前記選択手段による選択と、前記命令暗号化手段よる暗号化と、前記鍵偽装手段による置換と、前記鍵復元処理挿入手段による挿入と、前記命令復号処理挿入手段による挿入と、前記鍵偽装処理挿入手段による挿入と、前記命令偽装手段による置換と、前記命令復元処理挿入手段による挿入と、前記命令偽装処理挿入手段による挿入と、を予め定められた回数(例えば、図2および図3の反復回数Nに相当)だけ繰り返すことを特徴とする自己書き換え処理装置を提案している。   (3) The present invention relates to the self-rewriting processing device of (1) or (2), selection by the selection means, encryption by the instruction encryption means, replacement by the key impersonation means, and the key restoration processing. Insertion by insertion means, insertion by the instruction decryption processing insertion means, insertion by the key impersonation processing insertion means, replacement by the instruction impersonation means, insertion by the instruction restoration processing insertion means, and instruction impersonation processing insertion means The self-rewrite processing device is characterized by repeating the insertion by the predetermined number of times (for example, corresponding to the number of repetitions N in FIGS. 2 and 3).

この発明によれば、選択手段による選択と、命令暗号化手段よる暗号化と、鍵偽装手段による置換と、鍵復元処理挿入手段による挿入と、命令復号処理挿入手段による挿入と、鍵偽装処理挿入手段による挿入と、命令偽装手段による置換と、命令復元処理挿入手段による挿入と、命令偽装処理挿入手段による挿入と、を予め定められた回数だけ繰り返すこととした。   According to the present invention, selection by the selection means, encryption by the instruction encryption means, replacement by the key impersonation means, insertion by the key restoration processing insertion means, insertion by the instruction decryption processing insertion means, and key impersonation processing insertion The insertion by the means, the replacement by the instruction impersonation means, the insertion by the instruction restoration processing insertion means, and the insertion by the instruction impersonation processing insertion means are repeated a predetermined number of times.

このため、上述の予め定められた回数として、1以上の値を設定することで、ダミーに偽装した命令の元の命令の暗号化と、暗号化に用いる鍵の偽装と、を複数回行うことができ、保護対象プログラムの解析および改ざんの困難性をさらに向上させることができる。   For this reason, by setting a value of 1 or more as the above-mentioned predetermined number of times, encryption of the original instruction of the dummy disguised instruction and disguise of the key used for encryption are performed a plurality of times. It is possible to further improve the difficulty of analyzing and falsifying the program to be protected.

(4) 本発明は、選択手段(例えば、図1のCPU10に相当)、命令暗号化手段(例えば、図1のCPU10に相当)、鍵偽装手段(例えば、図1のCPU10に相当)、鍵復元処理挿入手段(例えば、図1のCPU10に相当)、命令復号処理挿入手段(例えば、図1のCPU10に相当)、鍵偽装処理挿入手段(例えば、図1のCPU10に相当)、命令偽装手段(例えば、図1のCPU10に相当)、命令復元処理挿入手段(例えば、図1のCPU10に相当)、および命令偽装処理挿入手段(例えば、図1のCPU10に相当)を備える自己書き換え処理装置における自己書き換え処理方法であって、前記選択手段が、保護対象プログラムに記述されている命令を少なくとも1つ選択する第1ステップ(例えば、図2のステップS6および図3のステップS22に相当)と、前記命令暗号化手段が、前記第1ステップにおいて選択した命令を、鍵を用いて暗号化する第2ステップ(例えば、図3のステップS23に相当)と、前記鍵偽装手段が、前記第2ステップにおいて用いた鍵を、ダミーの鍵に置換する第3ステップ(例えば、図3のステップS30に相当)と、前記鍵復元処理挿入手段が、前記第3ステップにおいて置換したダミーの鍵を元の鍵に置換する鍵復元処理(例えば、図5の鍵復元処理55に相当)を、前記保護対象プログラムに挿入する第4ステップ(例えば、図3のステップS31に相当)と、前記命令復号処理挿入手段が、前記第2ステップにおいて暗号化した命令を、前記鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理(例えば、図5の命令復号処理52Aに相当)を、前記保護対象プログラムに挿入する第5ステップ(例えば、図2のステップS7および図3のステップS26に相当)と、前記鍵偽装処理挿入手段が、前記鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理(例えば、図5の鍵偽装処理56に相当)を、前記保護対象プログラムに挿入する第6ステップ(例えば、図3のステップS32に相当)と、前記命令偽装手段が、前記第1ステップにおいて選択した命令をダミーの命令に置換する第7ステップ(例えば、図3のステップS25に相当)と、前記命令復元処理挿入手段が、前記第7ステップにおいて置換したダミーの命令を、前記命令復号処理の実行により復号された元の命令に置換する命令復元処理(例えば、図5の命令復元処理53に相当)を、前記保護対象プログラムに挿入する第8ステップ(例えば、図3のステップS27に相当)と、前記命令偽装処理挿入手段が、前記命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理(例えば、図5の命令偽装処理54に相当)を、前記保護対象プログラムに挿入する第9ステップ(例えば、図3のステップS28に相当)と、を備えることを特徴とする自己書き換え処理方法を提案している。 (4) The present invention includes selection means (for example, equivalent to the CPU 10 in FIG. 1), instruction encryption means (for example, equivalent to the CPU 10 in FIG. 1), key impersonation means (for example, equivalent to the CPU 10 in FIG. 1), key Restoration processing insertion means (for example, equivalent to CPU 10 in FIG. 1), instruction decryption processing insertion means (for example, equivalent to CPU 10 in FIG. 1), key impersonation processing insertion means (for example, equivalent to CPU 10 in FIG. 1), instruction impersonation means (For example, equivalent to the CPU 10 in FIG. 1), instruction restoration processing insertion means (for example, equivalent to the CPU 10 in FIG. 1), and instruction impersonation processing insertion means (for example, equivalent to the CPU 10 in FIG. 1). A self-rewriting processing method, wherein the selection means selects at least one instruction described in the protection target program (for example, step S in FIG. 2). 6 and corresponding to step S22 in FIG. 3) and a second step in which the instruction encryption means encrypts the instruction selected in the first step using a key (for example, corresponding to step S23 in FIG. 3). When the key disguise means, the key used in the second step, a third step of replacing the dummy key (e.g., corresponding to step S30 of FIG. 3) and, said key recovery process inserting means, said first A fourth step (for example, the step in FIG. 3) for inserting a key restoration process (for example, equivalent to the key restoration process 55 in FIG. 5) into which the dummy key replaced in the three steps is replaced with the original key. and equivalent) in S31, the instruction decoding insertion means, the instruction that was encrypted in the second step, the instruction decoding processing for decoding using the original key, which is substituted by the execution of the key recovery process (E.g., corresponding to the instruction decoding process 52A of FIG. 5), a fifth step of inserting into the protected program (e.g., corresponding to step S26 in step S7 and 3 in FIG. 2), the key disguise process inserting means A sixth step of inserting into the protection target program a key impersonation process (for example, equivalent to the key impersonation process 56 of FIG. 5) for replacing the original key replaced by the execution of the key restoration process with a dummy key. (For example, corresponding to step S32 in FIG. 3), and a seventh step (for example, corresponding to step S25 in FIG. 3) in which the instruction disguise means replaces the instruction selected in the first step with a dummy instruction; the instruction restoring process insertion means, the dummy instruction has been substituted in the seventh step, the instruction restoration process of replacing the instruction decoding original instruction decoded by the execution of the ( Eg to the corresponding) to the instruction recovery process 53 of Figure 5, the eighth step of inserting into the protected program (e.g., corresponding to step S27 in FIG. 3), said instruction disguise process insertion means, of the instruction restoration process Ninth step (for example, step of FIG. 3) of inserting into the protection target program an instruction forgery process (for example, equivalent to the instruction forgery process 54 of FIG. 5) that replaces the original instruction replaced by execution with a dummy instruction. Equivalent to S28) is proposed.

この発明によれば、保護対象プログラムに記述されている命令を少なくとも1つ選択する。そして、選択した命令を鍵を用いて暗号化し、この鍵をダミーの鍵に置換する。そして、ダミーの鍵を元の鍵に置換する鍵復元処理と、暗号化した命令を鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理と、鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理と、を保護対象プログラムに挿入する。また、上述の選択した命令をダミーの命令に置換し、ダミーの命令を命令復号処理の実行により復号された元の命令に置換する命令復元処理と、命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理と、を保護対象プログラムに挿入する。以上によれば、上述した効果と同様の効果を奏することができる。   According to the present invention, at least one instruction described in the protection target program is selected. Then, the selected instruction is encrypted using a key, and this key is replaced with a dummy key. Then, a key restoration process that replaces the dummy key with the original key, an instruction decryption process that decrypts the encrypted instruction using the original key replaced by the execution of the key restoration process, and an execution of the key restoration process A key impersonation process for replacing the replaced original key with a dummy key is inserted into the protection target program. Further, the instruction selected above is replaced with a dummy instruction, the instruction restoration process for replacing the dummy instruction with the original instruction decoded by execution of the instruction decoding process, and the original instruction replaced by execution of the instruction restoration process Instruction impersonation processing for replacing an instruction with a dummy instruction is inserted into the protection target program. According to the above, an effect similar to the effect described above can be achieved.

(5) 本発明は、保護対象プログラムに記述されている命令を少なくとも1つ選択する第1ステップ(例えば、図2のステップS6および図3のステップS22に相当)と、前記第1ステップにおいて選択した命令を、鍵を用いて暗号化する第2ステップ(例えば、図3のステップS23に相当)と、前記第2ステップにおいて用いた鍵を、ダミーの鍵に置換する第3ステップ(例えば、図3のステップS30に相当)と、前記第3ステップにおいて置換したダミーの鍵を元の鍵に置換する鍵復元処理(例えば、図5の鍵復元処理55に相当)を、前記保護対象プログラムに挿入する第4ステップ(例えば、図3のステップS31に相当)と、前記第2ステップにおいて暗号化した命令を、前記鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理(例えば、図5の命令復号処理52Aに相当)を、前記保護対象プログラムに挿入する第5ステップ(例えば、図2のステップS7および図3のステップS26に相当)と、前記鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理(例えば、図5の鍵偽装処理56に相当)を、前記保護対象プログラムに挿入する第6ステップ(例えば、図3のステップS32に相当)と、前記第1ステップにおいて選択した命令をダミーの命令に置換する第7ステップ(例えば、図3のステップS25に相当)と、前記第7ステップにおいて置換したダミーの命令を、前記命令復号処理の実行により復号された元の命令に置換する命令復元処理(例えば、図5の命令復元処理53に相当)を、前記保護対象プログラムに挿入する第8ステップ(例えば、図3のステップS27に相当)と、前記命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理(例えば、図5の命令偽装処理54に相当)を、前記保護対象プログラムに挿入する第9ステップ(例えば、図3のステップS28に相当)と、コンピュータに実行させるためのプログラムを提案している。   (5) The present invention selects a first step (for example, corresponding to step S6 in FIG. 2 and step S22 in FIG. 3) for selecting at least one instruction described in the protection target program, and selection in the first step. A second step (for example, corresponding to step S23 in FIG. 3) of encrypting the instruction using a key, and a third step (for example, FIG. 3) replacing the key used in the second step with a dummy key. 3) and a key restoration process (for example, equivalent to the key restoration process 55 in FIG. 5) for replacing the dummy key replaced in the third step with the original key is inserted into the protection target program. The fourth step (e.g., corresponding to step S31 in FIG. 3) and the original key replaced by executing the key recovery process with the instruction encrypted in the second step. And a fifth step (for example, corresponding to step S7 in FIG. 2 and step S26 in FIG. 3) for inserting an instruction decoding process (for example, corresponding to the instruction decoding process 52A in FIG. 5) into the protection target program; A sixth step (for example, inserting a key impersonation process (for example, equivalent to the key impersonation process 56 in FIG. 5) into the protection target program, which replaces the original key replaced by the execution of the key restoration process with a dummy key. , Corresponding to step S32 in FIG. 3), a seventh step (for example, corresponding to step S25 in FIG. 3) replacing the instruction selected in the first step with a dummy instruction, and a dummy replacing in the seventh step Is replaced with the original instruction decoded by the execution of the instruction decoding process (for example, equivalent to the instruction restoration process 53 of FIG. 5). An eighth step (for example, corresponding to step S27 in FIG. 3) to be inserted into the elephant program, and an instruction impersonation process (for example, in FIG. 5) that replaces the original instruction replaced by execution of the instruction restoration process with a dummy instruction. A program for causing a computer to execute a ninth step (for example, corresponding to step S28 in FIG. 3) of inserting a command forgery process 54 into the protection target program is proposed.

この発明によれば、プログラムをコンピュータに実行させることで、保護対象プログラムに記述されている命令を少なくとも1つ選択する。そして、選択した命令を鍵を用いて暗号化し、この鍵をダミーの鍵に置換する。そして、ダミーの鍵を元の鍵に置換する鍵復元処理と、暗号化した命令を鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理と、鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理と、を保護対象プログラムに挿入する。また、上述の選択した命令をダミーの命令に置換し、ダミーの命令を命令復号処理の実行により復号された元の命令に置換する命令復元処理と、命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理と、を保護対象プログラムに挿入する。以上によれば、上述した効果と同様の効果を奏することができる。   According to the present invention, at least one instruction described in the protection target program is selected by causing the computer to execute the program. Then, the selected instruction is encrypted using a key, and this key is replaced with a dummy key. Then, a key restoration process that replaces the dummy key with the original key, an instruction decryption process that decrypts the encrypted instruction using the original key replaced by the execution of the key restoration process, and an execution of the key restoration process A key impersonation process for replacing the replaced original key with a dummy key is inserted into the protection target program. Further, the instruction selected above is replaced with a dummy instruction, the instruction restoration process for replacing the dummy instruction with the original instruction decoded by execution of the instruction decoding process, and the original instruction replaced by execution of the instruction restoration process Instruction impersonation processing for replacing an instruction with a dummy instruction is inserted into the protection target program. According to the above, an effect similar to the effect described above can be achieved.

本発明によれば、ダミーに偽装した命令の元の命令を暗号化するとともに、暗号化に用いる鍵を偽装するため、保護対象プログラムの解析および改ざんの困難性を向上させることができる。   According to the present invention, since the original instruction of the dummy disguised instruction is encrypted and the key used for encryption is disguised, it is possible to improve the difficulty of analyzing and falsifying the protection target program.

本発明の一実施形態に係る自己書き換え処理装置の構成を示すブロック図である。It is a block diagram which shows the structure of the self-rewriting processing apparatus which concerns on one Embodiment of this invention. 前記自己書き換え処理装置における第1の処理のフローチャートである。It is a flowchart of the 1st process in the said self-rewriting processing apparatus. 前記自己書き換え処理装置における第2の処理のフローチャートである。It is a flowchart of the 2nd process in the said self-rewriting processing apparatus. 前記第1の処理および前記第2の処理を説明するための図である。It is a figure for demonstrating a said 1st process and a said 2nd process. 前記第1の処理および前記第2の処理を説明するための図である。It is a figure for demonstrating a said 1st process and a said 2nd process. 前記第1の処理および前記第2の処理を説明するための図である。It is a figure for demonstrating a said 1st process and a said 2nd process. 前記第1の処理および前記第2の処理を説明するための図である。It is a figure for demonstrating a said 1st process and a said 2nd process. 前記第1の処理および前記第2の処理を説明するための図である。It is a figure for demonstrating a said 1st process and a said 2nd process.

以下、本発明の実施形態について図面を参照しながら説明する。なお、以下の実施形態における構成要素は適宜、既存の構成要素などとの置き換えが可能であり、また、他の既存の構成要素との組合せを含む様々なバリエーションが可能である。したがって、以下の実施形態の記載をもって、特許請求の範囲に記載された発明の内容を限定するものではない。   Hereinafter, embodiments of the present invention will be described with reference to the drawings. Note that the constituent elements in the following embodiments can be appropriately replaced with existing constituent elements, and various variations including combinations with other existing constituent elements are possible. Accordingly, the description of the following embodiments does not limit the contents of the invention described in the claims.

[自己書き換え処理装置1の構成]
図1は、本発明の一実施形態に係る自己書き換え処理装置1の構成を示すブロック図である。自己書き換え処理装置1は、様々な演算処理を行うCPU(Central Processing Unit)10と、保護対象プログラムを記憶するキャッシュ20と、を備える。
[Configuration of Self-Rewriting Processing Device 1]
FIG. 1 is a block diagram showing a configuration of a self-rewriting processing device 1 according to an embodiment of the present invention. The self-rewriting processing device 1 includes a CPU (Central Processing Unit) 10 that performs various arithmetic processes, and a cache 20 that stores a protection target program.

自己書き換え処理装置1は、後述の第1の処理(図2参照)を実行した後、後述の第2の処理(図3参照)を実行することにより、保護対象プログラムの解析および改ざんの困難性を向上させる。   The self-rewrite processing device 1 executes the first process described later (see FIG. 2) and then executes the second process described later (see FIG. 3), thereby making it difficult to analyze and falsify the protection target program. To improve.

[第1の処理]
図2は、上述の第1の処理のフローチャートである。
[First processing]
FIG. 2 is a flowchart of the first process described above.

ステップS1において、自己書き換え処理装置1は、CPU10により、暗号化するビットサイズL(Lは、L>0を満たす整数)を設定し、ステップS2に処理を移す。具体的には、暗号化する命令の数と、1命令当たりのビット数と、を乗算してビットサイズLとする。例えば、1つの命令が32ビットである環境において、4つの命令を暗号化する場合には、ビットサイズLは、128ビットとなる。なお、暗号化する命令の数は、例えば自己書き換え処理装置1のユーザにより決定される。   In step S1, the CPU 10 sets the bit size L to be encrypted (L is an integer satisfying L> 0) by the CPU 10, and moves the process to step S2. Specifically, the bit size L is obtained by multiplying the number of instructions to be encrypted and the number of bits per instruction. For example, when four instructions are encrypted in an environment where one instruction is 32 bits, the bit size L is 128 bits. Note that the number of instructions to be encrypted is determined, for example, by the user of the self-rewrite processing device 1.

ステップS2において、自己書き換え処理装置1は、CPU10により、反復回数N(Nは、N≧0を満たす整数)を設定し、ステップS3に処理を移す。   In step S2, the self-rewrite processing device 1 sets the number of iterations N (N is an integer satisfying N ≧ 0) by the CPU 10, and moves the process to step S3.

ステップS3において、自己書き換え処理装置1は、CPU10により、変数Pに「0」を代入することで変数Pを初期化し、ステップS4に処理を移す。   In step S3, the self-rewrite processing device 1 initializes the variable P by substituting “0” for the variable P by the CPU 10, and moves the process to step S4.

ステップS4において、自己書き換え処理装置1は、CPU10により、暗号化した命令を格納するためのデータ領域をキャッシュ20に確保し、ステップS5に処理を移す。なお、命令の暗号化は、後述の図3のステップS23において行われるため、暗号化した命令は、ステップS4が実行された段階では存在していない。このため、ステップS4を実行した段階では、暗号化した命令を格納するためにキャッシュ20に確保したデータ領域には、nullが格納される。   In step S4, the self-rewrite processing device 1 uses the CPU 10 to secure a data area for storing the encrypted instruction in the cache 20, and moves the process to step S5. Since the instruction is encrypted in step S23 of FIG. 3 described later, the encrypted instruction does not exist at the stage where step S4 is executed. For this reason, at the stage of executing step S4, null is stored in the data area secured in the cache 20 for storing the encrypted instruction.

ステップS5において、自己書き換え処理装置1は、CPU10により、命令を暗号化する際に用いる鍵を生成し、この鍵を格納するためのデータ領域をキャッシュ20に確保し、上述の生成した鍵を上述の確保したデータ領域に格納し、ステップS6に処理を移す。鍵の生成には、暗号鍵生成用疑似乱数を用いる。暗号鍵生成用疑似乱数は、CPU10で生成してもよいし、CPU10とは別に、乱数を生成する乱数生成器と、乱数生成器で生成された乱数をサンプリングするサンプリング部と、を設け、これら乱数生成器およびサンプリング部で生成してもよい。   In step S5, the self-rewrite processing device 1 uses the CPU 10 to generate a key used when encrypting the instruction, secures a data area for storing the key in the cache 20, and uses the generated key as described above. Are stored in the secured data area, and the process proceeds to step S6. For the key generation, a pseudo random number for generating an encryption key is used. The pseudo random number for generating the encryption key may be generated by the CPU 10, or separately from the CPU 10, a random number generator that generates a random number and a sampling unit that samples the random number generated by the random number generator are provided. It may be generated by a random number generator and a sampling unit.

ステップS6において、自己書き換え処理装置1は、CPU10により、キャッシュ20に記憶されている保護対象プログラムのうち、保護する領域を選択し、ステップS7に処理を移す。なお、保護する領域は、例えば自己書き換え処理装置1のユーザにより、保護対象プログラムの中から決定されるものとする。また、キャッシュ20に記憶されている保護対象プログラムとは、C言語やJava(登録商標)といった高級言語で記述されているものとする。   In step S6, the self-rewriting processing device 1 selects an area to be protected from the protection target programs stored in the cache 20 by the CPU 10, and the process proceeds to step S7. It is assumed that the area to be protected is determined from the protection target program by the user of the self-rewrite processing device 1, for example. The protection target program stored in the cache 20 is described in a high-level language such as C language or Java (registered trademark).

ステップS7において、自己書き換え処理装置1は、CPU10により、命令復号処理を、ステップS6の処理を行った保護対象プログラムに挿入し、ステップS8に処理を移す。なお、命令復号処理とは、暗号化した命令を復号する処理のことである。この命令復号処理は、ステップS6の処理が行われた保護対象プログラムのうち、ステップS6において選択された領域の前方に、挿入される。なお、保護対象プログラムに記述されているどの命令を暗号化するのかは、後述の図3のステップS22において定まるため、ステップS7が実行された段階では分からない。このため、ステップS7を実行した段階では、命令復号処理には仮引数が割り当てられる。   In step S7, the self-rewrite processing device 1 inserts the instruction decryption process into the protection target program that has undergone the process of step S6 by the CPU 10, and moves the process to step S8. The instruction decryption process is a process for decrypting an encrypted instruction. This instruction decoding process is inserted in front of the area selected in step S6 in the protection target program subjected to the process in step S6. Note that which instruction described in the protection target program is to be encrypted is determined in step S22 of FIG. 3 to be described later, so it is not known at the stage when step S7 is executed. For this reason, a temporary argument is assigned to the instruction decoding process at the stage of executing step S7.

ステップS8において、自己書き換え処理装置1は、CPU10により、変数Pに1を加算し、ステップS9に処理を移す。   In step S8, the self-rewriting processing device 1 adds 1 to the variable P by the CPU 10, and proceeds to step S9.

ステップS9において、自己書き換え処理装置1は、CPU10により、変数Pが反復回数N以下であるか否かを判別する。そして、変数Pが反復回数N以下である場合には、すなわち上述のステップS7、S8の各処理を行った回数が反復回数N以下である場合には、ステップS7に処理を戻す。一方、変数Pが反復回数Nより大きい場合には、すなわち上述のステップS7、S8の各処理を行った回数が反復回数Nより多い場合には、ステップS10に処理を移す。   In step S <b> 9, the self-rewrite processing device 1 determines whether the variable P is equal to or less than the number of iterations N by the CPU 10. If the variable P is less than or equal to the number of iterations N, that is, if the number of times the processes in steps S7 and S8 are performed is less than or equal to the number of iterations N, the process returns to step S7. On the other hand, if the variable P is larger than the number of iterations N, that is, if the number of times the processes in steps S7 and S8 are performed is larger than the number of iterations N, the process proceeds to step S10.

ステップS10において、自己書き換え処理装置1は、CPU10により、ステップS7の処理を行った保護対象プログラムについて、アセンブラ記述を取得し、第1の処理を終了する。具体的には、ステップS7の処理を行った保護対象プログラムについて、コンパイルして、アセンブリプログラムに変換する。   In step S10, the self-rewrite processing device 1 acquires an assembler description for the protection target program that has undergone the process of step S7 by the CPU 10, and ends the first process. Specifically, the protection target program that has undergone the process of step S7 is compiled and converted into an assembly program.

[第2の処理]
図3は、上述の第2の処理のフローチャートである。
[Second processing]
FIG. 3 is a flowchart of the second process described above.

ステップS21において、自己書き換え処理装置1は、CPU10により、変数Qに「0」を代入することで変数Qを初期化し、ステップS22に処理を移す。   In step S21, the self-rewrite processing device 1 initializes the variable Q by substituting “0” into the variable Q by the CPU 10, and moves the process to step S22.

ステップS22において、自己書き換え処理装置1は、CPU10により、ステップS10において取得したアセンブラ記述の保護対象プログラムのうち、ステップS6において選択した保護する領域に対応する領域から、第1命令セットを選択し、ステップS23に処理を移す。なお、第1命令セットとは、暗号化する命令の集合のことであり、ステップS1において設定したビットサイズLに応じた数の命令で構成されるもののことである。例えば、1つの命令が32ビットである環境において、ビットサイズLとして128ビットを設定した場合には、第1命令セットは、4つの命令で構成されることとなる。   In step S22, the self-rewrite processing device 1 selects the first instruction set from the area corresponding to the area to be protected selected in step S6 among the protection target programs in the assembler description acquired in step S10 by the CPU 10. The process moves to step S23. The first instruction set is a set of instructions to be encrypted, and is composed of a number of instructions corresponding to the bit size L set in step S1. For example, in an environment where one instruction is 32 bits, when 128 bits is set as the bit size L, the first instruction set is composed of four instructions.

ステップS23において、自己書き換え処理装置1は、CPU10により、ステップS5において生成した鍵を用いて第1命令セットを暗号化し、ステップS24に処理を移す。   In step S23, the self-rewrite processing device 1 encrypts the first instruction set by the CPU 10 using the key generated in step S5, and moves the process to step S24.

ステップS24において、自己書き換え処理装置1は、CPU10により、ステップS23において暗号化した第1命令セットを、ステップS4において確保したデータ領域に格納し、ステップS25に処理を移す。   In step S24, the self-rewrite processing device 1 stores the first instruction set encrypted in step S23 by the CPU 10 in the data area secured in step S4, and moves the process to step S25.

ステップS25において、自己書き換え処理装置1は、CPU10により、第1命令セットをダミーの第1命令セットに置換し、ステップS26に処理を移す。これによれば、第1命令セットが偽装されることとなる。   In step S25, the CPU 10 replaces the first instruction set with a dummy first instruction set by the CPU 10, and moves the process to step S26. According to this, the first instruction set is camouflaged.

ステップS26において、自己書き換え処理装置1は、CPU10により、ステップS7において挿入した命令復号処理の引数に、ステップS22において選択した第1命令セットのアドレスと、ステップS24において格納した第1命令セットのアドレスと、を代入し、ステップS27に処理を移す。これによれば、鍵を用意した上で命令復号処理を実行すると、ステップS23において暗号化した第1命令セットが、復号されることとなる。   In step S26, the self-rewrite processing device 1 causes the CPU 10 to specify the address of the first instruction set selected in step S22 and the address of the first instruction set stored in step S24 as arguments of the instruction decoding process inserted in step S7. And the process proceeds to step S27. According to this, when the instruction decryption process is executed after preparing the key, the first instruction set encrypted in step S23 is decrypted.

ステップS27において、自己書き換え処理装置1は、CPU10により、命令復元処理を、ステップS26の処理を行った保護対象プログラムに挿入し、ステップS28に処理を移す。なお、命令復元処理とは、ダミーの第1命令セットを元の第1命令セットに置換する処理のことである。この命令復元処理は、ステップS26の処理が行われた保護対象プログラムのうち、ステップS26において引数を代入された命令復号処理と、ステップS25において置換されたダミーの第1命令セットと、の間に挿入される。これによれば、命令復号処理、命令復元処理の順に実行された後、第1命令セットが実行されることとなる。   In step S27, the self-rewrite processing device 1 uses the CPU 10 to insert an instruction restoration process into the protection target program that has undergone the process of step S26, and moves the process to step S28. The instruction restoration process is a process for replacing the dummy first instruction set with the original first instruction set. This instruction restoration process is performed between the instruction decoding process in which the argument is substituted in step S26 and the dummy first instruction set replaced in step S25 among the protection target programs subjected to the process of step S26. Inserted. According to this, after the instruction decoding process and the instruction restoration process are executed in this order, the first instruction set is executed.

なお、上述のように、第1命令セットは、ステップS23において暗号化される。このため、仮に、命令復号処理が実行されることなく、命令復元処理が実行された場合には、元の第1命令セットが暗号化された状態のまま、命令復元処理が実行されることになるので、ダミーの第1命令セットを元の第1命令セットに正しく置換することができなくなる。ところが、本実施形態では、命令復号処理が実行された後に、命令復元処理が実行されるので、ダミーの第1命令セットを元の第1命令セットに正しく置換することができる。   As described above, the first instruction set is encrypted in step S23. For this reason, if the instruction restoration process is executed without executing the instruction decryption process, the instruction restoration process is executed while the original first instruction set is encrypted. Therefore, the dummy first instruction set cannot be correctly replaced with the original first instruction set. However, in this embodiment, since the instruction restoration process is executed after the instruction decoding process is executed, the dummy first instruction set can be correctly replaced with the original first instruction set.

ステップS28において、自己書き換え処理装置1は、CPU10により、命令偽装処理を、ステップS27の処理を行った保護対象プログラムに挿入し、ステップS29に処理を移す。なお、命令偽装処理とは、元の第1命令セットをダミーの第1命令セットに置換する処理のことである。この命令偽装処理は、ステップS27の処理が行われた保護対象プログラムのうち、ステップS25において置換されたダミーの第1命令セットの後方に、挿入される。これによれば、第1命令セットが実行された後に、命令偽装処理が実行されることとなる。このため、第1命令セットが実行された後に、この第1命令セットは、再度偽装されることとなる。   In step S28, the self-rewrite processing device 1 uses the CPU 10 to insert the instruction disguise process into the protection target program that has undergone the process of step S27, and moves the process to step S29. The instruction disguise process is a process of replacing the original first instruction set with a dummy first instruction set. This instruction impersonation process is inserted behind the dummy first instruction set replaced in step S25 in the protection target program subjected to the process of step S27. According to this, after the first instruction set is executed, the instruction disguise process is executed. For this reason, after the first instruction set is executed, the first instruction set is camouflaged again.

ステップS29において、自己書き換え処理装置1は、CPU10により、ステップS23において用いた鍵にあたる命令セットを、第2命令セットとして選択し、ステップS30に処理を移す。   In step S29, the self-rewrite processing device 1 causes the CPU 10 to select the instruction set corresponding to the key used in step S23 as the second instruction set, and the process proceeds to step S30.

ステップS30において、自己書き換え処理装置1は、CPU10により、第2命令セットをダミーの第2命令セットに置換し、ステップS31に処理を移す。これによれば、第2命令セットが偽装されることとなる。   In step S30, the self-rewrite processing device 1 uses the CPU 10 to replace the second instruction set with a dummy second instruction set, and the process proceeds to step S31. According to this, the second instruction set is camouflaged.

ステップS31において、自己書き換え処理装置1は、CPU10により、鍵復元処理を、ステップS30の処理を行った保護対象プログラムに挿入し、ステップS32に処理を移す。なお、鍵復元処理とは、ダミーの第2命令セットを元の第2命令セットに置換する処理のことである。この鍵復元処理は、ステップS30の処理が行われた保護対象プログラムのうち、ステップS26において引数を代入された命令復号処理の前方に、挿入される。これによれば、鍵復元処理が実行された後に、命令復号処理が実行されることとなる。このため、命令復号処理が実行される時点では、偽装されていた鍵が元に戻された状態となる。   In step S31, the self-rewrite processing device 1 inserts the key recovery process into the protection target program that has been processed in step S30 by the CPU 10, and moves the process to step S32. The key recovery process is a process of replacing the dummy second instruction set with the original second instruction set. This key recovery process is inserted in front of the instruction decryption process in which the argument is substituted in step S26 among the protection target programs subjected to the process of step S30. According to this, the instruction decryption process is executed after the key restoration process is executed. For this reason, when the instruction decryption process is executed, the forged key is returned to the original state.

ステップS32において、自己書き換え処理装置1は、CPU10により、鍵偽装処理を、ステップS31の処理を行った保護対象プログラムに挿入し、ステップS33に処理を移す。なお、鍵偽装処理とは、元の第2命令セットをダミーの第2命令セットに置換する処理のことである。この鍵偽装処理は、ステップS31の処理が行われた保護対象プログラムのうち、ステップS26において引数を代入された命令復号処理の後方に、挿入される。これによれば、命令復号処理が実行された後に、鍵偽装処理が実行されることとなる。このため、命令復号処理において鍵が用いられた後に、この鍵は、再度偽装されることとなる。   In step S32, the self-rewrite processing device 1 inserts the key disguise process into the protection target program that has performed the process of step S31 by the CPU 10, and moves the process to step S33. The key disguise process is a process for replacing the original second instruction set with a dummy second instruction set. This key impersonation process is inserted behind the instruction decryption process in which the argument is substituted in step S26 among the protection target programs subjected to the process of step S31. According to this, the key impersonation process is executed after the instruction decryption process is executed. For this reason, after the key is used in the instruction decryption process, the key is forged again.

ステップS33において、自己書き換え処理装置1は、CPU10により、変数Qに1を加算し、ステップS34に処理を移す。   In step S33, the self-rewrite processing device 1 adds 1 to the variable Q by the CPU 10, and moves the process to step S34.

ステップS34において、自己書き換え処理装置1は、CPU10により、変数Qが反復回数N以下であるか否かを判別する。そして、変数Qが反復回数N以下である場合には、すなわち上述のステップS22〜S33の各処理を行った回数が反復回数N以下である場合には、ステップS22に処理を戻す。一方、変数Qが反復回数Nより大きい場合には、すなわち上述のステップS22〜S33の各処理を行った回数が反復回数Nより多い場合には、第2の処理を終了する。   In step S <b> 34, the self-rewrite processing device 1 determines whether the variable Q is equal to or less than the number of iterations N by the CPU 10. If the variable Q is less than or equal to the number of iterations N, that is, if the number of times the processes in steps S22 to S33 are performed is less than or equal to the number of iterations N, the process returns to step S22. On the other hand, if the variable Q is larger than the number of iterations N, that is, if the number of times the processes in steps S22 to S33 are performed is larger than the number of iterations N, the second process is terminated.

[第1の処理および第2の処理を行った後の保護対象プログラム]
まず、反復回数Nを「1」として、上述の第1の処理および上述の第2の処理を行った場合について、図4および図5を用いて以下に説明する。
[Protected program after the first process and the second process]
First, the case where the number of iterations N is “1” and the above-described first process and the above-described second process are performed will be described below with reference to FIGS. 4 and 5.

図4は、反復回数Nを「1」として上述の第1の処理を行った場合の、保護対象プログラム50を示す図である。   FIG. 4 is a diagram showing the protection target program 50 when the first process described above is performed with the iteration count N set to “1”.

まず、ステップS1〜S4の各処理が行われた後に、ステップS5の処理が行われ、暗号化に用いる鍵が生成され、キャッシュ20に確保されたデータ領域に格納される。このため、暗号化に用いる鍵は、保護対象プログラム50には記述されない。   First, after each process of steps S1 to S4 is performed, a process of step S5 is performed, and a key used for encryption is generated and stored in a data area secured in the cache 20. For this reason, the key used for encryption is not described in the protection target program 50.

次に、ステップS6の処理が行われ、保護する領域が選択される。なお、選択された領域には、保護したい命令の集合である命令セットが記述されていることとなる。   Next, the process of step S6 is performed and the area to be protected is selected. In the selected area, an instruction set that is a set of instructions to be protected is described.

次に、ステップS7の処理が行われ、ステップS6において選択された領域の前方に、すなわち保護したい命令セットの前方に、命令復号処理が挿入される。なお、ステップS7において命令復号処理が挿入された時点では、上述のステップS26の処理が行われていないので、命令復号処理には仮引数が割り当てられている。   Next, the process of step S7 is performed, and the instruction decoding process is inserted in front of the area selected in step S6, that is, in front of the instruction set to be protected. Note that when the instruction decoding process is inserted in step S7, the above-described process of step S26 is not performed, and therefore a temporary argument is assigned to the instruction decoding process.

次に、ステップS8、S9の各処理が行われた後に、ステップS10の処理が行われ、ステップS7の処理が行われた保護対象プログラムのアセンブラ記述が取得される。これによれば、上述の保護したい命令セットが、アセンブラで記述された保護したい命令セット51に変換されるとともに、上述の命令復号処理が、アセンブラで記述された命令復号処理52に変換されることとなる。   Next, after the processes of steps S8 and S9 are performed, the process of step S10 is performed, and the assembler description of the protection target program subjected to the process of step S7 is acquired. According to this, the instruction set to be protected is converted into the instruction set 51 to be protected described in the assembler, and the instruction decoding process is converted into the instruction decoding process 52 described in the assembler. It becomes.

図5は、保護対象プログラム50Aを示す図である。保護対象プログラム50Aは、図4に示した保護対象プログラム50に対して、反復回数Nを「1」として上述の第2の処理を行ったものである。   FIG. 5 is a diagram showing the protection target program 50A. The protection target program 50A is obtained by performing the above-described second process on the protection target program 50 shown in FIG.

まず、ステップS21の処理が行われた後に、ステップS22の処理が行われ、第1命令セットが選択される。ここでは、第1命令セットとして、図4に示した保護したい命令セット51が選択されたものとする。   First, after the process of step S21 is performed, the process of step S22 is performed and the first instruction set is selected. Here, it is assumed that the instruction set 51 to be protected shown in FIG. 4 is selected as the first instruction set.

次に、ステップS23の処理が行われ、第1命令セットとしての保護したい命令セット51が暗号化される。暗号化された第1命令セットは、ステップS24において、ステップS4において確保されたデータ領域に格納されるため、保護対象プログラム50Aには記述されない。   Next, the process of step S23 is performed, and the instruction set 51 to be protected as the first instruction set is encrypted. Since the encrypted first instruction set is stored in the data area secured in step S4 in step S24, it is not described in the protection target program 50A.

次に、ステップS25の処理が行われ、第1命令セットとしての保護したい命令セット51が、ダミーの第1命令セット51Aに置換され、偽装される。   Next, the process of step S25 is performed, and the instruction set 51 to be protected as the first instruction set is replaced with a dummy first instruction set 51A and is camouflaged.

次に、ステップS26の処理が行われ、図4に示した命令復号処理52の仮引数が上述の各アドレスに置き換えられる。ここでは、図4に示した命令復号処理52に対してステップS26の処理を行ったものを、命令復号処理52Aとする。   Next, the process of step S26 is performed, and the dummy argument of the instruction decoding process 52 shown in FIG. 4 is replaced with each address described above. Here, the instruction decoding process 52A is obtained by performing the process of step S26 on the instruction decoding process 52 shown in FIG.

次に、ステップS27の処理が行われ、命令復号処理52Aとダミーの第1命令セット51Aとの間に、命令復元処理53が挿入される。   Next, the process of step S27 is performed, and the instruction restoration process 53 is inserted between the instruction decoding process 52A and the dummy first instruction set 51A.

次に、ステップS28の処理が行われ、ダミーの第1命令セット51Aの後方に、命令偽装処理54が挿入される。   Next, the process of step S28 is performed, and the instruction disguise process 54 is inserted behind the dummy first instruction set 51A.

次に、ステップS29の処理が行われた後に、ステップS30の処理が行われ、ステップS23において保護したい命令セット51を暗号化する際に用いられた鍵が、ダミーの鍵に置換され、偽装される。   Next, after the process of step S29 is performed, the process of step S30 is performed, and the key used when encrypting the instruction set 51 to be protected in step S23 is replaced with a dummy key and impersonated. The

次に、ステップS31の処理が行われ、命令復号処理52Aの前方に、鍵復元処理55が挿入される。   Next, the process of step S31 is performed, and the key recovery process 55 is inserted in front of the instruction decryption process 52A.

次に、ステップS32の処理が行われ、命令復号処理52Aの後方に、鍵偽装処理56が挿入される。   Next, the process of step S32 is performed, and the key impersonation process 56 is inserted behind the instruction decryption process 52A.

次に、反復回数Nを「2」として、上述の第1の処理および上述の第2の処理を行った場合について、図6〜図8を用いて以下に説明する。   Next, the case where the number of iterations N is “2” and the above-described first process and the above-described second process are performed will be described below with reference to FIGS. 6 to 8.

図6は、反復回数Nを「2」として上述の第1の処理を行った場合の、保護対象プログラム60を示す図である。   FIG. 6 is a diagram showing the protection target program 60 when the above-described first processing is performed with the iteration count N being “2”.

保護対象プログラム60は、図4に示した保護対象プログラム50とは、挿入される命令復号処理の数が異なる。具体的には、保護対象プログラム60には、保護したい命令セット61の前方に、命令復号処理621、622が挿入される。   The protection target program 60 differs from the protection target program 50 shown in FIG. 4 in the number of instruction decoding processes to be inserted. Specifically, instruction decoding processes 621 and 622 are inserted into the protection target program 60 in front of the instruction set 61 to be protected.

図7は、保護対象プログラム60Aを示す図である。保護対象プログラム60Aは、図6に示した保護対象プログラム60に対して、ステップS21の処理を行った後に、ステップS22〜S33の各処理を1回行ったものである。   FIG. 7 is a diagram showing the protection target program 60A. The protection target program 60A is obtained by performing each of the processes of steps S22 to S33 once after performing the process of step S21 on the protection target program 60 shown in FIG.

保護対象プログラム60Aにおいては、保護対象プログラム50Aと同様に、ステップS22において、第1命令セットとして保護したい命令セット61が選択され、保護したい命令セット61に関してステップS23〜S33の各処理が行われる。このため、保護対象プログラム60Aには、図5に示した保護対象プログラム50Aの鍵復元処理55、命令復号処理52A、鍵偽装処理56、命令復元処理53、ダミーの第1命令セット51A、および命令偽装処理54のそれぞれに相当するものとして、鍵復元処理65、命令復号処理621A、鍵偽装処理66、命令復元処理63、ダミーの第1命令セット61A、および命令偽装処理64がそれぞれ記述されることとなる。また、保護対象プログラム60Aには、鍵復元処理65の前方に、図6に示した命令復号処理622が記述されることとなる。   In the protection target program 60A, as in the protection target program 50A, in step S22, the instruction set 61 to be protected is selected as the first instruction set, and the processes in steps S23 to S33 are performed on the instruction set 61 to be protected. For this reason, the protection target program 60A includes a key restoration process 55, an instruction decryption process 52A, a key impersonation process 56, an instruction restoration process 53, a dummy first instruction set 51A, and an instruction of the protection target program 50A shown in FIG. As corresponding to each of the impersonation processes 54, a key restoration process 65, an instruction decryption process 621A, a key impersonation process 66, an instruction restoration process 63, a dummy first instruction set 61A, and an instruction impersonation process 64 are described. It becomes. In the protection target program 60A, the instruction decryption process 622 shown in FIG.

図8は、保護対象プログラム60Bを示す図である。保護対象プログラム60Bは、図7に示した保護対象プログラム60Aに対して、ステップS22〜S33の各処理を1回行ったものである。   FIG. 8 is a diagram showing the protection target program 60B. The protection target program 60B is obtained by performing each process of steps S22 to S33 once for the protection target program 60A shown in FIG.

まず、ステップS21の処理が行われた後に、ステップS22の処理が行われ、第1命令セットが選択される。ここでは、第1命令セットとして、図7に示した鍵復元処理65が選択されたものとする。   First, after the process of step S21 is performed, the process of step S22 is performed and the first instruction set is selected. Here, it is assumed that the key recovery process 65 shown in FIG. 7 is selected as the first instruction set.

次に、ステップS23の処理が行われ、第1命令セットとしての鍵復元処理65が暗号化される。暗号化された第1命令セットは、ステップS24において、ステップS4において確保されたデータ領域に格納されるため、保護対象プログラム60Bには記述されない。   Next, the process of step S23 is performed, and the key restoration process 65 as the first instruction set is encrypted. Since the encrypted first instruction set is stored in the data area secured in step S4 in step S24, it is not described in the protection target program 60B.

次に、ステップS25の処理が行われ、第1命令セットとしての鍵復元処理65が、ダミーの第1命令セット65Aに置換され、偽装される。   Next, the process of step S25 is performed, and the key restoration process 65 as the first instruction set is replaced with a dummy first instruction set 65A and is camouflaged.

次に、ステップS26の処理が行われ、図7に示した命令復号処理622の仮引数が上述の各アドレスに置き換えられる。ここでは、図7に示した命令復号処理622に対してステップS26の処理を行ったものを、命令復号処理622Aとする。   Next, the process of step S26 is performed, and the dummy argument of the instruction decoding process 622 shown in FIG. 7 is replaced with each address described above. Here, the instruction decoding process 622A is obtained by performing the process of step S26 on the instruction decoding process 622 shown in FIG.

次に、ステップS27の処理が行われ、命令復号処理622Aとダミーの第1命令セット65Aとの間に、命令復元処理653が挿入される。   Next, the process of step S27 is performed, and the instruction restoration process 653 is inserted between the instruction decoding process 622A and the dummy first instruction set 65A.

次に、ステップS28の処理が行われ、ダミーの第1命令セット65Aの後方に、命令偽装処理654が挿入される。   Next, the process of step S28 is performed, and an instruction forgery process 654 is inserted behind the dummy first instruction set 65A.

次に、ステップS29の処理が行われた後に、ステップS30の処理が行われ、ステップS23において鍵復元処理65を暗号化する際に用いられた鍵が、ダミーの鍵に置換され、偽装される。   Next, after the process of step S29 is performed, the process of step S30 is performed, and the key used when encrypting the key recovery process 65 in step S23 is replaced with a dummy key and impersonated. .

次に、ステップS31の処理が行われ、命令復号処理622Aの前方に、鍵復元処理655が挿入される。   Next, the process of step S31 is performed, and the key recovery process 655 is inserted in front of the instruction decryption process 622A.

次に、ステップS32の処理が行われ、命令復号処理622Aの後方に、鍵偽装処理656が挿入される。   Next, the process of step S32 is performed, and the key impersonation process 656 is inserted behind the instruction decryption process 622A.

以上の自己書き換え処理装置1によれば、以下の効果を奏することができる。   According to the self-rewriting processing device 1 described above, the following effects can be obtained.

自己書き換え処理装置1は、ステップS25の処理を行って、保護対象プログラムに記述されている命令をダミーの命令に置換するとともに、ステップS23の処理を行って、元の命令を暗号化する。これによれば、ダミーに偽装された命令の元の命令は、暗号化された状態となる。   The self-rewriting processing device 1 performs the process of step S25, replaces the instruction described in the protection target program with a dummy instruction, and performs the process of step S23 to encrypt the original instruction. According to this, the original instruction of the instruction disguised as a dummy is in an encrypted state.

また、自己書き換え処理装置1は、ステップS30の処理を行って、ステップS23において命令を暗号化する際に用いる鍵を、ダミーの鍵に予め偽装する。   Further, the self-rewriting processing device 1 performs the process of step S30, and pretend to be a dummy key the key used when encrypting the instruction in step S23.

以上によれば、自己書き換え処理装置1は、ダミーに偽装した命令の元の命令を暗号化するとともに、暗号化に用いる鍵を偽装するため、保護対象プログラムの解析および改ざんの困難性を向上させることができる。   According to the above, since the self-rewrite processing device 1 encrypts the original instruction of the dummy disguised instruction and disguises the key used for encryption, it improves the difficulty of analyzing and falsifying the protection target program. be able to.

また、自己書き換え処理装置1は、ステップS2において設定した反復回数Nだけ、ステップS7、S8の処理と、ステップS22〜S33の処理と、を繰り返す。このため、保護対象プログラムに記述されている命令の偽装と、この命令の暗号化と、暗号化に用いた鍵の偽装と、を複数回行うことができるので、保護対象プログラムの解析および改ざんの困難性をさらに向上させることができる。   Further, the self-rewriting processing device 1 repeats the processes of steps S7 and S8 and the processes of steps S22 to S33 for the number of repetitions N set in step S2. For this reason, since it is possible to perform the impersonation of the instruction described in the protection target program, the encryption of this instruction, and the impersonation of the key used for the encryption multiple times, the analysis and alteration of the protection target program can be performed. The difficulty can be further improved.

以上、この発明の実施形態につき、図面を参照して詳述してきたが、具体的な構成はこの実施形態に限られるものではなく、この発明の要旨を逸脱しない範囲の設計等も含まれる。   The embodiments of the present invention have been described in detail with reference to the drawings. However, the specific configuration is not limited to the embodiments, and includes designs and the like that do not depart from the gist of the present invention.

例えば、上述の実施形態では、ステップS5において鍵を生成したが、これに限らず、例えば自己書き換え処理装置1とは異なる装置により予め生成してもよい。   For example, in the above-described embodiment, the key is generated in step S5. However, the present invention is not limited to this. For example, the key may be generated in advance by a device different from the self-rewriting processing device 1.

また、上述の実施形態では、ステップS28において命令偽装処理を挿入することとした。このため、命令偽装処理を実行すると、元の命令がダミーの命令に置換される。ここで、命令偽装処理の実行により置換されるダミーの命令は、ステップS25において置換したダミーの命令と同一であってもよいし、異なっていてもよい。また、命令を暗号化する際に用いた鍵についても、ステップS32において挿入した鍵偽装処理の実行により置換されるダミーの鍵は、ステップS30において置換したダミーの鍵と同一であってもよいし、異なっていてもよい。   In the above-described embodiment, the instruction impersonation process is inserted in step S28. For this reason, when the instruction disguise process is executed, the original instruction is replaced with a dummy instruction. Here, the dummy instruction replaced by the execution of the instruction impersonation process may be the same as or different from the dummy instruction replaced in step S25. Also, with respect to the key used when encrypting the instruction, the dummy key replaced by executing the key impersonation process inserted in step S32 may be the same as the dummy key replaced in step S30. , May be different.

また、上述の実施形態では、ステップS27において命令復元処理を挿入した後に、ステップS28において命令偽装処理を挿入することとしたが、これに限らず、命令偽装処理を挿入した後に命令復元処理を挿入することとしてもよい。また、鍵復元処理および鍵偽装処理についても、鍵偽装処理を挿入した後に鍵復元処理を挿入することとしてもよい。   In the above-described embodiment, after the instruction restoration process is inserted in step S27, the instruction impersonation process is inserted in step S28. However, the present invention is not limited to this, and the instruction restoration process is inserted after the instruction impersonation process is inserted. It is good to do. Also, with regard to the key restoration process and the key impersonation process, the key restoration process may be inserted after the key impersonation process is inserted.

また、上述の実施形態では、ステップS2において反復回数Nを設定することとした。ここで、反復回数Nを大きくするに従って、保護対象プログラムの解析および改ざんの困難性を向上させることができるが、その一方で、自己書き換え処理装置1で処理された保護対象プログラムを実行する際のパフォーマンスが低下する。このため、反復回数Nは、保護対象プログラムの解析および改ざんの困難性の度合いと、自己書き換え処理装置1で処理された保護対象プログラムを実行する際のパフォーマンスと、を勘案して決定されることが好ましい。   In the above-described embodiment, the number of iterations N is set in step S2. Here, as the number of iterations N is increased, it is possible to improve the difficulty of analyzing and falsifying the protection target program. On the other hand, when executing the protection target program processed by the self-rewrite processing device 1 Performance is degraded. For this reason, the number of iterations N is determined in consideration of the degree of difficulty in analyzing and falsifying the protection target program and the performance when the protection target program processed by the self-rewrite processing device 1 is executed. Is preferred.

1・・・自己書き換え処理装置
10・・・CPU
20・・・キャッシュ
50、50A、60、60A、60B・・・保護対象プログラム
DESCRIPTION OF SYMBOLS 1 ... Self-rewriting processing apparatus 10 ... CPU
20 ... cache 50, 50A, 60, 60A, 60B ... protection target program

Claims (5)

保護対象プログラムを記憶する記憶手段と、
前記保護対象プログラムに記述されている命令を少なくとも1つ選択する選択手段と、
前記選択手段により選択された命令を、鍵を用いて暗号化する命令暗号化手段と、
前記命令暗号化手段により用いられた鍵を、ダミーの鍵に置換する鍵偽装手段と、
前記鍵偽装手段により置換されたダミーの鍵を元の鍵に置換する鍵復元処理を、前記保護対象プログラムに挿入する鍵復元処理挿入手段と、
前記命令暗号化手段により暗号化された命令を、前記鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理を、前記保護対象プログラムに挿入する命令復号処理挿入手段と、
前記鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理を、前記保護対象プログラムに挿入する鍵偽装処理挿入手段と、
前記選択手段により選択された命令をダミーの命令に置換する命令偽装手段と、
前記命令偽装手段により置換されたダミーの命令を、前記命令復号処理の実行により復号された元の命令に置換する命令復元処理を、前記保護対象プログラムに挿入する命令復元処理挿入手段と、
前記命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理を、前記保護対象プログラムに挿入する命令偽装処理挿入手段と、を備えることを特徴とする自己書き換え処理装置。
Storage means for storing the protection target program;
Selecting means for selecting at least one instruction described in the protection target program;
An instruction encryption means for encrypting the instruction selected by the selection means using a key;
A key disguise means for replacing the key used by the instruction encryption means with a dummy key;
A key restoration process insertion means for inserting a key restoration process for replacing the dummy key replaced by the key impersonation means with the original key into the protection target program;
Instruction decryption processing insertion means for inserting into the protection target program instruction decryption processing for decrypting the instruction encrypted by the instruction encryption means using the original key replaced by execution of the key recovery processing;
A key impersonation process insertion means for inserting a key impersonation process in which the original key replaced by the execution of the key restoration process is replaced with a dummy key into the protection target program;
Instruction disguise means for replacing the instruction selected by the selection means with a dummy instruction;
Instruction restoration processing insertion means for inserting, into the protection target program, instruction restoration processing for replacing the dummy instruction replaced by the instruction disguise means with the original instruction decoded by execution of the instruction decoding processing;
A self-rewrite processing device comprising: an instruction disguise process insertion means for inserting an instruction disguise process for replacing an original instruction replaced by execution of the instruction restore process with a dummy instruction into the protection target program; .
前記命令復号処理挿入手段は、前記命令復号処理を、前記保護対象プログラムのうち、前記命令偽装手段により置換されたダミーの命令より前方に挿入し、
前記命令復元処理挿入手段は、前記命令復元処理を、前記保護対象プログラムのうち、前記命令復号処理と、前記命令偽装手段により置換されたダミーの命令と、の間に挿入し、
前記命令偽装処理挿入手段は、前記命令偽装処理を、前記保護対象プログラムのうち、前記命令偽装手段により置換されたダミーの命令の後方に挿入し、
前記鍵復元処理挿入手段は、前記鍵復元処理を、前記保護対象プログラムのうち前記命令復号処理より前方に挿入し、
前記鍵偽装処理挿入手段は、前記鍵偽装処理を、前記保護対象プログラムのうち前記命令復号処理より後方に挿入することを特徴とする請求項1に記載の自己書き換え処理装置。
The instruction decoding process insertion means inserts the instruction decoding process ahead of a dummy instruction replaced by the instruction disguise means in the protection target program,
The instruction restoration process insertion means inserts the instruction restoration process between the instruction decoding process and the dummy instruction replaced by the instruction impersonation means in the protection target program,
The instruction impersonation process insertion means inserts the instruction impersonation process behind the dummy instruction replaced by the instruction impersonation means in the protection target program,
The key recovery process insertion means inserts the key recovery process ahead of the instruction decryption process in the protection target program,
The self-rewriting processing device according to claim 1, wherein the key impersonation processing insertion unit inserts the key impersonation processing behind the instruction decryption processing in the protection target program.
前記選択手段による選択と、前記命令暗号化手段よる暗号化と、前記鍵偽装手段による置換と、前記鍵復元処理挿入手段による挿入と、前記命令復号処理挿入手段による挿入と、前記鍵偽装処理挿入手段による挿入と、前記命令偽装手段による置換と、前記命令復元処理挿入手段による挿入と、前記命令偽装処理挿入手段による挿入と、を予め定められた回数だけ繰り返すことを特徴とする請求項1または2に記載の自己書き換え処理装置。   Selection by the selection means, encryption by the instruction encryption means, replacement by the key impersonation means, insertion by the key restoration processing insertion means, insertion by the instruction decryption processing insertion means, and insertion of the key impersonation processing The insertion by the means, the replacement by the instruction impersonation means, the insertion by the instruction restoration processing insertion means, and the insertion by the instruction impersonation processing insertion means are repeated a predetermined number of times. 2. The self-rewriting processing device according to 2. 選択手段、命令暗号化手段、鍵偽装手段、鍵復元処理挿入手段、命令復号処理挿入手段、鍵偽装処理挿入手段、命令偽装手段、命令復元処理挿入手段、および命令偽装処理挿入手段を備える自己書き換え処理装置における自己書き換え処理方法であって、
前記選択手段が、保護対象プログラムに記述されている命令を少なくとも1つ選択する第1ステップと、
前記命令暗号化手段が、前記第1ステップにおいて選択した命令を、鍵を用いて暗号化する第2ステップと、
前記鍵偽装手段が、前記第2ステップにおいて用いた鍵を、ダミーの鍵に置換する第3ステップと、
前記鍵復元処理挿入手段が、前記第3ステップにおいて置換したダミーの鍵を元の鍵に置換する鍵復元処理を、前記保護対象プログラムに挿入する第4ステップと、
前記命令復号処理挿入手段が、前記第2ステップにおいて暗号化した命令を、前記鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理を、前記保護対象プログラムに挿入する第5ステップと、
前記鍵偽装処理挿入手段が、前記鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理を、前記保護対象プログラムに挿入する第6ステップと、
前記命令偽装手段が、前記第1ステップにおいて選択した命令をダミーの命令に置換する第7ステップと、
前記命令復元処理挿入手段が、前記第7ステップにおいて置換したダミーの命令を、前記命令復号処理の実行により復号された元の命令に置換する命令復元処理を、前記保護対象プログラムに挿入する第8ステップと、
前記命令偽装処理挿入手段が、前記命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理を、前記保護対象プログラムに挿入する第9ステップと、を備えることを特徴とする自己書き換え処理方法。
Self-rewriting comprising selection means, instruction encryption means, key impersonation means, key restoration processing insertion means, instruction decryption processing insertion means, key impersonation processing insertion means, instruction impersonation means, instruction restoration processing insertion means, and instruction impersonation processing insertion means A self-rewriting processing method in a processing device,
A first step in which the selection means selects at least one instruction described in the protection target program;
A second step in which the instruction encryption means encrypts the instruction selected in the first step using a key;
A third step in which the key disguise means replaces the key used in the second step with a dummy key;
A fourth step in which the key restoration processing inserting means inserts a key restoration processing in which the dummy key replaced in the third step is replaced with the original key into the protection target program;
The instruction decryption process inserting means inserts an instruction decryption process for decrypting the instruction encrypted in the second step using the original key replaced by the execution of the key restoration process into the protection target program. 5 steps,
A sixth step in which the key impersonation process insertion means inserts into the protection target program a key impersonation process that replaces the original key replaced by the execution of the key restoration process with a dummy key;
A seventh step in which the instruction disguise means replaces the instruction selected in the first step with a dummy instruction;
The instruction restoring process inserting means inserts into the protected program an instruction restoring process that replaces the dummy instruction replaced in the seventh step with the original instruction decoded by executing the instruction decoding process. Steps,
The instruction spoofing process inserting means includes a ninth step of inserting into the protection target program an instruction spoofing process that replaces the original instruction replaced by the execution of the instruction restoration process with a dummy instruction. Self-rewriting processing method.
保護対象プログラムに記述されている命令を少なくとも1つ選択する第1ステップと、
前記第1ステップにおいて選択した命令を、鍵を用いて暗号化する第2ステップと、
前記第2ステップにおいて用いた鍵を、ダミーの鍵に置換する第3ステップと、
前記第3ステップにおいて置換したダミーの鍵を元の鍵に置換する鍵復元処理を、前記保護対象プログラムに挿入する第4ステップと、
前記第2ステップにおいて暗号化した命令を、前記鍵復元処理の実行により置換された元の鍵を用いて復号する命令復号処理を、前記保護対象プログラムに挿入する第5ステップと、
前記鍵復元処理の実行により置換された元の鍵をダミーの鍵に置換する鍵偽装処理を、前記保護対象プログラムに挿入する第6ステップと、
前記第1ステップにおいて選択した命令をダミーの命令に置換する第7ステップと、
前記第7ステップにおいて置換したダミーの命令を、前記命令復号処理の実行により復号された元の命令に置換する命令復元処理を、前記保護対象プログラムに挿入する第8ステップと、
前記命令復元処理の実行により置換された元の命令をダミーの命令に置換する命令偽装処理を、前記保護対象プログラムに挿入する第9ステップと、をコンピュータに実行させるためのプログラム。
A first step of selecting at least one instruction described in the protection target program;
A second step of encrypting the instruction selected in the first step using a key;
A third step of replacing the key used in the second step with a dummy key;
A fourth step of inserting, into the protection target program, a key restoration process for replacing the dummy key replaced in the third step with the original key;
A fifth step of inserting, into the protection target program, an instruction decryption process for decrypting the instruction encrypted in the second step using the original key replaced by the execution of the key recovery process;
A sixth step of inserting, into the protection target program, a key impersonation process for replacing the original key replaced by the execution of the key restoration process with a dummy key;
A seventh step of replacing the instruction selected in the first step with a dummy instruction;
An eighth step of inserting into the protection target program an instruction restoration process that replaces the dummy instruction replaced in the seventh step with the original instruction decoded by executing the instruction decoding process;
A program for causing a computer to execute a ninth step of inserting, into the protection target program, an instruction disguise process for replacing an original instruction replaced by execution of the instruction restoration process with a dummy instruction.
JP2010092497A 2010-04-13 2010-04-13 Self-rewriting processing device, self-rewriting processing method, and program Expired - Fee Related JP5477994B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010092497A JP5477994B2 (en) 2010-04-13 2010-04-13 Self-rewriting processing device, self-rewriting processing method, and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010092497A JP5477994B2 (en) 2010-04-13 2010-04-13 Self-rewriting processing device, self-rewriting processing method, and program

Publications (2)

Publication Number Publication Date
JP2011221922A JP2011221922A (en) 2011-11-04
JP5477994B2 true JP5477994B2 (en) 2014-04-23

Family

ID=45038811

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010092497A Expired - Fee Related JP5477994B2 (en) 2010-04-13 2010-04-13 Self-rewriting processing device, self-rewriting processing method, and program

Country Status (1)

Country Link
JP (1) JP5477994B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6203028B2 (en) * 2013-12-13 2017-09-27 Kddi株式会社 Pseudorandom number generation apparatus and method, and program obfuscation apparatus and method

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002132364A (en) * 2000-10-19 2002-05-10 Yutaka Iizuka Method for protecting program from internal analysis, computer readable recording medium and program distribution method
JP2003280755A (en) * 2002-03-25 2003-10-02 Nec Corp Self-restorable program, program forming method and device, information processor and program
JP3944069B2 (en) * 2002-12-06 2007-07-11 国立大学法人 奈良先端科学技術大学院大学 Self-rewriting process addition program, self-rewriting process addition device, and self-rewriting process addition method
JP2004265194A (en) * 2003-03-03 2004-09-24 Matsushita Electric Ind Co Ltd Information processing apparatus and information processing method
JP2007164595A (en) * 2005-12-15 2007-06-28 Toshiba Corp Function calling method of computer system, computer system and library

Also Published As

Publication number Publication date
JP2011221922A (en) 2011-11-04

Similar Documents

Publication Publication Date Title
EP2398182B1 (en) A device and a method for generating software code
Kong et al. Deconstructing new cache designs for thwarting software cache-based side channel attacks
US20180349573A1 (en) Securing microprocessors against information leakage and physical tampering
EP2893431B1 (en) Protection against side channel attacks
JP5167348B2 (en) Software encryption method, software decryption method, software encryption device, and software decryption device
Gamido et al. Modified AES for text and image encryption
CN105453481B (en) Computing equipment including table networks
Bos et al. Assessing the feasibility of single trace power analysis of frodo
KR101324351B1 (en) Method for generating a cipher-based message authentication code
CN104272319B (en) method for protecting data
Chen et al. Balanced encoding to mitigate power analysis: a case study
JP6698774B2 (en) Security providing apparatus and method for common intermediate language, and security executing apparatus and method
CN105468940B (en) Method for protecting software and device
EP3097655A1 (en) Method of protecting secret data when used in a cryptographic algorithm
Zheng et al. How to compare selections of points of interest for side-channel distinguishers in practice?
Aulbach et al. SoK: On the physical security of UOV-based signature schemes
JPWO2015166701A1 (en) ENCRYPTION METHOD, PROGRAM, AND SYSTEM
JP5477994B2 (en) Self-rewriting processing device, self-rewriting processing method, and program
Moradi et al. On the Portability of Side-Channel Attacks-An Analysis of the Xilinx Virtex 4, Virtex 5, and Spartan 6 Bitstream Encryption Mechanism
EP2674892B1 (en) A method, a device and a computer program support for execution of encrypted computer code
JP2007013506A (en) Encryption processor, encryption method, decryption processor, decryption method and data structure
US20150269367A1 (en) Code diversity method and system
CN106599620A (en) Binary software protection method based on dynamic code conversion
Liu et al. Detecting side channel vulnerabilities in improved rotating S-box masking scheme—Presenting four non-profiled attacks
JP5416623B2 (en) Self-rewriting processing device, self-rewriting processing method, and program

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20130311

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20131129

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20131217

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20140107

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: 20140128

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20140208

R150 Certificate of patent or registration of utility model

Ref document number: 5477994

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees