JP7247638B2 - Electronic information storage medium, IC card, falsification check method, and program - Google Patents

Electronic information storage medium, IC card, falsification check method, and program Download PDF

Info

Publication number
JP7247638B2
JP7247638B2 JP2019026328A JP2019026328A JP7247638B2 JP 7247638 B2 JP7247638 B2 JP 7247638B2 JP 2019026328 A JP2019026328 A JP 2019026328A JP 2019026328 A JP2019026328 A JP 2019026328A JP 7247638 B2 JP7247638 B2 JP 7247638B2
Authority
JP
Japan
Prior art keywords
data
api
processing
tampering check
electronic information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2019026328A
Other languages
Japanese (ja)
Other versions
JP2020135265A (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.)
Dai Nippon Printing Co Ltd
Original Assignee
Dai Nippon Printing Co Ltd
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 Dai Nippon Printing Co Ltd filed Critical Dai Nippon Printing Co Ltd
Priority to JP2019026328A priority Critical patent/JP7247638B2/en
Publication of JP2020135265A publication Critical patent/JP2020135265A/en
Application granted granted Critical
Publication of JP7247638B2 publication Critical patent/JP7247638B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、外部からの攻撃等による改竄を検知可能なICカード等のセキュアエレメントの技術分野に関する。 The present invention relates to a technical field of a secure element such as an IC card capable of detecting falsification due to an external attack or the like.

セキュリティ性が重要視されるセキュアエレメントでは、外部からの攻撃などによる不正動作に対する防止手段を備えている必要がある。外部からの攻撃とは、セキュアエレメントに誤動作を起こさせるための方法であり、代表的な攻撃方法としてDFA(Differential Fault Analysis)が知られている。この攻撃方法では、例えば、セキュアエレメントに対してレーザ照射を行って出力された誤演算結果を、正しい演算結果と比較して解析することにより、攻撃者はセキュアエレメント内部の情報を得ることが可能になっている。特許文献1には、レーザ照射により誤動作が発生する前にレーザ照射を検知して、攻撃を回避することが可能な誤動作発生攻撃検出回路が開示されている。 A secure element, in which security is emphasized, must be equipped with measures to prevent unauthorized operations caused by attacks from the outside. An external attack is a method for causing a malfunction in a secure element, and DFA (Differential Fault Analysis) is known as a typical attack method. In this attack method, for example, by irradiating the secure element with a laser and analyzing the erroneous calculation result output by comparing it with the correct calculation result, the attacker can obtain the information inside the secure element. It has become. Patent Literature 1 discloses a malfunction occurrence attack detection circuit capable of detecting laser irradiation before a malfunction occurs due to laser irradiation and avoiding an attack.

特開2010-279003号公報Japanese Patent Application Laid-Open No. 2010-279003

ところで、セキュアエレメントに搭載されるアプリケーションは、一般に、命令コードにしたがって関数を呼び出し、呼び出された関数による処理の結果を利用するように構築される。しかし、当該関数による処理の結果が外部からの攻撃により改竄されることが懸念される。そのため、このような改竄を、複雑な回路を必要とせずに、より効率良くチェックする仕組みが望まれる。 By the way, an application installed in a secure element is generally constructed so as to call a function according to an instruction code and use the result of processing by the called function. However, there is concern that the result of processing by the function may be tampered with by an external attack. Therefore, a mechanism for checking such falsification more efficiently without requiring a complicated circuit is desired.

そこで、本発明は、外部からの攻撃による改竄を、複雑な回路を必要とせずに、より効率良くチェックすることが可能な電子情報記憶媒体、ICカード、改竄チェック方法、及びプログラムを提供することを課題とする。 Therefore, the present invention provides an electronic information storage medium, an IC card, a tampering check method, and a program that can more efficiently check tampering due to external attacks without requiring a complicated circuit. is the subject.

上記課題を解決するために、請求項1に記載の発明は、所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体であって、前記処理結果を、改竄チェック対象となる第1データとして記憶する第1記憶部と、前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを記憶する第2記憶部と、前記第1データ及び前記第2データを用いて改竄チェックを実行する改竄チェック部と、を備えることを特徴とする。 In order to solve the above problems, the invention according to claim 1 is an electronic information storage medium that calls a function according to a predetermined instruction code, executes processing by the called function, and stores the processing result. , a first storage unit for storing the processing result as first data to be checked for falsification, and a second storage unit for storing second data obtained at any timing from the start to the end of the processing. and a tampering check unit that performs tampering check using the first data and the second data.

請求項2に記載の発明は、請求項1に記載の電子情報記憶媒体において、前記関数は、前記電子情報記憶媒体に搭載されたアプリケーションが有する前記命令コードにしたがって当該アプリケーションから呼び出される第1API(Application Programming Interface)に含まれることを特徴とする。 The invention according to claim 2 is the electronic information storage medium according to claim 1, wherein the function is a first API ( Application Programming Interface).

請求項3に記載の発明は、請求項2に記載の電子情報記憶媒体において、前記第1データは、前記第1APIから前記アプリケーションに応答された戻り値であり、前記アプリケーションにより利用される前記第1記憶部に記憶され、前記第2データは、前記電子情報記憶媒体に搭載されたオペレーティングシステムにより利用される前記第2記憶部に記憶されることを特徴とする。 The invention according to claim 3 is the electronic information storage medium according to claim 2, wherein the first data is a return value sent from the first API to the application, and the first data is used by the application. 1 storage unit, and the second data is stored in the second storage unit used by an operating system installed in the electronic information storage medium.

請求項4に記載の発明は、請求項3に記載の電子情報記憶媒体において、前記アプリケーションから呼び出される第2APIであって前記第1APIとは異なる当該第2APIによる処理において、前記改竄チェック部は、前記第1データ及び前記第2データを用いて改竄チェックを実行することを特徴とする。 A fourth aspect of the present invention is the electronic information storage medium of the third aspect. A falsification check is performed using the first data and the second data.

請求項5に記載の発明は、請求項3に記載の電子情報記憶媒体において、前記アプリケーションから呼び出される第2APIであって前記第1APIとは異なる当該第2APIによる処理において、前記第2記憶部から前記第2データが取得され、当該第2データが戻り値として前記アプリケーションに応答され、前記アプリケーションによる処理において、前記改竄チェック部は、前記第1データ及び前記第2データを用いて改竄チェックを実行することを特徴とする。 The invention according to claim 5 is the electronic information storage medium according to claim 3, wherein in the processing by the second API that is called from the application and is different from the first API, from the second storage unit The second data is obtained, the second data is returned as a return value to the application, and in the processing by the application, the tampering check unit performs an tampering check using the first data and the second data. characterized by

請求項6に記載の発明は、請求項1乃至5の何れか一項に記載の電子情報記憶媒体において、前記第2記憶部は、前記処理の終了に至った時点で得られた第2データを記憶し、前記改竄チェック部は、前記第1データと前記第2データとが一致しているか否かを判定することで改竄チェックを実行することを特徴とする。 The invention according to claim 6 is the electronic information storage medium according to any one of claims 1 to 5, wherein the second storage unit stores second data obtained when the processing is completed. and the tampering check unit performs the tampering check by determining whether or not the first data and the second data match.

請求項7に記載の発明は、請求項1乃至5の何れか一項に記載の電子情報記憶媒体において、前記第2記憶部は、前記処理の終了に至る前の時点で得られた第2データを記憶し、前記改竄チェック部は、前記処理の終了に至る前の時点で得られた第2データに基づいて、前記処理の終了に至る前の時点から前記処理の終了に至った時点までに行われるべき処理により第3データを算出し、前記第1データと前記第3データとが一致しているか否かを判定することで改竄チェックを実行することを特徴とする。 The invention according to claim 7 is the electronic information storage medium according to any one of claims 1 to 5, wherein the second storage unit stores the second data obtained before the end of the process. data is stored, and the tampering check unit stores data from the time before the end of the process to the time until the end of the process, based on the second data obtained at the time before the end of the process. The tampering check is performed by calculating the third data by the processing to be performed in the first step, and determining whether or not the first data and the third data match.

請求項8に記載の発明は、請求項1乃至7の何れか一項に記載の電子情報記憶媒体において、前記改竄チェック部は、前記第1データ、及び前記第2記憶部に直近に記憶された前記第2データを用いて改竄チェックを実行することを特徴とする。 The invention according to claim 8 is the electronic information storage medium according to any one of claims 1 to 7, wherein the tampering check unit is stored immediately in the first data and the second storage unit. A tampering check is performed using the second data that has been obtained.

請求項9に記載の発明は、請求項1乃至7の何れか一項に記載の電子情報記憶媒体において、前記第2記憶部は、複数の前記関数のそれぞれによる処理に応じた前記第2データを前記関数毎に区別して記憶し、前記改竄チェック部は、前記第1データ、及び前記第2記憶部により記憶された複数の前記第2データのうちから指定された関数による処理に応じた前記第2データを用いて改竄チェックを実行することを特徴とする。 The invention according to claim 9 is the electronic information storage medium according to any one of claims 1 to 7, wherein the second storage unit stores the second data according to the processing by each of the plurality of functions. are stored separately for each function, and the tampering check unit stores the first data and the second data stored in the second storage unit according to processing by a function designated from among the plurality of second data. A falsification check is performed using the second data.

請求項10に記載の発明は、所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体であって、チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行し、前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行する改竄チェック部と、を備えることを特徴とする。 According to a tenth aspect of the invention, there is provided an electronic information storage medium that calls a first API according to a predetermined instruction code and executes processing by the called first API, wherein the plurality of second APIs for checking include: Calling a second API according to the first processing result by the first API, executing processing by the called second API, and checking for tampering using the first processing result by the first API and the second processing result by the second API and a tampering check unit that executes

請求項11に記載の発明は、所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶するICカードであって、前記処理結果を、改竄チェック対象となる第1データとして記憶する第1記憶部と、前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを記憶する第2記憶部と、前記第1データ及び前記第2データを用いて改竄チェックを実行する改竄チェック部と、を備えることを特徴とする。 According to an eleventh aspect of the invention, there is provided an IC card that calls a function in accordance with a predetermined instruction code, executes processing by the called function, and stores the processing result, wherein the processing result is subject to falsification check. a first storage unit for storing as first data, a second storage unit for storing second data obtained at any timing from the start to the end of the processing, the first data and the second and a falsification check unit that performs falsification check using the two data.

請求項12に記載の発明は、所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行するICカードであって、チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行し、前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行する改竄チェック部と、を備えることを特徴とする。 According to a twelfth aspect of the invention, there is provided an IC card that calls a first API according to a predetermined instruction code and executes processing by the called first API, wherein the first API out of a plurality of second APIs for checking call a second API according to the result of the first processing by the second API, execute processing by the called second API, and perform a tampering check using the first processing result by the first API and the second processing result by the second API. and a tampering check unit that

請求項13に記載の発明は、所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、前記処理結果を、改竄チェック対象となる第1データとして第1記憶部に記憶するステップと、前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを第2記憶部に記憶するステップと、前記第1データ及び前記第2データを用いて改竄チェックを実行するステップと、を含むことを特徴とする。 According to a thirteenth aspect of the invention, there is provided a falsification check method executed by a computer contained in an electronic information storage medium that calls a function according to a predetermined instruction code, executes processing by the called function, and stores the processing result. a step of storing the processing result in a first storage unit as first data to be checked for falsification; The method is characterized by comprising the step of storing in a second storage unit, and the step of performing a falsification check using the first data and the second data.

請求項14に記載の発明は、所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行するステップと、前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行するステップと、を備えることを特徴とする。 According to a fourteenth aspect of the invention, there is provided a tampering check method executed by a computer included in an electronic information storage medium that calls a first API according to a predetermined instruction code and executes processing by the called first API, the method comprising: a step of calling a second API corresponding to a first processing result by the first API among a plurality of second APIs to be used, and executing processing by the called second API; a first processing result by the first API; and a step of performing a tampering check using the second processing result by the second API.

請求項15に記載の発明は、所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体に含まれるコンピュータに、前記処理結果を、改竄チェック対象となる第1データとして第1記憶部に記憶するステップと、前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを第2記憶部に記憶するステップと、前記第1データ及び前記第2データを用いて改竄チェックを実行するステップと、を実行させることを特徴とする。 In the fifteenth aspect of the invention, a function is called according to a predetermined instruction code, a process by the called function is executed, and a computer included in an electronic information storage medium storing the process result stores the process result, a step of storing in a first storage unit as first data to be checked for falsification; and a step of storing in a second storage unit second data obtained at any timing from the start to the end of the processing. , and performing a falsification check using the first data and the second data.

請求項16に記載の発明は、所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体に含まれるコンピュータに、チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行するステップと、前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行するステップと、を実行させることを特徴とする。 According to a sixteenth aspect of the invention, a computer included in an electronic information storage medium that calls a first API according to a predetermined instruction code and executes processing by the called first API, among the plurality of second APIs for checking, , a step of calling a second API according to a first processing result by the first API and executing processing by the called second API; and a first processing result by the first API and a second processing result by the second API. and performing a tampering check using the

本発明によれば、外部からの攻撃による改竄を、複雑な回路を必要とせずに、より効率良くチェックすることができる。 ADVANTAGE OF THE INVENTION According to this invention, the falsification by the attack from the outside can be checked more efficiently, without requiring a complicated circuit.

SEのハードウェア構成例を示す図である。It is a figure which shows the hardware structural example of SE. SEの論理構成例を示す図である。It is a figure which shows the logical structural example of SE. SE内のメモリマップの一例を示す図である。It is a figure which shows an example of the memory map in SE. API(1)による処理結果として得られた第1データがアプリケーションメモリ領域M1に記憶され、API(1)による処理の終了に至った時点で得られた第2データがOSメモリ領域M2に記憶される様子を示す概念図である。First data obtained as a result of processing by API(1) is stored in application memory area M1, and second data obtained when processing by API(1) is completed is stored in OS memory area M2. It is a conceptual diagram showing a state of API(1)による処理結果として得られた第1データがアプリケーションメモリ領域M1に記憶され、API(1)による処理の終了に至る前の時点で得られた第2データがOSメモリ領域M2に記憶される様子を示す概念図である。First data obtained as a result of processing by API(1) is stored in application memory area M1, and second data obtained before the end of processing by API(1) is stored in OS memory area M2. FIG. 10 is a conceptual diagram showing how it is done. 複数の関数のそれぞれによる処理に応じた第2データを含むリストを示す図である。FIG. 10 is a diagram showing a list containing second data according to processing by each of a plurality of functions; 実施例1におけるアプリケーションによる処理の一例を示すフローチャートである。7 is a flowchart illustrating an example of processing by an application in Embodiment 1; 実施例1におけるOSによる処理の一例を示すフローチャートである。4 is a flowchart illustrating an example of processing by an OS in Embodiment 1; 実施例2におけるアプリケーションによる処理の一例を示すフローチャートである。FIG. 11 is a flow chart showing an example of processing by an application according to the second embodiment; FIG. 実施例2におけるOSによる処理の一例を示すフローチャートである。10 is a flowchart illustrating an example of processing by an OS in Example 2; 変形例における処理内容を疑似コードで表した図である。It is the figure which represented the processing content in a modification with the pseudo code.

以下、図面を参照して本発明の実施形態について詳細に説明する。以下に説明する実施形態は、セキュアエレメント(以下、「SE」という)に対して本発明を適用した場合の実施の形態である。 BEST MODE FOR CARRYING OUT THE INVENTION Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. The embodiment described below is an embodiment in which the present invention is applied to a secure element (hereinafter referred to as "SE").

