JP5689050B2 - Portable recording medium, portable recording medium control method, and portable recording medium control program - Google Patents

Portable recording medium, portable recording medium control method, and portable recording medium control program Download PDF

Info

Publication number
JP5689050B2
JP5689050B2 JP2011256295A JP2011256295A JP5689050B2 JP 5689050 B2 JP5689050 B2 JP 5689050B2 JP 2011256295 A JP2011256295 A JP 2011256295A JP 2011256295 A JP2011256295 A JP 2011256295A JP 5689050 B2 JP5689050 B2 JP 5689050B2
Authority
JP
Japan
Prior art keywords
flag
recording medium
portable recording
predetermined command
memory
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2011256295A
Other languages
Japanese (ja)
Other versions
JP2013109714A (en
Inventor
英朗 山本
英朗 山本
泰弘 細田
泰弘 細田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP2011256295A priority Critical patent/JP5689050B2/en
Publication of JP2013109714A publication Critical patent/JP2013109714A/en
Application granted granted Critical
Publication of JP5689050B2 publication Critical patent/JP5689050B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、可搬記録媒体、可搬記録媒体の制御方法、及び可搬記録媒体の制御プログラムに関する。   The present invention relates to a portable recording medium, a portable recording medium control method, and a portable recording medium control program.

近年普及しているICカード等の可搬記録媒体に関しては、可搬記録媒体に格納されたデータの読み書きするためのコマンドが、国際標準規格及び業界標準規格で規定されている(例えば非特許文献1、非特許文献2及び非特許文献3)。   With respect to portable recording media such as IC cards that have become widespread in recent years, commands for reading and writing data stored in portable recording media are defined in international standards and industry standards (for example, non-patent documents). 1, Non-Patent Document 2 and Non-Patent Document 3).

ICカードシステム利用促進協議会、「日本工業規格準拠JICSAP 外部端子付きICカード仕様」、ICカードシステム利用促進協議会、平成10年7月IC card system usage promotion council, “Japanese Industrial Standards-compliant JICSAP IC card specifications with external terminals”, IC card system utilization promotion council, July 1998 日本規格協会、「JIS X6319−3 ICカード実装仕様−第3部:共通コマンド」、平成23年5月Japan Standards Association, "JIS X6319-3 IC Card Mounting Specifications-Part 3: Common Commands", May 2011 ISO/IEC、"Identification cards-Integrated circuit cards-Part 4: Organization, security and commands for interchange"、2005年1月ISO / IEC, "Identification cards-Integrated circuit cards-Part 4: Organization, security and commands for interchange", January 2005

しかしながら、従来、可搬記録媒体において、国際標準規格及び業界標準規格の記述だけでは、実装時にメーカ間によって解釈が分かれる実装依存の仕様がある。このため、異なるメーカ間の製品を混在させて運用するシステムにおいて、一方のメーカの製品の挙動が、他方のメーカの製品が期待した挙動とならない事象が発生する可能性がある。   However, conventionally, in portable recording media, there are implementation-dependent specifications in which interpretation differs among manufacturers at the time of implementation only by descriptions of international standards and industry standards. For this reason, in a system in which products of different manufacturers are mixed and operated, an event may occur in which the behavior of one manufacturer's product does not become the behavior expected by the other manufacturer's product.

例えば、Update Recordなど書込みコマンドでは、不揮発性メモリにレコード構造のファイルを書き込んでいき、レコード構造のファイルを格納する領域(以下、ブロックという。)の空きが無くなった場合のリーダライタへの応答動作について2通りの実装方法がある。ある実装では、レコード構造のファイルの書込みが正常に終了したので、正常終了と判断して、ステータスワード(以下SWという。)として9000hをカードリーダライタに応答する。もう一方の実装では、書込みは正常終了したが、ブロックの空きが無くなったことの警告を発するため、SWとして6381hをリーダライタに応答する。なおここでSW中の末尾のhは、当該数値が16進数であることを意味する。   For example, in a write command such as Update Record, a record structure file is written to the nonvolatile memory, and a response operation to the reader / writer when the area for storing the record structure file (hereinafter referred to as a block) runs out. There are two mounting methods for. In one implementation, since writing of the record structure file has been completed normally, it is determined as normal termination, and 9000h is returned to the card reader / writer as a status word (hereinafter referred to as SW). In the other implementation, the writing is normally completed, but a warning that the block is no longer empty is issued, so 6381h is returned to the reader / writer as SW. Here, h at the end of SW means that the numerical value is a hexadecimal number.

また例えば、PUT DATAコマンド実行時の挙動も実装により異なる。PUT DATAコマンドとは、Tag/Length/Valueの3つのフィールドからなる構造をもつ形式のデータオブジェクトを更新するためのコマンドである。可搬記録媒体がPUT DATAコマンドを受信した場合、一度書き込まれたデータオブジェクトを更新するか否かで、実装方法が2通りある。ある実装では、一度書き込まれたデータオブジェクトを更新することを許容し、SWとして9000hをリーダライタに応答する。もう一方の実装では、一度書き込まれたデータオブジェクトを更新することを許容せず、SWを6985hとして応答する。   Also, for example, the behavior when executing the PUT DATA command varies depending on the implementation. The PUT DATA command is a command for updating a data object having a structure having three fields of Tag / Length / Value. When the portable recording medium receives the PUT DATA command, there are two mounting methods depending on whether or not the data object once written is updated. In some implementations, once written data objects are allowed to be updated and 9000h is returned to the reader / writer as SW. The other implementation does not allow the data object that has been written once to be updated, and responds with SW as 6985h.

このため、同一規格に準拠する機能でありながら、コマンド体系や挙動が互いに異なる可搬記録媒体を混在させて運用する場合、リーダライタ等の可搬記録媒体の上位装置は、当該可搬記録媒体の各挙動に合わせて複数の処理機能を実装しなければならず、システム構築の点でコスト高になる。   For this reason, in the case of operating a mixture of portable recording media having different command systems and behaviors while having functions conforming to the same standard, the host device of the portable recording medium such as a reader / writer A plurality of processing functions must be implemented according to each behavior of the system, which increases the cost in terms of system construction.

したがって、上記のような問題点に鑑みてなされた本発明の目的は、所定のコマンドに対する可搬記録媒体の挙動を同一にし、リーダライタ等の上位装置が可搬記録媒体の挙動に合わせて複数の処理機能を実装する必要が無く、互換性の高い可搬記録媒体、可搬記録媒体の制御方法、及び可搬記録媒体の制御プログラムを提供することにある。   Accordingly, an object of the present invention made in view of the above problems is to make the behavior of a portable recording medium the same with respect to a predetermined command, and a plurality of host devices such as reader / writers can be adapted to the behavior of the portable recording medium. It is an object to provide a highly compatible portable recording medium, a portable recording medium control method, and a portable recording medium control program.

上記課題を解決するために本発明に係る可搬記録媒体は、
定のコマンドに対応する応答を指定するフラグをデータ構造に含む該所定のコマンドをリーダライタから受信する通信インタフェースと、
前記フラグを格納するメモリと、
前記メモリに格納された前記フラグを解釈し、前記リーダライタに前記所定のコマンドに対応する応答をする演算装置と、
を有することを特徴とする。
また本発明に係る可搬記録媒体の制御方法は、
所定のコマンド及び該所定のコマンドに対応する応答を指定するフラグをリーダライタから受信する通信インタフェースと、
前記フラグを格納するメモリと、
前記メモリに格納された前記フラグを解釈し、前記リーダライタに前記所定のコマンドに対応する応答をする演算装置と、
を有し、
前記メモリは、前記所定のコマンドを実行した結果に関する複数の情報を格納し、
前記フラグは、前記所定のコマンドを実行した結果に関する前記複数の情報に各々対応する複数の応答の優先順位を指定し、
前記演算装置は、前記フラグにより指定された前記優先順位に基づき、前記リーダライタに前記所定のコマンドを実行した結果に関する情報に対応する応答をすることを特徴とする。
In order to solve the above problems, a portable recording medium according to the present invention provides:
A communication interface for receiving said predetermined command from the reader-writer includes a flag for designating a response corresponding to a Jo Tokoro commands in the data structure,
A memory for storing the flag;
An arithmetic unit that interprets the flag stored in the memory and responds to the reader / writer in response to the predetermined command;
It is characterized by having.
The control method of the portable recording medium according to the present invention includes:
A communication interface for receiving from the reader / writer a flag designating a predetermined command and a response corresponding to the predetermined command;
A memory for storing the flag;
An arithmetic unit that interprets the flag stored in the memory and responds to the reader / writer in response to the predetermined command;
Have
The memory stores a plurality of pieces of information related to a result of executing the predetermined command,
The flag specifies the priority order of a plurality of responses respectively corresponding to the plurality of information related to a result of executing the predetermined command;
The arithmetic device makes a response corresponding to information related to a result of executing the predetermined command to the reader / writer based on the priority specified by the flag.

また本発明に係る可搬記録媒体の制御方法は、
定のコマンドに対応する応答を指定するフラグをデータ構造に含む該所定のコマンドをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を含むことを特徴とする。
また本発明に係る可搬記録媒体の制御方法は、
所定のコマンド及び該所定のコマンドへの応答を指定するフラグをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を含み、
前記メモリに格納するステップは、前記所定のコマンドを実行した結果に関する複数の情報を前記メモリに格納し、
前記フラグは、前記所定のコマンドを実行した結果に関する前記複数の情報に各々対応する複数の応答の優先順位を指定し、
前記応答をするステップは、前記フラグにより指定された前記優先順位に基づき、前記リーダライタに前記所定のコマンドを実行した結果に関する情報に対応する応答をすることを特徴とする。
The control method of the portable recording medium according to the present invention includes:
Receiving said predetermined command from the reader-writer includes a flag for designating a response corresponding to a Jo Tokoro commands in the data structure,
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
It is characterized by including.
The control method of the portable recording medium according to the present invention includes:
Receiving a flag designating a predetermined command and a response to the predetermined command from the reader / writer;
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
Including
The step of storing in the memory stores a plurality of pieces of information related to a result of executing the predetermined command in the memory,
The flag specifies the priority order of a plurality of responses respectively corresponding to the plurality of information related to a result of executing the predetermined command;
The step of making a response is characterized by making a response corresponding to information related to a result of executing the predetermined command to the reader / writer based on the priority order designated by the flag.

また本発明に係る可搬記録媒体の制御プログラムは、
可搬記録媒体として動作するコンピュータに、
定のコマンドに対応する応答を指定するフラグをデータ構造に含む該所定のコマンドをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を実行させることを特徴とする。
また本発明に係る可搬記録媒体の制御プログラムは、
可搬記録媒体として動作するコンピュータに、
所定のコマンド及び該所定のコマンドへの応答を指定するフラグをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を実行させ、
前記メモリに格納するステップは、前記所定のコマンドを実行した結果に関する複数の情報を前記メモリに格納し、
前記フラグは、前記所定のコマンドを実行した結果に関する前記複数の情報に各々対応する複数の応答の優先順位を指定し、
前記応答をするステップは、前記フラグにより指定された前記優先順位に基づき、前記リーダライタに前記所定のコマンドを実行した結果に関する情報に対応する応答をすることを特徴とする。
A control program for a portable recording medium according to the present invention includes:
To a computer that operates as a portable recording medium,
Receiving said predetermined command from the reader-writer includes a flag for designating a response corresponding to a Jo Tokoro commands in the data structure,
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
Is executed.
A control program for a portable recording medium according to the present invention includes:
To a computer that operates as a portable recording medium,
Receiving a flag designating a predetermined command and a response to the predetermined command from the reader / writer;
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
And execute
The step of storing in the memory stores a plurality of pieces of information related to a result of executing the predetermined command in the memory,
The flag specifies the priority order of a plurality of responses respectively corresponding to the plurality of information related to a result of executing the predetermined command;
The step of making a response is characterized by making a response corresponding to information related to a result of executing the predetermined command to the reader / writer based on the priority order designated by the flag.

本発明における可搬記録媒体、可搬記録媒体の制御方法、及び可搬記録媒体の制御プログラムによれば、所定のコマンドに対する可搬記録媒体の挙動を同一にし、リーダライタ等の上位装置が可搬記録媒体の挙動に合わせて複数の処理機能を実装する必要が無く、高い互換性を確保することができる。   According to the portable recording medium, the portable recording medium control method, and the portable recording medium control program of the present invention, the behavior of the portable recording medium with respect to a predetermined command is made the same, and a host device such as a reader / writer is possible. It is not necessary to implement a plurality of processing functions in accordance with the behavior of the portable recording medium, and high compatibility can be ensured.

本発明の実施の形態1に係る可搬記録媒体1の構成図である。It is a block diagram of the portable recording medium 1 which concerns on Embodiment 1 of this invention. 本発明の実施の形態1に係る可搬記録媒体1のソフトウェア、データ、及びハードウェアの概念図である。It is a conceptual diagram of the software of the portable recording medium 1 which concerns on Embodiment 1 of this invention, data, and hardware. 本発明の実施の形態1に係る可搬記録媒体1が、リーダライタから受信するCREATEコマンドのデータ構造を示す図である。It is a figure which shows the data structure of the CREATE command which the portable recording medium 1 which concerns on Embodiment 1 of this invention receives from a reader / writer. CREATEコマンドのデータ構造のうち、P1の内容を詳細に示す図である。It is a figure which shows the content of P1 among the data structures of a CREATE command in detail. P1に基づきファイル構造を決定する動作を示すフローチャートである。It is a flowchart which shows the operation | movement which determines a file structure based on P1. CREATEコマンドのデータ構造のうち、データ部の内容を詳細に示す図である。It is a figure which shows the content of the data part in detail among the data structures of a CREATE command. 本発明の実施の形態1に係るフラグを不揮発性メモリ16に格納する際の動作を示すフローチャートである。4 is a flowchart showing an operation when a flag according to Embodiment 1 of the present invention is stored in a nonvolatile memory 16. フラグ及びプログラムが格納された不揮発性メモリ16の概念図である。It is a conceptual diagram of the non-volatile memory 16 in which a flag and a program are stored. メモリ管理情報の例である。It is an example of memory management information. 更新後のメモリ管理情報の例である。It is an example of the memory management information after an update. 本発明の実施の形態1に係る可搬記録媒体1の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the portable recording medium 1 which concerns on Embodiment 1 of this invention. 本発明の実施の形態2に係るフラグを不揮発性メモリ16に格納する際の動作を示すフローチャートである。7 is a flowchart showing an operation when a flag according to Embodiment 2 of the present invention is stored in a nonvolatile memory 16. 本発明の実施の形態2に係る可搬記録媒体1の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the portable recording medium 1 which concerns on Embodiment 2 of this invention. 本発明の実施の形態3に係る可搬記録媒体1が、リーダライタから受信するKEY REPLACEコマンドのデータ構造を示す図である。It is a figure which shows the data structure of the KEY REPLACE command which the portable recording medium 1 which concerns on Embodiment 3 of this invention receives from a reader / writer. 鍵置き換えに係る複数のエラー事象が発生した場合の該複数のエラー事象の優先順位とフラグとの関係を示すテーブルである。It is a table which shows the relationship between the priority and flag of a plurality of error events when a plurality of error events concerning key replacement occur. 本発明の実施の形態3に係るフラグを不揮発性メモリ16に格納する際の動作を示すフローチャートである。10 is a flowchart showing an operation when a flag according to Embodiment 3 of the present invention is stored in the nonvolatile memory 16. 本発明の実施の形態3に係る可搬記録媒体1の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the portable recording medium 1 which concerns on Embodiment 3 of this invention.

以下、本発明の実施の形態について説明する。   Embodiments of the present invention will be described below.

(実施の形態1)
図1は本発明の実施の形態1に係る可搬記録媒体1のブロック図である。本発明の実施の形態に係る可搬記録媒体1は、非接触通信インタフェース11と、接触通信インタフェース12と、CPU13と、RAM14と、ROM15と、不揮発性メモリ16と、電源回路(図示せず)とを備える。可搬記録媒体1は好ましくはICカードであるがこれに限られない。可搬記録媒体1は、好ましくは非接触通信インタフェース11と、接触通信インタフェース12との両方を備えるが、どちらか一方のみを備える構成でもよい。
(Embodiment 1)
FIG. 1 is a block diagram of a portable recording medium 1 according to Embodiment 1 of the present invention. A portable recording medium 1 according to an embodiment of the present invention includes a non-contact communication interface 11, a contact communication interface 12, a CPU 13, a RAM 14, a ROM 15, a nonvolatile memory 16, and a power supply circuit (not shown). With. The portable recording medium 1 is preferably an IC card, but is not limited thereto. The portable recording medium 1 preferably includes both the non-contact communication interface 11 and the contact communication interface 12, but may be configured to include only one of them.

非接触通信インタフェース11は、無線によりリーダライタとの通信を行う通信インタフェースである。非接触通信インタフェース11は、リーダライタから所定のコマンド及び該所定のコマンドに対応する応答を指定するフラグを受信する。本実施の形態においては所定のコマンドはCREATEコマンド及び書込みコマンドである。CREATEコマンドとは、可搬記録媒体1上でファイルを生成するためのコマンドである。書込みコマンドとは、不揮発性メモリ16に、レコード構造のファイル等を書き込むためのコマンドであり、例えばUpdate Record等であるがこれに限られない。   The non-contact communication interface 11 is a communication interface that communicates with a reader / writer wirelessly. The non-contact communication interface 11 receives a flag designating a predetermined command and a response corresponding to the predetermined command from the reader / writer. In the present embodiment, the predetermined commands are a CREATE command and a write command. The CREATE command is a command for generating a file on the portable recording medium 1. The write command is a command for writing a record structure file or the like in the nonvolatile memory 16, and is, for example, Update Record, but is not limited thereto.

接触通信インタフェース12は、リーダライタと電気的接点を介して通信を行う通信インタフェースである。接触通信インタフェース12は、カードリーダライタから所定のコマンド及び該所定のコマンドに対応する応答を指定するフラグを受信する。   The contact communication interface 12 is a communication interface that performs communication with the reader / writer via an electrical contact. The contact communication interface 12 receives a flag designating a predetermined command and a response corresponding to the predetermined command from the card reader / writer.

CPU13は、非接触通信インタフェース11又は接触通信インタフェース12が受信した所定のコマンドに対応する応答を指定するフラグを、後述する不揮発性メモリ16に格納する。また、CPU13は、非接触通信インタフェース11又は接触通信インタフェース12が受信した所定のコマンドを解釈し、該コマンドに対応するプログラムを実行する。そしてCPU13は、不揮発性メモリ16に格納されたフラグを解釈し、該所定のコマンドに対応する応答、すなわち所定のSWをリーダライタに応答する。また、CPU13は演算結果をメモリに格納する機能を有する。なおここではCPU13は、中央演算処理装置(Central Processor Unit)として説明するがこれに限られず、如何なる演算装置であってもよい。   The CPU 13 stores a flag designating a response corresponding to a predetermined command received by the non-contact communication interface 11 or the contact communication interface 12 in the nonvolatile memory 16 described later. The CPU 13 interprets a predetermined command received by the non-contact communication interface 11 or the contact communication interface 12 and executes a program corresponding to the command. Then, the CPU 13 interprets the flag stored in the nonvolatile memory 16 and responds to the reader / writer with a response corresponding to the predetermined command, that is, a predetermined SW. The CPU 13 has a function of storing the calculation result in a memory. Here, the CPU 13 is described as a central processor unit, but is not limited to this, and may be any arithmetic device.

RAM14は、ランダムアクセスメモリであり、CPU13が実行する各種プログラムを格納したり、演算結果を一時的に保持したりする機能を有する。   The RAM 14 is a random access memory, and has a function of storing various programs executed by the CPU 13 and temporarily holding calculation results.

ROM15は、CPU13が可搬記録媒体1の制御をするためのOS(オペレーティングシステム)を格納する。   The ROM 15 stores an OS (operating system) for the CPU 13 to control the portable recording medium 1.

不揮発性メモリ16は、非接触通信インタフェース11又は接触通信インタフェース12が受信したフラグを、CPU13の処理に基づき格納するメモリである。また、CPU13が所定のコマンドに対して処理を行うためのプログラム及び、データファイルが格納される。   The non-volatile memory 16 is a memory that stores the flag received by the non-contact communication interface 11 or the contact communication interface 12 based on the processing of the CPU 13. In addition, a program for the CPU 13 to process a predetermined command and a data file are stored.

図2は、本発明の実施の形態1に係る可搬記録媒体1のハードウェア24並びにROM15及び不揮発性メモリ16に備えられるプログラム及びデータの格納領域を示す概念図である。図2に示すように、ROM15には、OSが格納されるOS格納領域21が備えられる。該OS格納領域21に格納されたOSは、リーダライタから送信されるコマンドの処理機能、ファイル管理機能、カードアプリケーション及びライブラリの管理機能、アプリケーションのダウンロード機能、暗号処理機能等の、可搬記録媒体1において必要な各種基本的なソフトウェアを備える。一方、不揮発性メモリ16には、プログラム格納領域22及びデータファイル格納領域23が備えられ、各種プログラム及びデータファイルが格納される。コマンドインタフェースの下層には、ICチップ、暗号コプロセッサ25を備えるハードウェア24が備えられる。   FIG. 2 is a conceptual diagram showing program and data storage areas provided in the hardware 24 of the portable recording medium 1 and the ROM 15 and the nonvolatile memory 16 according to the first embodiment of the present invention. As shown in FIG. 2, the ROM 15 includes an OS storage area 21 in which the OS is stored. The OS stored in the OS storage area 21 is a portable recording medium such as a processing function of a command transmitted from a reader / writer, a file management function, a card application and library management function, an application download function, and an encryption processing function. 1 with various basic software necessary. On the other hand, the nonvolatile memory 16 includes a program storage area 22 and a data file storage area 23, and stores various programs and data files. A hardware 24 including an IC chip and a cryptographic coprocessor 25 is provided below the command interface.

図3は、可搬記録媒体1が、リーダライタから受信するコマンドのひとつであるCREATEコマンドのデータ構造を示す図である。図3に示すように、CREATEコマンドは、CLAと、INSと、P1と、P2と、Lcと、Tagと、Lenと、データ部とを備える。   FIG. 3 is a diagram illustrating a data structure of a CREATE command that is one of commands received by the portable recording medium 1 from the reader / writer. As shown in FIG. 3, the CREATE command includes CLA, INS, P1, P2, Lc, Tag, Len, and a data part.

CLAとは、セキュアメッセージングの有無等を示すクラスバイトであり、例えば9Xhである。データ長は1バイトである。INSとは、可搬記録媒体1の機能を指示するための1バイトの情報であり、値がE0hである場合は、CREATEコマンドを示し、可搬記録媒体1内に格納するファイルの情報を生成する。   CLA is a class byte indicating the presence / absence of secure messaging, for example, 9Xh. The data length is 1 byte. INS is 1-byte information for instructing the function of the portable recording medium 1. When the value is E0h, it indicates a CREATE command, and information on a file to be stored in the portable recording medium 1 is generated. To do.

P1は、1バイトの第一パラメータであり、ファイル記述バイトを示す。P1の値を基に、ファイル形式やファイル構造を決定する。P2は、1バイトの第二パラメータであるが、CREATEコマンドでは使用せず、固定値00hである。Lcは、後続のTag、Len及びデータ部の長さを示す。Lenは1バイト又は3バイトである。Tagは、FCPテンプレートを示す。なおFCPとは、ファイル制御パラメータ(File Control Parameter)であり、論理的属性、構造的属性、及びセキュリティ属性などのファイル制御用パラメータの集合である。Tagは1バイトであり、例えば“62”である。Lenは、BER(Basic Encoding Rules)−TLV(Tag・Length・Value)形式で記述される。Lenは1バイト又は3バイトである。データ部は、FCP情報に相当する部分であり、データ長は可変である。   P1 is a 1-byte first parameter indicating a file description byte. The file format and file structure are determined based on the value of P1. P2 is a 1-byte second parameter, but is not used in the CREATE command and has a fixed value of 00h. Lc indicates the length of the subsequent Tag, Len, and data portion. Len is 1 byte or 3 bytes. Tag indicates an FCP template. The FCP is a file control parameter (File Control Parameter), and is a set of file control parameters such as a logical attribute, a structural attribute, and a security attribute. Tag is 1 byte, for example, “62”. Len is described in BER (Basic Encoding Rules) -TLV (Tag, Length, Value) format. Len is 1 byte or 3 bytes. The data part is a part corresponding to the FCP information, and the data length is variable.

図4は、CREATEコマンドのデータ構造のうち、P1の内容を詳細に示すテーブルである。P1は、1バイト(8ビット)から構成され、図4に示すように右側のビットから左側のビットまで順番に、b1〜b8として定義されている。可搬記録媒体1のCPU13は、P1を解釈して、生成するファイル構造を決定する。   FIG. 4 is a table showing the details of P1 in the data structure of the CREATE command. P1 is composed of 1 byte (8 bits) and is defined as b1 to b8 in order from the right bit to the left bit as shown in FIG. The CPU 13 of the portable recording medium 1 interprets P1 and determines a file structure to be generated.

図5は、可搬記録媒体1のCPU13が、P1を解釈して、生成するファイルの種類(形式)であるファイル構造を決定する処理フローを示す。CPU13は、当該処理フローにより決定したファイル構造のファイルを可搬記録媒体1の不揮発性メモリ16上に格納する。以下、当該フローを詳細に説明する。   FIG. 5 shows a processing flow in which the CPU 13 of the portable recording medium 1 interprets P1 and determines the file structure that is the type (format) of the file to be generated. The CPU 13 stores the file having the file structure determined by the processing flow on the nonvolatile memory 16 of the portable recording medium 1. Hereinafter, the flow will be described in detail.

まず可搬記録媒体1は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタからコマンドを受信する(ステップS1)。続いて可搬記録媒体1のCPU13は、受信したコマンドの各部の内容を解釈し、INSの値がE0であるか否かを判定する(ステップS2)。INSの値がE0hでなければステップS3に進む。INSの値がE0hであればステップS4に進む。   First, the portable recording medium 1 receives a command from the reader / writer via the non-contact communication interface 11 or the contact communication interface 12 (step S1). Subsequently, the CPU 13 of the portable recording medium 1 interprets the contents of each part of the received command and determines whether or not the value of INS is E0 (step S2). If the value of INS is not E0h, the process proceeds to step S3. If the value of INS is E0h, the process proceeds to step S4.

INSの値がE0hでない場合、CPU13は、当該コマンドはCREATEコマンドでないと判定し、他の機能を実行する(ステップS3)。   If the value of INS is not E0h, the CPU 13 determines that the command is not a CREATE command and executes another function (step S3).

一方INSの値がE0hである場合、CPU13は、当該コマンドはCREATEコマンドであると判定し、コマンドからP1を読み出す(ステップS4)。   On the other hand, if the value of INS is E0h, the CPU 13 determines that the command is a CREATE command, and reads P1 from the command (step S4).

続いてCPU13は、読み出したP1のうち、b8の値が0bか否かを判定する(ステップS5)。b8の値が0bでない場合ステップS6に進む。b8の値が0bであればステップS7に進む。   Subsequently, the CPU 13 determines whether or not the value of b8 is 0b in the read P1 (step S5). If the value of b8 is not 0b, the process proceeds to step S6. If the value of b8 is 0b, the process proceeds to step S7.

b8の値が0bでない場合、CPU13は、生成するファイル構造は、独自ファイルであると判断し、当該独自ファイルを生成する(ステップS6)。その後、処理が終了する。   When the value of b8 is not 0b, the CPU 13 determines that the file structure to be generated is a unique file, and generates the unique file (step S6). Thereafter, the process ends.

一方、b8の値が0bである場合、CPU13は、生成するファイル構造を、他のビットb1〜b6に基づいて決定する。この場合CPU13は、b6、b5、及びb4の値が何であるかを判定する(ステップS7)。ここでは、b6、b5、及びb4のビットを3つ並べた3桁の2進数をb6b5b4と表記する。   On the other hand, when the value of b8 is 0b, the CPU 13 determines the file structure to be generated based on the other bits b1 to b6. In this case, the CPU 13 determines what the values of b6, b5, and b4 are (step S7). Here, a three-digit binary number in which three bits b6, b5, and b4 are arranged is represented as b6b5b4.

b6b5b4の値が000bである場合、CPU13は、生成するファイル構造がWEFであると判断する(ステップS8)。なおここで000bにおける末尾のbは、2進数を意味する。   When the value of b6b5b4 is 000b, the CPU 13 determines that the file structure to be generated is WEF (step S8). Here, the last b in 000b means a binary number.

他方、b6b5b4の値が001bである場合、CPU13は、生成するファイル構造がIEFであると判断する(ステップS9)。またb6b5b4の値が010bである場合、CPU13は、生成するファイル構造がデータオブジェクトWEF(Simple−TLV)であると判断する(ステップS10)。またb6b5b4の値が011bである場合、CPU13は、生成するファイル構造がデータオブジェクトWEF(BER−TLV)であると判断する(ステップS11)。またb6b5b4の値が111bである場合、CPU13は、生成するファイル構造がDFであると判断する(ステップS12)。b6b5b4の値がこれら以外の場合、P1の値が異常であるとして、CPU13はエラーと判断し(ステップS13)、SWとしてエラーをリーダライタに応答する(ステップS14)。すなわちCPU13は、規定されていないファイル形式、ファイル構造を示す値を読み出した場合は、P1に係るエラーと判断する。   On the other hand, if the value of b6b5b4 is 001b, the CPU 13 determines that the file structure to be generated is IEF (step S9). When the value of b6b5b4 is 010b, the CPU 13 determines that the file structure to be generated is the data object WEF (Simple-TLV) (step S10). If the value of b6b5b4 is 011b, the CPU 13 determines that the file structure to be generated is the data object WEF (BER-TLV) (step S11). If the value of b6b5b4 is 111b, the CPU 13 determines that the file structure to be generated is DF (step S12). If the values of b6b5b4 are other than these, the CPU 13 determines that the value of P1 is abnormal and determines that there is an error (step S13), and responds the error to the reader / writer as SW (step S14). That is, if the CPU 13 reads a value indicating an undefined file format or file structure, it determines that the error is related to P1.

b6b5b4の値が000b、001b、010b、又は011bの場合は、続いてステップS14に進む。該ステップにおいてCPU13は、b3b2b1の値が何であるかを判定する(ステップS15)。   When the value of b6b5b4 is 000b, 001b, 010b, or 011b, the process proceeds to step S14. In this step, the CPU 13 determines what the value of b3b2b1 is (step S15).

b3b2b1の値が000bである場合、CPU13は、ファイル構造の詳細として、透過構造であると判断し、当該透過構造ファイルを生成する(ステップS16)。また、b3b2b1の値が001bである場合、CPU13は、ファイル構造の詳細として、固定長順編成(BER−TLV)であると判断し、当該固定長順編成ファイルを生成する(ステップS17)。また、b3b2b1の値が011bである場合、CPU13は、ファイル構造の詳細として、固定長順編成(Simple−TLV)であると判断し、当該固定長順編成ファイルを生成する(ステップS18)。また、b3b2b1の値が100bである場合、CPU13は、ファイル構造の詳細として、可変長順編成(BER)であると判断し、当該可変長順編成ファイルを生成する(ステップS19)。また、b3b2b1の値が101bである場合、CPU13は、ファイル構造の詳細として、可変長順編成(Simple−TLV)であると判断し、当該可変長順編成ファイルを生成する(ステップS20)。また、b3b2b1の値が110bである場合、CPU13は、ファイル構造の詳細として、固定長循環順編成(BER−TLV)であると判断し、当該固定長循環順編成ファイルを生成する(ステップS21)。また、b3b2b1の値が111bである場合、CPU13は、ファイル構造の詳細として、固定長循環順編成(Simple−TLV)であると判断し、当該固定長循環順編成ファイルを生成する(ステップS22)。b3b2b1の値がこれら以外の場合、P1の値が異常であるとして、CPU13はエラーと判断し(ステップS23)、当該エラーを示すSWを、リーダライタに応答する(ステップS24)。   If the value of b3b2b1 is 000b, the CPU 13 determines that the file structure is a transparent structure and generates the transparent structure file (step S16). On the other hand, when the value of b3b2b1 is 001b, the CPU 13 determines that the fixed-length sequential organization (BER-TLV) is used as the details of the file structure, and generates the fixed-length sequential organization file (step S17). On the other hand, when the value of b3b2b1 is 011b, the CPU 13 determines that the fixed-length sequential organization (Simple-TLV) is used as the details of the file structure, and generates the fixed-length sequential organization file (step S18). If the value of b3b2b1 is 100b, the CPU 13 determines that the variable length sequential organization (BER) is the file structure details, and generates the variable length sequential organization file (step S19). If the value of b3b2b1 is 101b, the CPU 13 determines that the variable length sequential organization (Simple-TLV) is the file structure details, and generates the variable length sequential organization file (step S20). On the other hand, if the value of b3b2b1 is 110b, the CPU 13 determines that the file structure details are fixed-length circulation sequential organization (BER-TLV), and generates the fixed-length circulation sequential organization file (step S21). . On the other hand, when the value of b3b2b1 is 111b, the CPU 13 determines that the file structure details are fixed-length circulation sequential organization (Simple-TLV), and generates the fixed-length circulation sequential organization file (step S22). . If the value of b3b2b1 is other than these, the CPU 13 determines that the value of P1 is abnormal and determines that there is an error (step S23), and responds the SW indicating the error to the reader / writer (step S24).

なお、ファイル構造がデータオブジェクトWEF(Simple−TLV)である場合には、ファイル構造の詳細として、透過構造、固定長順編成(Simple−TLV)、可変長順編成(Simple−TLV)、又は固定長循環順編成(Simple−TLV)の4パターンのみをとる。また、ファイル構造がデータオブジェクトWEF(BER−TLV)である場合には、ファイル構造の詳細として、透過構造、固定長順編成(BER)、可変長順編成(BER−TLV)、又は固定長循環順編成(BER−TLV)の4パターンのみをとる。   When the file structure is the data object WEF (Simple-TLV), the details of the file structure include a transparent structure, fixed-length sequential organization (Simple-TLV), variable-length sequential organization (Simple-TLV), or fixed. Only 4 patterns of long circulation sequential organization (Simple-TLV) are taken. When the file structure is a data object WEF (BER-TLV), the details of the file structure include a transparent structure, fixed-length sequential organization (BER), variable-length sequential organization (BER-TLV), or fixed-length circulation. Only 4 patterns of sequential organization (BER-TLV) are taken.

図6は、可搬記録媒体1が、リーダライタから受信するCREATEコマンドのデータ構造のうち、データ部の内容を詳細に示す図である。図6に示すように、データ部は、EFIDと、セキュリティ属性と、セキュアメッセージング属性と、レコード構造又はデータオブジェクト構造と、フラグとを備える。EFIDには、ファイルIDが格納され、データ長は2バイトである。セキュリティ属性には、セキュリティの属性を示すデータを設定する情報が格納され、データ長は12バイトである。セキュアメッセージング属性には、セキュアメッセージングの属性を示すデータを設定する情報が格納され、データ長は1バイトである。形式指定情報には、レコード構造又はデータオブジェクト構造の形式を指定する情報が格納され、データ長は4バイトである。フラグには、書込みによりブロックの空きが無くなった場合、警告をするか否かを示すデータが格納され、データ長は1バイトである。   FIG. 6 is a diagram showing in detail the contents of the data portion of the data structure of the CREATE command received by the portable recording medium 1 from the reader / writer. As shown in FIG. 6, the data part includes an EFID, a security attribute, a secure messaging attribute, a record structure or data object structure, and a flag. The EFID stores a file ID and has a data length of 2 bytes. The security attribute stores information for setting data indicating the security attribute and has a data length of 12 bytes. The secure messaging attribute stores information for setting data indicating the attribute of secure messaging, and the data length is 1 byte. The format designation information stores information for designating the format of the record structure or data object structure, and the data length is 4 bytes. The flag stores data indicating whether or not to warn when there is no free block due to writing, and the data length is 1 byte.

ここでフラグとは、可搬記録媒体1が、リーダライタから受信したコマンドに対し、カードリーダライタに応答するSWを指定するデータである。フラグの値は、カードリーダライタ及びその上位装置に係るアプリケーションにより一意に定められる。図6におけるフラグは、書込みコマンドを受信した場合でかつ書込みによりブロックの空きが無くなった場合に警告するか否かを示すフラグである。フラグが00bの場合、可搬記録媒体1は、SWを9000hとして応答する。すなわちフラグが00bの場合には、可搬記録媒体1は、リーダライタに警告しない。一方、フラグが01bの場合、可搬記録媒体1は、SWと6381hとして応答する。すなわちフラグが01bの場合には可搬記録媒体1はリーダライタに警告する。   Here, the flag is data that designates an SW that responds to the card reader / writer in response to a command received by the portable recording medium 1 from the reader / writer. The value of the flag is uniquely determined by the application related to the card reader / writer and its host device. The flag in FIG. 6 is a flag indicating whether or not to warn when a write command is received and when there is no block free due to writing. When the flag is 00b, the portable recording medium 1 responds with SW set to 9000h. That is, when the flag is 00b, the portable recording medium 1 does not warn the reader / writer. On the other hand, when the flag is 01b, the portable recording medium 1 responds as SW and 6381h. That is, when the flag is 01b, the portable recording medium 1 warns the reader / writer.

図7は、CPU13が、CREATEコマンドにおけるフラグを不揮発性メモリ16に格納する際の動作を示すフローチャートである。以下詳細に当該フローチャートを説明する。   FIG. 7 is a flowchart showing the operation when the CPU 13 stores the flag in the CREATE command in the nonvolatile memory 16. The flowchart will be described in detail below.

まず可搬記録媒体1のCPU13は、CREATEコマンドにおけるデータ部のうち、“形式指定情報”の値を読み出す(ステップS101)。続いて可搬記録媒体1のCPU13は、CREATEコマンドにおけるデータ部のうち、フラグの値を読み出す(ステップS102)。   First, the CPU 13 of the portable recording medium 1 reads the value of “format designation information” in the data part in the CREATE command (step S101). Subsequently, the CPU 13 of the portable recording medium 1 reads the value of the flag in the data part in the CREATE command (step S102).

続いてCPU13は、読み出したフラグの値が何であるかを判定する(ステップS103)。CPU13は、当該フラグの値に基づき、書込みの際にブロックの空きが無くなった場合、リーダライタに警告するか否かを決定する。   Subsequently, the CPU 13 determines what the read flag value is (step S103). Based on the value of the flag, the CPU 13 determines whether or not to warn the reader / writer when there is no free block at the time of writing.

フラグが00bであった場合、CPU13は、SWとして9000hをカードリーダライタに応答するフラグを不揮発性メモリ16に書き込むものと判断する(ステップS104)。続いて、CPU13は、ステップS101で読み出したレコード構造に基づき、所定のレコード構造のファイルを不揮発性メモリ16の所定のエリアに書き込む(ステップS105)。続いてCPU13は、ステップS102で読み出したフラグを、不揮発性メモリ16に書込み(ステップS106)、処理が終了する。   When the flag is 00b, the CPU 13 determines that 9000h as SW is written in the nonvolatile memory 16 in response to the card reader / writer (step S104). Subsequently, the CPU 13 writes a file having a predetermined record structure in a predetermined area of the nonvolatile memory 16 based on the record structure read in step S101 (step S105). Subsequently, the CPU 13 writes the flag read in step S102 into the nonvolatile memory 16 (step S106), and the process ends.

フラグが01bであった場合、CPU13は、SWとして6381hをリーダライタに応答するフラグを不揮発性メモリ16に書き込むものと判断する(ステップS107)。続いてCPU13は、ステップS101で読み出したレコード構造に基づき、所定のレコード構造のファイルを不揮発性メモリ16の所定のエリアに書き込む(ステップS108)。続いてCPU13は、ステップS102で読み出したフラグを、不揮発性メモリ16に書込み(ステップS109)、処理が終了する。   When the flag is 01b, the CPU 13 determines that the flag for responding to the reader / writer as 6181h as the SW is written in the nonvolatile memory 16 (step S107). Subsequently, the CPU 13 writes a file having a predetermined record structure in a predetermined area of the nonvolatile memory 16 based on the record structure read in step S101 (step S108). Subsequently, the CPU 13 writes the flag read in step S102 into the nonvolatile memory 16 (step S109), and the process ends.

フラグが00b、01bのいずれでもない場合、CPU13はエラーと判断する(ステップS110)。そしてCPU13は、CREATEコマンドのエラーを示すSWをリーダライタに応答し(ステップS111)、処理が終了する。   If the flag is neither 00b nor 01b, the CPU 13 determines that an error has occurred (step S110). Then, the CPU 13 responds to the reader / writer with the SW indicating the error of the CREATE command (step S111), and the process ends.

図8は、このようにして可搬記録媒体1のCPU13によりフラグ及びプログラムが格納された不揮発性メモリ16の概念図を示す。   FIG. 8 is a conceptual diagram of the nonvolatile memory 16 in which the flag and the program are stored by the CPU 13 of the portable recording medium 1 in this way.

不揮発性メモリ16の先頭のメモリアドレス00000001には、メモリ管理情報が格納される。当該領域をメモリ管理情報格納領域という。メモリ管理情報は、ブロックの空き状況に係る情報を含む。ブロックの空き状況に係る情報は、各ブロックに割り当てられたレコード番号及び空き状況に係るステータスにより構成される。レコード番号は一意にレコードを識別する番号である。空き状況に係るステータスは、“未書込”又は“書込済”である。“未書込”とは、当該ブロックにレコード構造のファイルが格納されていないことを意味する。“書込済”とは、当該ブロックにレコード構造のファイルが格納されていることを意味する。レコード構造のファイルが格納されていないブロックを空きブロックという。   Memory management information is stored at the top memory address 00000001 of the nonvolatile memory 16. This area is called a memory management information storage area. The memory management information includes information related to block availability. The information related to the block availability is composed of the record number assigned to each block and the status related to the availability. The record number is a number that uniquely identifies the record. The status related to the empty status is “not written” or “written”. “Unwritten” means that a file having a record structure is not stored in the block. “Writed” means that a record-structured file is stored in the block. A block in which a record structure file is not stored is called an empty block.

図8のメモリアドレス00000002には、可搬記録媒体1が受信したCREATEコマンドに基づくレコード構造のファイルが格納される。   8 stores a file having a record structure based on the CREATE command received by the portable recording medium 1.

メモリアドレス00000003〜メモリアドレス1000FFFCには、該レコード構造のファイルを格納できるアドレス空間が備えられる。該アドレス空間が、ブロックに対応する。   The memory address 00000003 to memory address 1000FFFC is provided with an address space in which a file having the record structure can be stored. The address space corresponds to a block.

メモリアドレス1000FFFD〜メモリアドレス1000FFFEには、プログラム格納領域22が備えられる。CPU13は、システム動作時に、予め書込み時のブロックの空き状況に応じて所定のSWをリーダライタに応答するプログラムを格納している。なお、不揮発性メモリ16の代わりにROM15にプログラム格納領域22を設け、当該ROM15に設けられたプログラム格納領域22に、書込み後のブロックの空き状況に応じて所定のSWをリーダライタに応答するプログラムを格納してもよい。   A memory area 1000FFFD to a memory address 1000FFFE are provided with a program storage area 22. The CPU 13 stores in advance a program that responds to a reader / writer with a predetermined SW in accordance with the block availability at the time of writing during system operation. A program storage area 22 is provided in the ROM 15 instead of the non-volatile memory 16, and a program that responds to the reader / writer with a predetermined SW in the program storage area 22 provided in the ROM 15 according to the block availability after writing. May be stored.

