JP7563181B2 - Electronic information storage medium, patch program writing method, and program - Google Patents
Electronic information storage medium, patch program writing method, and program Download PDFInfo
- Publication number
- JP7563181B2 JP7563181B2 JP2021001439A JP2021001439A JP7563181B2 JP 7563181 B2 JP7563181 B2 JP 7563181B2 JP 2021001439 A JP2021001439 A JP 2021001439A JP 2021001439 A JP2021001439 A JP 2021001439A JP 7563181 B2 JP7563181 B2 JP 7563181B2
- Authority
- JP
- Japan
- Prior art keywords
- patch
- storage area
- program
- state
- writing
- 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
Links
Images
Landscapes
- Stored Programmes (AREA)
Description
本発明は、セキュアエレメント等の電子情報記憶媒体に記憶されるアプリケーションプログラムに対してパッチプログラムを適用する方法等の技術に関する。 The present invention relates to a method and technology for applying a patch program to an application program stored in an electronic information storage medium such as a secure element.
従来、アプリケーションプログラムに対してパッチプログラムを適用する方法として、関数の呼出アドレスに関連付けてパッチプログラムの呼出アドレスが記憶されるパッチテーブルを用いた技術が知られている。例えば特許文献1に開示された技術では、関数を呼び出すとき割り込みを発生させ、呼び出された関数の呼出アドレスに関連付けられたパッチプログラムの呼出アドレスを利用して当該パッチプログラムを呼び出すように構成される。このようなパッチプログラムは、例えば工場においてICカードに書き込まれることでアプリケーションプログラムに対して適用することが可能である。 Conventionally, a known method for applying a patch program to an application program is a technology that uses a patch table in which the call address of a patch program is stored in association with the call address of a function. For example, the technology disclosed in Patent Document 1 is configured to generate an interrupt when a function is called, and to call the patch program using the call address of the patch program associated with the call address of the called function. Such a patch program can be applied to an application program by being written to an IC card in a factory, for example.
ところで、例えばeUICC(Embedded Universal Integrated Circuit Card)のような組み込み型のセキュアエレメントでは、運用中にオンライン(例えばOTA)により不具合修正や機能変更をするため、パッチプログラムを書き込む場合がある。かかる場合において、パッチプログラムの書き込みが予期せぬノイズや電源断などで中断されてもセキュアエレメントが復旧可能であることが要求される。 In the case of an embedded secure element such as an eUICC (Embedded Universal Integrated Circuit Card), patch programs may be written online (e.g., OTA) during operation to correct defects or change functions. In such cases, it is required that the secure element be able to recover even if the writing of the patch program is interrupted by unexpected noise or a power outage.
そこで、本発明は、上記点に鑑みてなされたものであり、パッチプログラムの書き込みが予期せぬノイズや電源断などで中断されても正常に復旧することが可能な電子情報記憶媒体、パッチプログラムの書き込み方法、及びプログラムを提供することを課題とする。 The present invention has been made in consideration of the above points, and aims to provide an electronic information storage medium, a patch program writing method, and a program that can restore normal operation even if the writing of a patch program is interrupted by unexpected noise or a power outage.
上記課題を解決するために、請求項1に記載の発明は、アプリケーションプログラムを記憶するための第1記憶領域と、前記アプリケーションプログラムに対して適用されるパッチプログラムを記憶するための第2記憶領域と、前記パッチプログラムの呼び出し時に参照されるパッチテーブルを記憶するための第3記憶領域と、前記パッチプログラムの呼び出し時に参照されないパッチテーブルを記憶するための第4記憶領域とを有するメモリを備える電子情報記憶媒体であって、外部端末から送信された前記パッチプログラム及び前記パッチテーブルを前記メモリに書き込む前に前記パッチプログラム及び前記パッチテーブルの状態を初期状態に設定し、その後、前記パッチプログラムの前記第2記憶領域への書き込み、且つ、前記パッチテーブルの前記第4記憶領域への書き込みが完了した後に、前記状態を待機状態に設定する設定手段と、前記電子情報記憶媒体のリセット後に外部端末からコマンドが受信されたとき、前記状態が初期状態である場合に前記第3記憶領域及び前記第4記憶領域を初期化する一方、前記状態が待機状態である場合に前記第4記憶領域から前記第3記憶領域に前記パッチテーブルを書き込む書き込み手段と、を備えることを特徴とする。 In order to solve the above problem, the invention described in claim 1 is an electronic information storage medium having a memory having a first storage area for storing an application program, a second storage area for storing a patch program to be applied to the application program, a third storage area for storing a patch table to be referenced when the patch program is called, and a fourth storage area for storing a patch table not referenced when the patch program is called, characterized in that the electronic information storage medium includes a setting means for setting the states of the patch program and the patch table to an initial state before writing the patch program and the patch table transmitted from an external terminal to the memory, and then setting the state to a standby state after writing of the patch program to the second storage area and writing of the patch table to the fourth storage area are completed, and a writing means for initializing the third storage area and the fourth storage area when the state is the initial state when a command is received from an external terminal after resetting the electronic information storage medium, and writing the patch table from the fourth storage area to the third storage area when the state is the standby state.
請求項2に記載の発明は、請求項1に記載の電子情報記憶媒体において、前記設定手段は、前記第3記憶領域及び前記第4記憶領域が初期化された場合、または前記第4記憶領域から前記第3記憶領域に前記パッチテーブルが書き込まれた場合に、前記状態を通常状態に設定することを特徴とする。
The invention described in
請求項3に記載の発明は、請求項1または2に記載の電子情報記憶媒体において、前記設定手段は、前記状態が待機状態である場合に前記第4記憶領域から前記第3記憶領域に前記パッチテーブルが書き込まれる前に前記状態を初期状態に設定することを特徴とする。
The invention described in claim 3 is characterized in that, in the electronic information storage medium described in
請求項4に記載の発明は、請求項2または3に記載の電子情報記憶媒体において、前記リセット後に外部端末からコマンドが受信されたとき、前記状態が通常状態である場合に前記パッチプログラム及び前記パッチテーブルを検証し、当該検証が成功した場合に前記コマンドに応じた処理を実行させる制御手段を更に備えることを特徴とする。
The invention described in claim 4 is characterized in that, in the electronic information storage medium described in
請求項5に記載の発明は、請求項1乃至4の何れか一項に記載の電子情報記憶媒体において、前記パッチプログラムが前記第2記憶領域に書き込まれる際に、前記書き込み手段は、前記外部端末から送信されたバージョンデータであって当該パッチプログラムのバージョンを示すバージョンデータを前記メモリにおける所定の記憶領域に書き込み、前記外部端末からの要求に応じて、前記所定の記憶領域からバージョンデータを読み出して当該外部端末へ送信する送信手段を更に備えることを特徴とする。 The invention described in claim 5 is characterized in that, in the electronic information storage medium described in any one of claims 1 to 4, when the patch program is written to the second storage area, the writing means writes version data transmitted from the external terminal and indicating the version of the patch program to a specified storage area in the memory, and further includes a transmission means for reading the version data from the specified storage area and transmitting it to the external terminal in response to a request from the external terminal.
請求項6に記載の発明は、アプリケーションプログラムを記憶するための第1記憶領域と、前記アプリケーションプログラムに対して適用されるパッチプログラムを記憶するための第2記憶領域と、前記パッチプログラムの呼び出し時に参照されるパッチテーブルを記憶するための第3記憶領域と、前記パッチプログラムの呼び出し時に参照されないパッチテーブルを記憶するための第4記憶領域とを有するメモリを備える電子情報記憶媒体により実行されるパッチプログラムの書き込み方法であって、外部端末から送信された前記パッチプログラム及び前記パッチテーブルを前記メモリに書き込む前に前記パッチプログラム及び前記パッチテーブルの状態を初期状態に設定し、その後、前記パッチプログラムの前記第2記憶領域への書き込み、且つ、前記パッチテーブルの前記第4記憶領域への書き込みが完了した後に、前記状態を待機状態に設定するステップと、前記電子情報記憶媒体のリセット後に外部端末からコマンドが受信されたとき、前記状態が初期状態である場合に前記第3記憶領域及び前記第4記憶領域を初期化する一方、前記状態が待機状態である場合に前記第4記憶領域から前記第3記憶領域に前記パッチテーブルを書き込むステップと、を含むことを特徴とする。 The invention described in claim 6 is a method for writing a patch program executed by an electronic information storage medium having a memory having a first storage area for storing an application program, a second storage area for storing a patch program to be applied to the application program, a third storage area for storing a patch table to be referenced when the patch program is called, and a fourth storage area for storing a patch table not referenced when the patch program is called, the method including the steps of: setting the states of the patch program and the patch table transmitted from an external terminal to an initial state before writing the patch program and the patch table to the memory, and then setting the state to a standby state after writing the patch program to the second storage area and writing the patch table to the fourth storage area are completed; and, when a command is received from an external terminal after resetting the electronic information storage medium, initializing the third storage area and the fourth storage area if the state is the initial state, and writing the patch table from the fourth storage area to the third storage area if the state is the standby state.
請求項7に記載の発明は、アプリケーションプログラムを記憶するための第1記憶領域と、前記アプリケーションプログラムに対して適用されるパッチプログラムを記憶するための第2記憶領域と、前記パッチプログラムの呼び出し時に参照されるパッチテーブルを記憶するための第3記憶領域と、前記パッチプログラムの呼び出し時に参照されないパッチテーブルを記憶するための第4記憶領域とを有するメモリを備える電子情報記憶媒体に含まれるコンピュータを、外部端末から送信された前記パッチプログラム及び前記パッチテーブルを前記メモリに書き込む前に前記パッチプログラム及び前記パッチテーブルの状態を初期状態に設定し、その後、前記パッチプログラムの前記第2記憶領域への書き込み、且つ、前記パッチテーブルの前記第4記憶領域への書き込みが完了した後に、前記状態を待機状態に設定する設定手段と、前記電子情報記憶媒体のリセット後に外部端末からコマンドが受信されたとき、前記状態が初期状態である場合に前記第3記憶領域及び前記第4記憶領域を初期化する一方、前記状態が待機状態である場合に前記第4記憶領域から前記第3記憶領域に前記パッチテーブルを書き込む書き込み手段として機能させることを特徴とする。 The invention described in claim 7 is characterized in that a computer included in an electronic information storage medium having a memory having a first storage area for storing an application program, a second storage area for storing a patch program to be applied to the application program, a third storage area for storing a patch table referenced when the patch program is called, and a fourth storage area for storing a patch table not referenced when the patch program is called is made to function as a setting means for setting the states of the patch program and the patch table to an initial state before writing the patch program and the patch table transmitted from an external terminal to the memory, and then setting the state to a standby state after writing of the patch program to the second storage area and writing of the patch table to the fourth storage area are completed, and a writing means for initializing the third storage area and the fourth storage area when the state is the initial state when a command is received from an external terminal after resetting the electronic information storage medium, and writing the patch table from the fourth storage area to the third storage area when the state is a standby state.
本発明によれば、パッチプログラムの書き込みが予期せぬノイズや電源断などで中断されても正常に復旧することができる。 According to the present invention, even if the writing of a patch program is interrupted by unexpected noise or a power outage, it can be restored normally.
以下、図面を参照して本発明の実施形態について詳細に説明する。以下に説明する実施形態は、セキュアエレメント(以下、「SE」という)に対して本発明を適用した場合の実施の形態である。 The following describes in detail an embodiment of the present invention 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.SE1の構成及び機能]
先ず、図1を参照して、本実施形態に係るSE1の構成及び機能について説明する。図1は、SE1の概要構成例を示す図である。SE1は、本発明の電子情報記憶媒体の一例である。図1に示すように、SE1は、CPU(Central Processing Unit)10、RAM(Random Access Memory)11、NVM(Nonvolatile Memory)12(不揮発性メモリ)、及びI/O回路13などを備えて構成される(ROMが備えられる場合もある)。SE1は、例えば各種カード(例えば、クレジットカードやデビットカード)、またはスマートフォン等の端末に搭載されて使用される。なお、SE1は、着脱可能な小型のICカードとして端末に搭載されてもよいし、eUICC(Embedded Universal Integrated Circuit Card)として端末から容易に取り外しや取り換えができないように組み込み基盤上に搭載(つまり、端末と一体的に形成)されてもよい。
[1. Configuration and Function of SE1]
First, the configuration and functions of the SE1 according to this embodiment will be described with reference to FIG. 1. FIG. 1 is a diagram showing an example of the schematic configuration of the SE1. The SE1 is an example of an electronic information storage medium of the present invention. As shown in FIG. 1, the SE1 is configured to include a CPU (Central Processing Unit) 10, a RAM (Random Access Memory) 11, an NVM (Nonvolatile Memory) 12 (nonvolatile memory), and an I/O circuit 13 (ROM may also be included). The SE1 is used by being mounted on various cards (e.g., credit cards and debit cards) or terminals such as smartphones. The SE1 may be mounted on a terminal as a small, detachable IC card, or may be mounted on an embedded board (i.e., formed integrally with the terminal) as an eUICC (Embedded Universal Integrated Circuit Card) so that it cannot be easily removed or replaced from the terminal.
I/O回路13は、外部端末2との間のインターフェースを担う。外部端末2の例として、後述するパッチプログラムを提供するホスト(コンピュータ)、及びSE1の機能を利用する機器(例えば、上記各種カードの通信相手や上記端末のコントローラ)が挙げられる。インターフェースの例として、SPI(Serial Peripheral Interface)、I2C(Inter-Integrated Circuit)、及びISO7816のインターフェースなどが挙げられる。SE1と外部端末2との間の通信は、直接的に行われてもよいし、上記端末の無線通信部を介して間接的に行われてもよい。後者の場合、当該端末の無線通信部によりプロトコル変換が行われる。なお、SE1と上記ホストとの間の通信は、相互認証を実行して確立したセキュアチャネルを通じて行われることが望ましい。
The I/
また、外部端末2から送信されたコマンド(コマンドAPDU)は、I/O回路13を通じて受信される。受信されるコマンドは、少なくともヘッダ(CLA(命令クラス)、INS(命令コード)、P1及びP2(パラメータ)からなる)を含むAPDU(Application Protocol Data Unit)により構成される。さらに、コマンドは、上記ヘッダに加えて、プログラム(例えば、パッチプログラム)やデータ(例えば、パッチテーブル)等を有するボディを含む場合もある。また、コマンドに対するレスポンス(レスポンスAPDU)は、I/O回路13を通じて外部端末2へ送信される。ここで、レスポンスは、少なくとも処理結果を示すSW(ステータスワード)からなり、データを含む場合もある。
In addition, a command (command APDU) sent from the
CPU10は、NVM12に記憶された各種プログラムを実行するプロセッサ(コンピュータ)である。RAM11は、作業用メモリとして利用され、例えば、後入れ先出しの構造を有するスタック領域を有する。スタック領域には、例えば、ローカル変数、引数、戻り値などがフレーム単位で書き込まれ、その後、フレーム単位で取得される。なお、スタック領域は、NVM12に設けられてもよい。NVM12は、記憶部の一例であり、例えばフラッシュメモリが適用される。NVM12は、「Electrically Erasable Programmable Read-Only Memory」であってもよい。NVM12には、各種プログラム(本発明のプログラムを含む)が予め記憶(例えば、SE1の出荷前に記憶)される。各種プログラムには、オペレーティングシステム(以下、「OS」という)、アプリケーションプログラム(以下、「アプリケーション」という)などが含まれる。なお、OSまたはアプリケーションは、本発明における設定手段、書き込み手段、制御手段、及び送信手段の一例である。
The
また、NVM12には、アプリケーションに対して適用されるパッチプログラムが後から書き込まれる(例えば、SE1の出荷後の運用中に書き込まれる)ようになっている。パッチプログラムにより、アプリケーションの不具合修正や機能を変更または追加することができる。かかる機能には、例えば、暗号演算機能や生体認証(例えば、指紋認証や掌紋認証)機能などがある。さらに、NVM12には、パッチプログラムの呼び出し時に参照されるパッチテーブルが後から書き込まれる。パッチテーブルには、パッチプログラムの呼び出しアドレスが格納される。例えば、パッチプログラムの呼び出しアドレスは、アプリケーションにより呼び出される関数の呼び出しアドレスに関連付けられて格納される。 In addition, patch programs to be applied to applications are written later to NVM12 (for example, written during operation after shipment of SE1). The patch programs can be used to fix defects in applications and change or add functions. Such functions include, for example, cryptographic calculation functions and biometric authentication (for example, fingerprint authentication and palm print authentication) functions. Furthermore, a patch table that is referenced when a patch program is called is written later to NVM12. The call address of the patch program is stored in the patch table. For example, the call address of the patch program is stored in association with the call address of a function called by an application.
図2は、NVM12のメモリマップの一例を示す図である。図2の例では、NVM12は、プログラム記憶領域121(第1記憶領域の一例)、パッチ記憶領域122(第2記憶領域の一例)、第1テーブル記憶領域123(第3記憶領域の一例)、第2テーブル記憶領域124(第4記憶領域の一例)、及びデータ記憶領域125を有する。プログラム記憶領域121は、OS、及びアプリケーションを記憶するための領域である。パッチ記憶領域122は、パッチプログラムを記憶するための領域である。外部端末2から送信(ダウンロード)されたパッチプログラムは、パッチ記憶領域122に書き込まれる。
Figure 2 is a diagram showing an example of a memory map of
第1テーブル記憶領域123は、パッチプログラムの呼び出し時(アプリケーションの動作時)にOSにより参照されるパッチテーブルを記憶するための領域である。第2テーブル記憶領域124は、パッチプログラムの呼び出し時にOSにより参照されないパッチテーブルを記憶するための領域である。ただし、後述する通常状態において、第1テーブル記憶領域123及び第2テーブル記憶領域124には、同じパッチテーブルが記憶されるようになっている。外部端末2から送信されるパッチテーブルは、第1テーブル記憶領域123には書き込まれずに、先ずは第2テーブル記憶領域124に書き込まれようになっている。その後、第2テーブル記憶領域124に記憶されているパッチテーブルは、第1テーブル記憶領域123に書き込まれる。つまり、パッチテーブルは、第2テーブル記憶領域124から第1テーブル記憶領域123にコピーされるようになっている。
The first
データ記憶領域125には、セキュアチャネルを確立するための認証処理に用いられる認証用データ、及びパッチ記憶領域122に記憶されているパッチプログラムのバージョンを示すバージョンデータが記憶される。なお、バージョンデータは、第1テーブル記憶領域123及び第2テーブル記憶領域124に記憶されてもよい。データ記憶領域125は、各種データを記憶するための領域である。
The
OSは、SE1におけるパッチプログラム及びパッチテーブルの状態(以下、「パッチ状態」という)を、「初期状態」、「待機状態」、及び「通常状態」の3つの状態で管理する。図3(A)~図3(D)は、OSにより管理される初期状態、待機状態、及び通常状態を示す概念図である。図4は、パッチ状態の遷移例を示す図である。パッチ状態は、図4の矢印で示すように遷移する。 The OS manages the state of the patch program and patch table in SE1 (hereinafter referred to as the "patch state") in three states: the "initial state," the "standby state," and the "normal state." Figures 3(A) to 3(D) are conceptual diagrams showing the initial state, standby state, and normal state managed by the OS. Figure 4 is a diagram showing an example of transitions in the patch state. The patch state transitions as shown by the arrows in Figure 4.
初期状態とは、第1テーブル記憶領域123及び第2テーブル記憶領域124がSE1の出荷時の状態である。初期状態では、図3(A)に示すように、第1テーブル記憶領域123及び第2テーブル記憶領域124に記憶されるパッチテーブルが不定値となっている。ここで、不定値とは、パッチテーブルとして正常に利用可能であるか否かが定まっていない値を意味し、その値が破損(換言すると、パッチテーブルが破損)している場合もある。そのため、初期状態では、第1テーブル記憶領域123にパッチテーブルが記憶されているか否かに関わらず、OSは、第1テーブル記憶領域123にパッチテーブルが記憶されていないと判断して処理を行う。例えば破損されたパッチテーブルが参照されてパッチプログラムの呼び出しが行われると、SE1が動作不能に陥り復旧(復帰)不可になる可能性がある。従って、初期状態において、第1テーブル記憶領域123はOSにより参照されない。
The initial state is the state in which the first
待機状態は、外部端末2から送信されるパッチテーブルが第2テーブル記憶領域124に書き込まれたが、当該パッチテーブルがまだ第1テーブル記憶領域123には書き込まれていない状態である。待機状態では、図3(B)に示すように、第2テーブル記憶領域124に記憶されるパッチテーブルは正常値になっているが、第1テーブル記憶領域123に記憶されるパッチテーブルは初期値になっている。ここで、正常値とは、パッチテーブルとして正常に利用可能である値を意味し、その値はパッチプログラムの呼び出しアドレスを示す。一方、初期値とは、パッチプログラムの呼び出しアドレスではないことをOSが判断可能な値である。換言すると、初期値は、パッチプログラムが充てられていないことを示す値である。従って、待機状態において、第1テーブル記憶領域123はOSにより参照されるが、パッチプログラムの呼び出しは行われない。
In the standby state, the patch table sent from the
通常状態は、パッチプログラムの呼び出し時にOSにより第1テーブル記憶領域123のパッチテーブルが参照可能な状態である。通常状態では、アプリケーションに対してパッチプログラムが適用されていない状態もあるし、アプリケーションに対してパッチプログラムが適用されている状態もある。ここで、アプリケーションに対してパッチプログラムが適用されていない状態とは、図3(C)に示すように、パッチプログラムが書き込まれておらず、第1テーブル記憶領域123及び第2テーブル記憶領域124に初期値が書き込まれている(つまり、初期化されている)状態である。一方、アプリケーションに対してパッチプログラムが適用されている状態とは、パッチプログラム及びパッチテーブルが書き込まれ、その後、第2テーブル記憶領域124から第1テーブル記憶領域123にコピーされることで、図3(D)に示すように、第1テーブル記憶領域123のパッチテーブル(正常値)がOSにより参照されて当該パッチプログラムの呼び出しが可能になっている状態である。
The normal state is a state in which the OS can refer to the patch table in the first
以上の構成において、SE1は、外部端末2から送信されたパッチプログラム及びパッチテーブルをNVM12に書き込む前にパッチ状態を初期状態に設定する。これにより、以降の処理中に予期せぬノイズや電源断などで例えばパッチテーブルが破損してもSE1が動作不能に陥り復旧不可になることを回避することができる。パッチ状態が初期状態に設定された後、SE1は、パッチプログラムのパッチ記憶領域122への書き込み、且つ、パッチテーブルの第2テーブル記憶領域124への書き込みが完了した後に、パッチ状態を待機状態に設定する。そして、SE1のリセット後に外部端末2からコマンドが受信されたとき、パッチ状態が初期状態である場合に、SE1は、第1テーブル記憶領域123及び第2テーブル記憶領域124を初期化する。こうして、第1テーブル記憶領域123及び第2テーブル記憶領域124が初期化された場合に、パッチ状態は通常状態に設定される。
In the above configuration, SE1 sets the patch state to the initial state before writing the patch program and patch table transmitted from the
一方、SE1のリセット後に外部端末2からコマンドが受信されたとき、パッチ状態が待機状態である場合に、SE1は、第2テーブル記憶領域124から第1テーブル記憶領域123にパッチテーブルを書き込む(コピーする)。ここで、第2テーブル記憶領域124から第1テーブル記憶領域123にパッチテーブルが書き込まれる前に、パッチ状態は初期状態に設定されるとよい。これにより、以降の処理中に予期せぬノイズや電源断などで例えばパッチテーブルが破損してもSE1が動作不能に陥り復旧不可になることを回避することができる。こうして、第2テーブル記憶領域124から第1テーブル記憶領域123にパッチテーブルが書き込まれた場合に、パッチ状態は通常状態に設定される。
On the other hand, when a command is received from the
一方、SE1のリセット後に外部端末2からコマンドが受信されたとき、パッチ状態が通常状態である場合に、SE1は、パッチプログラム及びパッチテーブルを検証し、当該検証が成功した場合に、コマンドに応じた処理をアプリケーションに実行させる。なお、パッチ状態が通常状態である場合、パッチテーブルが破損している可能性は低いので、パッチプログラム及びパッチテーブルが検証されずに、コマンドに応じた処理が実行されてもよい。
On the other hand, when a command is received from the
なお、外部端末2から送信されたパッチプログラムがパッチ記憶領域122に書き込まれる際に(例えば、パッチプログラムの書き込みの直前または直後に)、SE1は、外部端末2から送信されたバージョンデータであって当該パッチプログラムのバージョンを示すバージョンデータをNVM12における所定の記憶領域(例えば、データ記憶領域125または第2テーブル記憶領域124)に書き込み、外部端末2からの要求に応じて、当該所定の記憶領域からバージョンデータを読み出して当該外部端末2へ送信するとよい。
When the patch program transmitted from the
[2.SE1の動作]
(2.1.パッチプログラム及びパッチテーブルのダウンロード時の動作)
次に、図5を参照して、パッチプログラム及びパッチテーブルのダウンロード時の動作について説明する。図5は、パッチプログラム及びパッチテーブルのダウンロード時におけるSE1と外部端末2とのやり取りの一例を示すシーケンス図である。図5において、外部端末2は、パッチプログラムを書き込むアプリケーションを選択するためのSELECTコマンドをSE1へ送信する(ステップS1)。SE1(OS)は、SELECTコマンドを受信すると、SELECTコマンドで指定されたアプリケーションを選択し(ステップS2)、正常終了(SW:9000)及びFCI(File Control Information)を含むレスポンスを外部端末2へ送信する(ステップS3)。
2. SE1 Operation
(2.1. Operation when downloading patch program and patch table)
Next, the operation when downloading the patch program and the patch table will be described with reference to Fig. 5. Fig. 5 is a sequence diagram showing an example of the exchange between the SE1 and the
次いで、外部端末2は、SE1からのレスポンスを受信すると、SE1との間で相互認証(ステップS4)を開始する。かかる相互認証が開始されると、外部端末2は、INITALIZE UPDATEコマンドをSE1へ送信する。SE1は、外部端末2からのINITALIZE UPDATEコマンドを受信すると、セッション鍵を生成し、認証用データを含むレスポンスを外部端末2へ送信する。外部端末2は、SE1からのレスポンスを受信すると、セッション鍵を生成し、SE1の正当性を検証する。そして、外部端末2は、SE1の正当性検証に成功すると、認証用データを含むEXTERNAL AUTHENTICATEコマンドをSE1へ送信する。SE1は、外部端末2からのEXTERNAL AUTHENTICATEコマンドを受信すると、外部端末2の正当性を検証する。そして、SE1は、外部端末2の正当性検証に成功すると、認証成功を示すレスポンスを外部端末2へ送信する。これにより、セキュアチャネルを確立するための相互認証が終了し、SE1と外部端末2との間のセキュアチャネルが確立する。セキュアチャネルの確立後、相互認証で生成されたセッション鍵を用いて、後述するように、外部端末2がSE1へ送信するコマンドが保護される。
Next, when the
次いで、外部端末2は、パッチ状態を設定させるためのSET STATUSコマンドをSE1へ送信する(ステップS5)。SE1は、SET STATUSコマンドを受信すると、パッチ状態を初期状態に設定し(ステップS6)、正常終了(SW:9000)を含むレスポンスを外部端末2へ送信する(ステップS7)。次いで、外部端末2は、SE1からのレスポンスを受信すると、パッチプログラムを含むSTORE DATAコマンドをSE1へ送信する(ステップS8)。SE1は、STORE DATAコマンドを受信すると、ステップS2で選択されたアプリケーションによりパッチプログラムをパッチ記憶領域122に書き込み(ステップS9)、正常終了(SW:9000)を含むレスポンスを外部端末2へ送信する(ステップS10)。なお、パッチプログラムのデータ長が1度に送信可能なデータ長を超える場合、当該パッチプログラムは分割され、分割されたパッチプログラムを含むSTORE DATAコマンドとそのレスポンスの送受信が複数回実施される。
Next, the
パッチプログラムの書き込みが完了し、外部端末2は、SE1からのレスポンスを受信すると、パッチテーブルを含むSTORE DATAコマンドをSE1へ送信する(ステップS11)。SE1は、STORE DATAコマンドを受信すると、ステップS2で選択されたアプリケーションによりパッチテーブルを第2テーブル記憶領域124に書き込み(ステップS12)、正常終了(SW:9000)を含むレスポンスを外部端末2へ送信する(ステップS13)。なお、パッチテーブルのデータ長が1度に送信可能なデータ長を超える場合、当該パッチテーブルは分割され、分割されたパッチテーブルを含むSTORE DATAコマンドとそのレスポンスの送受信が複数回実施される。
When writing of the patch program is complete and the
パッチテーブルの書き込みが完了し、外部端末2は、SE1からのレスポンスを受信すると、ステップS9でパッチ記憶領域122に書き込まれたパッチプログラムのバージョンを示すバージョンデータを含むSTORE DATAコマンドをSE1へ送信する(ステップS14)。SE1は、STORE DATAコマンドを受信すると、ステップS2で選択されたアプリケーションによりバージョンデータをデータ記憶領域125に書き込み(ステップS15)、正常終了(SW:9000)を含むレスポンスを外部端末2へ送信する(ステップS16)。ここで、データ記憶領域125に過去に書き込まれたバージョンデータが記憶されている場合、当該バージョンデータは後から受信された最新のバージョンデータにより上書きされる。これにより、新しいパッチプログラムがパッチ記憶領域122に書き込まれる度に、そのバージョンを示すバージョンデータがデータ記憶領域125に書き込まれる。なお、バージョンデータは、第2テーブル記憶領域124に書き込まれてもよい。
When writing of the patch table is completed and the
バージョンデータの書き込みが完了し、外部端末2は、SE1からのレスポンスを受信すると、パッチ状態を設定させるためのSET STATUSコマンドをSE1へ送信する(ステップS17)。SE1は、SET STATUSコマンドを受信すると、パッチ状態を待機状態に設定し(ステップS18)、正常終了(SW:9000)を含むレスポンスを外部端末2へ送信する(ステップS19)。なお、上述したように、この時点ではパッチプログラムは動作しない。
When writing of the version data is complete and the
(2.2.SE1のリセット時の動作)
次に、図6を参照して、SE1のリセット時の動作について説明する。図6は、SE1のリセット時におけるSE1(OS)の処理を示すフローチャートである。図6に示す処理は、外部端末2からリセットが受信された場合に開始される。図6に示す処理が開始されると、SE1は、初期応答情報(例えば、プロトコル形式及び通信速度など)を含むATR(Answer To Reset)を外部端末2へ送信する(ステップS21)。外部端末2は、SE1からのレスポンスを受信すると、所定のコマンドをSE1へ送信する。ここで受信されるコマンドは、リセット後の最初のコマンド(以下、「初回コマンド」という)であり、そのコマンドの種類は不問とする。そして、SE1は、外部端末2からの初回コマンドを受信すると(ステップS22)、ステップS23へ進む。
(2.2. SE1 Reset Operation)
Next, the operation of the SE1 at the time of resetting will be described with reference to FIG. 6. FIG. 6 is a flowchart showing the process of the SE1 (OS) at the time of resetting the SE1. The process shown in FIG. 6 is started when a reset is received from the
ステップS23では、SE1は、パッチ状態を判定する。パッチ状態が初期状態であると判定された場合(ステップS23:初期状態)、処理はステップS24へ進む。一方、パッチ状態が待機状態であると判定された場合(ステップS23:待機状態)、処理はステップS27へ進む。一方、パッチ状態が通常状態であると判定された場合(ステップS23:通常状態)、処理はステップS30へ進む。なお、ステップS23~S34の処理は、初回コマンドが受信された場合にのみ実行されればよく、リセット後、初回コマンドの後に受信されたコマンドの場合、ステップS23~S34の処理は実行されずに、当該受信されたコマンドに応じた処理が実行され、その処理の結果を示すレスポンスが外部端末2へ送信されるように構成すればよい。
In step S23, SE1 determines the patch state. If it is determined that the patch state is the initial state (step S23: initial state), the process proceeds to step S24. On the other hand, if it is determined that the patch state is the standby state (step S23: standby state), the process proceeds to step S27. On the other hand, if it is determined that the patch state is the normal state (step S23: normal state), the process proceeds to step S30. Note that the processes of steps S23 to S34 need only be executed when an initial command is received. If a command is received after the initial command after the reset, the processes of steps S23 to S34 are not executed, and instead, a process according to the received command is executed, and a response indicating the result of the process is sent to the
ステップS24では、SE1は、第1テーブル記憶領域123に初期値を書き込む。次いで、SE1は、第2テーブル記憶領域124に初期値を書き込む(ステップS25)。次いで、SE1は、パッチ状態を通常状態に設定し(ステップS26)、ステップS34へ進む。
In step S24, SE1 writes an initial value to the first
ステップS27では、SE1は、パッチ状態を初期状態に設定する。次いで、SE1は、第2テーブル記憶領域124から第1テーブル記憶領域123にパッチテーブルをコピーする(ステップS28)。なお、バージョンデータが第2テーブル記憶領域124に記憶されている場合、当該バージョンデータは、パッチテーブルとともに第1テーブル記憶領域123にコピーされる。次いで、SE1は、パッチ状態を通常状態に設定し(ステップS29)、ステップS34へ進む。
In step S27, SE1 sets the patch state to the initial state. Next, SE1 copies the patch table from the second
ステップS30では、SE1は、パッチ記憶領域122のパッチプログラム、及び第1テーブル記憶領域123のパッチテーブルの検証を行う。かかる検証では、例えばチェックサム等を用いてパッチプログラム及びパッチテーブルそれぞれの同一性が確認される。次いで、SE1は、ステップS30の検証が成功したか否かを判定する(ステップS31)。そして、検証成功であると判定された場合(ステップS31:YES)、ステップS34へ進む。一方、検証失敗であると判定された場合(ステップS31:NO)、処理はステップS32へ進む。
In step S30, SE1 verifies the patch program in the
ステップS32では、SE1は、第2テーブル記憶領域124から第1テーブル記憶領域123にパッチテーブルをコピーする。なお、バージョンデータが第2テーブル記憶領域124に記憶されている場合、当該バージョンデータは、パッチテーブルとともに第1テーブル記憶領域123にコピーされる。次いで、SE1は、復旧が成功したか否かを判定する(ステップS33)。例えば、第1テーブル記憶領域123にパッチテーブルを用いて正常にパッチプログラムを呼び出することができ、当該パッチプログラムを実行可能であれば復旧が成功したと判定される。そして、復旧が成功したと判定された場合(ステップS33:YES)、処理はステップS34へ進む。一方、復旧が成功していないと判定された場合(ステップS33:NO)、処理はステップS24へ移行する。
In step S32, SE1 copies the patch table from the second
ステップS34では、SE1は、初回コマンドに応じた処理を実行する。次いで、SE1は、ステップS34での処理の結果を示すレスポンスを外部端末2へ送信し(ステップS35)、処理を終了する。 In step S34, SE1 executes processing according to the initial command. Next, SE1 transmits a response indicating the result of the processing in step S34 to the external terminal 2 (step S35), and ends the processing.
(2.3.パッチプログラムのバージョン確認時の動作)
次に、図7を参照して、パッチプログラムのバージョン確認時の動作について説明する。図7は、パッチプログラムのバージョン確認時におけるSE1と外部端末2とのやり取りの一例を示すシーケンス図である。図7において、外部端末2は、定期的または不定期に、任意のアプリケーションを選択するためのSELECTコマンドをSE1へ送信する(ステップS41)。SE1(OS)は、SELECTコマンドを受信すると、SELECTコマンドで指定されたアプリケーションを選択し(ステップS42)、正常終了(SW:9000)及びFCIを含むレスポンスを外部端末2へ送信する(ステップS43)。
(2.3. Operation when checking patch program version)
Next, the operation when checking the version of a patch program will be described with reference to Fig. 7. Fig. 7 is a sequence diagram showing an example of the exchange between the SE1 and the
次いで、外部端末2は、SE1からのレスポンスを受信すると、バージョンデータを取得するためのGETコマンドをSE1へ送信する(ステップS44)。SE1は、GETコマンドを受信すると、GETコマンドにより特定されるバージョンデータをデータ記憶領域125または第1テーブル記憶領域123から読み出し(ステップS45)、正常終了(SW:9000)及び読み出されたバージョンデータを含むレスポンスを外部端末2へ送信する(ステップS46)。
Next, when the
次いで、外部端末2は、SE1からのレスポンスを受信すると、当該レスポンスに含まれるバージョンデータが示すバージョンの更新確認が実施される。例えば、外部端末2は、当該バージョンが更新されているか否かを判定する。そして、当該バージョンが更新されている(例えば、バージョンが最新である)と判定された場合、パッチプログラムの適用に成功したと判断される。一方、バージョンが更新されていないと判定された場合、図5に示す処理(シーケンス)が再実施される。これにより、パッチプログラムを最新の状態に保つことができる。
Next, when the
以上説明したように、上記実施形態によれば、SE1は、外部端末2から送信されたパッチプログラム及びパッチテーブルをNVM12に書き込む前にパッチ状態を初期状態に設定し、パッチプログラムのパッチ記憶領域122への書き込み、且つ、パッチテーブルの第2テーブル記憶領域124への書き込みが完了した後に、パッチ状態を待機状態に設定する。その後、SE1のリセット後に外部端末2から初回コマンドが受信されたとき、SE1は、パッチ状態が初期状態である場合に、第1テーブル記憶領域123及び第2テーブル記憶領域124を初期化する一方、SE1のリセット後に外部端末2からコマンドが受信されたとき、パッチ状態が待機状態である場合に、SE1は、第2テーブル記憶領域124から第1テーブル記憶領域123にパッチテーブルをコピーするように構成したので、パッチプログラムの書き込みが予期せぬノイズや電源断などで中断されても正常に復旧することができる。
As described above, according to the above embodiment, SE1 sets the patch state to the initial state before writing the patch program and patch table transmitted from the
1 SE
2 外部端末
10 CPU
11 RAM
12 NVM
13 I/O回路
121 プログラム記憶領域
122 パッチ記憶領域
123 第1テーブル記憶領域
124 第2テーブル記憶領域
125 データ記憶領域
1 SE
2
11 RAM
12 NVM
13 I/
Claims (7)
外部端末から送信された前記パッチプログラム及び前記パッチテーブルを前記メモリに書き込む前に前記パッチプログラム及び前記パッチテーブルの状態を初期状態に設定し、その後、前記パッチプログラムの前記第2記憶領域への書き込み、且つ、前記パッチテーブルの前記第4記憶領域への書き込みが完了した後に、前記状態を待機状態に設定する設定手段と、
前記電子情報記憶媒体のリセット後に外部端末からコマンドが受信されたとき、前記状態が初期状態である場合に前記第3記憶領域及び前記第4記憶領域を初期化する一方、前記状態が待機状態である場合に前記第4記憶領域から前記第3記憶領域に前記パッチテーブルを書き込む書き込み手段と、
を備えることを特徴とする電子情報記憶媒体。 An electronic information storage medium comprising a memory having a first storage area for storing an application program, a second storage area for storing a patch program to be applied to the application program, a third storage area for storing a patch table to be referenced when the patch program is called, and a fourth storage area for storing a patch table not to be referenced when the patch program is called,
a setting means for setting states of the patch program and the patch table to an initial state before writing the patch program and the patch table transmitted from an external terminal into the memory, and then setting the states to a standby state after writing of the patch program into the second storage area and writing of the patch table into the fourth storage area are completed;
a writing means for initializing the third storage area and the fourth storage area when the state is an initial state, and for writing the patch table from the fourth storage area to the third storage area when the state is a standby state, when a command is received from an external terminal after the electronic information storage medium is reset;
An electronic information storage medium comprising:
前記外部端末からの要求に応じて、前記所定の記憶領域からバージョンデータを読み出して当該外部端末へ送信する送信手段を更に備えることを特徴とする請求項1乃至4の何れか一項に記載の電子情報記憶媒体。 when the patch program is written into the second storage area, the writing means writes version data transmitted from the external terminal and indicating a version of the patch program into a predetermined storage area in the memory;
5. The electronic information storage medium according to claim 1, further comprising a transmission unit that reads out version data from the predetermined storage area and transmits the version data to the external terminal in response to a request from the external terminal.
外部端末から送信された前記パッチプログラム及び前記パッチテーブルを前記メモリに書き込む前に前記パッチプログラム及び前記パッチテーブルの状態を初期状態に設定し、その後、前記パッチプログラムの前記第2記憶領域への書き込み、且つ、前記パッチテーブルの前記第4記憶領域への書き込みが完了した後に、前記状態を待機状態に設定するステップと、
前記電子情報記憶媒体のリセット後に外部端末からコマンドが受信されたとき、前記状態が初期状態である場合に前記第3記憶領域及び前記第4記憶領域を初期化する一方、前記状態が待機状態である場合に前記第4記憶領域から前記第3記憶領域に前記パッチテーブルを書き込むステップと、
を含むことを特徴とするパッチプログラムの書き込み方法。 1. A patch program writing method executed by an electronic information storage medium having a memory having a first storage area for storing an application program, a second storage area for storing a patch program to be applied to the application program, a third storage area for storing a patch table to be referenced when the patch program is called, and a fourth storage area for storing a patch table not to be referenced when the patch program is called, the method comprising:
setting states of the patch program and the patch table to an initial state before writing the patch program and the patch table transmitted from an external terminal into the memory, and then setting the states to a standby state after writing of the patch program into the second storage area and writing of the patch table into the fourth storage area are completed;
when a command is received from an external terminal after resetting the electronic information storage medium, initializing the third storage area and the fourth storage area if the state is an initial state, and writing the patch table from the fourth storage area to the third storage area if the state is a standby state;
13. A method for writing a patch program, comprising:
外部端末から送信された前記パッチプログラム及び前記パッチテーブルを前記メモリに書き込む前に前記パッチプログラム及び前記パッチテーブルの状態を初期状態に設定し、その後、前記パッチプログラムの前記第2記憶領域への書き込み、且つ、前記パッチテーブルの前記第4記憶領域への書き込みが完了した後に、前記状態を待機状態に設定する設定手段と、
前記電子情報記憶媒体のリセット後に外部端末からコマンドが受信されたとき、前記状態が初期状態である場合に前記第3記憶領域及び前記第4記憶領域を初期化する一方、前記状態が待機状態である場合に前記第4記憶領域から前記第3記憶領域に前記パッチテーブルを書き込む書き込み手段として機能させることを特徴とするプログラム。 a computer included in an electronic information storage medium having a memory having a first storage area for storing an application program, a second storage area for storing a patch program to be applied to the application program, a third storage area for storing a patch table to be referenced when the patch program is called, and a fourth storage area for storing a patch table to be not referenced when the patch program is called,
a setting means for setting states of the patch program and the patch table to an initial state before writing the patch program and the patch table transmitted from an external terminal into the memory, and then setting the states to a standby state after writing of the patch program into the second storage area and writing of the patch table into the fourth storage area are completed;
A program characterized by functioning as a writing means that, when a command is received from an external terminal after resetting the electronic information storage medium, initializes the third memory area and the fourth memory area if the state is an initial state, and writes the patch table from the fourth memory area to the third memory area if the state is a standby state.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2021001439A JP7563181B2 (en) | 2021-01-07 | 2021-01-07 | Electronic information storage medium, patch program writing method, and program |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2021001439A JP7563181B2 (en) | 2021-01-07 | 2021-01-07 | Electronic information storage medium, patch program writing method, and program |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2022106442A JP2022106442A (en) | 2022-07-20 |
| JP7563181B2 true JP7563181B2 (en) | 2024-10-08 |
Family
ID=82457240
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2021001439A Active JP7563181B2 (en) | 2021-01-07 | 2021-01-07 | Electronic information storage medium, patch program writing method, and program |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP7563181B2 (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2002189609A (en) | 2000-12-20 | 2002-07-05 | Nec Corp | System and method for updating software adapted to accident |
| JP2010134644A (en) | 2008-12-03 | 2010-06-17 | Dainippon Printing Co Ltd | Ic card and patch execution method |
| JP2017138763A (en) | 2016-02-03 | 2017-08-10 | 大日本印刷株式会社 | Electronic information storage medium, data writing method, and data writing program |
| WO2018150820A1 (en) | 2017-02-17 | 2018-08-23 | 日立オートモティブシステムズ株式会社 | Information processing device |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPH02194434A (en) * | 1989-01-23 | 1990-08-01 | Mitsubishi Electric Corp | Electronic computer |
-
2021
- 2021-01-07 JP JP2021001439A patent/JP7563181B2/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2002189609A (en) | 2000-12-20 | 2002-07-05 | Nec Corp | System and method for updating software adapted to accident |
| JP2010134644A (en) | 2008-12-03 | 2010-06-17 | Dainippon Printing Co Ltd | Ic card and patch execution method |
| JP2017138763A (en) | 2016-02-03 | 2017-08-10 | 大日本印刷株式会社 | Electronic information storage medium, data writing method, and data writing program |
| WO2018150820A1 (en) | 2017-02-17 | 2018-08-23 | 日立オートモティブシステムズ株式会社 | Information processing device |
Also Published As
| Publication number | Publication date |
|---|---|
| JP2022106442A (en) | 2022-07-20 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP4896837B2 (en) | Portable electronic device and method for controlling portable electronic device | |
| EP1619579A2 (en) | Mobile electronic equipment | |
| JP3958243B2 (en) | IC card and its OS startup method | |
| WO2003083647A1 (en) | Communication terminal software updating method, communication terminal, and software updating method | |
| US7428992B2 (en) | Secure device and system for issuing IC cards | |
| JP7563181B2 (en) | Electronic information storage medium, patch program writing method, and program | |
| JP2023100087A (en) | Restoration processing method for electronic information recording medium | |
| JP2004192329A (en) | Program rewriting method and terminal device | |
| JP5754287B2 (en) | IC chip, processing method in IC chip, UIM, portable terminal, and processing program for IC chip | |
| JP5419123B2 (en) | Electronic device system and firmware update method | |
| JP2006099616A (en) | Portable electronic device and method for controlling portable electronic device | |
| JP2001154926A (en) | Storage method using flash memory and recording medium recording storage control program | |
| JP6946027B2 (en) | IC cards, portable electronic devices, programs, processing devices and processing systems | |
| JP5341947B2 (en) | IC card, control method of IC card, and control method of portable electronic device | |
| JP7420179B1 (en) | Electronic information storage medium, IC card, issuance processing method, and program | |
| US20240134651A1 (en) | Download method of program to settlement terminal and settlement terminal | |
| JP2021056815A (en) | Electronic information storage medium, data storage and restoration method, and program | |
| JP7559404B2 (en) | Electronic information storage medium, program addition method, and program | |
| JP7322923B2 (en) | Secure element, transaction control method and device | |
| JP7501808B2 (en) | IC chip | |
| JP2007141113A (en) | IC card with biometrics authentication function and IC card program | |
| JP5092370B2 (en) | Portable information recording medium and program thereof | |
| JP2004078294A (en) | Signal processing device | |
| JP2005228225A (en) | Memory card adapter | |
| JP2025091715A (en) | ELECTRONIC INFORMATION STORAGE MEDIUM, IC CHIP, IC CARD, ERROR CODE RESPONSE METHOD, AND PROGRAM |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20231128 |
|
| A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20240711 |
|
| 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: 20240827 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20240909 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 7563181 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |