JP2020135265A - Electronic information storage media, ic card, falsification check method, and program - Google Patents

Electronic information storage media, ic card, falsification check method, and program Download PDF

Info

Publication number
JP2020135265A
JP2020135265A JP2019026328A JP2019026328A JP2020135265A JP 2020135265 A JP2020135265 A JP 2020135265A JP 2019026328 A JP2019026328 A JP 2019026328A JP 2019026328 A JP2019026328 A JP 2019026328A JP 2020135265 A JP2020135265 A JP 2020135265A
Authority
JP
Japan
Prior art keywords
data
api
processing
processing result
called
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.)
Granted
Application number
JP2019026328A
Other languages
Japanese (ja)
Other versions
JP7247638B2 (en
Inventor
正剛 福永
Masatake Fukunaga
正剛 福永
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

Abstract

To provide an electronic information storage media capable of more efficiently checking falsification by an external attack without requiring a complicated circuit, an IC card, a falsification check method, and a program.SOLUTION: A secure element stores processing results by a function called according to a byte code owned by an application in an application memory area M1 as first data subjected to falsification check. Second data obtained at any timing from a start to an end of the processing is stored in an OS memory area M2. The falsification check is executed using the first data and the second data.SELECTED DRAWING: Figure 4

Description

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

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

ところで、セキュアエレメントに搭載されるアプリケーションは、一般に、命令コードにしたがって関数を呼び出し、呼び出された関数による処理の結果を利用するように構築される。しかし、当該関数による処理の結果が外部からの攻撃により改竄されることが懸念される。そのため、このような改竄を、複雑な回路を必要とせずに、より効率良くチェックする仕組みが望まれる。 By the way, an application mounted on 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 a concern that the result of processing by the function may be falsified by an external attack. Therefore, a mechanism for more efficiently checking such tampering without requiring a complicated circuit is desired.

そこで、本発明は、外部からの攻撃による改竄を、複雑な回路を必要とせずに、より効率良くチェックすることが可能な電子情報記憶媒体、ICカード、改竄チェック方法、及びプログラムを提供することを課題とする。 Therefore, the present invention provides an electronic information storage medium, an IC card, a falsification check method, and a program capable of more efficiently checking falsification due to an attack from the outside 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 that stores the processing result as the first data to be tampered with, and a second storage that stores the second data obtained at any timing from the start to the end of the processing. It is characterized by including a unit and a tampering check unit that executes a tampering check using the first data and the second data.

請求項2に記載の発明は、請求項1に記載の電子情報記憶媒体において、前記関数は、前記電子情報記憶媒体に搭載されたアプリケーションが有する前記命令コードにしたがって当該アプリケーションから呼び出される第1API(Application Programming Interface)に含まれることを特徴とする。 The invention according to claim 2 is the first API (in the electronic information storage medium according to claim 1, wherein the function is called from the application according to the instruction code of the application mounted on the electronic information storage medium. It is characterized by being included in the 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 in response to the application from the first API, and the first data is used by the application. It is stored in one storage unit, and the second data is stored in the second storage unit used by the operating system mounted on the electronic information storage medium.

請求項4に記載の発明は、請求項3に記載の電子情報記憶媒体において、前記アプリケーションから呼び出される第2APIであって前記第1APIとは異なる当該第2APIによる処理において、前記改竄チェック部は、前記第1データ及び前記第2データを用いて改竄チェックを実行することを特徴とする。 According to the fourth aspect of the present invention, in the electronic information storage medium according to the third aspect, in the processing by the second API, which is the second API called from the application and is different from the first API, the falsification check unit is used. It is characterized in that a falsification check is executed 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 second API called from the application in the electronic information storage medium according to claim 3, and is different from the first API in the processing by the second storage unit from the second storage unit. The second data is acquired, the second data is responded to the application as a return value, and in the processing by the application, the falsification check unit executes a falsification check using the first data and the second data. It is characterized by doing.

請求項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 is the second data obtained at the time when the processing is completed. The tampering check unit is characterized in that the tampering check is executed 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 is obtained at a time before the end of the process. The tampering check unit stores data, and based on the second data obtained at the time before the end of the process, from the time before the end of the process to the time when the end of the process is reached. It is characterized in that the tampering check is executed by calculating the third data by the processing to be performed in 1 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 falsification check unit is most recently stored in the first data and the second storage unit. It is characterized in that a falsification check is executed using the second data.

請求項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 is the second data corresponding to processing by each of the plurality of the functions. Is stored separately for each of the functions, and the tampering check unit responds to processing by a function specified from the first data and a plurality of the second data stored by the second storage unit. It is characterized in that a tampering check is executed using the second data.

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

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

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

請求項13に記載の発明は、所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、前記処理結果を、改竄チェック対象となる第1データとして第1記憶部に記憶するステップと、前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを第2記憶部に記憶するステップと、前記第1データ及び前記第2データを用いて改竄チェックを実行するステップと、を含むことを特徴とする。 The invention according to claim 13 is 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. The step of storing the processing result in the first storage unit as the first data to be tampered with, and the second data obtained at any timing from the start to the end of the processing. It is characterized by including a step of storing in the second storage unit and a step of executing a tampering check using the first data and the second data.

請求項14に記載の発明は、所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行するステップと、前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行するステップと、を備えることを特徴とする。 The invention according to claim 14 is a falsification 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. Of the plurality of second APIs to be used, a step of calling the second API corresponding to the first processing result by the first API and executing the processing by the called second API, the first processing result by the first API, and the above. It is characterized by including a step of executing a falsification check using the second processing result by the second API.

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

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

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

SEのハードウェア構成例を示す図である。It is a figure which shows the hardware configuration example of SE. SEの論理構成例を示す図である。It is a figure which shows the logical structure 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に記憶される様子を示す概念図である。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 M2. It is a conceptual diagram which shows the state. API(1)による処理結果として得られた第1データがアプリケーションメモリ領域M1に記憶され、API(1)による処理の終了に至る前の時点で得られた第2データがOSメモリ領域M2に記憶される様子を示す概念図である。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 OS memory area M2. It is a conceptual diagram which shows the state of being done. 複数の関数のそれぞれによる処理に応じた第2データを含むリストを示す図である。It is a figure which shows the list which contains the 2nd data corresponding to the processing by each of a plurality of functions. 実施例1におけるアプリケーションによる処理の一例を示すフローチャートである。It is a flowchart which shows an example of the processing by an application in Example 1. FIG. 実施例1におけるOSによる処理の一例を示すフローチャートである。It is a flowchart which shows an example of the processing by an OS in Example 1. FIG. 実施例2におけるアプリケーションによる処理の一例を示すフローチャートである。It is a flowchart which shows an example of the processing by the application in Example 2. 実施例2におけるOSによる処理の一例を示すフローチャートである。It is a flowchart which shows an example of the processing by the OS in Example 2. 変形例における処理内容を疑似コードで表した図である。It is the figure which represented the processing content in the modification by pseudo code.

以下、図面を参照して本発明の実施形態について詳細に説明する。以下に説明する実施形態は、セキュアエレメント(以下、「SE」という)に対して本発明を適用した場合の実施の形態である。 Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. The embodiment described below is an embodiment when 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. SE configuration and function]
First, the configuration and function of SE (an example of the electronic information storage medium of the present invention) according to the present embodiment will be described with reference to FIGS. 1 and 2. FIG. 1 is a diagram showing a hardware configuration example of SE, and FIG. 2 is a diagram showing a logical configuration example of SE. As shown in FIG. 1, the SE includes a CPU (Central Processing Unit) 10, a RAM (Random Access Memory) 11, a ROM (Read Only Memory) 12, an NVM (Nonvolatile Memory) 13 (nonvolatile memory), and an I / O. A circuit 14 and the like are provided. However, the ROM 12 may not be provided. Various programs and data are stored in the ROM 12 or the NVM 13. As a result, as shown in FIG. 2, the SE is equipped with the application, APIs (1) to (3), and an operating system (hereinafter referred to as "OS"). In the example of FIG. 2, one application is installed, but 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 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 (that is, integrated with the terminal). It may be formed in). The I / O circuit 14 serves as an interface with an external device that is a communication partner of the SE. Examples of the interface include an ISO7816 interface, a SWP (Single Wire Protocol) interface, and an SPI (Serial Peripheral Interface). Examples of external devices include servers and terminals. The I / O circuit 14 may include, for example, an antenna and a modulation / demodulation circuit.