メモリアドレス1000FFFFには、プログラム格納領域22に格納されたプログラムに関するフラグ設定エリアが備えられている。CPU13は、当該フラグ設定エリアに、CREATEコマンドから読み出したフラグを格納する。   The memory address 1000FFFF is provided with a flag setting area related to the program stored in the program storage area 22. The CPU 13 stores the flag read from the CREATE command in the flag setting area.

図9Aは、メモリ管理情報の一例を示す。図9Aに示すメモリ管理情報では、レコード番号001〜003に係るブロックのステータスがいずれも書込済であり、レコード番号004に係るブロックのステータスは未書込である。   FIG. 9A shows an example of memory management information. In the memory management information shown in FIG. 9A, the statuses of the blocks related to the record numbers 001 to 003 are all written, and the status of the block related to the record number 004 is unwritten.

次に、本発明の実施の形態1に係る可搬記録媒体1について、図10に示すフローチャートによりその動作を説明する。なお、図7の動作フローにより、可搬記録媒体1の不揮発性メモリ16には所定のフラグが格納されているものとする。   Next, the operation of the portable recording medium 1 according to Embodiment 1 of the present invention will be described with reference to the flowchart shown in FIG. It is assumed that a predetermined flag is stored in the nonvolatile memory 16 of the portable recording medium 1 according to the operation flow of FIG.

はじめに、可搬記録媒体1は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタから書込みコマンドを受信する(ステップS120)。   First, the portable recording medium 1 receives a write command from the reader / writer via the non-contact communication interface 11 or the contact communication interface 12 (step S120).

続いて、可搬記録媒体1のCPU13は、不揮発性メモリ16から、書込みコマンド用のプログラム及びフラグ設定エリアに格納されたフラグを取得する(ステップS121)。当該フラグを解釈し、CPU13は、不揮発性メモリ16の空きブロックが無くなった場合の処理方法を確定する。   Subsequently, the CPU 13 of the portable recording medium 1 acquires the program for write command and the flag stored in the flag setting area from the nonvolatile memory 16 (step S121). The CPU 13 interprets the flag and determines a processing method when there is no more empty block in the nonvolatile memory 16.

続いてCPU13は、不揮発性メモリ16に格納されたメモリ管理情報を取得する(ステップS122)。そしてCPU13は、メモリ管理情報に基づき、不揮発性メモリ16に空きブロックがあるか否かを判定する(ステップS123)。不揮発性メモリ16に空きブロックが無い場合、ステップS124に進む。不揮発性メモリ16に空きブロックがある場合、ステップS125に進む。   Subsequently, the CPU 13 acquires the memory management information stored in the nonvolatile memory 16 (Step S122). Then, the CPU 13 determines whether there is an empty block in the nonvolatile memory 16 based on the memory management information (step S123). If there is no empty block in the nonvolatile memory 16, the process proceeds to step S124. If there is an empty block in the nonvolatile memory 16, the process proceeds to step S125.

不揮発性メモリ16に空きブロックが無い場合、書込みができないため、CPU13は、非接触通信インタフェース11又は接触通信インタフェース12を介して、エラーをリーダライタに応答する(ステップS124)。そして処理が終了する。   If there is no empty block in the non-volatile memory 16, writing is not possible, so the CPU 13 responds an error to the reader / writer via the non-contact communication interface 11 or the contact communication interface 12 (step S124). Then, the process ends.

一方、不揮発性メモリ16に空きブロックがある場合、CPU13は、書込みコマンド用のプログラムを用いて、所望のレコード構造のファイルを不揮発性メモリ16に書き込む(ステップS125)。続いて、CPU13は、不揮発性メモリ16に格納されているメモリ管理情報を更新する(ステップS126)。具体的にはCPU13は、所望のレコード構造のファイルを書き込んだレコード番号に係るステータスを、“未書込”から“書込済”に変更する。例えばメモリ管理情報格納領域に、図9Aに示すメモリ管理情報が格納されている場合、レコード番号004が空きブロックであるため、CPU13は、当該ブロックに所望のレコード構造のファイルを書き込む。そして書き込んだ後に、CPU13は、レコード番号004のステータスを、“書込済”に変更し、メモリ管理情報を更新する。図9Bは、更新後のメモリ管理情報を示す。   On the other hand, when there is an empty block in the nonvolatile memory 16, the CPU 13 writes a file having a desired record structure in the nonvolatile memory 16 using a program for a write command (step S125). Subsequently, the CPU 13 updates the memory management information stored in the nonvolatile memory 16 (step S126). Specifically, the CPU 13 changes the status relating to the record number in which the file having the desired record structure is written from “unwritten” to “written”. For example, when the memory management information shown in FIG. 9A is stored in the memory management information storage area, since the record number 004 is an empty block, the CPU 13 writes a file having a desired record structure in the block. After writing, the CPU 13 changes the status of the record number 004 to “written” and updates the memory management information. FIG. 9B shows the updated memory management information.

続いてCPU13は、不揮発性メモリ16に空きブロックがあるか否かを判定する(ステップS127)。不揮発性メモリ16に空きブロックがある場合、ステップS128に進む。不揮発性メモリ16に空きブロックが無い場合、ステップS129に進む。例えば図9Bに示す更新後のメモリ管理情報に基づき本ステップS127における判定をした場合、不揮発性メモリ16に空きブロックが無いため、ステップS129に進む。   Subsequently, the CPU 13 determines whether or not there is an empty block in the nonvolatile memory 16 (step S127). If there is an empty block in the nonvolatile memory 16, the process proceeds to step S128. If there is no empty block in the nonvolatile memory 16, the process proceeds to step S129. For example, when the determination in step S127 is made based on the updated memory management information shown in FIG. 9B, the process proceeds to step S129 because there is no empty block in the nonvolatile memory 16.

不揮発性メモリ16に空きブロックがある場合、CPU13は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタに正常終了として応答、すなわちSWとして9000hを応答し(ステップS128)、処理が終了する。   When there is an empty block in the non-volatile memory 16, the CPU 13 responds to the reader / writer as normal termination via the non-contact communication interface 11 or the contact communication interface 12, that is, responds 9000h as SW (step S128). finish.

一方、不揮発性メモリ16に空きブロックが無い場合、CPU13は、ステップS111において取得したフラグが、SWとして9000hをリーダライタに応答するフラグであるか否かを判定する(ステップS129)。   On the other hand, when there is no empty block in the non-volatile memory 16, the CPU 13 determines whether or not the flag acquired in step S111 is a flag for responding 9000h to the reader / writer as SW (step S129).

判定の結果、取得したフラグがSWとして9000hをカードリーダライタに応答するフラグの場合、CPU13は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタに正常終了として応答、すなわちSWとして9000hをリーダライタに応答する(ステップS130)。一方、SWとして9000hをリーダライタに応答するフラグでない場合、すなわちSWとして6381hをリーダライタに応答するフラグである場合、CPU13は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタに警告終了として応答、すなわちSWとして6381hを応答し(ステップS131)、処理が終了する。   As a result of the determination, if the acquired flag is a flag for responding 9000h to the card reader / writer as SW, the CPU 13 responds to the reader / writer as normal termination via the non-contact communication interface 11 or the contact communication interface 12, that is, as SW. 9000h is returned to the reader / writer (step S130). On the other hand, if the SW is not a flag for responding 9000h to the reader / writer, that is, if the SW is a flag for responding 681h to the reader / writer, the CPU 13 communicates with the reader / writer via the non-contact communication interface 11 or the contact communication interface 12. A response is returned as the end of warning, that is, 6381h is returned as SW (step S131), and the process ends.

このように本発明によれば、リーダライタ及びその上位機種に係るアプリケーションにより一意に定められるフラグによって所定のコマンドである書込みコマンドに対する可搬記録媒体1の挙動を同一にしているため、リーダライタ等の上位装置が可搬記録媒体1の挙動に合わせて複数の処理機能を実装する必要が無く、高い互換性を確保することができる。   As described above, according to the present invention, the behavior of the portable recording medium 1 with respect to the write command that is a predetermined command is made the same by the flag uniquely determined by the reader / writer and the application related to the higher-level model. It is not necessary for the higher-level device to implement a plurality of processing functions in accordance with the behavior of the portable recording medium 1, and high compatibility can be ensured.

(実施の形態2)
以下に、本発明の実施の形態2について説明をする。実施の形態2に係る可搬記録媒体1の構成は実施の形態1と同一であるが、実施の形態2に係る可搬記録媒体1は、非接触通信インタフェース11又は接触通信インタフェース12を介して、所定のコマンドとして受信するコマンドがCREATEコマンド及びPUT DATAコマンドである点が相違する。
(Embodiment 2)
The second embodiment of the present invention will be described below. The configuration of the portable recording medium 1 according to the second embodiment is the same as that of the first embodiment, but the portable recording medium 1 according to the second embodiment is connected via the non-contact communication interface 11 or the contact communication interface 12. The difference is that the commands received as the predetermined commands are the CREATE command and the PUT DATA command.

図11は、CPU13が、CREATEコマンドにおけるフラグを不揮発性メモリ16に格納する際の動作を示すフローチャートである。以下詳細に当該フローチャートを説明する。実施の形態1と同一の動作については同一の符号を付し、説明は省略する。   FIG. 11 is a flowchart showing an operation when the CPU 13 stores the flag in the CREATE command in the nonvolatile memory 16. The flowchart will be described in detail below. The same operations as those in the first embodiment are denoted by the same reference numerals, and description thereof is omitted.

ステップS102の後に、CPU13は、読み出したフラグの値が何であるかを判定する(ステップS203)。CPU13は、当該フラグの値に基づき、PUT DATAコマンドがリーダライタから送信された場合に、不揮発性メモリ16に一度書き込まれたデータオブジェクトを更新することを許容するか否かを確定する。   After step S102, the CPU 13 determines what the read flag value is (step S203). Based on the value of the flag, the CPU 13 determines whether or not it is permitted to update the data object once written in the nonvolatile memory 16 when a PUT DATA command is transmitted from the reader / writer.

CREATEコマンドにおけるフラグが00bであった場合、CPU13は、SWとして9000hをリーダライタに応答するフラグを不揮発性メモリ16に書き込むものと判断する(ステップS204)。続いて、CPU13は、ステップS101で読み出したデータオブジェクト構造に基づき、所定のデータオブジェクト構造のファイルを不揮発性メモリ16の所定のエリアに書き込む(ステップS205)。続いてCPU13は、ステップS102で読み出したフラグを、不揮発性メモリ16に書込み(ステップS206)、処理が終了する。   When the flag in the CREATE command is 00b, the CPU 13 determines that 9000h as a SW is written in the nonvolatile memory 16 in response to the reader / writer (step S204). Subsequently, the CPU 13 writes a file having a predetermined data object structure in a predetermined area of the nonvolatile memory 16 based on the data object structure read in step S101 (step S205). Subsequently, the CPU 13 writes the flag read in step S102 into the nonvolatile memory 16 (step S206), and the process ends.