[1.SEの構成及び機能]
先ず、図1及び図2を参照して、本実施形態に係るSE(本発明の電子情報記憶媒体の一例)の構成及び機能について説明する。図1は、SEのハードウェア構成例を示す図であり、図2は、SEの論理構成例を示す図である。図1に示すように、SEは、CPU(Central Processing Unit)10、RAM(Random Access Memory)11、ROM(Read Only Memory)12、NVM(Nonvolatile Memory)13(不揮発性メモリ)、及びI/O回路14などを備える。ただし、ROM12は備えられない場合もある。ROM12またはNVM13には、各種プログラム及びデータが記憶される。これにより、SEには、図2に示すように、アプリケーション、API(1)~(3)、及びオペレーティングシステム(以下、「OS」という)が搭載される。図2の例では、1つのアプリケーションが搭載された例を示しているが、複数のアプリケーションが搭載される場合もある。
[1. Configuration and functions of SE]
First, with reference to FIGS. 1 and 2, the configuration and functions of an SE (an example of an electronic information storage medium of the present invention) according to this embodiment will be described. FIG. 1 is a diagram showing a hardware configuration example of the SE, and FIG. 2 is a diagram showing a logical configuration example of the SE. As shown in FIG. 1, SE includes CPU (Central Processing Unit) 10, RAM (Random Access Memory) 11, ROM (Read Only Memory) 12, NVM (Nonvolatile Memory) 13 (nonvolatile memory), and I/O Circuit 14 and the like are provided. However, the ROM 12 may not be provided in some cases. Various programs and data are stored in the ROM 12 or NVM 13 . Accordingly, as shown in FIG. 2, the SE is loaded with applications, APIs (1) to (3), and an operating system (hereinafter referred to as "OS"). Although the example in FIG. 2 shows an example in which one application is installed, a plurality of applications may be installed.

なお、SEは、ICチップとしてICカードに搭載されてもよいし、eUICC(Embedded Universal Integrated Circuit Card)として端末から容易に取り外しや取り換えができないように組み込み基盤上に実装(つまり、端末と一体的に形成)されてもよい。I/O回路14は、SEの通信相手となる外部装置とのインターフェースを担う。インターフェースの例として、ISO7816のインターフェース、SWP(Single Wire Protocol)のインターフェース、及びSPI(Serial Peripheral Interface)などが挙げられる。外部装置の例として、サーバ、及び端末などが挙げられる。I/O回路14には、例えば、アンテナ、及び変復調回路が備えられてもよい。 The SE may be mounted on an IC card as an IC chip, or may be mounted on an embedded board as an eUICC (Embedded Universal Integrated Circuit Card) so that it cannot be easily removed or replaced from the terminal (i.e. integrated with the terminal). may be formed). The I/O circuit 14 serves as an interface with an external device with which the SE communicates. Examples of interfaces include an ISO7816 interface, an SWP (Single Wire Protocol) interface, and an SPI (Serial Peripheral Interface). Examples of external devices include servers and terminals. The I/O circuitry 14 may include, for example, an antenna and modulation/demodulation circuitry.

アプリケーションは、オブジェクトの振る舞いを定義するクラスから実体として作成され、OS上で実行されるインスタンスであり、複数のバイトコード(命令コードの一例)を含んで構成される。バイトコードは、ソースコードとネイティブコードとの間の中間コードである。アプリケーションの実行では、アプリケーションが有するバイトコードがOSの一機能として搭載される仮想マシン(例えば、Java(登録商標)Virtual Machine)により解釈(つまり、どのような命令であるかが特定)され、解釈されたバイトコードにしたがって処理(アプリケーションによる処理)が行われる。バイトコードにより特定される命令の例として、書き込み命令、読み出し命令、論理演算命令、条件分岐命令、関数呼び出し命令などが挙げられる。関数呼び出し命令を示すバイトコードの例としてINVOKEVIRTUALがあり、これは、API(API(1)~(3)の何れか)を呼び出すことができる。 An application is an instance that is created as an entity from a class that defines the behavior of an object, that is executed on an OS, and that includes a plurality of bytecodes (an example of instruction codes). Bytecode is intermediate code between source code and native code. When executing an application, the bytecode of the application is interpreted by a virtual machine (for example, Java (registered trademark) Virtual Machine) installed as a function of the OS (that is, what kind of instruction it is specified). Processing (processing by the application) is performed according to the received bytecode. Examples of instructions specified by bytecodes include write instructions, read instructions, logic operation instructions, conditional branch instructions, and function call instructions. An example of a bytecode indicating a function call instruction is INVOKEVIRTUAL, which can call an API (any of APIs (1)-(3)).

API(1)~(3)は、それぞれ、1以上の関数(メソッドともいう)により構成される。API(1)~(3)により提供される機能(アプリケーションを補助する機能)は互いに異なる。例えば、API(1)は、第1APIの一例であり、当該API(1)による処理結果にはセキュリティ性の担保が求められる。API(1)による処理例として、署名検証処理が挙げられる。この場合のAPI(1)を構成する関数として、例えば、boolean verifyCert()が用いられる。boolean verifyCertの引数(入力)は、input(入力データ)、inputLen(入力データ長)、certificate(署名データ)、certLen(署名データ長)、及びalgo(署名(暗号演算)アルゴリズム)となる。boolean verifyCert()による署名検証結果(つまり、出力としての処理結果)は、true(真)またはfalse(偽)となる。なお、API(1)による処理結果は、boolean型の値に限定されるものではなく、例えば比較結果(例えば、一致、または不一致を示す値)や、暗号演算結果(例えば、'11 22 33…FF'(h)のようなデータ)など、処理結果に関するデータであれば、どのようなものでも適用可能である。一方、API(2)は、第2APIの一例であり、API(1)による処理結果の改竄チェックに用いられる(つまり、第2APIはチェック用となる)。なお、API(3)による処理結果にはセキュリティ性の担保が求められないため、当該処理結果の改竄チェックは行われない。 APIs (1) to (3) each consist of one or more functions (also called methods). The functions provided by APIs (1)-(3) (functions that assist applications) are different from each other. For example, API (1) is an example of the first API, and the processing result of API (1) is required to ensure security. An example of processing by API (1) is signature verification processing. For example, boolean verifyCert( ) is used as a function that configures API(1) in this case. Arguments (inputs) of boolean verifyCert are input (input data), inputLen (input data length), certificate (signature data), certLen (signature data length), and algo (signature (encryption calculation) algorithm). The result of signature verification by boolean verifyCert( ) (that is, the processing result as output) is true or false. Note that the processing result by API (1) is not limited to a boolean type value. Data such as FF'(h)) can be applied as long as it is data related to processing results. On the other hand, API(2) is an example of a second API, and is used for checking falsification of the processing result by API(1) (that is, the second API is for checking). Note that security is not required for processing results by API (3), so no tampering check is performed on the processing results.

OSは、アプリケーションにより呼び出されたAPIによる処理(つまり、当該APIを構成する関数による処理)を実行し、その処理結果を戻り値としてアプリケーションに応答する。こうして応答された戻り値(処理結果)は、アプリケーションにより利用されるアプリケーションメモリ領域に記憶され、アプリケーションによる処理において用いられる。特に、API(1)による処理結果は、改竄チェック対象となる第1データとしてアプリケーションメモリ領域に記憶される。 The OS executes processing by the API called by the application (that is, processing by functions constituting the API), and responds to the application with the processing result as a return value. The returned value (processing result) thus responded is stored in the application memory area used by the application and used in the processing by the application. In particular, the result of processing by API (1) is stored in the application memory area as the first data to be checked for falsification.

図3は、SE内のメモリマップの一例を示す図である。図3に示すように、SE内には、アプリケーションにより利用されるアプリケーションメモリ領域M1(第1記憶部の一例)と、OSにより利用されるOSメモリ領域M2(第2記憶部の一例)とが、例えばRAM11またはNVM13に確保される。アプリケーションメモリ領域M1は、後入れ先出しの構造を有するスタック領域を含んで構成される。スタック領域には、ローカル変数、引数、戻り値などがフレーム単位で書き込まれ、その後、フレーム単位で取得される。OSメモリ領域M2には、API(1)による処理の開始から終了に至るまでの何れかのタイミングで得られた第2データが記憶される。例えば、API(1)による処理の終了に至った時点で得られた第2データがOSメモリ領域M2に記憶される。或いは、API(1)による処理の終了に至る前の時点で得られた第2データがOSメモリ領域M2に記憶される。そして、アプリケーションメモリ領域M1に記憶された第1データ、及びOSメモリ領域M2に記憶された第2データが用いられて改竄チェックが実行される。 FIG. 3 is a diagram showing an example of a memory map within the SE. As shown in FIG. 3, the SE includes an application memory area M1 (an example of a first storage section) used by applications and an OS memory area M2 (an example of a second storage section) used by the OS. , is secured in the RAM 11 or the NVM 13, for example. The application memory area M1 includes a stack area having a last-in first-out structure. Local variables, arguments, return values, etc. are written to the stack area in units of frames, and then retrieved in units of frames. The OS memory area M2 stores second data obtained at any timing from the start to the end of processing by API(1). For example, the second data obtained when the processing by API(1) ends is stored in the OS memory area M2. Alternatively, the second data obtained before the end of processing by API(1) is stored in the OS memory area M2. Then, the tampering check is performed using the first data stored in the application memory area M1 and the second data stored in the OS memory area M2.

図4は、API(1)による処理結果として得られた第1データがアプリケーションメモリ領域M1に記憶され、API(1)による処理の終了に至った時点で得られた第2データがOSメモリ領域M2に記憶される様子を示す概念図である。図4の例では、第1データと第2データは、互いに同じタイミングで得られたデータであるので、外部からの攻撃により何れか一方のデータが改竄されなければ互いに同じ値になる。そのため、この場合、アプリケーションメモリ領域M1に記憶された第1データと、OSメモリ領域M2に記憶された第2データとが一致しているか否かを判定することで改竄チェックが実行され、第1データと第2データとが一致していなければデータが改竄されたものと判定される。なお、外部からの攻撃により、第1データと第2データとが同じ値に改竄される可能性は極めて低い。図4に示す構成によれば、改竄チェックに要する処理時間を、より短縮することができる。 In FIG. 4, the first data obtained as a result of processing by API(1) is stored in the application memory area M1, and the second data obtained when the processing by API(1) is completed is stored in the OS memory area. FIG. 4 is a conceptual diagram showing how data is stored in M2; In the example of FIG. 4, since the first data and the second data are data obtained at the same timing, they have the same value unless one of the data is tampered with by an external attack. Therefore, in this case, the tampering check is executed by determining whether or not the first data stored in the application memory area M1 and the second data stored in the OS memory area M2 match. If the data and the second data do not match, it is determined that the data has been tampered with. The possibility that the first data and the second data are tampered with the same value by an attack from the outside is extremely low. According to the configuration shown in FIG. 4, the processing time required for the falsification check can be further shortened.

一方、図5は、API(1)による処理結果として得られた第1データがアプリケーションメモリ領域M1に記憶され、API(1)による処理の終了に至る前の時点で得られた第2データがOSメモリ領域M2に記憶される様子を示す概念図である。図5の例では、第2データはAPI(1)による処理途中段階のデータ(この例では、関数2の戻り値)であるので、外部からの攻撃により何れか一方のデータが改竄されなくても互いに同じ値にならない。そのため、この場合、OSメモリ領域M2に記憶された第2データ(つまり、API(1)による処理の終了に至る前の時点で得られた第2データ)に基づいて、API(1)による処理の終了に至る前の時点から当該処理の終了に至った時点までに行われるべき処理(図5の例では、処理α)により第3データが算出される。そして、アプリケーションメモリ領域M1に記憶された第1データと、当該算出された第3データとが一致しているか否かを判定することで改竄チェックが実行され、第1データと第3データとが一致していなければデータが改竄されたものと判定される。図5に示す構成によれば、第1データと第2データとは異なるタイミングで記憶され、かつ異なる値であるので、外部からの攻撃により、第1データと第2データとが同じ値に改竄される可能性をより一層低減することができる。 On the other hand, in FIG. 5, the first data obtained as a result of processing by API(1) is stored in the application memory area M1, and the second data obtained before the end of processing by API(1) is stored in the application memory area M1. FIG. 3 is a conceptual diagram showing how data is stored in an OS memory area M2; In the example of FIG. 5, the second data is data in the middle of processing by API (1) (in this example, the return value of function 2), so any one of the data must not be tampered with by an external attack. are not the same value. Therefore, in this case, based on the second data stored in the OS memory area M2 (that is, the second data obtained before the end of the processing by API (1)), the processing by API (1) The third data is calculated by the process (process α in the example of FIG. 5) to be performed from the point before the end of the process until the end of the process. Then, the tampering check is executed by determining whether the first data stored in the application memory area M1 and the calculated third data match, and the first data and the third data are checked. If they do not match, it is determined that the data has been tampered with. According to the configuration shown in FIG. 5, since the first data and the second data are stored at different timings and have different values, the first data and the second data can be tampered with to the same value by an external attack. It is possible to further reduce the possibility of being

ところで、図4及び図5に示すように、第2データが記憶されるOSメモリ領域M2には、最新の第2データ(1回分の第2データ)が記憶されるとよい。つまり、OSメモリ領域M2に既に記憶されている第2データが、API(1)による後の処理で得られた第2データにより上書きされることで、第2データが最新に保たれる。これにより、第2データを記憶するために確保されるOSメモリ領域M2のサイズ(メモリ容量)を低減することができる。OSメモリ領域M2のサイズは、API(1)による処理で得られる第2データのサイズに応じて決定されるとよい。この場合、例えば、暗号演算結果が第2データとして記憶される場合のOSメモリ領域M2のサイズは、boolean型の値が第2データとして記憶される場合のOSメモリ領域M2のサイズよりも大きくなる。 By the way, as shown in FIGS. 4 and 5, it is preferable that the latest second data (one second data) is stored in the OS memory area M2 in which the second data is stored. That is, the second data is kept up-to-date by overwriting the second data already stored in the OS memory area M2 with the second data obtained by subsequent processing by API (1). As a result, the size (memory capacity) of the OS memory area M2 reserved for storing the second data can be reduced. The size of the OS memory area M2 may be determined according to the size of the second data obtained by processing by API (1). In this case, for example, the size of the OS memory area M2 when the cryptographic operation result is stored as the second data is larger than the size of the OS memory area M2 when the boolean type value is stored as the second data. .

なお、改竄チェックに用いられる第2データは、例えば、API(2)による処理においてOSメモリ領域M2から取得される。この場合のAPI(2)を構成する関数として、例えば、boolean checkResult()が用いられる。boolean checkResult()は、OSメモリ領域M2から直近に記憶された(つまり、直前の関数による処理で記憶された)最新の第2データを取得し、これを戻り値としてアプリケーションに応答することができる。この場合、boolean checkResult()の引数は必要なく(第2データが記憶されたメモリ領域は固定であるため)、API(2)による処理において取得された第2データが戻り値として第2データがアプリケーションに応答され、その後、アプリケーションによる処理において第1データ及び第2データが用いられて改竄チェックが実行される。つまり、この場合、アプリケーションが改竄チェック部として改竄チェックを行う。別の例として、API(2)による処理において、第1データ及び第2データの取得、及び第1データ及び第2データを用いた改竄チェックが実行され、その改竄チェック結果(例えば、データ改竄無)がアプリケーションに応答されてもよい。この場合、OSが改竄チェック部として改竄チェックを行うことになる。 Note that the second data used for the falsification check is acquired from the OS memory area M2, for example, in processing by API(2). For example, boolean checkResult() is used as a function that configures API(2) in this case. boolean checkResult( ) obtains the latest second data stored most recently from the OS memory area M2 (that is, stored by processing by the immediately preceding function), and can respond to the application as a return value. . In this case, the boolean checkResult() argument is not necessary (because the memory area where the second data is stored is fixed), and the second data obtained in the processing by API (2) is used as the return value. In response to the application, a tamper check is then performed using the first data and the second data in processing by the application. That is, in this case, the application performs the tampering check as the tampering check unit. As another example, in the processing by API (2), acquisition of the first data and the second data, falsification check using the first data and the second data are executed, and the falsification check result (for example, no data falsification ) may be returned to the application. In this case, the OS performs the tampering check as the tampering check unit.