アプリケーションは、オブジェクトの振る舞いを定義するクラスから実体として作成され、OS上で実行されるインスタンスであり、複数のバイトコード(命令コードの一例)を含んで構成される。バイトコードは、ソースコードとネイティブコードとの間の中間コードである。アプリケーションの実行では、アプリケーションが有するバイトコードがOSの一機能として搭載される仮想マシン(例えば、Java(登録商標)Virtual Machine)により解釈(つまり、どのような命令であるかが特定)され、解釈されたバイトコードにしたがって処理(アプリケーションによる処理)が行われる。バイトコードにより特定される命令の例として、書き込み命令、読み出し命令、論理演算命令、条件分岐命令、関数呼び出し命令などが挙げられる。関数呼び出し命令を示すバイトコードの例としてINVOKEVIRTUALがあり、これは、API(API(1)〜(3)の何れか)を呼び出すことができる。 An application is an instance created as an entity from a class that defines the behavior of an object and executed on the OS, and is configured to include a plurality of byte codes (examples of instruction codes). Bytecode is an intermediate code between source code and native code. In the execution of an application, the bytecode of the application is interpreted (that is, what kind of instruction is specified) and interpreted by a virtual machine (for example, Java (registered trademark) Virtual Machine) installed as a function of the OS. Processing (processing by the application) is performed according to the bytecode. Examples of instructions specified by bytecode include write instructions, read instructions, logical operation instructions, conditional branch instructions, function call instructions, and the like. INVOKE VIRTUAL is an example of a bytecode indicating a function call instruction, which can call an API (any of APIs (1) to (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) are each composed of one or more functions (also referred to as methods). The functions (functions that assist the application) provided by APIs (1) to (3) are different from each other. For example, API (1) is an example of the first API, and the processing result by the 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 constituting API (1) in this case. The arguments (input) of boolean verifyCert are input (input data), inputLen (input data length), certificate (signature data), certLen (signature data length), and algo (signature (cryptographic operation) algorithm). The signature verification result (that is, the processing result as output) by boolean verifyCert () is true (true) or false (false). The processing result by API (1) is not limited to the boolean type value, and is, for example, a comparison result (for example, a value indicating match or disagreement) or a cryptographic operation result (for example, '11 22 33 ... Any data related to the processing result, such as (data such as FF'(h)), can be applied. On the other hand, the API (2) is an example of the second API, and is used for checking the falsification of the processing result by the API (1) (that is, the second API is for checking). Since security is not required for the processing result by API (3), the falsification check of the processing result is not performed.

OSは、アプリケーションにより呼び出されたAPIによる処理(つまり、当該APIを構成する関数による処理)を実行し、その処理結果を戻り値としてアプリケーションに応答する。こうして応答された戻り値(処理結果)は、アプリケーションにより利用されるアプリケーションメモリ領域に記憶され、アプリケーションによる処理において用いられる。特に、API(1)による処理結果は、改竄チェック対象となる第1データとしてアプリケーションメモリ領域に記憶される。 The OS executes the processing by the API called by the application (that is, the processing by the functions constituting the API), and responds to the application with the processing result as a return value. The return value (processing result) returned in this way is stored in the application memory area used by the application and used in the processing by the application. In particular, the processing result 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 in the SE. As shown in FIG. 3, the application memory area M1 (an example of the first storage unit) used by the application and the OS memory area M2 (an example of the second storage unit) used by the OS are contained in the SE. For example, it is secured in RAM 11 or NVM 13. The application memory area M1 is configured to include a stack area having a back-in first-out structure. Local variables, arguments, return values, etc. are written in the stack area in frame units, and then acquired in frame units. The OS memory area M2 stores the second data obtained at any timing from the start to the end of the processing by the API (1). For example, the second data obtained when the processing by the API (1) is completed is stored in the OS memory area M2. Alternatively, the second data obtained at a time before the end of the processing by the API (1) is stored in the OS memory area M2. Then, the falsification check is executed 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 the OS memory area. It is a conceptual diagram which shows the state which 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 falsified by an attack from the outside. Therefore, in this case, the falsification 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, and the first If the data and the second data do not match, it is determined that the data has been tampered with. It is extremely unlikely that the first data and the second data will be tampered with to the same value by an attack from the outside. 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 obtained. It is a conceptual diagram which shows the state of being stored in the OS memory area M2. In the example of FIG. 5, since the second data is the data in the middle of processing by API (1) (in this example, the return value of the function 2), one of the data is not tampered with by an external attack. Do not have the same value. Therefore, in this case, the processing by the API (1) is 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 the API (1)). The third data is calculated by the process (process α in the example of FIG. 5) that should be performed from the point before the end of the process to the time when the process ends. Then, a falsification check is executed by determining whether or not 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 combined. 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 are falsified to the same value by an attack from the outside. The possibility of being done can be further reduced.