フラグが01bであった場合、CPU13は、SWとして6985hをリーダライタに応答するフラグを不揮発性メモリ16に書き込むものと判断する(ステップS207)。続いてCPU13は、ステップS101で読み出したレコード構造に基づき、所定のデータオブジェクト構造のファイルを不揮発性メモリ16の所定のエリアに書き込む(ステップS208)。続いてCPU13は、ステップS102で読み出したフラグを、不揮発性メモリ16に書込み(ステップS209)、処理が終了する。   When the flag is 01b, the CPU 13 determines that the flag for responding to the reader / writer as 6985h as the SW is written in the nonvolatile memory 16 (step S207). Subsequently, the CPU 13 writes a file having a predetermined data object structure in a predetermined area of the nonvolatile memory 16 based on the record structure read in step S101 (step S208). Subsequently, the CPU 13 writes the flag read in step S102 into the nonvolatile memory 16 (step S209), and the process ends.

フラグが00b、01bのいずれでもない場合、CPU13はエラーと判断する(ステップS210)。そしてCPU13は、CREATEコマンドのエラーを示すSWをリーダライタに応答し(ステップS211)、処理が終了する。   If the flag is neither 00b nor 01b, the CPU 13 determines that an error has occurred (step S210). Then, the CPU 13 responds to the reader / writer with the SW indicating the error of the CREATE command (step S211), and the process ends.

次に、本発明の実施の形態2に係る可搬記録媒体1について、図12に示すフローチャートによりその動作を説明する。なお、図11の動作フローにより、可搬記録媒体1の不揮発性メモリ16には所定のフラグが格納されているものとする。   Next, the operation of the portable recording medium 1 according to Embodiment 2 of the present invention will be described with reference to the flowchart shown in FIG. It is assumed that a predetermined flag is stored in the nonvolatile memory 16 of the portable recording medium 1 according to the operation flow of FIG.

はじめに、可搬記録媒体1は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタから所定のコマンドとして、PUT DATAコマンドを受信する(ステップS220)。   First, the portable recording medium 1 receives a PUT DATA command as a predetermined command from the reader / writer via the non-contact communication interface 11 or the contact communication interface 12 (step S220).

続いて、可搬記録媒体1のCPU13は、不揮発性メモリ16から、PUT DATAコマンド用のプログラム及びフラグ設定エリアに格納されたフラグを取得する(ステップS221)。当該フラグを解釈し、CPU13は、PUT DATAコマンドがリーダライタから送信された場合に、不揮発性メモリ16に一度書き込まれたデータオブジェクトを更新することを許容するか否かを確定する。   Subsequently, the CPU 13 of the portable recording medium 1 acquires the program for the PUT DATA command and the flag stored in the flag setting area from the nonvolatile memory 16 (step S221). The CPU 13 interprets the flag, and determines whether or not to allow the data object once written in the nonvolatile memory 16 to be updated when the PUT DATA command is transmitted from the reader / writer.

続いて、CPU13は、ステップS221において取得したフラグが、PUT DATAコマンド実行時のSWとして9000hをリーダライタに応答するフラグであるか否かを判定する(ステップS222)。   Subsequently, the CPU 13 determines whether or not the flag acquired in step S221 is a flag for responding 9000h to the reader / writer as the SW when executing the PUT DATA command (step S222).

判定の結果、取得したフラグが、PUT DATA実行時におけるデータオブジェクト更新時のSWとして9000hをカードリーダライタに応答するフラグの場合、CPU13は、データオブジェクトを更新する(ステップS223)。そしてCPU13は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタに正常終了として応答、すなわちSWとして9000hをリーダライタに応答する(ステップS224)。   As a result of the determination, when the acquired flag is a flag for responding 9000h to the card reader / writer as the SW at the time of updating the data object at the time of executing the PUT DATA, the CPU 13 updates the data object (step S223). Then, the CPU 13 responds to the reader / writer as normal termination via the non-contact communication interface 11 or the contact communication interface 12, that is, responds 9000h as SW to the reader / writer (step S224).

一方、PUT DATA実行時におけるデータオブジェクト更新時のSWとして9000hをリーダライタに応答するフラグでない場合、すなわちSWとして6985hをカードリーダライタに応答するフラグである場合、CPU13は、非接触通信インタフェース11又は接触通信インタフェース12を介して、リーダライタに異常終了として応答、すなわちSWとして6985hをリーダライタに応答し(ステップS225)、処理が終了する。   On the other hand, when 9000h is not a flag that responds to the reader / writer as the SW when updating the data object at the time of PUT DATA execution, that is, when SW is 6985h as a flag that responds to the card reader / writer, the CPU 13 A response is sent to the reader / writer as abnormal termination via the contact communication interface 12, that is, 6985h is returned to the reader / writer as SW (step S225), and the processing is terminated.

このように本発明によれば、リーダライタ及びその上位機種に係るアプリケーションにより一意に定められるフラグによって所定のコマンドであるPUT DATAコマンドに対する可搬記録媒体1の挙動を同一にしているため、リーダライタ等の上位装置が可搬記録媒体1の挙動に合わせて複数の処理機能を実装する必要が無く、高い互換性を確保することができる。   As described above, according to the present invention, the behavior of the portable recording medium 1 with respect to the PUT DATA command which is a predetermined command is made the same by the flag uniquely determined by the reader / writer and the application related to the higher-level model. It is not necessary for a higher-level device such as a plurality of processing functions to be mounted in accordance with the behavior of the portable recording medium 1, and high compatibility can be ensured.

(実施の形態3)
以下に、本発明の実施の形態3について説明をする。実施の形態3に係る可搬記録媒体1の構成は実施の形態1と同一であるが、実施の形態3に係る可搬記録媒体1は、非接触通信インタフェース11又は接触通信インタフェース12を介して、所定のコマンドとして受信するコマンドがKEY REPLACEコマンドである点が相違する。
(Embodiment 3)
The third embodiment of the present invention will be described below. Although the configuration of the portable recording medium 1 according to the third embodiment is the same as that of the first embodiment, the portable recording medium 1 according to the third embodiment is connected via the non-contact communication interface 11 or the contact communication interface 12. The difference is that the command received as the predetermined command is the KEY REPLACE command.

図13は、可搬記録媒体1が、リーダライタから受信するコマンドのひとつであるKEY REPLACEコマンドのデータ構造及びデータ構造の各項目の説明を示す図である。KEY REPLACEコマンドとは、可搬記録媒体1内においてデータの暗号化及び復号に用いられる鍵を、新規の鍵に置き換えるためのコマンドである。図13に示すように、KEY REPLACEコマンドは、CLAと、INSと、P1と、P2と、Lcと、データと、Leとを備える。   FIG. 13 is a diagram illustrating the data structure of the KEY REPLACE command, which is one of the commands received from the reader / writer by the portable recording medium 1, and the description of each item of the data structure. The KEY REPLACE command is a command for replacing a key used for data encryption and decryption in the portable recording medium 1 with a new key. As shown in FIG. 13, the KEY REPLACE command includes CLA, INS, P1, P2, Lc, data, and Le.

CLAは、KEY REPLACEコマンドの場合00hである。INSは、KEY REPLACEコマンドの場合、F1hである。   CLA is 00h for the KEY REPLACE command. INS is F1h for the KEY REPLACE command.

P1は、2バイトの第一パラメータであり、現在の鍵のバージョンを示す。例えばP1は、0002hである。P2は、2バイトの第二パラメータであり、鍵IDを示す。例えばP2は、010Ahである。Lcは後続のデータ部及びLeのデータ長を示す。データ部は、先頭の2バイト長のフラグと、フラグに後続する2バイト長の新規鍵のバージョン番号と、新規鍵のバージョン番号に後続する16バイト長の鍵データ本体とを備える。例えば、フラグが0002h、新規鍵のバージョン番号が0003h、鍵データ本体が873A047AF5862BB16422101C859D867F34hの場合、データ部は、0002|0003|873A047AF5862BB16422101C859D867F34hである。Leは1バイトのデータであり、例えば00hである。   P1 is a 2-byte first parameter indicating the current key version. For example, P1 is 0002h. P2 is a 2-byte second parameter and indicates a key ID. For example, P2 is 010 Ah. Lc indicates the data length of the subsequent data part and Le. The data portion includes a leading 2-byte length flag, a 2-byte long new key version number following the flag, and a 16-byte key data body following the new key version number. For example, if the flag is 0002h, the new key version number is 0003h, and the key data body is 873A047AF5862BB1642101C859D867F34h, the data portion is 0002 | 0003 | 873A047AF5862BB1642101C859D867F34h. Le is 1-byte data, for example, 00h.

図14は、可搬記録媒体1が、リーダライタからKEY REPLACEコマンドを受信した後に、鍵置き換えに係る複数のエラー事象が発生した場合の該複数のエラー事象の優先順位とフラグとの関係を示すテーブルである。ここで、可搬記録媒体1において、鍵置き換えに係るエラー事象が複数生じた場合、可搬記録媒体1のCPU13は、該複数のエラー事象のうち、最も優先順位の高いエラー事象に係る応答をカードリーダライタに対して送信する。すなわち、KEY REPLACEコマンドに対応する応答としては複数の応答があり、CPU13は、複数の応答のうち最も優先順位の高い応答をリーダライタに対して送信する。   FIG. 14 shows the relationship between the priorities of the plurality of error events and the flags when a plurality of error events related to key replacement occur after the portable recording medium 1 receives the KEY REPLACE command from the reader / writer. It is a table. Here, when a plurality of error events related to key replacement occur in the portable recording medium 1, the CPU 13 of the portable recording medium 1 sends a response related to the error event with the highest priority among the plurality of error events. Sent to the card reader / writer. That is, there are a plurality of responses as responses corresponding to the KEY REPLACE command, and the CPU 13 transmits a response with the highest priority among the plurality of responses to the reader / writer.

しかしながら実装によってこの優先順位は異なる。そこで実施の形態3においては、フラグにより、可搬記録媒体1におけるエラー事象の優先順位を指定し、所定の優先順位に統一する。なおフラグの値は、リーダライタ及びその上位機種に係るアプリケーションにより一意に定められる。   However, this priority varies depending on the implementation. Therefore, in the third embodiment, the priority order of error events in the portable recording medium 1 is designated by a flag and unified to a predetermined priority order. Note that the value of the flag is uniquely determined by an application related to the reader / writer and its upper model.