また、API(1)が複数の関数により構成される場合、例えば図5に示す複数の関数のそれぞれによる処理に応じた第2データ(例えば、それぞれの関数毎に最新の第2データ)が関数毎に区別されて記憶されてもよい。図6は、複数の関数のそれぞれによる処理に応じた第2データを含むリストを示す図である。このようなリストがOSメモリ領域M2に記憶されることになる。この場合、改竄チェックに用いる第2データとして、どの関数による処理に応じた第2データを用いるかを指定する必要がある。例えば、上述したboolean checkResult()を用いる場合、引数により関数(または関数による処理に応じた第2データの記憶領域を示すアドレス)を指定することで、boolean checkResult()の戻り値として、指定された関数による処理に応じた第2データがアプリケーションに応答され、その後、アプリケーションによる処理において第1データ及び第2データが用いられて改竄チェックが実行される。これにより、セキュリティ性をより一層向上することができる。この場合も、上述した別の例と同様に、API(2)による処理において、第1データ及び第2データの取得、及び第1データ及び第2データを用いた改竄チェックが実行され、その改竄チェック結果(例えば、データ改竄無)がアプリケーションに応答されてもよい。 Further, when the API (1) is composed of a plurality of functions, for example, second data (for example, the latest second data for each function) corresponding to processing by each of the plurality of functions shown in FIG. may be stored separately for each. FIG. 6 is a diagram showing a list including second data according to processing by each of a plurality of functions. Such a list is stored in the OS memory area M2. In this case, it is necessary to specify the second data corresponding to the processing by which function to use as the second data used for the falsification check. For example, when using the boolean checkResult() described above, by specifying the function (or the address indicating the storage area of the second data according to the processing by the function) as an argument, the return value of the boolean checkResult() is specified. The second data corresponding to the processing by the function is responded to the application, and then the first data and the second data are used in the processing by the application to check for tampering. Thereby, security can be further improved. Also in this case, as in the other example described above, in the processing by the API (2), the acquisition of the first data and the second data and the tampering check using the first data and the second data are executed. A check result (eg, no data tampering) may be returned to the application.

[2.SEの動作]
次に、SEの動作について、実施例1と実施例2とに分けて説明する。
[2. Operation of SE]
Next, the operation of the SE will be described separately for a first embodiment and a second embodiment.

(実施例1)
先ず、図7及び図8に基づいて、SEの動作の実施例1について説明する。実施例1では、アプリケーションが改竄チェックを行う場合の例である。図7は、実施例1におけるアプリケーションによる処理の一例を示すフローチャートであり、図8は、実施例1におけるOSによる処理の一例を示すフローチャートである。
(Example 1)
First, Example 1 of the operation of the SE will be described with reference to FIGS. 7 and 8. FIG. The first embodiment is an example in which an application checks for tampering. FIG. 7 is a flow chart showing an example of processing by an application in the first embodiment, and FIG. 8 is a flow chart showing an example of processing by an OS in the first embodiment.

図7に示す処理は、SEが外部装置から、例えば、署名検証の実行命令を示すコマンドを受信した場合に開始される。図7に示す処理が開始されると、アプリケーションは、上記コマンドに応じて、API(1)を呼び出し(ステップS1)、呼び出されたAPI(1)による処理結果(つまり、第1データ)を戻り値として取得し、当該戻り値をアプリケーションメモリ領域M1に格納する(ステップS2)。次いで、アプリケーションは、API(2)を呼び出し(ステップS3)、呼び出されたAPI(2)による処理結果(つまり、第2データ)を戻り値として取得し、当該戻り値をアプリケーションメモリ領域M1に格納する(ステップS4)。 The processing shown in FIG. 7 is started when the SE receives, for example, a command indicating an instruction to execute signature verification from an external device. When the process shown in FIG. 7 is started, the application calls API (1) in response to the command (step S1), and returns the result of processing by the called API (1) (that is, the first data). value, and stores the return value in the application memory area M1 (step S2). Next, the application calls API (2) (step S3), acquires the processing result (that is, second data) by the called API (2) as a return value, and stores the return value in application memory area M1. (step S4).

次いで、アプリケーションは、ステップS2で格納された第1データと、ステップS4で格納された第2データとを用いて改竄チェックを実行してデータ改竄の有無を判定する(ステップS5)。改竄チェックでは、例えば、第1データと第2データとが一致しているか否かが判定され、第1データと第2データとが一致していない場合にデータ改竄有と判定される。或いは、改竄チェックでは、上述したように、第2データから第3データが算出され、第1データと第3データとが一致しているか否かが判定され、第1データと第3データとが一致していない場合にデータ改竄有と判定される。 Next, the application performs a falsification check using the first data stored in step S2 and the second data stored in step S4 to determine whether or not data has been falsified (step S5). In the falsification check, for example, it is determined whether or not the first data and the second data match, and if the first data and the second data do not match, it is determined that the data has been falsified. Alternatively, in the falsification check, as described above, the third data is calculated from the second data, it is determined whether or not the first data and the third data match, and the first data and the third data are determined. If they do not match, it is determined that the data has been falsified.

そして、データ改竄有と判定された場合(ステップS5:有)、エラー処理が行われる(ステップS6)。エラー処理では、例えば、SEの動作が停止され、外部装置に対してエラー応答が出力される。一方、データ改竄無と判定された場合(ステップS5:無)、アプリケーションによる処理が続行される(ステップS7)。 If it is determined that data has been falsified (step S5: Yes), error processing is performed (step S6). In error processing, for example, the operation of the SE is stopped and an error response is output to the external device. On the other hand, if it is determined that the data has not been falsified (step S5: no), the application continues processing (step S7).

一方、図8に示す処理は、アプリケーションからAPIの呼び出しがあった場合に開始される。図8に示す処理が開始されると、OSは、呼び出しがあったAPIが改竄チェック対象(検証対象)のAPI(1)であるか否かを判定する(ステップS11)。呼び出しがあったAPIがAPI(1)であると判定された場合(ステップS11:YES)、ステップS12へ進む。一方、呼び出しがあったAPIがAPI(1)でないと判定された場合(ステップS11:NO)、ステップS15へ進む。 On the other hand, the processing shown in FIG. 8 is started when an API is called from an application. When the process shown in FIG. 8 is started, the OS determines whether the called API is the API (1) to be checked for tampering (verified) (step S11). If it is determined that the called API is API (1) (step S11: YES), the process proceeds to step S12. On the other hand, if it is determined that the called API is not API (1) (step S11: NO), the process proceeds to step S15.

ステップS12では、OSは、アプリケーションにより呼び出されたAPI(1)による処理を開始する。次いで、OSは、API(1)による処理の終了に至った時点で得られた第2データ、または、API(1)による処理の終了に至る前の時点で得られた第2データを、OSメモリ領域M2に記憶する(ステップS13)。次いで、OSは、API(1)による処理結果(つまり、第1データ)を戻り値としてアプリケーションに応答する(ステップS14)。 In step S12, the OS starts processing by API (1) called by the application. Next, the OS converts the second data obtained when the processing by API(1) ends or the second data obtained before the processing by API(1) ends to the OS Store in the memory area M2 (step S13). Next, the OS responds to the application with the result of processing by API (1) (that is, the first data) as a return value (step S14).

ステップS15では、OSは、呼び出しがあったAPIが改竄チェック用のAPI(2)であるか否かを判定する。呼び出しがあったAPIがAPI(2)であると判定された場合(ステップS15:YES)、ステップS16へ進む。一方、呼び出しがあったAPIがAPI(2)でないと判定された場合(ステップS15:NO)、ステップS19へ進む。 In step S15, the OS determines whether the called API is the tampering check API (2). If it is determined that the called API is API (2) (step S15: YES), the process proceeds to step S16. On the other hand, if it is determined that the called API is not API (2) (step S15: NO), the process proceeds to step S19.

ステップS16では、OSは、アプリケーションにより呼び出されたAPI(2)による処理を開始する。そして、OSは、OSメモリ領域M2から最新の第2データ、または指定された関数による処理に応じた第2データを取得する(ステップS17)。次いで、OSは、API(2)による処理結果(つまり、第2データ)を戻り値としてアプリケーションに応答する(ステップS18)。一方、ステップS19では、OSは、呼び出しがあった通常のAPI(3)による処理を実行し、その処理結果を戻り値としてアプリケーションに応答する(ステップS20)。 In step S16, the OS starts processing by API (2) called by the application. Then, the OS acquires the latest second data or the second data according to the processing by the specified function from the OS memory area M2 (step S17). Next, the OS responds to the application with the result of processing by API (2) (that is, second data) as a return value (step S18). On the other hand, in step S19, the OS executes processing by the called normal API (3), and responds to the application with the processing result as a return value (step S20).

(実施例2)
次に、図9及び図10に基づいて、SEの動作の実施例2について説明する。実施例2では、OSが改竄チェックを行う場合の例である。図9は、実施例2におけるアプリケーションによる処理の一例を示すフローチャートであり、図10は、実施例2におけるOSによる処理の一例を示すフローチャートである。
(Example 2)
Next, Example 2 of the operation of the SE will be described with reference to FIGS. 9 and 10. FIG. The second embodiment is an example in which the OS checks for tampering. FIG. 9 is a flow chart showing an example of processing by an application in the second embodiment, and FIG. 10 is a flow chart showing an example of processing by an OS in the second embodiment.

図9に示す処理は、SEが外部装置から、例えば、署名検証の実行命令を示すコマンドを受信した場合に開始される。図9に示す処理が開始されると、アプリケーションは、上記コマンドに応じて、API(1)を呼び出し(ステップS21)、呼び出されたAPI(1)による処理結果(つまり、第1データ)を戻り値として取得し、当該戻り値をアプリケーションメモリ領域M1に格納する(ステップS22)。次いで、アプリケーションは、API(2)を呼び出し(ステップS23)、呼び出されたAPI(2)による処理結果(データ改竄無)を戻り値として取得し(ステップS24)、処理を続行する(ステップS25)。 The processing shown in FIG. 9 is started when the SE receives, for example, a command indicating an instruction to execute signature verification from an external device. When the process shown in FIG. 9 is started, the application calls API (1) in response to the command (step S21), and returns the result of processing by the called API (1) (that is, the first data). value, and stores the return value in the application memory area M1 (step S22). Next, the application calls API (2) (step S23), acquires the processing result (no data falsification) by the called API (2) as a return value (step S24), and continues processing (step S25). .

一方、図10に示す処理は、アプリケーションからAPIの呼び出しがあった場合に開始される。図10に示す処理が開始されると、OSは、呼び出しがあったAPIが改竄チェック対象のAPI(1)であるか否かを判定する(ステップS31)。呼び出しがあったAPIがAPI(1)であると判定された場合(ステップS31:YES)、ステップS32へ進む。一方、呼び出しがあったAPIがAPI(1)でないと判定された場合(ステップS31:NO)、ステップS35へ進む。 On the other hand, the processing shown in FIG. 10 is started when an API is called from an application. When the process shown in FIG. 10 is started, the OS determines whether the called API is the API (1) to be checked for tampering (step S31). If it is determined that the called API is API (1) (step S31: YES), the process proceeds to step S32. On the other hand, if it is determined that the called API is not API (1) (step S31: NO), the process proceeds to step S35.

ステップS32では、OSは、アプリケーションにより呼び出されたAPI(1)による処理を開始する。次いで、OSは、API(1)による処理の終了に至った時点で得られた第2データ、または、API(1)による処理の終了に至る前の時点で得られた第2データを、OSメモリ領域M2に記憶する(ステップS33)。次いで、OSは、API(1)による処理結果(つまり、第1データ)を戻り値としてアプリケーションに応答する(ステップS34)。 In step S32, the OS starts processing by API (1) called by the application. Next, the OS converts the second data obtained when the processing by API(1) ends or the second data obtained before the processing by API(1) ends to the OS Store in the memory area M2 (step S33). Next, the OS responds to the application with the result of processing by API (1) (that is, the first data) as a return value (step S34).

ステップS35では、OSは、呼び出しがあったAPIが改竄チェック用のAPI(2)であるか否かを判定する。呼び出しがあったAPIがAPI(2)であると判定された場合(ステップS35:YES)、ステップS36へ進む。一方、呼び出しがあったAPIがAPI(2)でないと判定された場合(ステップS35:NO)、ステップS42へ進む。 In step S35, the OS determines whether the called API is the tampering check API (2). If it is determined that the called API is API (2) (step S35: YES), the process proceeds to step S36. On the other hand, if it is determined that the called API is not API (2) (step S35: NO), the process proceeds to step S42.

ステップS36では、OSは、アプリケーションにより呼び出されたAPI(2)による処理を開始する。そして、OSは、アプリケーションメモリ領域M1から第1データを取得する(ステップS37)。次いで、OSは、OSメモリ領域M2から最新の第2データ、または指定された関数による処理に応じた第2データを取得する(ステップS38)。次いで、OSは、ステップS37で取得された第1データと、ステップS38で取得された第2データとを用いて改竄チェックを実行してデータ改竄の有無を判定する(ステップS39)。この改竄チェックでは、上記ステップS5と同じように処理が行われる。 In step S36, the OS starts processing by API (2) called by the application. Then, the OS acquires the first data from the application memory area M1 (step S37). Next, the OS acquires the latest second data or the second data according to the processing by the designated function from the OS memory area M2 (step S38). Next, the OS performs a falsification check using the first data obtained in step S37 and the second data obtained in step S38 to determine whether or not data has been falsified (step S39). This falsification check is performed in the same manner as in step S5.

そして、データ改竄有と判定された場合(ステップS39:有)、エラー処理が行われる(ステップS40)。一方、データ改竄無と判定された場合(ステップS39:無)、API(2)による処理結果(つまり、データ改竄無)が戻り値としてアプリケーションに応答される(ステップS41)。なお、ステップS42では、呼び出しがあった通常のAPIによる処理が実行され、その処理結果が戻り値としてアプリケーションに応答される(ステップS43)。 If it is determined that data has been falsified (step S39: Yes), error processing is performed (step S40). On the other hand, if it is determined that there is no data falsification (step S39: no), the result of processing by API (2) (that is, no data falsification) is returned as a return value to the application (step S41). In step S42, processing by the called normal API is executed, and the processing result is returned to the application as a return value (step S43).

以上説明したように、上記実施形態によれば、SEは、アプリケーションが有するバイトコードにしたがって呼び出された関数による処理結果を改竄チェック対象となる第1データとしてアプリケーションメモリ領域M1に記憶し、当該処理の開始から終了に至るまでの何れかのタイミングで得られた第2データをOSメモリ領域M2に記憶し、第1データ及び第2データを用いて改竄チェックを実行するように構成したので、外部からの攻撃による改竄を、複雑な回路を必要とせずに、より効率良くチェックし、改竄が検出された場合にはエラー処理を行うことができる。 As described above, according to the above embodiment, the SE stores in the application memory area M1 the result of processing by the function called according to the bytecode of the application as the first data to be checked for tampering. The second data obtained at any timing from the start to the end of is stored in the OS memory area M2, and the falsification check is performed using the first data and the second data. It is possible to efficiently check for tampering due to an attack from a host without requiring a complicated circuit, and perform error processing when tampering is detected.

特に、セキュリティ性を担保することが必要な処理において汎用的な機能を担うAPIが利用される場合、APIによる処理結果が外部からの攻撃により改竄されることが懸念されるが、APIの仕様は決まっているため、API内で追加のセキュリティ対策を施すことが困難である。上記実施形態によれば、SEは、セキュリティ性の担保が求められるAPI(1)による処理結果を改竄チェック対象となる第1データとしてアプリケーションメモリ領域M1に記憶し、当該処理の開始から終了に至るまでの何れかのタイミングで得られた第2データをOSメモリ領域M2に記憶し、第1データ及び第2データを用いて改竄チェックを実行するように構成したので、API内で追加のセキュリティ対策を施すことが困難である場合であっても、外部からの攻撃による改竄を、より効率良くチェックし、改竄が検出された場合にはエラー処理を行うことができる。 In particular, when APIs with general-purpose functions are used in processes that require security, there is concern that the processing results of the APIs may be tampered with by external attacks. Because it is fixed, it is difficult to implement additional security measures within the API. According to the above embodiment, the SE stores in the application memory area M1 the result of processing by API (1), which requires security assurance, as the first data to be checked for falsification, and the processing is started to end. Since the second data obtained at any timing up to is stored in the OS memory area M2 and the tampering check is performed using the first data and the second data, additional security measures are taken within the API. Even if it is difficult to perform the tampering, it is possible to more efficiently check for tampering due to an attack from the outside, and to perform error processing when tampering is detected.

さらに、上記実施形態によれば、セキュリティ性の担保が求められるAPI(1)による処理結果の改竄チェックを、別のAPI(2)を利用して実行するように構成したので、より簡単な構成で改竄チェックの機能をSEに実装することができる。 Furthermore, according to the above-described embodiment, the tampering check of the processing result by API (1), which requires security assurance, is performed using another API (2), so the configuration is simpler. can implement the tampering check function in the SE.