ところで、図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 (second data for one time) is stored in the OS memory area M2 in which the second data is stored. That is, the second data already stored in the OS memory area M2 is overwritten by the second data obtained in the subsequent processing by the API (1), so that the second data is kept up to date. 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 the 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が改竄チェック部として改竄チェックを行うことになる。 The second data used for the falsification check is acquired from the OS memory area M2 in the processing by the API (2), for example. For example, boolean checkResult () is used as a function constituting API (2) in this case. boolean checkResult () can acquire the latest second data stored most recently (that is, stored in the process by the previous function) from the OS memory area M2, and can respond to the application using this as the return value. .. In this case, the argument of boolean checkResult () is not necessary (because the memory area where the second data is stored is fixed), and the second data acquired in the processing by API (2) is used as the return value. After responding to the application, the tampering check is executed using the first data and the second data in the processing by the application. That is, in this case, the application performs a tampering check as a tampering check unit. As another example, in the processing by API (2), the acquisition of the first data and the second data and the falsification check using the first data and the second data are executed, and the falsification check result (for example, no data falsification) is executed. ) May be responded to by the application. In this case, the OS performs a falsification check as a falsification 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データを用いた改竄チェックが実行され、その改竄チェック結果(例えば、データ改竄無)がアプリケーションに応答されてもよい。 When the API (1) is composed of a plurality of functions, for example, the second data corresponding to the processing by each of the plurality of functions shown in FIG. 5 (for example, the latest second data for each function) is a function. It may be distinguished and stored for each. FIG. 6 is a diagram showing a list including the second data corresponding to the processing by each of the plurality of functions. Such a list will be stored in the OS memory area M2. In this case, it is necessary to specify which function is used as the second data to be used for the falsification check. For example, when the above-mentioned boolean checkResult () is used, it is specified as the return value of boolean checkResult () by specifying the function (or the address indicating the storage area of the second data according to the processing by the function) by the argument. The second data corresponding to the processing by the function is returned to the application, and then the falsification check is executed by using the first data and the second data in the processing by the application. As a result, security can be further improved. In this case as well, as in the other example described above, in the processing by API (2), the acquisition of the first data and the second data and the falsification check using the first data and the second data are executed, and the falsification is performed. The check result (for example, no data tampering) may be returned to the application.

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