例えばフラグが0001hの場合、該エラー事象のうち、“新規鍵のデータ長が正しくない”というエラー事象及びその応答の優先順位を、最高の優先順位である1番に指定する。なお図14中、優先順位が1番であることを(1)として表記している。また、エラー事象のうち、“Lcの値が正しくない”というエラー事象及びその応答の優先順位を2番に指定する。同様に当該優先順位は(2)として表記している。他のエラー事象についても同様に図14に示す通り、それぞれ3番目の優先順位から9番目の優先順位まで、(3)〜(9)として表記し、各エラー事象及びその応答に付与している。ここで、フラグが0001hの場合の優先順位を、第1の優先順位と呼ぶ。同様にフラグが0002h、0003h、0004h、及び0005hの場合も、各エラー事象及びその応答に優先順位を付与し、当該優先順位を、それぞれ第2の優先順位、第3の優先順位、第4の優先順位、及び第5の優先順位と呼ぶ。   For example, when the flag is 0001h, among the error events, the error event “the data length of the new key is not correct” and the priority of the response are designated as the highest priority number 1. In FIG. 14, (1) indicates that the priority is the first. Further, among the error events, the error event “Lc value is not correct” and the priority of the response are designated as the second. Similarly, the priority is expressed as (2). Similarly, as shown in FIG. 14, the other error events are expressed as (3) to (9) from the third priority to the ninth priority, and are given to each error event and its response. . Here, the priority when the flag is 0001h is referred to as a first priority. Similarly, when the flags are 0002h, 0003h, 0004h, and 0005h, priority is given to each error event and its response, and the priority is assigned to the second priority, the third priority, Called priority and fifth priority.

図15は、CPU13が、KEY REPLACEコマンドにおけるフラグを不揮発性メモリ16に格納する際の動作を示すフローチャートである。以下詳細に当該フローチャートを説明する。   FIG. 15 is a flowchart showing an operation when the CPU 13 stores the flag in the KEY REPLACE command in the nonvolatile memory 16. The flowchart will be described in detail below.

まず可搬記録媒体1のCPU13は、KEY REPLACEコマンドにおけるデータ部のうち、フラグの値を読み出す(ステップS301)。   First, the CPU 13 of the portable recording medium 1 reads the value of the flag in the data part in the KEY REPLACE command (step S301).

続いてCPU13は、読み出したフラグの値が何であるかを判定する(ステップS302)。CPU13は、当該フラグの値に基づき、エラー事象及び応答の優先順位を確定する。   Subsequently, the CPU 13 determines what the value of the read flag is (step S302). The CPU 13 determines the priority order of the error event and the response based on the value of the flag.

フラグが0001hであった場合、CPU13は、第1の優先順位に係るフラグを不揮発性メモリ16に書き込むものと判断する(ステップS303)。続いてCPU13は、ステップS301で読み出したフラグを、不揮発性メモリ16に書込み(ステップS304)、処理が終了する。   When the flag is 0001h, the CPU 13 determines that the flag related to the first priority order is to be written in the nonvolatile memory 16 (step S303). Subsequently, the CPU 13 writes the flag read in step S301 into the nonvolatile memory 16 (step S304), and the process ends.

フラグが0002hであった場合、CPU13は、第2の優先順位に係るフラグを不揮発性メモリ16に書き込むものと判断する(ステップS305)。続いてCPU13は、ステップS301で読み出したフラグを、不揮発性メモリ16に書込み(ステップS306)、処理が終了する。   When the flag is 0002h, the CPU 13 determines that the flag related to the second priority order is to be written in the nonvolatile memory 16 (step S305). Subsequently, the CPU 13 writes the flag read in step S301 into the nonvolatile memory 16 (step S306), and the process ends.

フラグが0003hであった場合、CPU13は、第3の優先順位に係るフラグを不揮発性メモリ16に書き込むものと判断する(ステップS307)。続いてCPU13は、ステップS301で読み出したフラグを、不揮発性メモリ16に書込み(ステップS308)、処理が終了する。   When the flag is 0003h, the CPU 13 determines that the flag related to the third priority order is to be written in the nonvolatile memory 16 (step S307). Subsequently, the CPU 13 writes the flag read in step S301 into the nonvolatile memory 16 (step S308), and the process ends.

フラグが0004hであった場合、CPU13は、第4の優先順位に係るフラグを不揮発性メモリ16に書き込むものと判断する(ステップS309)。続いてCPU13は、ステップS301で読み出したフラグを、不揮発性メモリ16に書込み(ステップS3010)、処理が終了する。   When the flag is 0004h, the CPU 13 determines that the flag related to the fourth priority order is to be written in the nonvolatile memory 16 (step S309). Subsequently, the CPU 13 writes the flag read in step S301 into the nonvolatile memory 16 (step S3010), and the process ends.

フラグが0005hであった場合、CPU13は、第5の優先順位に係るフラグを不揮発性メモリ16に書き込むものと判断する(ステップS311)。続いてCPU13は、ステップS301で読み出したフラグを、不揮発性メモリ16に書込み(ステップS312)、処理が終了する。   When the flag is 0005h, the CPU 13 determines that the flag related to the fifth priority order is to be written in the nonvolatile memory 16 (step S311). Subsequently, the CPU 13 writes the flag read in step S301 into the nonvolatile memory 16 (step S312), and the process ends.

フラグが0001h、0002h、0003h、0004h、及び0005hのいずれでもない場合、CPU13はエラーと判断する(ステップS313)。そしてCPU13は、KEY REPLACEコマンドのエラーを示すSWをリーダライタに応答し(ステップS314)、処理が終了する。   If the flag is not any of 0001h, 0002h, 0003h, 0004h, and 0005h, the CPU 13 determines that an error has occurred (step S313). Then, the CPU 13 responds to the reader / writer with the SW indicating the error of the KEY REPLACE command (step S314), and the process ends.

次に、本発明の実施の形態3に係る可搬記録媒体1について、図16に示すフローチャートによりその動作を説明する。なお、図15の動作フローにより、可搬記録媒体1の不揮発性メモリ16には所定のフラグが格納されているものとする。   Next, the operation of the portable recording medium 1 according to Embodiment 3 of the present invention will be described with reference to the flowchart shown in FIG. It is assumed that a predetermined flag is stored in the nonvolatile memory 16 of the portable recording medium 1 according to the operation flow of FIG.

はじめに、可搬記録媒体1において、鍵置き換えに係るエラー事象が複数発生する(ステップS320)。このとき、可搬記録媒体1のCPU13は、当該複数エラー事象を示す情報を、メモリ内に保持する(ステップS321)。すなわちCPU13は、所定のコマンドを実行した結果に関する複数の情報をメモリに格納する。   First, a plurality of error events related to key replacement occur in the portable recording medium 1 (step S320). At this time, the CPU 13 of the portable recording medium 1 holds information indicating the plurality of error events in the memory (step S321). That is, the CPU 13 stores a plurality of information related to the result of executing the predetermined command in the memory.

次に、可搬記録媒体1のCPU13は、不揮発性メモリ16に格納されたフラグを取得する(ステップS322)。当該フラグを解釈し、CPU13は、エラー事象及びその応答の優先順位を確定する。   Next, the CPU 13 of the portable recording medium 1 acquires a flag stored in the nonvolatile memory 16 (step S322). Interpreting the flag, the CPU 13 determines the priority of the error event and its response.

続いて、CPU13は、ステップS322において取得したフラグが何であるかを判定する(ステップS323)。   Subsequently, the CPU 13 determines what the flag acquired in step S322 is (step S323).

判定の結果、取得したフラグが0001hである場合、CPU13は、エラー事象が複数発生した場合に、非接触通信インタフェース11又は接触通信インタフェース12を介して、第1の優先順位に基づき、発生した複数のエラー事象のうち最も優先順位の高いエラー事象を、メモリ内に保持されている当該複数エラー事象を示すデータの中から選択し、当該最も優先順位の高いエラー事象に対応するSWをリーダライタに応答する(ステップS324)。   As a result of the determination, if the acquired flag is 0001h, the CPU 13 determines that the plurality of generated error events has occurred based on the first priority order via the non-contact communication interface 11 or the contact communication interface 12. The error event with the highest priority is selected from the data indicating the plurality of error events stored in the memory, and the SW corresponding to the error event with the highest priority is selected as the reader / writer. A response is made (step S324).

判定の結果、取得したフラグが0002hである場合、CPU13は、エラー事象が複数発生した場合に、非接触通信インタフェース11又は接触通信インタフェース12を介して、第2の優先順位に基づき、発生した複数のエラー事象のうち最も優先順位の高いエラー事象を、メモリ内に保持されている当該複数エラー事象を示すデータの中から選択し、当該最も優先順位の高いエラー事象に対応するSWをリーダライタに応答する(ステップS325)。   As a result of the determination, when the acquired flag is 0002h, the CPU 13 generates a plurality of error events based on the second priority order via the non-contact communication interface 11 or the contact communication interface 12 when a plurality of error events occur. The error event with the highest priority is selected from the data indicating the plurality of error events stored in the memory, and the SW corresponding to the error event with the highest priority is selected as the reader / writer. A response is made (step S325).

判定の結果、取得したフラグが0003hである場合、CPU13は、エラー事象が複数発生した場合に、非接触通信インタフェース11又は接触通信インタフェース12を介して、第3の優先順位に基づき、発生した複数のエラー事象のうち最も優先順位の高いエラー事象を、メモリ内に保持されている当該複数エラー事象を示すデータの中から選択し、当該最も優先順位の高いエラー事象に対応するSWをリーダライタに応答する(ステップS326)。   As a result of the determination, when the acquired flag is 0003h, the CPU 13 generates the plurality of error events generated based on the third priority order via the non-contact communication interface 11 or the contact communication interface 12 when a plurality of error events occur. The error event with the highest priority is selected from the data indicating the plurality of error events stored in the memory, and the SW corresponding to the error event with the highest priority is selected as the reader / writer. A response is made (step S326).

判定の結果、取得したフラグが0004hである場合、CPU13は、エラー事象が複数発生した場合に、非接触通信インタフェース11又は接触通信インタフェース12を介して、第4の優先順位に基づき、発生した複数のエラー事象のうち最も優先順位の高いエラー事象を、メモリ内に保持されている当該複数エラー事象を示すデータの中から選択し、当該最も優先順位の高いエラー事象に対応するSWをリーダライタに応答する(ステップS327)。   As a result of the determination, when the acquired flag is 0004h, the CPU 13 generates the plurality of error events that have occurred based on the fourth priority order via the non-contact communication interface 11 or the contact communication interface 12 when a plurality of error events occur. The error event with the highest priority is selected from the data indicating the plurality of error events stored in the memory, and the SW corresponding to the error event with the highest priority is selected as the reader / writer. A response is made (step S327).

判定の結果、取得したフラグが0005hである場合、CPU13は、エラー事象が複数発生した場合に、非接触通信インタフェース11又は接触通信インタフェース12を介して、第5の優先順位に基づき、発生した複数のエラー事象のうち最も優先順位の高いエラー事象を、メモリ内に保持されている当該複数エラー事象を示すデータの中から選択し、当該最も優先順位の高いエラー事象に対応するSWをリーダライタに応答する(ステップS328)。   As a result of the determination, when the acquired flag is 0005h, the CPU 13 generates the plurality of generated error events based on the fifth priority order via the non-contact communication interface 11 or the contact communication interface 12 when a plurality of error events occur. The error event with the highest priority is selected from the data indicating the plurality of error events stored in the memory, and the SW corresponding to the error event with the highest priority is selected as the reader / writer. A response is made (step S328).

SWをリーダライタに応答した後、CPU13は、当該複数エラー事象を示す情報を、メモリから削除する。(ステップS329)   After responding SW to the reader / writer, the CPU 13 deletes information indicating the plurality of error events from the memory. (Step S329)

このように本発明によれば、リーダライタ及びその上位機種に係るアプリケーションにより一意に定められるフラグによって所定のコマンドであるKEY REPLACEコマンドに関する可搬記録媒体1の挙動を同一にしているため、リーダライタ等の上位装置が可搬記録媒体1の挙動に合わせて複数の処理機能を実装する必要が無く、高い互換性を確保することができる。   As described above, according to the present invention, the behavior of the portable recording medium 1 regarding the KEY REPLACE command, which is a predetermined command, is made the same by the flag uniquely determined by the reader / writer and the application related to the higher-level model. It is not necessary for a higher-level device such as a plurality of processing functions to be mounted in accordance with the behavior of the portable recording medium 1, and high compatibility can be ensured.

ここで、可搬記録媒体1として機能させるために、コンピュータを好適に用いることができ、そのようなコンピュータは、可搬記録媒体1の各機能を実現する処理内容を記述したプログラムを、当該コンピュータの記憶部に格納しておき、当該コンピュータの中央演算処理装置によってこのプログラムを読み出して実行させることで実現することができる。   Here, in order to function as the portable recording medium 1, a computer can be preferably used, and such a computer can store a program describing processing contents for realizing each function of the portable recording medium 1. This program can be realized by reading out and executing this program by the central processing unit of the computer.

本発明を諸図面や実施例に基づき説明してきたが、当業者であれば本開示に基づき種々の変形や修正を行うことが容易であることに注意されたい。したがって、これらの変形や修正は本発明の範囲に含まれることに留意されたい。例えば、各手段、各ステップ等に含まれる機能等は論理的に矛盾しないように再配置可能であり、複数の手段やステップ等を1つに組み合わせたり、或いは分割したりすることが可能である。   Although the present invention has been described based on the drawings and examples, it should be noted that those skilled in the art can easily make various modifications and corrections based on the present disclosure. Therefore, it should be noted that these variations and modifications are included in the scope of the present invention. For example, the functions included in each means, each step, etc. can be rearranged so that there is no logical contradiction, and a plurality of means, steps, etc. can be combined or divided into one. .

1 可搬記録媒体
11 非接触通信インタフェース
12 接触通信インタフェース
13 CPU
14 RAM
15 ROM
16 不揮発性メモリ
21 OS格納領域
22 プログラム格納領域
23 データファイル格納領域
24 ハードウェア
25 暗号コプロセッサ
DESCRIPTION OF SYMBOLS 1 Portable recording medium 11 Non-contact communication interface 12 Contact communication interface 13 CPU
14 RAM
15 ROM
16 Non-volatile memory 21 OS storage area 22 Program storage area 23 Data file storage area 24 Hardware 25 Cryptographic coprocessor

Claims (6)

定のコマンドに対応する応答を指定するフラグをデータ構造に含む該所定のコマンドをリーダライタから受信する通信インタフェースと、
前記フラグを格納するメモリと、
前記メモリに格納された前記フラグを解釈し、前記リーダライタに前記所定のコマンドに対応する応答をする演算装置と、
を有することを特徴とする可搬記録媒体。
A communication interface for receiving said predetermined command from the reader-writer includes a flag for designating a response corresponding to a Jo Tokoro commands in the data structure,
A memory for storing the flag;
An arithmetic unit that interprets the flag stored in the memory and responds to the reader / writer in response to the predetermined command;
A portable recording medium comprising:
所定のコマンド及び該所定のコマンドに対応する応答を指定するフラグをリーダライタから受信する通信インタフェースと、
前記フラグを格納するメモリと、
前記メモリに格納された前記フラグを解釈し、前記リーダライタに前記所定のコマンドに対応する応答をする演算装置と、
を有し、
前記メモリは、前記所定のコマンドを実行した結果に関する複数の情報を格納し、
前記フラグは、前記所定のコマンドを実行した結果に関する前記複数の情報に各々対応する複数の応答の優先順位を指定し、
前記演算装置は、前記フラグにより指定された前記優先順位に基づき、前記リーダライタに前記所定のコマンドを実行した結果に関する情報に対応する応答をすることを特徴とする可搬記録媒体。
A communication interface for receiving from the reader / writer a flag designating a predetermined command and a response corresponding to the predetermined command;
A memory for storing the flag;
An arithmetic unit that interprets the flag stored in the memory and responds to the reader / writer in response to the predetermined command;
Have
The memory stores a plurality of pieces of information related to a result of executing the predetermined command,
The flag specifies the priority order of a plurality of responses respectively corresponding to the plurality of information related to a result of executing the predetermined command;
The arithmetic unit, based on said specified the priority by a flag, the portable recording medium characterized in that the response corresponding to the information about the result of executing the reader writer to the predetermined command.
定のコマンドに対応する応答を指定するフラグをデータ構造に含む該所定のコマンドをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を含む可搬記録媒体の制御方法。
Receiving said predetermined command from the reader-writer includes a flag for designating a response corresponding to a Jo Tokoro commands in the data structure,
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
A method for controlling a portable recording medium including:
所定のコマンド及び該所定のコマンドへの応答を指定するフラグをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を含み、
前記メモリに格納するステップは、前記所定のコマンドを実行した結果に関する複数の情報を前記メモリに格納し、
前記フラグは、前記所定のコマンドを実行した結果に関する前記複数の情報に各々対応する複数の応答の優先順位を指定し、
前記応答をするステップは、前記フラグにより指定された前記優先順位に基づき、前記リーダライタに前記所定のコマンドを実行した結果に関する情報に対応する応答をすることを特徴とする可搬記録媒体の制御方法。
Receiving a flag designating a predetermined command and a response to the predetermined command from the reader / writer;
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
Including
The step of storing in the memory stores a plurality of pieces of information related to a result of executing the predetermined command in the memory,
The flag specifies the priority order of a plurality of responses respectively corresponding to the plurality of information related to a result of executing the predetermined command;
The step of the response, based on said specified the priority by a flag, a portable recording medium you characterized in that the response corresponding to the information about the execution result of the predetermined command to the reader writer Control method.
可搬記録媒体として動作するコンピュータに、
定のコマンドに対応する応答を指定するフラグをデータ構造に含む該所定のコマンドをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を実行させるための可搬記録媒体の制御プログラム。
To a computer that operates as a portable recording medium,
Receiving said predetermined command from the reader-writer includes a flag for designating a response corresponding to a Jo Tokoro commands in the data structure,
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
A portable recording medium control program for executing
可搬記録媒体として動作するコンピュータに、
所定のコマンド及び該所定のコマンドへの応答を指定するフラグをリーダライタから受信するステップと、
前記フラグをメモリに格納するステップと、
前記メモリに格納された前記フラグを解釈し、前記所定のコマンドに対する応答をするステップと、
を実行させ、
前記メモリに格納するステップは、前記所定のコマンドを実行した結果に関する複数の情報を前記メモリに格納し、
前記フラグは、前記所定のコマンドを実行した結果に関する前記複数の情報に各々対応する複数の応答の優先順位を指定し、
前記応答をするステップは、前記フラグにより指定された前記優先順位に基づき、前記リーダライタに前記所定のコマンドを実行した結果に関する情報に対応する応答をすることを特徴とする可搬記録媒体の制御プログラム。
To a computer that operates as a portable recording medium,
Receiving a flag designating a predetermined command and a response to the predetermined command from the reader / writer;
Storing the flag in a memory;
Interpreting the flag stored in the memory and responding to the predetermined command;
And execute
The step of storing in the memory stores a plurality of pieces of information related to a result of executing the predetermined command in the memory,
The flag specifies the priority order of a plurality of responses respectively corresponding to the plurality of information related to a result of executing the predetermined command;
Step, based on the priority specified by the flag, before the portable recording medium characterized in that the response corresponding to the information about the execution result of the predetermined command to cut Daraita to the response Control program.
JP2011256295A 2011-11-24 2011-11-24 Portable recording medium, portable recording medium control method, and portable recording medium control program Active JP5689050B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011256295A JP5689050B2 (en) 2011-11-24 2011-11-24 Portable recording medium, portable recording medium control method, and portable recording medium control program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011256295A JP5689050B2 (en) 2011-11-24 2011-11-24 Portable recording medium, portable recording medium control method, and portable recording medium control program

Publications (2)

Publication Number Publication Date
JP2013109714A JP2013109714A (en) 2013-06-06
JP5689050B2 true JP5689050B2 (en) 2015-03-25

Family

ID=48706373

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011256295A Active JP5689050B2 (en) 2011-11-24 2011-11-24 Portable recording medium, portable recording medium control method, and portable recording medium control program

Country Status (1)

Country Link
JP (1) JP5689050B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6862734B2 (en) * 2016-09-20 2021-04-21 凸版印刷株式会社 Storage medium device and program

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH089795Y2 (en) * 1986-03-28 1996-03-21 シチズン時計株式会社 IC card
JPH05301425A (en) * 1992-04-27 1993-11-16 Ricoh Co Ltd Image forming apparatus
JP3480746B2 (en) * 1993-11-11 2003-12-22 株式会社東芝 Portable electronic devices
JP2008076487A (en) * 2006-09-19 2008-04-03 Murata Mach Ltd Image forming apparatus

Also Published As

Publication number Publication date
JP2013109714A (en) 2013-06-06

Similar Documents

Publication Publication Date Title
JP4211101B2 (en) Information processing apparatus and method, and recording medium
JP4633647B2 (en) Control method, control system, and connection confirmation method
JPH03240127A (en) Program control system
EP2278501B1 (en) Smartcard for portable electronic device
JP5689050B2 (en) Portable recording medium, portable recording medium control method, and portable recording medium control program
CN104484289A (en) Sector-based embedded system write protection device and method
CN111782605A (en) Chip card file management method, device, terminal and storage medium
US7979606B2 (en) Method for storing data
CN102023873B (en) Application program execution method and system, storage media controller and storage device
CN112527341B (en) Vehicle system upgrading method, vehicle system and computer storage medium
CN113849230A (en) Server starting method and device, electronic equipment and readable storage medium
JP2593007B2 (en) Program embedded device
JP2006190180A (en) Information device and start management program
JP4747450B2 (en) Portable information processing device
KR100256522B1 (en) I/o memory card type pager
KR101437962B1 (en) Data processing apparatus and data processing method
JP4839751B2 (en) RFID tag
JP3641693B2 (en) IC card and method of using the same
JP7438432B1 (en) Electronic information storage medium, IC chip, IC card, record writing method, and program
JP2010198112A (en) Removable device built-in equipment, removable device, and method for managing drive identification information
CN104252334A (en) Branch target address acquiring method and device
JP6823289B2 (en) IC card and computer program
KR20080068381A (en) Flash memory card
JP2008047042A (en) Portable electronic device and ic card
CN116400972A (en) Starting method, device and medium of baseboard management controller

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20140306

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140820

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20140902

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20141104

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20150127

R150 Certificate of patent or registration of utility model

Ref document number: 5689050

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150