(変形例)
上記実施形態においては、API(1)による処理結果を記憶するためのアプリケーションメモリ領域M1を用意した場合の例を説明したが、以下に説明する変形例によれば、このようなアプリケーションメモリ領域M1を用意することなく、外部からの攻撃による改竄を、より効率良くチェックするように構成することもできる。この場合、SEは、アプリケーションが有するバイトコードにしたがってAPI(1)を呼び出し、呼び出されたAPI(1)による処理を実行し、チェック用となる複数のAPI(2)のうちAPI(1)による第1処理結果に応じたAPI(2)を呼び出し、呼び出されたAPI(2)による処理を実行し、API(1)による第1処理結果と、API(2)による第2処理結果とを用いて改竄チェックを実行する。この改竄チェックでは、第1処理結果と第2処理結果とが一致しているか否かが判定され、第1処理結果と第2処理結果とが一致していない場合にデータ改竄有と判定されることで、上述したように、エラー処理が行われる。
(Modification)
In the above embodiment, an example in which the application memory area M1 for storing the processing result by API (1) is prepared has been described. can be configured to more efficiently check for tampering due to external attacks. In this case, the SE calls the API (1) according to the bytecode of the application, executes the processing by the called API (1), and executes the processing by the API (1) among the multiple APIs (2) for checking. calling API(2) according to the first processing result, executing processing by the called API(2), using the first processing result by API(1) and the second processing result by API(2); tamper check. In this tampering check, it is determined whether or not the first processing result and the second processing result match, and if the first processing result and the second processing result do not match, it is determined that the data has been tampered with. As a result, error processing is performed as described above.

図11は、変形例における処理内容を疑似コードで表した図である。図11の例では、API(1)を構成する関数はverifyCert()になっており、チェック用となる複数のAPI(2)を構成する関数は、それぞれ、isTrue()とisFalse()になっている。API(1)による第1処理結果(trueまたはfalse)は、OSにより保持される。そして、第1処理結果がtrueであれば、trueに応じたAPI(2)(換言すると、trueに対応するAPI(2))であるisTrue()が呼び出され、呼び出されたisTrue()による処理が実行されることで直前の処理結果が第2処理結果として取得される。そして、verifyCert()による第1処理結果(つまり、OSが管理するメモリ領域に保持された第1処理結果)と、isTrue()による第2処理結果とが比較され、一致している場合には正常終了となる一方、一致していない場合には異常終了となる。他方、第1処理結果がfalseであれば、falseに応じたAPI(2)であるisFalse()が呼び出され、呼び出されたisFalse()による処理が実行されることで直前の処理結果が第2処理結果として取得される。そして、verifyCert()による第1処理結果(つまり、OSにより保持された第1処理結果)と、isFalse()による第2処理結果とが比較され、一致している場合には正常終了となる一方、一致していない場合には異常終了となる。なお、変形例は、第1処理結果及び第2処理結果がtrue/falseのように2値以上で区別される値(例えば、同じ、大きい、小さい、マイナス、プラス、など)となるその他の例に対しても適用可能である。 FIG. 11 is a diagram representing processing contents in the modified example in pseudo code. In the example of FIG. 11, the function that configures API (1) is verifyCert(), and the functions that configure multiple APIs for checking (2) are isTrue() and isFalse(), respectively. ing. The first processing result (true or false) by API (1) is held by the OS. Then, if the first processing result is true, the API (2) corresponding to true (in other words, the API (2) corresponding to true) isTrue() is called, and the process by the called isTrue() is executed, the immediately preceding processing result is obtained as the second processing result. Then, the first processing result of verifyCert() (that is, the first processing result held in the memory area managed by the OS) is compared with the second processing result of isTrue(), and if they match, It ends normally, but if it does not match, it ends abnormally. On the other hand, if the first processing result is false, isFalse(), which is API (2) corresponding to false, is called, and the processing by the called isFalse() is executed, so that the previous processing result is changed to the second Acquired as a processing result. Then, the first processing result of verifyCert() (that is, the first processing result held by the OS) and the second processing result of isFalse() are compared, and if they match, the processing ends normally. , and if they do not match, an abnormal end occurs. In addition, the modified example is another example where the first processing result and the second processing result are values that are distinguished by two or more values such as true/false (e.g., the same, larger, smaller, minus, plus, etc.) It is also applicable to

なお、上記実施形態においては、バイトコードを解釈する仮想マシンが搭載されたSEに対して本発明を適用したが、バイトコード以外の命令コードを実行することが可能なSEに対しても本発明を適用可能である。 In the above embodiment, the present invention is applied to an SE equipped with a virtual machine that interprets bytecodes. is applicable.

10 CPU
11 RAM
12 ROM
13 NVM
14 I/O回路
10 CPUs
11 RAM
12 ROMs
13 NVM
14 I/O circuit

Claims (16)