(実施例1)
先ず、図7及び図8に基づいて、SEの動作の実施例1について説明する。実施例1では、アプリケーションが改竄チェックを行う場合の例である。図7は、実施例1におけるアプリケーションによる処理の一例を示すフローチャートであり、図8は、実施例1におけるOSによる処理の一例を示すフローチャートである。
(Example 1)
First, the first embodiment of the SE operation will be described with reference to FIGS. 7 and 8. The first embodiment is an example in which the application performs a tampering check. FIG. 7 is a flowchart showing an example of processing by the application in the first embodiment, and FIG. 8 is a flowchart showing an example of the processing by the 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 process shown in FIG. 7 is started when the SE receives, for example, a command indicating an execution command for signature verification from an external device. When the process shown in FIG. 7 is started, the application calls the API (1) in response to the above command (step S1), and returns the processing result (that is, the first data) by the called API (1). It is acquired as a value and the return value is stored in the application memory area M1 (step S2). Next, the application calls the API (2) (step S3), acquires the processing result (that is, the second data) by the called API (2) as a return value, and stores the return value in the application memory area M1. (Step S4).

次いで、アプリケーションは、ステップS2で格納された第1データと、ステップS4で格納された第2データとを用いて改竄チェックを実行してデータ改竄の有無を判定する(ステップS5)。改竄チェックでは、例えば、第1データと第2データとが一致しているか否かが判定され、第1データと第2データとが一致していない場合にデータ改竄有と判定される。或いは、改竄チェックでは、上述したように、第2データから第3データが算出され、第1データと第3データとが一致しているか否かが判定され、第1データと第3データとが一致していない場合にデータ改竄有と判定される。 Next, the application executes a falsification check using the first data stored in step S2 and the second data stored in step S4 to determine whether or not the data has been tampered with (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 tampered with. 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 combined. If they do not match, it is determined that the data has been tampered with.

そして、データ改竄有と判定された場合(ステップS5:有)、エラー処理が行われる(ステップS6)。エラー処理では、例えば、SEの動作が停止され、外部装置に対してエラー応答が出力される。一方、データ改竄無と判定された場合(ステップS5:無)、アプリケーションによる処理が続行される(ステップS7)。 Then, when it is determined that the data has been tampered with (step S5: yes), error processing is performed (step S6). In the error processing, for example, the SE operation is stopped and an error response is output to the external device. On the other hand, when it is determined that the data has not been tampered with (step S5: none), the processing by the application is continued (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 process shown in FIG. 8 is started when the application calls the API. When the process shown in FIG. 8 is started, the OS determines whether or not the called API is the API (1) of the falsification check target (verification target) (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 uses the second data obtained at the time when the processing by API (1) is completed, or the second data obtained at the time before the processing by API (1) is completed. It is stored in the memory area M2 (step S13). Next, the OS responds to the application with the processing result (that is, the first data) by the API (1) 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 or not the called API is the API (2) for tampering check. 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 the API (2) called by the application. Then, the OS acquires the latest second data from the OS memory area M2 or the second data corresponding to the processing by the designated function (step S17). Next, the OS responds to the application with the processing result (that is, the second data) by the API (2) as a return value (step S18). On the other hand, in step S19, the OS executes the processing by the normal API (3) that has been called, 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, the second embodiment of the SE operation will be described with reference to FIGS. 9 and 10. The second embodiment is an example in which the OS performs a tampering check. FIG. 9 is a flowchart showing an example of processing by the application in the second embodiment, and FIG. 10 is a flowchart showing an example of the processing by the OS in the second embodiment.

図9に示す処理は、SEが外部装置から、例えば、署名検証の実行命令を示すコマンドを受信した場合に開始される。図9に示す処理が開始されると、アプリケーションは、上記コマンドに応じて、API(1)を呼び出し(ステップS21)、呼び出されたAPI(1)による処理結果(つまり、第1データ)を戻り値として取得し、当該戻り値をアプリケーションメモリ領域M1に格納する(ステップS22)。次いで、アプリケーションは、API(2)を呼び出し(ステップS23)、呼び出されたAPI(2)による処理結果(データ改竄無)を戻り値として取得し(ステップS24)、処理を続行する(ステップS25)。 The process shown in FIG. 9 is started when the SE receives, for example, a command indicating an execution command for signature verification from an external device. When the process shown in FIG. 9 is started, the application calls the API (1) in response to the above command (step S21), and returns the processing result (that is, the first data) by the called API (1). It is acquired as a value and the return value is stored in the application memory area M1 (step S22). Next, the application calls the API (2) (step S23), acquires the processing result (no data tampering) by the called API (2) as a return value (step S24), and continues the 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 process shown in FIG. 10 is started when the application calls the API. When the process shown in FIG. 10 is started, the OS determines whether or not the called API is the API (1) to be tampered with (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 the API (1) called by the application. Next, the OS uses the second data obtained at the time when the processing by API (1) is completed, or the second data obtained at the time before the processing by API (1) is completed. It is stored in the memory area M2 (step S33). Next, the OS responds to the application with the processing result (that is, the first data) by the API (1) 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 or not the called API is the API (2) for tampering check. 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 the 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 from the OS memory area M2 or the second data according to the processing by the designated function (step S38). Next, the OS executes a falsification check using the first data acquired in step S37 and the second data acquired in step S38 to determine the presence or absence of data tampering (step S39). In this falsification check, the process is performed in the same manner as in step S5.

そして、データ改竄有と判定された場合(ステップS39:有)、エラー処理が行われる(ステップS40)。一方、データ改竄無と判定された場合(ステップS39:無)、API(2)による処理結果(つまり、データ改竄無)が戻り値としてアプリケーションに応答される(ステップS41)。なお、ステップS42では、呼び出しがあった通常のAPIによる処理が実行され、その処理結果が戻り値としてアプリケーションに応答される(ステップS43)。 Then, when it is determined that the data has been tampered with (step S39: yes), error processing is performed (step S40). On the other hand, when it is determined that there is no data tampering (step S39: none), the processing result by API (2) (that is, no data tampering) is returned to the application as a return value (step S41). In step S42, the processing by the normal API that was called 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 the processing result by the function called according to the byte code of the application in the application memory area M1 as the first data to be tampered with, and the processing is performed. 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 executed using the first data and the second data. It is possible to check tampering due to an attack from the user more efficiently without the need for a complicated circuit, and to 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 an API that has a general-purpose function is used in processing that requires security, there is a concern that the processing result by the API may be falsified by an attack from the outside, but the API specifications are Since it is fixed, it is difficult to take additional security measures within the API. According to the above embodiment, the SE stores the processing result by the API (1), which is required to ensure security, in the application memory area M1 as the first data to be tampered with, and goes from the start to the end of the processing. Since the second data obtained at any of the timings up to is stored in the OS memory area M2 and the falsification check is executed using the first data and the second data, additional security measures are taken in the API. Even if it is difficult to perform the above, it is possible to more efficiently check the falsification caused by an external attack and perform error processing when the falsification is detected.

さらに、上記実施形態によれば、セキュリティ性の担保が求められるAPI(1)による処理結果の改竄チェックを、別のAPI(2)を利用して実行するように構成したので、より簡単な構成で改竄チェックの機能をSEに実装することができる。 Further, according to the above embodiment, the falsification check of the processing result by the API (1), which is required to ensure the security, is executed by using another API (2), so that the configuration is simpler. The tampering check function can be implemented in 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 example)
In the above embodiment, an example in which the application memory area M1 for storing the processing result by the API (1) is prepared has been described, but according to the modification described below, such an application memory area M1 It can also be configured to more efficiently check for tampering due to external attacks without having to prepare. In this case, the SE calls the API (1) according to the byte code of the application, executes the process by the called API (1), and uses the API (1) among the plurality of APIs (2) to be checked. The API (2) according to the first processing result is called, the processing by the called API (2) is executed, and the first processing result by the API (1) and the second processing result by the API (2) are used. And execute a tampering check. In this falsification 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 showing the processing contents in the modified example with pseudo code. In the example of FIG. 11, the functions constituting API (1) are verifyCert (), and the functions constituting a plurality of APIs (2) to be checked 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, isTrue (), which is API (2) corresponding to true (in other words, API (2) corresponding to true) is called, and the processing by the called isTrue () is performed. Is executed, the immediately preceding processing result is acquired as the second processing result. Then, the first processing result by verifyCert () (that is, the first processing result held in the memory area managed by the OS) is compared with the second processing result by isTrue (), and if they match. It ends normally, but if they do 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 immediately preceding processing result is the second. Obtained as a processing result. Then, the first processing result by verifyCert () (that is, the first processing result held by the OS) is compared with the second processing result by isFalse (), and if they match, the process ends normally. If they do not match, the process ends abnormally. In addition, the modified example is another example in which the first processing result and the second processing result are values that can be distinguished by two or more values (for example, same, large, small, minus, plus, etc.) such as true / false. 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 a bytecode, but the present invention is also applied to an SE capable of executing an instruction code other than a bytecode. Is applicable.

10 CPU
11 RAM
12 ROM
13 NVM
14 I/O回路
10 CPU
11 RAM
12 ROM
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 the first data to be checked for falsification, and
A second storage unit that stores the second data obtained at any timing from the start to the end of the process, and
A falsification check unit that executes a falsification check using the first data and the second data, and
An electronic information storage medium characterized by comprising.
前記関数は、前記電子情報記憶媒体に搭載されたアプリケーションが有する前記命令コードにしたがって当該アプリケーションから呼び出される第1API(Application Programming Interface)に含まれることを特徴とする請求項1に記載の電子情報記憶媒体。 The electronic information storage according to claim 1, wherein the function is included in a first API (Application Programming Interface) called from the application according to the instruction code of the application mounted on the electronic information storage medium. Medium. 前記第1データは、前記第1APIから前記アプリケーションに応答された戻り値であり、前記アプリケーションにより利用される前記第1記憶部に記憶され、
前記第2データは、前記電子情報記憶媒体に搭載されたオペレーティングシステムにより利用される前記第2記憶部に記憶されることを特徴とする請求項2に記載の電子情報記憶媒体。
The first data is a return value in response to the application from the first API, and is stored in the first storage unit used by the application.
The electronic information storage medium according to claim 2, wherein the second data is stored in the second storage unit used by an operating system mounted on the electronic information storage medium.
前記アプリケーションから呼び出される第2APIであって前記第1APIとは異なる当該第2APIによる処理において、前記改竄チェック部は、前記第1データ及び前記第2データを用いて改竄チェックを実行することを特徴とする請求項3に記載の電子情報記憶媒体。 In the processing by the second API, which is the second API called from the application and is different from the first API, the falsification check unit is characterized in that the falsification check is executed using the first data and the second data. The electronic information storage medium according to claim 3. 前記アプリケーションから呼び出される第2APIであって前記第1APIとは異なる当該第2APIによる処理において、前記第2記憶部から前記第2データが取得され、当該第2データが戻り値として前記アプリケーションに応答され、
前記アプリケーションによる処理において、前記改竄チェック部は、前記第1データ及び前記第2データを用いて改竄チェックを実行することを特徴とする請求項3に記載の電子情報記憶媒体。
In the processing by the second API, which is the second API called from the application and is different from the first API, the second data is acquired from the second storage unit, and the second data is returned to the application as a return value. ,
The electronic information storage medium according to claim 3, wherein the falsification check unit executes a falsification check using the first data and the second data in the processing by the application.
前記第2記憶部は、前記処理の終了に至った時点で得られた第2データを記憶し、
前記改竄チェック部は、前記第1データと前記第2データとが一致しているか否かを判定することで改竄チェックを実行することを特徴とする請求項1乃至5の何れか一項に記載の電子情報記憶媒体。
The second storage unit stores the second data obtained at the time when the processing is completed, and stores the second data.
The falsification check unit according to any one of claims 1 to 5, wherein the falsification check unit executes the falsification check by determining whether or not the first data and the second data match. Electronic information storage medium.
前記第2記憶部は、前記処理の終了に至る前の時点で得られた第2データを記憶し、
前記改竄チェック部は、前記処理の終了に至る前の時点で得られた第2データに基づいて、前記処理の終了に至る前の時点から前記処理の終了に至った時点までに行われるべき処理により第3データを算出し、前記第1データと前記第3データとが一致しているか否かを判定することで改竄チェックを実行することを特徴とする請求項1乃至5の何れか一項に記載の電子情報記憶媒体。
The second storage unit stores the second data obtained at a time before the end of the process, and stores the second data.
The falsification check unit is a process to be performed from a time before the end of the process to a time when the process is completed, based on the second data obtained at the time before the end of the process. Any one of claims 1 to 5, wherein the falsification check is executed by calculating the third data according to the above method 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の何れか一項に記載の電子情報記憶媒体。 Any one of claims 1 to 7, wherein the falsification check unit executes a falsification check using the first data and the second data most recently stored in the second storage unit. The electronic information storage medium described in. 前記第2記憶部は、複数の前記関数のそれぞれによる処理に応じた前記第2データを前記関数毎に区別して記憶し、
前記改竄チェック部は、前記第1データ、及び前記第2記憶部により記憶された複数の前記第2データのうちから指定された関数による処理に応じた前記第2データを用いて改竄チェックを実行することを特徴とする請求項1乃至7の何れか一項に記載の電子情報記憶媒体。
The second storage unit separately stores the second data corresponding to the processing by each of the plurality of functions for each function, and stores the second data.
The tampering check unit executes a tampering check using the first data and the second data corresponding to the processing by the designated function from the plurality of the second data stored by the second storage unit. The electronic information storage medium according to any one of claims 1 to 7, wherein the electronic information storage medium is characterized by the above.
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体であって、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行し、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行する改竄チェック部と、
を備えることを特徴とする電子情報記憶媒体。
An electronic information storage medium that calls the first API according to a predetermined instruction code and executes processing by the called first API.
Of the plurality of second APIs to be checked, the second API corresponding to the first processing result by the first API is called, and the processing by the called second API is executed.
A falsification check unit that executes a falsification check using the first processing result by the first API and the second processing result by the second API.
An electronic information storage medium characterized by 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 the first data to be checked for falsification, and
A second storage unit that stores the second data obtained at any timing from the start to the end of the process, and
A falsification check unit that executes a falsification check using the first data and the second data, and
An IC card characterized by being equipped with.
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行するICカードであって、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行し、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行する改竄チェック部と、
を備えることを特徴とするICカード。
An IC card that calls the first API according to a predetermined instruction code and executes processing by the called first API.
Of the plurality of second APIs to be checked, the second API corresponding to the first processing result by the first API is called, and the processing by the called second API is executed.
A falsification check unit that executes a falsification check using the first processing result by the first API and the second processing result by the second API.
An IC card characterized by being equipped with.
所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、
前記処理結果を、改竄チェック対象となる第1データとして第1記憶部に記憶するステップと、
前記処理の開始から終了に至るまでの何れかのタイミングで得られた第2データを第2記憶部に記憶するステップと、
前記第1データ及び前記第2データを用いて改竄チェックを実行するステップと、
を含むことを特徴とする改竄チェック方法。
It is a falsification 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 the first storage unit as the first data to be tampered with,
A step of storing the second data obtained at any timing from the start to the end of the process in the second storage unit, and
A step of executing a tampering check using the first data and the second data, and
A tampering check method characterized by including.
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体に含まれるコンピュータにより実行される改竄チェック方法であって、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行するステップと、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行するステップと、
を備えることを特徴とする改竄チェック方法。
It is a falsification check method executed by a computer included in an electronic information storage medium that calls the first API according to a predetermined instruction code and executes the processing by the called first API.
Of the plurality of second APIs to be checked, a step of calling the second API according to the first processing result of the first API and executing the processing by the called second API.
A step of executing 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 method characterized by being equipped with.
所定の命令コードにしたがって関数を呼び出し、呼び出された関数による処理を実行し、その処理結果を記憶する電子情報記憶媒体に含まれるコンピュータに、
前記処理結果を、改竄チェック対象となる第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 the first storage unit as the first data to be tampered with,
A step of storing the second data obtained at any timing from the start to the end of the process in the second storage unit, and
A step of executing a tampering check using the first data and the second data, and
A program characterized by executing.
所定の命令コードにしたがって第1APIを呼び出し、呼び出された第1APIによる処理を実行する電子情報記憶媒体に含まれるコンピュータに、
チェック用となる複数の第2APIのうち、前記第1APIによる第1処理結果に応じた第2APIを呼び出し、呼び出された第2APIによる処理を実行するステップと、
前記第1APIによる第1処理結果と、前記第2APIによる第2処理結果とを用いて改竄チェックを実行するステップと、
を実行させることを特徴とするプログラム。
To the computer included in the electronic information storage medium that calls the first API according to a predetermined instruction code and executes the processing by the called first API.
Of the plurality of second APIs for checking, a step of calling the second API according to the first processing result of the first API and executing the processing by the called second API
A step of executing a tampering check using the first processing result by the first API and the second processing result by the second API, and
A program characterized by executing.
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 true JP2020135265A (en) 2020-08-31
JP7247638B2 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
JP7247638B2 (en) 2023-03-29

Similar Documents

Publication Publication Date Title
US7797682B2 (en) Controlled execution of a program used for a virtual machine on a portable data carrier
CN109933986B (en) Malicious code detection method and device
US8117662B2 (en) Smartcard system
CN109472172A (en) Method for preventing the unauthorized data access from memory
Lancia et al. Java card virtual machine compromising from a bytecode verified applet
US20060289656A1 (en) Portable electronic apparatus and data output method therefor
WO2001097010A2 (en) Data processing method and device for protected execution of instructions
CN105893877B (en) Method for secure data reading and data processing system
JP7247638B2 (en) Electronic information storage medium, IC card, falsification check method, and program
CN106682512A (en) Method, device and system for preventing programs from being corrected
US10289808B2 (en) Method and system for secure data processing
US20060265578A1 (en) Detection of a sequencing error in the execution of a program
JP6769265B2 (en) Electronic information storage medium, IC card, data abnormality confirmation method, and data abnormality confirmation program
US20100031357A1 (en) Defending Smart Cards Against Attacks by Redundant Processing
US7806319B2 (en) System and method for protection of data contained in an integrated circuit
US10242183B2 (en) Method of executing a program by a processor and electronic entity comprising such a processor
JP2008204085A (en) Semiconductor memory
CN111625784B (en) Anti-debugging method of application, related device and storage medium
JP6424633B2 (en) Electronic information storage medium, abnormality detection method, and program
JP6175882B2 (en) Information storage medium, IC card, and bytecode execution method
CN113434247A (en) Safety protection method for JAVA card virtual machine
JP2018163446A (en) Electronic information storage medium, ic card, tampering check method, and tampering check program
US20240020140A1 (en) Computer system enabled with runtime software module tracking
CN116569166A (en) Stack-based analysis with verified stack trace generation and acceleration of shadow stacks
JP5200686B2 (en) Information processing apparatus, normal processing determination method, and information processing program

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