所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体であって、
前記処理結果を、改竄チェック対象となる第1データとして記憶する第1記憶部と、
前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを記憶する第2記憶部と、
前記第1データ及び前記第2データを用いて改竄チェックを実行する改竄チェック部と、
を備えることを特徴とする電子情報記憶媒体。
An electronic information storage medium that calls a function according to a predetermined instruction code, executes processing by the called function, and stores the processing result,
a first storage unit that stores the processing result as first data to be checked for falsification;
a second storage unit that stores second data obtained at any timing from the start to the end of the processing;
a tampering check unit that performs a tampering check using the first data and the second data;
An electronic information storage medium comprising:
前記関数は、前記電子情報記憶媒体に搭載されたアプリケーションが有する前記命令コードにしたがって当該アプリケーションから呼び出される第1API(Application Programming Interface)に含まれることを特徴とする請求項1に記載の電子情報記憶媒体。 2. The electronic information storage according to claim 1, wherein said function is included in a first API (Application Programming Interface) called by said application according to said instruction code possessed by said application installed in said electronic information storage medium. medium. 前記第1データは、前記第1APIから前記アプリケーションに応答された戻り値であり、前記アプリケーションにより利用される前記第1記憶部に記憶され、
前記第2データは、前記電子情報記憶媒体に搭載されたオペレーティングシステムにより利用される前記第2記憶部に記憶されることを特徴とする請求項2に記載の電子情報記憶媒体。
the first data is a return value returned from the first API to the application and is stored in the first storage unit used by the application;
3. The electronic information storage medium according to claim 2, wherein said second data is stored in said second storage unit used by an operating system installed in said electronic information storage medium.
前記アプリケーションから呼び出される第2APIであって前記第1APIとは異なる当該第2APIによる処理において、前記改竄チェック部は、前記第1データ及び前記第2データを用いて改竄チェックを実行することを特徴とする請求項3に記載の電子情報記憶媒体。 The tampering check unit performs an tampering check using the first data and the second data in processing by a second API that is called from the application and is different from the first API. 4. The electronic information storage medium according to claim 3. 前記アプリケーションから呼び出される第2APIであって前記第1APIとは異なる当該第2APIによる処理において、前記第2記憶部から前記第2データが取得され、当該第2データが戻り値として前記アプリケーションに応答され、
前記アプリケーションによる処理において、前記改竄チェック部は、前記第1データ及び前記第2データを用いて改竄チェックを実行することを特徴とする請求項3に記載の電子情報記憶媒体。
The second data is acquired from the second storage unit in a process by the second API that is called from the application and is different from the first API, and the second data is returned as a return value to the application. ,
4. The electronic information storage medium according to claim 3, wherein in the processing by the application, the tampering check section performs the tampering check using the first data and the second data.
前記第2記憶部は、前記処理の終了に至った時点で得られた第2データを記憶し、
前記改竄チェック部は、前記第1データと前記第2データとが一致しているか否かを判定することで改竄チェックを実行することを特徴とする請求項1乃至5の何れか一項に記載の電子情報記憶媒体。
The second storage unit stores second data obtained when the processing is completed,
6. The tampering check unit according to any one of claims 1 to 5, wherein the tampering check is performed by determining whether the first data and the second data match. electronic information storage media.
前記第2記憶部は、前記処理の終了に至る前の時点で得られた第2データを記憶し、
前記改竄チェック部は、前記処理の終了に至る前の時点で得られた第2データに基づいて、前記処理の終了に至る前の時点から前記処理の終了に至った時点までに行われるべき処理により第3データを算出し、前記第1データと前記第3データとが一致しているか否かを判定することで改竄チェックを実行することを特徴とする請求項1乃至5の何れか一項に記載の電子情報記憶媒体。
The second storage unit stores second data obtained before the end of the process,
The tampering check unit performs processing to be performed from a time before the end of the process to a time before the end of the process, based on second data obtained at a time before the end of the process. 6. The tampering check is executed by calculating the third data by and determining whether or not the first data and the third data match. The electronic information storage medium described in .
前記改竄チェック部は、前記第1データ、及び前記第2記憶部に直近に記憶された前記第2データを用いて改竄チェックを実行することを特徴とする請求項1乃至7の何れか一項に記載の電子情報記憶媒体。 8. The tampering check unit executes the tampering check using the first data and the second data stored most recently in the second storage unit. The electronic information storage medium described in . 前記第2記憶部は、複数の前記関数のそれぞれによる処理に応じた前記第2データを前記関数毎に区別して記憶し、
前記改竄チェック部は、前記第1データ、及び前記第2記憶部により記憶された複数の前記第2データのうちから指定された関数による処理に応じた前記第2データを用いて改竄チェックを実行することを特徴とする請求項1乃至7の何れか一項に記載の電子情報記憶媒体。
wherein the second storage unit stores the second data according to the processing by each of the plurality of functions separately for each function;
The tampering check unit performs an tampering check using the first data and the second data according to processing by a specified function from among the plurality of second data stored in the second storage unit. 8. The electronic information storage medium according to any one of claims 1 to 7, characterized by:
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体であって、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行し、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行する改竄チェック部と、
を備えることを特徴とする電子情報記憶媒体。
An electronic information storage medium that calls a first API according to a predetermined instruction code and executes processing by the called first API,
Calling a second API according to a first processing result by the first API among a plurality of second APIs for checking, executing processing by the called second API,
a tampering check unit that performs a tampering check using a first processing result by the first API and a second processing result by the second API;
An electronic information storage medium comprising:
所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶するICカードであって、
前記処理結果を、改竄チェック対象となる第1データとして記憶する第1記憶部と、
前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを記憶する第2記憶部と、
前記第1データ及び前記第2データを用いて改竄チェックを実行する改竄チェック部と、
を備えることを特徴とするICカード。
An IC card that calls a function according to a predetermined instruction code, executes processing by the called function, and stores the processing result,
a first storage unit that stores the processing result as first data to be checked for falsification;
a second storage unit that stores second data obtained at any timing from the start to the end of the processing;
a tampering check unit that performs a tampering check using the first data and the second data;
An IC card comprising:
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行するICカードであって、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行し、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行する改竄チェック部と、
を備えることを特徴とするICカード。
An IC card that calls a first API according to a predetermined instruction code and executes processing by the called first API,
Calling a second API according to a first processing result by the first API among a plurality of second APIs for checking, executing processing by the called second API,
a tampering check unit that performs a tampering check using a first processing result by the first API and a second processing result by the second API;
An IC card comprising:
所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、
前記処理結果を、改竄チェック対象となる第1データとして第1記憶部に記憶するステップと、
前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを第2記憶部に記憶するステップと、
前記第1データ及び前記第2データを用いて改竄チェックを実行するステップと、
を含むことを特徴とする改竄チェック方法。
A tampering check method executed by a computer included in an electronic information storage medium that calls a function according to a predetermined instruction code, executes processing by the called function, and stores the processing result,
a step of storing the processing result in a first storage unit as first data to be checked for falsification;
a step of storing second data obtained at any timing from the start to the end of the process in a second storage unit;
performing a tampering check using the first data and the second data;
A tampering check method characterized by comprising:
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行するステップと、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行するステップと、
を備えることを特徴とする改竄チェック方法。
A tampering check method executed by a computer included in an electronic information storage medium that calls a first API according to a predetermined instruction code and executes processing by the called first API,
a step of calling a second API according to a first processing result by the first API among a plurality of second APIs for checking, and executing processing by the called second API;
performing a tampering check using the first processing result by the first API and the second processing result by the second API;
A tampering check method comprising:
所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体に含まれるコンピュータに、
前記処理結果を、改竄チェック対象となる第1データとして第1記憶部に記憶するステップと、
前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを第2記憶部に記憶するステップと、
前記第1データ及び前記第2データを用いて改竄チェックを実行するステップと、
を実行させることを特徴とするプログラム。
A computer included in an electronic information storage medium that calls a function according to a predetermined instruction code, executes processing by the called function, and stores the processing result,
a step of storing the processing result in a first storage unit as first data to be checked for falsification;
a step of storing second data obtained at any timing from the start to the end of the process in a second storage unit;
performing a tampering check using the first data and the second data;
A program characterized by causing the execution of
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体に含まれるコンピュータに、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行するステップと、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行するステップと、
を実行させることを特徴とするプログラム。
A computer included in an electronic information storage medium that calls a first API according to a predetermined instruction code and executes processing by the called first API,
a step of calling a second API according to a first processing result by the first API among a plurality of second APIs for checking, and executing processing by the called second API;
performing a tampering check using the first processing result by the first API and the second processing result by the second API;
A program characterized by causing the execution of
JP2019026328A 2019-02-18 2019-02-18 Electronic information storage medium, IC card, falsification check method, and program Active JP7247638B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2019026328A JP7247638B2 (en) 2019-02-18 2019-02-18 Electronic information storage medium, IC card, falsification check method, and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2019026328A JP7247638B2 (en) 2019-02-18 2019-02-18 Electronic information storage medium, IC card, falsification check method, and program

Publications (2)

Publication Number Publication Date
JP2020135265A JP2020135265A (en) 2020-08-31
JP7247638B2 true JP7247638B2 (en) 2023-03-29

Family

ID=72263165

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2019026328A Active JP7247638B2 (en) 2019-02-18 2019-02-18 Electronic information storage medium, IC card, falsification check method, and program

Country Status (1)

Country Link
JP (1) JP7247638B2 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013164732A (en) 2012-02-10 2013-08-22 Isis Asset Co Ltd Information processor
JP2016535902A (en) 2013-08-29 2016-11-17 リバティ ヴォールツ リミテッド System for accessing data from multiple devices
JP2018500823A (en) 2014-12-12 2018-01-11 ナグラビジョン エス アー Device key protection

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013164732A (en) 2012-02-10 2013-08-22 Isis Asset Co Ltd Information processor
JP2016535902A (en) 2013-08-29 2016-11-17 リバティ ヴォールツ リミテッド System for accessing data from multiple devices
JP2018500823A (en) 2014-12-12 2018-01-11 ナグラビジョン エス アー Device key protection

Also Published As

Publication number Publication date
JP2020135265A (en) 2020-08-31

Similar Documents

Publication Publication Date Title
US11113384B2 (en) Stack overflow protection by monitoring addresses of a stack of multi-bit protection codes
JP3710671B2 (en) One-chip microcomputer, IC card using the same, and access control method for one-chip microcomputer
Iguchi-Cartigny et al. Developing a Trojan applets in a smart card
US8122514B2 (en) Software enhanced trusted platform module
EP2854066A1 (en) System and method for firmware integrity verification using multiple keys and OTP memory
US20100228997A1 (en) Method and apparatus for verifying authenticity of initial boot code
US7797682B2 (en) Controlled execution of a program used for a virtual machine on a portable data carrier
US8751817B2 (en) Data processing apparatus and validity verification method
US20050209716A1 (en) Method and system for writing nv memories in a controller architecture, corresponding computer program product and computer-readable storage medium
JP2748339B2 (en) Method and apparatus for improving the safety of integrated circuits
CN109933986B (en) Malicious code detection method and device
US20030101351A1 (en) Blocking of the operation of an integrated circuit
Lancia et al. Java card virtual machine compromising from a bytecode verified applet
CN109472172A (en) Method for preventing the unauthorized data access from memory
US20060289656A1 (en) Portable electronic apparatus and data output method therefor
JP2004503860A (en) Data processing method and apparatus for execution of protected instructions
JP7247638B2 (en) Electronic information storage medium, IC card, falsification check method, and program
JPH0827730B2 (en) Single-chip microcomputer and test method thereof
Lackner et al. Towards the hardware accelerated defensive virtual machine–type and bound protection
US10289808B2 (en) Method and system for secure data processing
US7806319B2 (en) System and method for protection of data contained in an integrated circuit
JP6424633B2 (en) Electronic information storage medium, abnormality detection method, and program
US7822953B2 (en) Protection of a program against a trap
CN113434247A (en) Safety protection method for JAVA card virtual machine
JP2008129697A (en) Data transfer control method between memories in ic card

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20211224

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20230227

R150 Certificate of patent or registration of utility model

Ref document number: 7247638

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150