JP2008047042A - Portable electronic device and ic card - Google Patents

Portable electronic device and ic card Download PDF

Info

Publication number
JP2008047042A
JP2008047042A JP2006224323A JP2006224323A JP2008047042A JP 2008047042 A JP2008047042 A JP 2008047042A JP 2006224323 A JP2006224323 A JP 2006224323A JP 2006224323 A JP2006224323 A JP 2006224323A JP 2008047042 A JP2008047042 A JP 2008047042A
Authority
JP
Japan
Prior art keywords
data
write
address
writing
command
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2006224323A
Other languages
Japanese (ja)
Other versions
JP4868979B2 (en
Inventor
Hitoshi Komatsu
仁 小松
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.)
Toshiba Corp
Original Assignee
Toshiba 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 Toshiba Corp filed Critical Toshiba Corp
Priority to JP2006224323A priority Critical patent/JP4868979B2/en
Publication of JP2008047042A publication Critical patent/JP2008047042A/en
Application granted granted Critical
Publication of JP4868979B2 publication Critical patent/JP4868979B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a portable electronic device and an IC card with a data area reusable even when a write failure occurs during data write for allowing efficient data write processing. <P>SOLUTION: When write error (a write failure) occurs in writing data, especially data with a long data length, to a write once binary EF (elementary file), a defective area is found by using a previous write start address and a write ending address stored inside, and a write binary command is received again. <P>COPYRIGHT: (C)2008,JPO&INPIT

Description

本発明は、たとえば、書換え可能な不揮発性メモリおよびCPU(セントラル・プロセッシング・ユニット)などの制御素子を有するIC(集積回路)チップを内蔵し、外部から供給されるコマンド(命令)に基づき各種処理を実行してその処理結果を外部へ出力するICカードなどの携帯可能電子装置およびICカードに関する。   The present invention incorporates an IC (integrated circuit) chip having control elements such as a rewritable nonvolatile memory and a CPU (Central Processing Unit), for example, and performs various processes based on commands (instructions) supplied from the outside. The present invention relates to a portable electronic device such as an IC card and an IC card that execute the above and output the processing result to the outside.

最近、携帯可能電子装置として、書換え可能な不揮発性メモリとしてのEEPROM、揮発性メモリとしてのRAM、これらのメモリに対してアクセス(データの読出しおよびまたは書込み等)を行なう制御素子としてのCPU、および、CPUの動作用プログラム等を格納したROMを有し、外部装置(ICカードリーダ・ライタ)から供給されるコマンド(命令)に対応した処理を実行して、その処理結果を外部装置へ出力する手段を備えたICチップを内蔵したICカードが産業各方面で利用されている。   Recently, as portable electronic devices, an EEPROM as a rewritable nonvolatile memory, a RAM as a volatile memory, a CPU as a control element for accessing (reading or writing data, etc.) these memories, and , Having a ROM storing a CPU operation program and the like, executing a process corresponding to a command supplied from an external device (IC card reader / writer), and outputting the processing result to the external device IC cards incorporating IC chips provided with means are used in various industries.

この種のICカードにおいて、不揮発性メモリには、メモリ容量が大容量で、バイナリデータを1回だけ書込めて書換えができないデータ領域(バイナリ・エレメンタリ・ファイル)が設定されているものがある(たとえば、非特許文献1参照)。
このような1回だけデータの書込みが許可されたデータ領域に対して、たとえば、特に画像データ等のデータ長が長いデータを書込む場合、分割して外部から入力されたデータを順次書込むことになる。その書込み途中において、通信異常等でデータの書込みが中断された場合、再度同一コマンドを実行しても途中までデータが書込まれているため、書込み異常となり、当該ICカードを再利用することはできない。
日本工業規格準拠 JICSAP 外部端子付きICカード仕 様(平成10年7月 第1.1版) 特開平10−214232号公報
In this type of IC card, some nonvolatile memories have a large memory capacity and a data area (binary elementary file) in which binary data is written only once and cannot be rewritten is set ( For example, refer nonpatent literature 1).
For example, when writing data having a long data length such as image data, for example, when writing data having a long data length to the data area in which data writing is permitted only once, the data inputted from the outside is sequentially written. become. If the data writing is interrupted due to a communication error in the middle of the writing, even if the same command is executed again, the data has been written halfway, so a writing error occurs and the IC card cannot be reused. Can not.
Japanese Industrial Standard Compliant JICSAP IC Card Specification with External Terminal (July 1998, 1.1 edition) JP-A-10-214232

しかし、上記した従来の技術では、1回だけデータの書込みが許可されたデータ領域に対して特にデータ長の長いデータを書込む途中において、通信異常等でデータの書込みが中断された場合、再度同一コマンドを実行しても途中までデータが書込まれているため、書込み異常(書込み失敗)となり、当該ICカードを再利用することはできず、効率的ではないという問題がある。   However, in the above-described conventional technique, when data writing is interrupted due to a communication error or the like in the middle of writing data having a long data length to the data area in which data writing is permitted only once, Even if the same command is executed, data is written halfway, so that there is a writing abnormality (writing failure), the IC card cannot be reused, and there is a problem that it is not efficient.

そこで、本発明は、たとえば、1回だけデータの書込みが許可されたデータ領域に対して特にデータ長の長いデータを書込む際に書込み異常(書込み失敗)が発生した場合、内部に記録した前回の書込み先頭アドレスおよび書込み最終アドレスを利用することで、書込み失敗している領域を見付け出し、再度書込み命令を受付けることにより、データ領域を再利用でき、効率的なデータ書込み処理が可能となる携帯可能電子装置およびICカードを提供することを目的とする。   Therefore, the present invention, for example, in the case where a writing error (writing failure) occurs when writing data having a long data length in a data area in which data writing is permitted only once, for example, the previously recorded inside By using the write start address and the write end address, it is possible to find an area where writing has failed and accept the write command again, so that the data area can be reused, enabling efficient data writing processing. An object is to provide a possible electronic device and an IC card.

本発明の携帯可能電子装置は、1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、この書込み処理手段によるデータの書込みが正常に終了した場合、前記アドレス記憶手段内の書込み先頭アドレスおよび書込み最終アドレスを特定の値に初期化する初期化手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスと一致するか否かを判定する第1の判定手段と、この第1の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスと一致する場合、当該データ領域に対する前回のデータ書込み処理が正常に終了しなかったものと判断して、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段とを具備している。   The portable electronic device according to the present invention includes a memory in which at least one data area in which data writing is permitted once is set, and data writing in the data area in which data writing is permitted only once When an address storage means for storing a start address and a write end address and a command for instructing data write to the data area in which data write is permitted only once are received, specific information in the command Address calculating means for obtaining a write start address and a write end address indicating the current data write range, and an address writing means for writing the write start address and write end address calculated by the address calculation means into the address storage means, , The data of the length specified by the received command is Write processing means for performing processing to write only to the data area in which data writing is permitted, and when writing of data by this writing processing means is completed normally, the write start address and write end in the address storage means When an initialization means for initializing an address to a specific value and a command for instructing data writing to the data area in which data writing is permitted only once are received again, the address for the command is received. First determination means for determining whether or not the current write start address and write end address calculated by the calculation means match the previous write start address and write end address in the address storage means; As a result of determination by the determination means, the current write start address and write end address are If the start address and the write end address match, it is determined that the previous data write process for the data area did not end normally, and the data in the data area was specified by the re-received instruction. Rewriting processing means for performing processing for rewriting data of length.

また、本発明の携帯可能電子装置は、1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内であるか否かを判定する第2の判定手段と、この第2の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内である場合、当該データ領域に対する前回のデータ書込み処理に書込み失敗があったか否かを判定する第3の判定手段と、この第3の判定手段による判定の結果、前回のデータ書込み処理に書込み失敗があった場合、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段とを具備している。   The portable electronic device of the present invention also includes a memory in which at least one data area in which data writing is permitted once is set, and data in the data area in which data writing is permitted only once. When the address storage means for storing the write start address and the write end address and the instruction to write data to the data area in which data writing is permitted only once are received, Address calculation means for obtaining the write start address and write end address indicating the current data write range based on the specific information, and address writing for writing the write start address and write end address calculated by the address calculation means into the address storage means Means and data of a length specified by the received command. Write processing means for performing a process of writing data to a data area permitted to write data once, and an instruction for instructing data writing to the data area permitted to write data only once If received again, whether the current write start address and write end address calculated by the address calculation means for the instruction are within the range of the previous write start address and write end address in the address storage means If the result of the determination by the second determination means and the second determination means is that the current write start address and write end address are within the range of the previous write start address and write end address, the data Third determination means for determining whether or not there has been a write failure in the previous data write processing for the area As a result of the determination by the third determination means, if there is a write failure in the previous data write process, the process of rewriting the data in the data area with the data of the length specified by the command received again Rewriting processing means for performing the above.

また、本発明のICカードは、1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、この書込み処理手段によるデータの書込みが正常に終了した場合、前記アドレス記憶手段内の書込み先頭アドレスおよび書込み最終アドレスを特定の値に初期化する初期化手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスと一致するか否かを判定する第1の判定手段と、この第1の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスと一致する場合、当該データ領域に対する前回のデータ書込み処理が正常に終了しなかったものと判断して、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段とを有して構成されるICモジュールと、このICモジュールを収納したICカード本体とを具備している。   Also, the IC card of the present invention has a memory in which at least one data area in which data writing is permitted once is set, and data writing in the data area in which data writing is permitted only once. When an address storage means for storing a start address and a write end address and a command for instructing data write to the data area in which data write is permitted only once are received, specific information in the command Address calculating means for obtaining a write start address and a write end address indicating the current data write range, and an address writing means for writing the write start address and write end address calculated by the address calculation means into the address storage means, , The data of the length specified by the received command is Write processing means for performing processing to write only to the data area in which data writing is permitted, and when writing of data by this writing processing means is completed normally, the write start address and write end in the address storage means When an initialization means for initializing an address to a specific value and a command for instructing data writing to the data area in which data writing is permitted only once are received again, the address for the command is received. First determination means for determining whether or not the current write start address and write end address calculated by the calculation means match the previous write start address and write end address in the address storage means; As a result of determination by the determination means, the current write start address and write end address are If the start address and the write end address match, it is determined that the previous data write process for the data area did not end normally, and the data in the data area was specified by the re-received instruction. There is provided an IC module having a rewrite processing means for performing a process of rewriting to length data, and an IC card main body containing the IC module.

また、本発明のICカードは、1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内であるか否かを判定する第2の判定手段と、この第2の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内である場合、当該データ領域に対する前回のデータ書込み処理に書込み失敗があったか否かを判定する第3の判定手段と、この第3の判定手段による判定の結果、前回のデータ書込み処理に書込み失敗があった場合、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段とを有して構成されるICモジュールと、このICモジュールを収納したICカード本体とを具備している。   Also, the IC card of the present invention has a memory in which at least one data area in which data writing is permitted once is set, and data writing in the data area in which data writing is permitted only once. When an address storage means for storing a start address and a write end address and a command for instructing data write to the data area in which data write is permitted only once are received, specific information in the command Address calculating means for obtaining a write start address and a write end address indicating the current data write range, and an address writing means for writing the write start address and write end address calculated by the address calculation means into the address storage means, , The data of the length specified by the received command is The write processing means for performing the process of writing data only in the data area permitted to write data and the instruction for instructing the data writing to the data area permitted to write data only once are received again. In this case, it is determined whether or not the current write start address and write end address calculated by the address calculation means for the instruction are within the range of the previous write start address and write end address in the address storage means. And when the current write start address and write end address are within the range of the previous write start address and write end address, the previous determination for the data area is made. A third determination means for determining whether or not there has been a write failure in the data write process; As a result of the determination by the third determination means, when there is a write failure in the previous data write process, a process of rewriting the data in the data area with the data of the length specified by the command received again is performed. An IC module having rewrite processing means and an IC card main body storing the IC module are provided.

本発明によれば、たとえば、1回だけデータの書込みが許可されたデータ領域に対して特にデータ長の長いデータを書込む際に書込み異常(書込み失敗)が発生した場合、内部に記録した前回の書込み先頭アドレスおよび書込み最終アドレスを利用することで、書込み失敗している領域を見付け出し、再度書込み命令を受付けることにより、データ領域を再利用でき、効率的なデータ書込み処理が可能となる携帯可能電子装置およびICカードを提供できる。   According to the present invention, for example, when a write error (write failure) occurs when writing data having a long data length in a data area in which data write is permitted only once, the previous time recorded inside By using the write start address and the write end address, it is possible to find an area where writing has failed and accept the write command again, so that the data area can be reused, enabling efficient data writing processing. Possible electronic devices and IC cards can be provided.

以下、本発明の実施の形態について図面を参照して説明する。
図1は、本発明の実施の形態に係る携帯可能電子装置としてのICカードを取扱うICカードシステムの構成例を示すものである。このICカードシステムは、ICカード11をカードリーダ・ライタ12を介してパーソナルコンピュータなどの端末装置13と接続可能にするとともに、端末装置13にキーボード14、CRT表示部15、プリンタ16を接続して構成される。
Embodiments of the present invention will be described below with reference to the drawings.
FIG. 1 shows a configuration example of an IC card system that handles an IC card as a portable electronic device according to an embodiment of the present invention. In this IC card system, the IC card 11 can be connected to a terminal device 13 such as a personal computer via a card reader / writer 12, and a keyboard 14, a CRT display unit 15, and a printer 16 are connected to the terminal device 13. Composed.

図2は、ICカード11の構成を示すもので、制御素子としてのCPU101、記憶内容が書換え可能な記憶手段(メモリ)としてのデータメモリ102、ワーキングメモリ103、プログラムメモリ104、および、カードリーダ・ライタ12との電気的接触を得るためのコンタクト部105によって構成されている。そして、これらのうち、破線内の部分(CPU101、データメモリ102、ワーキングメモリ103、プログラムメモリ104)は1つ(あるいは複数)のICチップ106で構成され、さらに、このICチップ106とコンタクト部105とが一体的にICモジュール化されて、ICカード本体11a内に埋設されている。   FIG. 2 shows the configuration of the IC card 11, and includes a CPU 101 as a control element, a data memory 102 as a storage means (memory) whose contents can be rewritten, a working memory 103, a program memory 104, a card reader, The contact portion 105 is used to obtain electrical contact with the writer 12. Of these, the portion within the broken line (CPU 101, data memory 102, working memory 103, program memory 104) is composed of one (or a plurality) of IC chips 106, and further this IC chip 106 and contact portion 105. Are integrated into an IC module and embedded in the IC card main body 11a.

データメモリ102は、たとえば、EEPROMなどの記憶内容が書換え可能な不揮発性メモリで構成されていて、各種アプリケーションデータなどがファイル構造で記憶される。   The data memory 102 is configured by a nonvolatile memory such as an EEPROM, which can rewrite stored contents, and stores various application data in a file structure.

たとえば、データメモリ102には、メモリ容量が大容量で、バイナリデータを1回だけ書込めて書換えができないデータ領域(バイナリ・エレメンタリ・ファイル、以下バイナリEFと略称する)が少なくとも1つ以上設定されていて、このバイナリEFには画像データ等(たとえば、10Kバイトあるいは20Kバイト以上の顔画像等)のデータ長が長いデータが格納されるものとする。   For example, the data memory 102 has at least one data area (binary elementary file, hereinafter abbreviated as binary EF) that has a large memory capacity and cannot be rewritten by writing binary data only once. In this binary EF, data having a long data length such as image data (for example, a face image of 10 Kbytes or 20 Kbytes or more) is stored.

ワーキングメモリ103は、CPU101が処理を行なう際の処理データなどを一時的に保持するための作業用メモリであり、たとえば、RAMなどで構成される。
プログラムメモリ104は、たとえば、マスクROMなどの記憶内容が書換え不可能な不揮発性メモリで構成されており、CPU101の制御プログラムなどを記憶するものである。
The working memory 103 is a working memory for temporarily storing processing data when the CPU 101 performs processing, and is configured by, for example, a RAM.
The program memory 104 is composed of, for example, a non-volatile memory that cannot be rewritten, such as a mask ROM, and stores a control program of the CPU 101 and the like.

図3は、データメモリ102内に前記バイナリEFを定義するためのEF定義情報の構成例を示すものである。たとえば、図3に示す例では、3つのEF定義情報21,22,23は、データメモリ102内に格納されていて、当該バイナリEFを識別するための識別情報である「EFID」、データメモリ102において当該バイナリEFが定義される位置を示す情報である「先頭アドレス」、当該バイナリEFの大きさ(格納可能なデータ長)を示す情報である「サイズ」、当該バイナリEFに対し前回データを書込んだ際の先頭のアドレスを示す情報である「前回書込み先頭アドレス」、および、当該バイナリEFに対し前回データを書込んだ際の最終のアドレスを示す情報である「前回書込み最終アドレス」を有して構成される。   FIG. 3 shows a configuration example of EF definition information for defining the binary EF in the data memory 102. For example, in the example shown in FIG. 3, the three EF definition information 21, 22, and 23 are stored in the data memory 102, and “EFID” that is identification information for identifying the binary EF, the data memory 102 The “start address” which is information indicating the position where the binary EF is defined, “size” which is information indicating the size (data length that can be stored) of the binary EF, and the previous data is written to the binary EF. “Last write start address”, which is information indicating the start address when the last read, and “Last write last address”, which is information indicating the last address when the previous data was written to the binary EF, are included. Configured.

たとえば、図3に示す例では、EF定義情報21は、EFIDが「0001」、先頭アドレスが「8000」、サイズが「1000」となっている。これは、データメモリ102におけるアドレス「8000」から「1000」バイト分の領域、つまり、アドレス「8000〜8FFF」までが「EFID=0001」のバイナリEFであることを定義することを示している。また、図3に示す例では、EF定義情報21は、前回書込み先頭アドレスおよび前回書込み最終アドレスは共に初期値として特定の値(たとえば、オールFF)が書込まれている状態を示している。   For example, in the example shown in FIG. 3, the EF definition information 21 has an EFID “0001”, a head address “8000”, and a size “1000”. This indicates that an area from the address “8000” to “1000” bytes in the data memory 102, that is, the address “8000 to 8FFF” is defined as a binary EF of “EFID = 0001”. In the example shown in FIG. 3, the EF definition information 21 indicates a state in which specific values (for example, all FFs) are written as initial values for the previous write start address and the previous write final address.

図3に示す例では、EF定義情報22は、EFIDが「0002」、先頭アドレスが「9000」、サイズが「200」となっている。これは、データメモリ102におけるアドレス「9000」から「200」バイト分の領域、つまり、アドレス「9000〜91FF」までが「EFID=0002」のバイナリEFであることを定義することを示している。また、図3に示す例では、EF定義情報22は、前回書込み先頭アドレスおよび前回書込み最終アドレスは共に初期値として特定の値(たとえば、オールFF)が書込まれている状態を示している。   In the example shown in FIG. 3, the EF definition information 22 has an EFID of “0002”, a head address of “9000”, and a size of “200”. This indicates that an area from the address “9000” to “200” bytes in the data memory 102, that is, the address “9000 to 91FF” is defined as a binary EF of “EFID = 0002”. In the example shown in FIG. 3, the EF definition information 22 indicates a state in which specific values (for example, all FF) are written as initial values for both the previous write start address and the previous write last address.

図3に示す例では、EF定義情報23は、EFIDが「0003」、先頭アドレスが「9200」、サイズが「100」となっている。これは、データメモリ102におけるアドレス「9200」から「100」バイト分の領域、つまり、アドレス「9200〜92FF」までが「EFID=0003」のバイナリEFであることを定義することを示している。また、図3に示す例では、EF定義情報23は、前回書込み先頭アドレスおよび前回書込み最終アドレスは共に初期値として特定の値(たとえば、オールFF)が書込まれている状態を示している。   In the example shown in FIG. 3, the EF definition information 23 has an EFID “0003”, a head address “9200”, and a size “100”. This indicates that an area from address “9200” to “100” bytes in the data memory 102, that is, addresses “9200 to 92FF” is defined as binary EF of “EFID = 0003”. In the example shown in FIG. 3, the EF definition information 23 indicates a state in which specific values (for example, all FFs) are written as initial values for the previous write start address and the previous write final address.

図4は、データメモリ102の1回だけデータの書込みが許可されたデータ領域(バイナリEF)に対してバイナリデータを書込む際のライトバイナリ(WRITE BINARY)コマンド(命令)のフォーマットを示すものである。ライトバイナリコマンドは、外部のカードリーダ・ライタ12から入力されるもので、コマンドを識別する機能などを持つ分類部(CLA:class)、命令部(INS:instruction)、パラメータデータ(P1、P2)、書込むデータの長さを表すデータ長(Lc)、および、書込みデータ(DATA)から構成されている。   FIG. 4 shows a format of a write binary (WRITE BINARY) command (instruction) when writing binary data to a data area (binary EF) in which data writing is permitted only once in the data memory 102. is there. The write binary command is input from an external card reader / writer 12, and includes a classification unit (CLA: class) having a function for identifying the command, an instruction unit (INS: instruction), and parameter data (P1, P2). The data length (Lc) indicating the length of data to be written and the write data (DATA).

CLA部およびINS部には、当該コマンドの種類を示す情報が格納される。図4に示す例では、CLA部およびINS部には、ライトバイナリコマンドであることを示す「00」および「D0」が格納されている。   Information indicating the type of the command is stored in the CLA part and the INS part. In the example shown in FIG. 4, “00” and “D0” indicating a write binary command are stored in the CLA part and the INS part.

P1部およびP2部には、当該コマンドの処理パラメータを示す情報が格納される。すなわち、P1部には、データの書込み対象となるバイナリEFを指定する情報(EFIDを示す情報)が格納される。図4に示す例では、P1部には、「81(16進数)=10000001(2進数)」が格納されている。なお、図4に示す例では、P1部における値の2進数の下5桁がEFの識別情報(EFID)を示すものとする。つまり、図4に示す例では、P1部はEFIDとして「00001」を指定している。   Information indicating processing parameters of the command is stored in the P1 part and the P2 part. That is, information (information indicating EFID) for specifying the binary EF to which data is to be written is stored in the P1 part. In the example shown in FIG. 4, “81 (hexadecimal number) = 10000001 (binary number)” is stored in the P1 part. In the example shown in FIG. 4, it is assumed that the last five digits of the binary number of the value in the P1 part indicate the identification information (EFID) of the EF. That is, in the example shown in FIG. 4, the P1 part designates “00001” as the EFID.

また、P2部には、P1部で指定されるバイナリEFにおけるデータの書込む位置(アドレス)を示す情報としてのオフセット値が格納される。図4に示す例では、P2部には、P1部で指定される「EFID=0001」のバイナリEFにおけるオフセット値を示す情報として「00」が格納されている。すなわち、図4に示す例では、EFIDが「00001で」、かつ、オフセット値が「0」である。このため、図4に示すライトバイナリコマンドでは、P1部およびP2部において、データの書込み開始位置として、「EFID=0001」のバイナリEFに対する先頭アドレスを指定している。   The P2 part stores an offset value as information indicating a position (address) at which data is written in the binary EF designated by the P1 part. In the example illustrated in FIG. 4, “00” is stored in the P2 portion as information indicating the offset value in the binary EF of “EFID = 0001” specified in the P1 portion. That is, in the example shown in FIG. 4, the EFID is “00001” and the offset value is “0”. Therefore, in the write binary command shown in FIG. 4, the head address for the binary EF of “EFID = 0001” is designated as the data write start position in the P1 and P2 parts.

また、Lc部には、バイナリデータとして書込むべきデータ全体の長さ(データ長)を示す情報が格納される。DATA部には、書込むべきデータのうち最初の部分のデータが格納される。この場合、DATA部には、所定の長さまでのデータが格納されるものとする。つまり、Lc部で指定されている長さのデータが必ずしもDATA部に全てが格納されているわけではない。バイナリデータとして書込むべきデータ全体の長さが、DATA部に格納しきれない長さであれば、DATA部には、書込むべきデータのうち最初の部分のデータが格納される。   In the Lc portion, information indicating the length (data length) of the entire data to be written as binary data is stored. The DATA part stores the first part of the data to be written. In this case, data up to a predetermined length is stored in the DATA section. That is, not all data having the length specified in the Lc part is necessarily stored in the DATA part. If the length of the entire data to be written as binary data is not long enough to be stored in the DATA part, the first part of the data to be written is stored in the DATA part.

たとえば、図4に示す例では、Lc部にはデータ長として「1000」が指定されている。これは、書込むべきバイナリデータ全体のデータ長が「1000」であることを示している。また、DATA部には、データ長が「100」のデータが格納されている。ここでは、DATA部に格納可能なデータ長が「100」であるとする。この場合、図4に示すように、ライトバイナリコマンドのDATA部には、書込むべきバイナリデータ全体のうち先頭からデータ長が「100」までのデータだけしか格納されていない。   For example, in the example shown in FIG. 4, “1000” is designated as the data length in the Lc portion. This indicates that the data length of the entire binary data to be written is “1000”. In the DATA section, data having a data length of “100” is stored. Here, it is assumed that the data length that can be stored in the DATA section is “100”. In this case, as shown in FIG. 4, in the DATA portion of the write binary command, only the data from the beginning to the data length of “100” is stored in the entire binary data to be written.

したがって、書込むべきバイナリデータのうち残りの「900」のデータは、当該ライトバイナリコマンドとは、別にICカード11に供給する必要がある。このため、ライトバイナリコマンドでは、当該コマンドのDATA部に格納しきれない残りのデータ(バイナリデータ)を続けてICカード11に供給できるようになっている。ここでは、当該ライトバイナリコマンドに続けて、データ長が「100」のデータが順次送信されるようになっているものとする。   Therefore, the remaining “900” data among the binary data to be written needs to be supplied to the IC card 11 separately from the write binary command. For this reason, in the write binary command, the remaining data (binary data) that cannot be stored in the DATA portion of the command can be continuously supplied to the IC card 11. Here, it is assumed that data having a data length of “100” is sequentially transmitted following the write binary command.

図5は、図4に示すライトバイナリコマンドに続いて送信されるべきデータ(コマンド)の例を示す図である。図4に示すライトバイナリコマンドで指定された書込むべきバイナリデータ全体は、図5に示すようなデータ長が「100」のデータごとに分割される。これらのデータ長が「100」のデータは、ライトバイナリコマンドに続いて順次送信されるようになっている。   FIG. 5 is a diagram showing an example of data (command) to be transmitted following the write binary command shown in FIG. The entire binary data to be written specified by the write binary command shown in FIG. 4 is divided into data having a data length of “100” as shown in FIG. These data having a data length of “100” are sequentially transmitted following the write binary command.

すなわち、ライトバイナリコマンドのDATA部に格納しきれないデータ長が大きなバイナリデータは、所定のデータ長に基づいて分割され、ライトバイナリコマンドに続いて順次、カードリーダ・ライタ12からICカード11へ供給されるようになっている。これにより、ICカード11では、ライトバイナリコマンドのLc部で指定されている長さのバイナリデータを、ライトバイナリコマンドのDATA部、および、ライトバイナリコマンドに続く送信データとして順次受信する。この場合、ICカード11は、受信したデータを書込む処理を行なうようになっている。   That is, binary data having a large data length that cannot be stored in the DATA portion of the write binary command is divided based on a predetermined data length, and sequentially supplied from the card reader / writer 12 to the IC card 11 following the write binary command. It has come to be. As a result, the IC card 11 sequentially receives binary data having a length specified in the Lc portion of the write binary command as transmission data following the DATA portion of the write binary command and the write binary command. In this case, the IC card 11 performs processing for writing received data.

次に、このような構成において、第1の実施の形態に係るライトバイナリコマンドに対するデータ書込み処理について図6および図7に示すフローチャートを参照して説明する。
CPU101は、カードリーダ・ライタ12からのリセット解除により活性化されると、カードリーダ・ライタ12に対し初期応答データを送信する(ステップS1)。初期応答データを正常に送信すると、CPU101は、カードリーダ・ライタ12から入力されるコマンドの受信を待機し、コマンドを正常に受信すると(ステップS2)、当該コマンドのCLA部およびINS部によりコマンドの種類を確認する(ステップS3)。確認の結果、受信したコマンドがライトバイナリコマンド以外の場合、CPU101は、対応するコマンド処理を実行するが(ステップS4)、ここでは説明を省略する。
Next, data write processing for the write binary command according to the first embodiment in such a configuration will be described with reference to the flowcharts shown in FIGS.
When activated by reset cancellation from the card reader / writer 12, the CPU 101 transmits initial response data to the card reader / writer 12 (step S1). When the initial response data is normally transmitted, the CPU 101 waits for reception of a command input from the card reader / writer 12, and when the command is normally received (step S2), the CLA portion and INS portion of the command receive a command. The type is confirmed (step S3). As a result of the confirmation, if the received command is other than the write binary command, the CPU 101 executes the corresponding command processing (step S4), but the description is omitted here.

ステップS3における確認の結果、受信したコマンドがライトバイナリコマンドの場合、CPU101は、当該コマンドのP1部およびP2部によって指定されたバイナリEFがデータメモリ102内に存在するか否かをチェックし(ステップS5)、指定されたバイナリEFが存在しない場合は所定のエラー処理を実行し(ステップS6)、ステップS2のコマンド受信待ち状態に戻る。   If the received command is a write binary command as a result of the confirmation in step S3, the CPU 101 checks whether the binary EF designated by the P1 part and the P2 part of the command exists in the data memory 102 (step S3). S5) If the designated binary EF does not exist, predetermined error processing is executed (step S6), and the process returns to the command reception waiting state in step S2.

ステップS5におけるチェックの結果、指定されたバイナリEFが存在する場合、CPU101は、今回受信したコマンドにより書込まれる対象EFの書込み先頭アドレスおよび書込み最終アドレスを計算する(ステップS7)。この計算は、当該EFのEF定義情報内の先頭アドレスに受信したコマンドのP1部内のオフセット値を加算することで書込み先頭アドレスが得られ(先頭アドレス+オフセット値=書込み先頭アドレス)、また、当該EFのEF定義情報内の先頭アドレスに受信したコマンドのP1部内のオフセット値とLc部内のデータ長を加算することで書込み最終アドレスが得られる(先頭アドレス+オフセット値+データ長=書込み最終アドレス)。   As a result of the check in step S5, if the designated binary EF exists, the CPU 101 calculates the write start address and write end address of the target EF written by the command received this time (step S7). In this calculation, the write start address is obtained by adding the offset value in the P1 part of the received command to the start address in the EF definition information of the EF (start address + offset value = write start address). The write end address is obtained by adding the offset value in the P1 portion of the received command and the data length in the Lc portion to the start address in the EF definition information of the EF (start address + offset value + data length = write end address). .

次に、CPU101は、当該EFのEF定義情報内に前回書込み先頭アドレスおよび前回書込み最終アドレスが書込まれているか否かを確認する(ステップS8)。この確認の結果、両アドレスが書込まれている場合はステップS9に進み、両アドレスが書込まれていない場合、前回のデータ書込みは正常に終わったものと判断してステップS10に進む。   Next, the CPU 101 checks whether or not the previous write start address and the previous write last address are written in the EF definition information of the EF (step S8). As a result of the confirmation, if both addresses are written, the process proceeds to step S9. If both addresses are not written, it is determined that the previous data writing is normally completed, and the process proceeds to step S10.

ステップS9では、ステップS7で計算された今回の書込み対象EFの書込み先頭アドレスおよび書込み最終アドレスが、当該EFのEF定義情報内に書込まれている前回書込み先頭アドレスおよび前回書込み最終アドレスと一致しているか否かを確認する。   In step S9, the write start address and write end address of the current write target EF calculated in step S7 match the previous write start address and previous write last address written in the EF definition information of the EF. Check if it is.

この確認の結果、両アドレスが不一致の場合、新たなEFに対するデータ書込みであると判断してステップS10に進み、両アドレスが一致の場合、コマンドのやり直しと判断してステップS11に進む。   As a result of this confirmation, if both addresses do not match, it is determined that data is written to a new EF, and the process proceeds to step S10. If both addresses match, it is determined that the command is to be retried and the process proceeds to step S11.

ステップS10では、今回書込む対象EFが未書込み状態であるか、つまりデータ未書込み状態を示す特定データ(たとえば、オールFF)であるか否かを確認する。この確認の結果、今回書込む対象EFが未書込み状態でない場合、CPU101は、所定のエラー処理を実行し(ステップS12)、ステップS2のコマンド受信待ち状態に戻る。
ステップS10における確認の結果、今回書込む対象EFが未書込み状態である場合、ステップS11に進む。
In step S10, it is confirmed whether or not the target EF to be written this time is in an unwritten state, that is, specific data (for example, all FF) indicating a data unwritten state. As a result of this confirmation, if the target EF to be written this time is not in an unwritten state, the CPU 101 executes a predetermined error process (step S12) and returns to the command reception waiting state in step S2.
As a result of the confirmation in step S10, when the target EF to be written this time is in an unwritten state, the process proceeds to step S11.

ステップS11では、ステップS7で計算された今回の書込み対象EFの書込み先頭アドレスおよび書込み最終アドレスを、当該EFのEF定義情報の前回書込み先頭アドレスおよび前回書込み最終アドレスとして書込む。   In step S11, the write start address and write end address of the current write target EF calculated in step S7 are written as the previous write start address and previous write end address of the EF definition information of the EF.

次に、CPU101は、受信したコマンドのP2部に格納されているオフセット値で指定される先頭アドレスから当該コマンドのDATA部に格納されているデータを書込む処理を行なう(ステップS13)。
たとえば、図4に示すようなライトバイナリコマンドを受信した場合、データメモリ102における「EFID=0001」のバイナリEFの先頭アドレス「8000」からDATA部に格納されているデータ(全データ長「1000」のうちの最初のデータ長「100」分のデータ)を書込む処理を行なう。
Next, the CPU 101 performs a process of writing data stored in the DATA part of the command from the head address specified by the offset value stored in the P2 part of the received command (step S13).
For example, when a write binary command as shown in FIG. 4 is received, data stored in the DATA portion from the start address “8000” of the binary EF of “EFID = 0001” in the data memory 102 (total data length “1000”) Of the first data length of “100”) is written.

ステップS13の書込み処理が終了すると、CPU101は、全データの受信および書込み処理が完了したか否かを確認する(ステップS14)。この確認は、当該コマンドのLc部に格納されているデータ長のデータ(つまり、全データ長分のバイナリデータ)の書込みが完了したか否かにより判断される。   When the writing process in step S13 is completed, the CPU 101 checks whether or not all data reception and writing processes are completed (step S14). This confirmation is determined by whether or not the writing of the data having the data length stored in the Lc portion of the command (that is, binary data for the entire data length) has been completed.

ステップS14における確認の結果、全データの受信および書込み処理が完了していない場合、CPU101は、受信した分のデータの書込み終了を示すレスポンスをカードリーダ・ライタ12に送信し、次のデータ(バイナリデータ)の受信待ち状態となる。カードリーダ・ライタ12では、ICカード11からの書込み終了を示すレスポンスに応じて次のデータ(バイナリデータ)を送信する処理を行なう。   As a result of the confirmation in step S14, if reception and writing of all data has not been completed, the CPU 101 transmits a response indicating completion of writing of the received data to the card reader / writer 12, and the next data (binary (Data) waiting to be received. The card reader / writer 12 performs processing for transmitting the next data (binary data) in response to a response indicating the end of writing from the IC card 11.

上記データ受信待ち状態において、カードリーダ・ライタ12から次のデータが送信されると、CPU101は、当該データを受信する受信処理を行なう(ステップS15)。この受信処理において、CPU101は、データが正常に受信されているか否かをチェックする処理を行なっている(ステップS16)。   When the next data is transmitted from the card reader / writer 12 in the data reception waiting state, the CPU 101 performs a reception process for receiving the data (step S15). In this reception process, the CPU 101 performs a process of checking whether or not data is normally received (step S16).

ステップS16におけるチェックの結果、カードリーダ・ライタ12から送信されたデータが正常に受信されたと判断した場合、CPU101は、ステップS13に戻り、受信したデータの書込み処理を行なう。   If the CPU 101 determines that the data transmitted from the card reader / writer 12 has been normally received as a result of the check in step S16, the CPU 101 returns to step S13 and performs a process of writing the received data.

ステップS16におけるチェックの結果、データの受信処理において通信異常が発生したと判断した場合、つまり、バイナリデータの受信途中で通信異常が発生した場合、CPU101は、所定のエラー処理を実行し(ステップS17)、ステップS2のコマンド受信待ち状態に戻る。   As a result of the check in step S16, if it is determined that a communication error has occurred in the data reception process, that is, if a communication error has occurred in the middle of binary data reception, the CPU 101 executes a predetermined error process (step S17). ), The process returns to the command reception waiting state in step S2.

このように、CPU101は、ライトバイナリコマンドで指定された全データが受信済みと判断されるまで、ステップS13〜S16の処理を繰り返し実行する。これにより、通信エラーなどのエラーが発生しなければ、複数に分割されて供給されるバイナリデータをライトバイナリコマンドで指定された条件にしたがってデータメモリ102に書込むことができる。   As described above, the CPU 101 repeatedly executes the processes of steps S13 to S16 until it is determined that all data specified by the write binary command has been received. As a result, if an error such as a communication error does not occur, binary data that is divided and supplied can be written into the data memory 102 according to the conditions specified by the write binary command.

ステップS14において、全データ(ライトバイナリコマンドのLc部で指定されたデータ長のバイナリデータ)の受信および書込み処理がすべて終了したと判断した場合、CPU101は、受信したライトバイナリコマンドに対する全ての処理が正常に終了したものと判断する。   If it is determined in step S14 that all the data (binary data having the data length specified in the Lc portion of the write binary command) has been received and written, the CPU 101 performs all the processes for the received write binary command. Judged to have completed normally.

この場合、CPU101は、当該ライトバイナリコマンドで指定されていたEFの定義情報における前回書込み先頭アドレスおよび前回書込み最終アドレスを特定の値(たとえば、オールFF)に初期化する処理を行なうとともに、正常終了処理を行ない(ステップS18)、ステップS2のコマンド受信待ち状態に戻る。ここに、正常終了処理としては、たとえば、当該ライトバイナリコマンドで指定された全データの書込みが終了した旨をカードリーダ・ライタ12に通知する処理などを行なう。   In this case, the CPU 101 performs a process of initializing the previous write start address and the previous write final address in the EF definition information specified by the write binary command to specific values (for example, all FFs) and completes normally. Processing is performed (step S18), and the process returns to the command reception waiting state in step S2. Here, as the normal termination process, for example, a process of notifying the card reader / writer 12 that writing of all data designated by the write binary command is completed.

次に、第2の実施の形態に係るライトバイナリコマンドに対するデータ書込み処理について図8および図9に示すフローチャートを参照して説明する。
CPU101は、カードリーダ・ライタ12からのリセット解除により活性化されると、カードリーダ・ライタ12に対し初期応答データを送信する(ステップS21)。初期応答データを正常に送信すると、CPU101は、カードリーダ・ライタ12から入力されるコマンドの受信を待機し、コマンドを正常に受信すると(ステップS22)、当該コマンドのCLA部およびINS部によりコマンドの種類を確認する(ステップS23)。確認の結果、受信したコマンドがライトバイナリコマンド以外の場合、CPU101は、対応するコマンド処理を実行するが(ステップS24)、ここでは説明を省略する。
Next, data write processing for a write binary command according to the second embodiment will be described with reference to the flowcharts shown in FIGS.
When activated by reset cancellation from the card reader / writer 12, the CPU 101 transmits initial response data to the card reader / writer 12 (step S21). When the initial response data is normally transmitted, the CPU 101 waits for reception of a command input from the card reader / writer 12, and when the command is normally received (step S22), the CLA unit and the INS unit of the command receive the command. The type is confirmed (step S23). As a result of the confirmation, if the received command is other than the write binary command, the CPU 101 executes the corresponding command processing (step S24), but the description is omitted here.

ステップS23における確認の結果、受信したコマンドがライトバイナリコマンドの場合、CPU101は、当該コマンドのP1部およびP2部によって指定されたバイナリEFがデータメモリ102内に存在するか否かをチェックし(ステップS25)、指定されたバイナリEFが存在しない場合は所定のエラー処理を実行し(ステップS26)、ステップS2のコマンド受信待ち状態に戻る。   If the received command is a write binary command as a result of the confirmation in step S23, the CPU 101 checks whether the binary EF designated by the P1 part and the P2 part of the command exists in the data memory 102 (step S23). S25) If the designated binary EF does not exist, predetermined error processing is executed (step S26), and the process returns to the command reception waiting state in step S2.

ステップS25におけるチェックの結果、指定されたバイナリEFが存在する場合、CPU101は、今回受信したコマンドにより書込まれる対象EFの書込み先頭アドレスおよび書込み最終アドレスを計算する(ステップS27)。この計算は、当該EFのEF定義情報内の先頭アドレスに受信したコマンドのP1部内のオフセット値を加算することで書込み先頭アドレスが得られ(先頭アドレス+オフセット値=書込み先頭アドレス)、また、当該EFのEF定義情報内の先頭アドレスに受信したコマンドのP1部内のオフセット値とLc部内のデータ長を加算することで書込み最終アドレスが得られる(先頭アドレス+オフセット値+データ長=書込み最終アドレス)。   As a result of the check in step S25, if the designated binary EF exists, the CPU 101 calculates the write start address and write end address of the target EF written by the command received this time (step S27). In this calculation, the write start address is obtained by adding the offset value in the P1 part of the received command to the start address in the EF definition information of the EF (start address + offset value = write start address). The write end address is obtained by adding the offset value in the P1 portion of the received command and the data length in the Lc portion to the start address in the EF definition information of the EF (start address + offset value + data length = write end address). .

次に、CPU101は、当該EFのEF定義情報内に前回書込み先頭アドレスおよび前回書込み最終アドレスが書込まれているか否かを確認する(ステップS28)。この確認の結果、両アドレスが書込まれている場合はステップS29に進み、両アドレスが書込まれていない場合、前回のデータ書込みは正常に終わったものと判断してステップS30に進む。   Next, the CPU 101 checks whether or not the previous write start address and the previous write last address are written in the EF definition information of the EF (step S28). As a result of the confirmation, if both addresses are written, the process proceeds to step S29. If both addresses are not written, it is determined that the previous data writing is normally completed, and the process proceeds to step S30.

ステップS29では、ステップS27で計算された今回の書込み対象EFの書込み先頭アドレスおよび書込み最終アドレスが、当該EFのEF定義情報内に書込まれている前回書込み先頭アドレスおよび前回書込み最終アドレスの範囲内であるか否かを確認する。   In step S29, the write start address and write end address of the current write target EF calculated in step S27 are within the range of the previous write start address and previous write end address written in the EF definition information of the EF. It is confirmed whether or not.

この確認の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回書込み先頭アドレスおよび前回書込み最終アドレスの範囲内である場合はステップS31に進み、今回の書込み先頭アドレスおよび書込み最終アドレスが前回書込み先頭アドレスおよび前回書込み最終アドレスの範囲内でない場合、新たなEFに対するデータ書込みであると判断してステップS31に進む。   As a result of this confirmation, if the current write start address and the write last address are within the range of the previous write start address and the previous write last address, the process proceeds to step S31, and the current write start address and the write final address are the previous write start address. If it is not within the range of the last address written last time, it is determined that data is written to a new EF, and the process proceeds to step S31.

ステップS30では、今回書込む対象EFが未書込み状態であるか、つまりデータ未書込み状態を示す特定データ(たとえば、オールFF)であるか否かを確認する。この確認の結果、今回書込む対象EFが未書込み状態でない場合、CPU101は、所定のエラー処理を実行し(ステップS33)、ステップS22のコマンド受信待ち状態に戻る。
ステップS30における確認の結果、今回書込む対象EFが未書込み状態である場合、ステップS32に進む。
In step S30, it is confirmed whether or not the target EF to be written this time is an unwritten state, that is, specific data (for example, all FF) indicating a data unwritten state. As a result of the confirmation, if the target EF to be written this time is not in an unwritten state, the CPU 101 executes a predetermined error process (step S33) and returns to the command reception waiting state in step S22.
As a result of the confirmation in step S30, if the target EF to be written this time is in an unwritten state, the process proceeds to step S32.

ステップS31では、前回のデータ書込み処理が途中で失敗したか否かを確認する。この確認の結果、前回書込み処理が途中で失敗している場合、CPU101は、コマンドのやり直しと判断してステップS32に進む。
ステップS31における確認の結果、前回書込み処理の失敗がない場合、CPU101は、新たなEFに対するデータ書込みであると判断してステップS30に進む。
In step S31, it is confirmed whether or not the previous data writing process has failed midway. As a result of the confirmation, if the previous writing process has failed in the middle, the CPU 101 determines that the command is to be redone, and proceeds to step S32.
As a result of the confirmation in step S31, if there is no failure in the previous writing process, the CPU 101 determines that the data writing is for the new EF, and proceeds to step S30.

ここに、ステップS31における前回書込み処理失敗の確認方法(判定方法)は、データ未書込み状態が特定データ(たとえば、オールFF)であることから、当該EFにおいて前回書込み最終アドレスから前方にあらかじめ定められた所定バイト分特定データ(FF)が連続して存在するか否かをチェックし、所定バイト分特定データ(FF)が連続して存在する場合、最後までデータ書込みができなかったものと判断して、書込み失敗と判定する。   Here, the confirmation method (determination method) of the previous write processing failure in step S31 is predetermined in advance from the last write last address in the EF because the data unwritten state is specific data (for example, all FF). It is checked whether specific data (FF) for a predetermined number of bytes exists continuously. If specific data (FF) for a predetermined number of bytes exists continuously, it is determined that data could not be written to the end. It is determined that the writing has failed.

ステップS32では、ステップS27で計算された今回の書込み対象EFの書込み先頭アドレスおよび書込み最終アドレスを、当該EFのEF定義情報の前回書込み先頭アドレスおよび前回書込み最終アドレスとして書込む。   In step S32, the write start address and write end address of the current write target EF calculated in step S27 are written as the previous write start address and previous write end address of the EF definition information of the EF.

次に、CPU101は、受信したコマンドのP2部に格納されているオフセット値で指定される先頭アドレスから当該コマンドのDATA部に格納されているデータを書込む処理を行なう(ステップS34)。
たとえば、図4に示すようなライトバイナリコマンドを受信した場合、データメモリ102における「EFID=0001」のバイナリEFの先頭アドレス「8000」からDATA部に格納されているデータ(全データ長「1000」のうちの最初のデータ長「100」分のデータ)を書込む処理を行なう。
Next, the CPU 101 performs processing for writing data stored in the DATA portion of the command from the head address specified by the offset value stored in the P2 portion of the received command (step S34).
For example, when a write binary command as shown in FIG. 4 is received, data stored in the DATA portion from the start address “8000” of the binary EF of “EFID = 0001” in the data memory 102 (total data length “1000”) Of the first data length of “100”) is written.

ステップS34の書込み処理が終了すると、CPU101は、全データの受信および書込み処理が完了したか否かを確認する(ステップS35)。この確認は、当該コマンドのLc部に格納されているデータ長のデータ(つまり、全データ長分のバイナリデータ)の書込みが完了したか否かにより判断される。   When the writing process in step S34 is completed, the CPU 101 confirms whether or not all data reception and writing processes are completed (step S35). This confirmation is determined by whether or not the writing of the data having the data length stored in the Lc portion of the command (that is, binary data for the entire data length) has been completed.

ステップS35における確認の結果、全データの受信および書込み処理が完了していない場合、CPU101は、受信した分のデータの書込み終了を示すレスポンスをカードリーダ・ライタ12に送信し、次のデータ(バイナリデータ)の受信待ち状態となる。カードリーダ・ライタ12では、ICカード11からの書込み終了を示すレスポンスに応じて次のデータ(バイナリデータ)を送信する処理を行なう。   As a result of the confirmation in step S35, if reception and writing of all data has not been completed, the CPU 101 transmits a response indicating completion of writing of the received data to the card reader / writer 12, and the next data (binary (Data) waiting to be received. The card reader / writer 12 performs processing for transmitting the next data (binary data) in response to a response indicating the end of writing from the IC card 11.

上記データ受信待ち状態において、カードリーダ・ライタ12から次のデータが送信されると、CPU101は、当該データを受信する受信処理を行なう(ステップS36)。この受信処理において、CPU101は、データが正常に受信されているか否かをチェックする処理を行なっている(ステップS37)。   When the next data is transmitted from the card reader / writer 12 in the data reception waiting state, the CPU 101 performs a reception process for receiving the data (step S36). In this reception process, the CPU 101 performs a process of checking whether or not data is normally received (step S37).

ステップS37におけるチェックの結果、カードリーダ・ライタ12から送信されたデータが正常に受信されたと判断した場合、CPU101は、ステップS34に戻り、受信したデータの書込み処理を行なう。   If the CPU 101 determines that the data transmitted from the card reader / writer 12 has been normally received as a result of the check in step S37, the CPU 101 returns to step S34 and performs a process of writing the received data.

ステップS37におけるチェックの結果、データの受信処理において通信異常が発生したと判断した場合、つまり、バイナリデータの受信途中で通信異常が発生した場合、CPU101は、所定のエラー処理を実行し(ステップS38)、ステップS22のコマンド受信待ち状態に戻る。   As a result of the check in step S37, if it is determined that a communication error has occurred in the data reception process, that is, if a communication error has occurred in the middle of binary data reception, the CPU 101 executes a predetermined error process (step S38). ), The process returns to the command reception waiting state in step S22.

このように、CPU101は、ライトバイナリコマンドで指定された全データが受信済みと判断されるまで、ステップS34〜S37の処理を繰り返し実行する。これにより、通信エラーなどのエラーが発生しなければ、複数に分割されて供給されるバイナリデータをライトバイナリコマンドで指定された条件にしたがってデータメモリ102に書込むことができる。   As described above, the CPU 101 repeatedly executes the processes of steps S34 to S37 until it is determined that all the data designated by the write binary command has been received. As a result, if an error such as a communication error does not occur, binary data that is divided and supplied can be written into the data memory 102 according to the conditions specified by the write binary command.

ステップS35において、全データ(ライトバイナリコマンドのLc部で指定されたデータ長のバイナリデータ)の受信および書込み処理がすべて終了したと判断した場合、CPU101は、受信したライトバイナリコマンドに対する全ての処理が正常に終了したものと判断して、正常終了処理を行ない(ステップS39)、ステップS22のコマンド受信待ち状態に戻る。ここに、正常終了処理としては、たとえば、当該ライトバイナリコマンドで指定された全データの書込みが終了した旨をカードリーダ・ライタ12に通知する処理などを行なう。   If it is determined in step S35 that all the data (binary data having the data length specified by the Lc portion of the write binary command) has been received and written, the CPU 101 performs all the processes for the received write binary command. It is determined that the process has been completed normally, normal termination processing is performed (step S39), and the process returns to the command reception waiting state in step S22. Here, as the normal termination process, for example, a process of notifying the card reader / writer 12 that writing of all data designated by the write binary command is completed.

次に、第3の実施の形態に係るライトバイナリコマンドに対するデータ書込み処理について説明する。   Next, data write processing for a write binary command according to the third embodiment will be described.

第3の実施の形態は、前述した第2の実施の形態におけるステップS31の処理、すなわち、前回書込み処理失敗の確認方法(判定方法)が異なるもので、その外は第2の実施の形態と同様であるので説明は省略し、異なる部分についてだけ詳細に説明する。   The third embodiment is different in the process of step S31 in the second embodiment described above, that is, the confirmation method (determination method) of the previous write process failure, and the others are the same as in the second embodiment. Since it is the same, description is abbreviate | omitted and only a different part is demonstrated in detail.

受信したデータを書込み対象EFに書込む際にまれに、書込み処理を失敗しているが、ICカード11からカードリーダ・ライタ12へのレスポンスは正常である場合も考えられる。その際は、途中に未書込み状態が存在する。このような場合に適用されるのが第3の実施の形態に係る前回書込み処理失敗の確認方法(判定方法)であり、以下、それについて説明する。   In rare cases, when the received data is written to the write target EF, the write process has failed, but the response from the IC card 11 to the card reader / writer 12 may be normal. In that case, an unwritten state exists in the middle. What is applied in such a case is the previous write process failure confirmation method (determination method) according to the third embodiment, which will be described below.

まず、第1の方法として、データ未書込み状態が特定データ(たとえば、オールFF)であることから、当該EFにおいて前回書込み先頭アドレスから前回書込み最終アドレスまでの間に、あらかじめ定められた所定バイト分特定データ(FF)が存在するか否かをチェックし、所定バイト分特定データ(FF)が存在する場合、書込み途中でデータ書込みができなかったものと判断して、書込み失敗と判定する。   First, as a first method, since the data unwritten state is specific data (for example, all FF), a predetermined number of bytes determined in advance between the previous write start address and the previous write final address in the EF. It is checked whether or not the specific data (FF) exists, and when the specific data (FF) exists for a predetermined number of bytes, it is determined that the data could not be written during the writing, and it is determined that the writing has failed.

次に、第2の方法として、ライトバイナリコマンドを受信した際に、当該コマンドのDATA部に格納されているデータに対してFF検索処理を実施することで連続するFFの最大数を求め、この求めた最大のFF連続数を記録しておく。すなわち、この例の場合、EF定義情報は図10に示すように、図3の構成に「FF検知長」が付加された構成となっており、このFF検知長に上記求めた最大のFF連続数を格納しておくものである。   Next, as a second method, when a write binary command is received, the maximum number of consecutive FFs is obtained by performing FF search processing on the data stored in the DATA portion of the command, and this Record the maximum number of consecutive FFs obtained. That is, in the case of this example, as shown in FIG. 10, the EF definition information has a configuration in which “FF detection length” is added to the configuration in FIG. Stores numbers.

そして、次回のライトバイナリコマンド受信時に、当該EFにおいて前回書込み先頭アドレスから前回書込み最終アドレスまでの間に連続して存在するFFの数を求め、この求めたFF連続数が当該EFのEF定義情報内のFF検知長(最大のFF連続数)よりも大きいか否かを判定し、求めたFF連続数がEF定義情報内のFF検知長よりも大きい場合、書込み途中でデータ書込みができなかったものと判断して、書込み失敗と判定する。   When the next write binary command is received, the number of FFs continuously present in the EF from the previous write start address to the last write last address is obtained, and the obtained FF continuous number is the EF definition information of the EF. It is determined whether or not it is larger than the FF detection length (maximum number of FFs), and if the obtained number of FFs is larger than the FF detection length in the EF definition information, data could not be written during writing. It is determined that the writing has failed.

なお、図10に示す例では、FF検知長は初期値として特定の値(たとえば、数値「0」)が書込まれている状態を示している。   In the example illustrated in FIG. 10, the FF detection length indicates a state where a specific value (for example, a numerical value “0”) is written as an initial value.

以上説明したように、上記実施の形態によれば、1回だけデータの書込みが許可されたバイナリEFに対して特にデータ長の長いデータを書込む際に書込み異常(書込み失敗)が発生した場合、内部に記録した前回の書込み先頭アドレスおよび書込み最終アドレスを利用することで、書込み失敗している領域を見付け出し、再度ライトバイナリコマンドを受付けることにより、バイナリEFを再利用でき、効率的なデータ書込み処理が可能となる。   As described above, according to the above embodiment, when a write error (write failure) occurs when writing data with a long data length to binary EF that is allowed to write data only once. By using the previous write start address and write end address recorded internally, it is possible to find the area where writing has failed and accept the write binary command again, so that the binary EF can be reused and efficient data Write processing is possible.

なお、前記実施の形態では、携帯可能電子装置として接触式のICカードに適用した場合について説明したが、本発明はこれに限定されるものではなく、非接触式のICカードなどへの応用も可能であり、また、PDAと称される携帯端末装置や携帯電話機などであっても適用でき、さらに、携帯可能電子装置の形状もカード型に限らず、冊子型、ブロック型あるいはタグ型など、他の形状であってもよい。   In the above embodiment, the case where the present invention is applied to a contact type IC card as a portable electronic device has been described. However, the present invention is not limited to this and can be applied to a non-contact type IC card. It can also be applied to a portable terminal device or a mobile phone called PDA, and the shape of the portable electronic device is not limited to a card type, but a booklet type, a block type, a tag type, Other shapes may be used.

本発明の実施の形態に係る携帯可能電子装置としてのICカードを取扱うICカードシステムの構成例を示すブロック図。The block diagram which shows the structural example of the IC card system which handles the IC card as a portable electronic device which concerns on embodiment of this invention. ICカードの構成を概略的に示すブロック図。1 is a block diagram schematically showing the configuration of an IC card. EF定義情報の構成例を概略的に示す図。The figure which shows schematically the structural example of EF definition information. ライトバイナリコマンドのフォーマットを示す模式図。The schematic diagram which shows the format of a write binary command. ライトバイナリコマンドに続く送信データの例を示す図。The figure which shows the example of the transmission data following a write binary command. 第1の実施の形態に係るライトバイナリコマンドに対するデータ書込み処理について説明するフローチャート。6 is a flowchart for explaining data write processing for a write binary command according to the first embodiment. 第1の実施の形態に係るライトバイナリコマンドに対するデータ書込み処理について説明するフローチャート。6 is a flowchart for explaining data write processing for a write binary command according to the first embodiment. 第2の実施の形態に係るライトバイナリコマンドに対するデータ書込み処理について説明するフローチャート。9 is a flowchart for explaining data write processing for a write binary command according to the second embodiment. 第2の実施の形態に係るライトバイナリコマンドに対するデータ書込み処理について説明するフローチャート。9 is a flowchart for explaining data write processing for a write binary command according to the second embodiment. 第3の実施の形態に係るEF定義情報の構成例を概略的に示す図。The figure which shows schematically the structural example of the EF definition information which concerns on 3rd Embodiment.

符号の説明Explanation of symbols

11…ICカード(携帯可能電子装置)、11a…ICカード本体、12…カードリーダ・ライタ、13…端末装置、14…キーボード、15…CRT表示部、16…プリンタ、101…CPU(制御素子)、102…データメモリ(記憶手段)、103…ワーキングメモリ、104…プログラムメモリ、105…コンタクト部、106…ICチップ、21,22,23…EF定義情報。   DESCRIPTION OF SYMBOLS 11 ... IC card (portable electronic device), 11a ... IC card main body, 12 ... Card reader / writer, 13 ... Terminal device, 14 ... Keyboard, 15 ... CRT display part, 16 ... Printer, 101 ... CPU (control element) , 102 ... Data memory (storage means), 103 ... Working memory, 104 ... Program memory, 105 ... Contact part, 106 ... IC chip, 21, 22, 23 ... EF definition information.

Claims (10)

1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、
前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、
前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、
このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、
前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、
この書込み処理手段によるデータの書込みが正常に終了した場合、前記アドレス記憶手段内の書込み先頭アドレスおよび書込み最終アドレスを特定の値に初期化する初期化手段と、
前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスと一致するか否かを判定する第1の判定手段と、
この第1の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスと一致する場合、当該データ領域に対する前回のデータ書込み処理が正常に終了しなかったものと判断して、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段と、
を具備したことを特徴とする携帯可能電子装置。
A memory in which at least one data area in which data writing is permitted only once is set; and
Address storage means for storing a write start address and a write end address of data for a data area in which data writing is permitted only once;
When a command for instructing data writing to the data area where data writing is permitted only once is received, the write start address and write end address indicating the current data write range based on the specific information in the command Address calculating means for obtaining
Address writing means for writing the write start address and write end address calculated by the address calculation means into the address storage means;
Write processing means for performing a process of writing data of a length specified by the received instruction to the data area in which data writing is permitted only once;
When the writing of data by the writing processing means is normally completed, an initializing means for initializing a write head address and a write end address in the address storage means to specific values;
When a command for instructing data writing to the data area in which data writing is permitted only once is received again, the current write head address and write last address calculated by the address calculation means for the command First determination means for determining whether the address matches the previous write start address and write end address in the address storage means;
As a result of the determination by the first determination means, if the current write start address and write end address match the previous write start address and write end address, the previous data write processing for the data area does not end normally. Rewriting processing means for performing processing for rewriting the data in the data area to data of a length specified by the re-received instruction;
A portable electronic device comprising:
1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、
前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、
前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、
このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、
前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、
前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内であるか否かを判定する第2の判定手段と、
この第2の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内である場合、当該データ領域に対する前回のデータ書込み処理に書込み失敗があったか否かを判定する第3の判定手段と、
この第3の判定手段による判定の結果、前回のデータ書込み処理に書込み失敗があった場合、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段と、
を具備したことを特徴とする携帯可能電子装置。
A memory in which at least one data area in which data writing is permitted only once is set; and
Address storage means for storing a write start address and a write end address of data for a data area in which data writing is permitted only once;
When a command for instructing data writing to the data area where data writing is permitted only once is received, the write start address and write end address indicating the current data write range based on the specific information in the command Address calculating means for obtaining
Address writing means for writing the write start address and write end address calculated by the address calculation means into the address storage means;
Write processing means for performing a process of writing data of a length specified by the received instruction to the data area in which data writing is permitted only once;
When a command for instructing data writing to the data area in which data writing is permitted only once is received again, the current write head address and write last address calculated by the address calculation means for the command Second determination means for determining whether the address is within the range of the previous write start address and write end address in the address storage means;
As a result of the determination by the second determination means, if the current write start address and write end address are within the range of the previous write start address and write end address, a write failure has occurred in the previous data write process for the data area. Third determination means for determining whether or not there has been,
As a result of the determination by the third determination means, if there is a write failure in the previous data write process, the process of rewriting the data in the data area with the data of the length specified by the command received again Rewrite processing means to be performed;
A portable electronic device comprising:
前記第3の判定手段は、当該データ領域において、前記アドレス記憶手段内の前回の書込み最終アドレスから前方に所定長分連続してデータ未書込み状態を示す特定データが存在した場合に前回のデータ書込み処理に書込み失敗があったと判定することを特徴とする請求項2記載の携帯可能電子装置。   In the data area, the third determination unit writes the previous data when there is specific data indicating a data unwritten state continuously for a predetermined length ahead from the last write last address in the address storage unit. The portable electronic device according to claim 2, wherein it is determined that there has been a writing failure in the process. 前記第3の判定手段は、当該データ領域において、前記アドレス記憶手段内の前回の書込み先頭アドレスから書込み最終アドレスの間に所定長分連続してデータ未書込み状態を示す特定データが存在した場合に前回のデータ書込み処理の途中で書込み失敗があったと判定することを特徴とする請求項2記載の携帯可能電子装置。   In the data area, when the specific data indicating the data non-written state is continuously present for a predetermined length between the previous write start address and the write end address in the data storage area, The portable electronic device according to claim 2, wherein it is determined that there has been a writing failure during the previous data writing process. 前記第3の判定手段は、前回の命令受信時に当該命令により書込むデータにおいてデータ未書込み状態を示す特定データを検索することにより当該特定データが連続する数を記憶しておき、今回の命令受信時に当該データ領域においてデータ未書込み状態を示す特定データを検索することにより、前記アドレス記憶手段内の前回の書込み先頭アドレスから書込み最終アドレスの間に連続してデータ未書込み状態を示す特定データが前記記憶しておいた数以上存在する場合に前回のデータ書込み処理の途中で書込み失敗があったと判定することを特徴とする請求項2記載の携帯可能電子装置。   The third determination means stores the number of consecutive specific data by searching for specific data indicating a data unwritten state in the data written by the command when the previous command is received, and receives the current command By searching for specific data indicating a data non-written state in the data area sometimes, the specific data indicating the data non-written state continuously between the previous write start address and the write final address in the address storage means 3. The portable electronic device according to claim 2, wherein when there are more than the stored number, it is determined that there has been a writing failure during the previous data writing process. 1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、この書込み処理手段によるデータの書込みが正常に終了した場合、前記アドレス記憶手段内の書込み先頭アドレスおよび書込み最終アドレスを特定の値に初期化する初期化手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスと一致するか否かを判定する第1の判定手段と、この第1の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスと一致する場合、当該データ領域に対する前回のデータ書込み処理が正常に終了しなかったものと判断して、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段とを有して構成されるICモジュールと、
このICモジュールを収納したICカード本体と、
を具備したことを特徴とするICカード。
A memory in which at least one data area in which data writing is permitted only once is set, and a write start address and a write end address of data in the data area in which data writing is permitted only once are stored. Address storage means for receiving data and a command for instructing data writing to the data area in which data writing is permitted only once, the current data writing range is indicated based on specific information in the command. An address calculation means for obtaining a write start address and a write end address, an address write means for writing the write start address and the write end address calculated by the address calculation means into the address storage means, and designated by the received instruction The length data is allowed to be written only once. Write processing means for performing processing for writing to the data area, and when writing of data by the write processing means is normally completed, the write start address and write end address in the address storage means are initialized to specific values. And when the instruction for instructing data writing to the data area in which data writing is permitted only once is received again, the present time calculated by the address calculating means for the instruction The first determination means for determining whether or not the write start address and write end address of the first address coincide with the previous write start address and write end address in the address storage means, and the result of determination by the first determination means This write start address and write end address are the previous write start address and write end address. If it matches the address, it is determined that the previous data writing process for the data area did not end normally, and the data in the data area is changed to data of the length specified by the received instruction again. An IC module having a rewrite processing means for performing a rewrite process;
An IC card body containing the IC module;
An IC card comprising:
1回だけデータの書込みが許可されたデータ領域が少なくとも1つ以上設定されているメモリと、前記1回だけデータの書込みが許可されたデータ領域に対するデータの書込み先頭アドレスおよび書込み最終アドレスを記憶するためのアドレス記憶手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を受信した場合、当該命令内の特定情報に基づき今回のデータ書込み範囲を示す書込み先頭アドレスおよび書込み最終アドレスを求めるアドレス算出手段と、このアドレス算出手段により算出された書込み先頭アドレスおよび書込み最終アドレスを前記アドレス記憶手段に書込むアドレス書込み手段と、前記受信した命令により指定された長さのデータを前記1回だけデータの書込みが許可されたデータ領域に対して書込む処理を行なう書込み処理手段と、前記1回だけデータの書込みが許可されたデータ領域に対してデータの書込みを指示する命令を再度受信した場合、当該命令に対して前記アドレス算出手段により算出された今回の書込み先頭アドレスおよび書込み最終アドレスが前記アドレス記憶手段内の前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内であるか否かを判定する第2の判定手段と、この第2の判定手段による判定の結果、今回の書込み先頭アドレスおよび書込み最終アドレスが前回の書込み先頭アドレスおよび書込み最終アドレスの範囲内である場合、当該データ領域に対する前回のデータ書込み処理に書込み失敗があったか否かを判定する第3の判定手段と、この第3の判定手段による判定の結果、前回のデータ書込み処理に書込み失敗があった場合、当該データ領域内のデータを前記再度受信した命令にて指定された長さのデータに書換える処理を行なう書換え処理手段とを有して構成されるICモジュールと、
このICモジュールを収納したICカード本体と、
を具備したことを特徴とするICカード。
A memory in which at least one data area in which data writing is permitted only once is set, and a write start address and a write end address of data in the data area in which data writing is permitted only once are stored. Address storage means for receiving data and a command for instructing data writing to the data area in which data writing is permitted only once, the current data writing range is indicated based on specific information in the command. An address calculation means for obtaining a write start address and a write end address, an address write means for writing the write start address and the write end address calculated by the address calculation means into the address storage means, and designated by the received instruction The length data is allowed to be written only once. A write processing means for performing processing for writing to the data area, and a command for instructing data writing to the data area for which data writing is permitted only once. Second determination means for determining whether or not the current write start address and write end address calculated by the address calculation means are within the range of the previous write start address and write end address in the address storage means; If, as a result of the determination by the second determination means, the current write head address and write last address are within the range of the previous write start address and write last address, the previous data write process for the data area failed to be written. Third determination means for determining whether or not there has been, and determination by the third determination means As a result, there is a rewrite processing means for performing a process of rewriting the data in the data area to the data of the length specified by the re-received instruction when there is a write failure in the previous data write process. A configured IC module;
An IC card body containing the IC module;
An IC card comprising:
前記第3の判定手段は、当該データ領域において、前記アドレス記憶手段内の前回の書込み最終アドレスから前方に所定長分連続してデータ未書込み状態を示す特定データが存在した場合に前回のデータ書込み処理に書込み失敗があったと判定することを特徴とする請求項7記載のICカード。   In the data area, the third determination unit writes the previous data when there is specific data indicating a data unwritten state continuously for a predetermined length ahead from the last write last address in the address storage unit. 8. The IC card according to claim 7, wherein it is determined that there has been a writing failure in the processing. 前記第3の判定手段は、当該データ領域において、前記アドレス記憶手段内の前回の書込み先頭アドレスから書込み最終アドレスの間に所定長分連続してデータ未書込み状態を示す特定データが存在した場合に前回のデータ書込み処理の途中で書込み失敗があったと判定することを特徴とする請求項7記載のICカード。   In the data area, when the specific data indicating the data non-written state is continuously present for a predetermined length between the previous write start address and the write end address in the data storage area, 8. The IC card according to claim 7, wherein it is determined that a writing failure has occurred during the previous data writing process. 前記第3の判定手段は、前回の命令受信時に当該命令により書込むデータにおいてデータ未書込み状態を示す特定データを検索することにより当該特定データが連続する数を記憶しておき、今回の命令受信時に当該データ領域においてデータ未書込み状態を示す特定データを検索することにより、前記アドレス記憶手段内の前回の書込み先頭アドレスから書込み最終アドレスの間に連続してデータ未書込み状態を示す特定データが前記記憶しておいた数以上存在する場合に前回のデータ書込み処理の途中で書込み失敗があったと判定することを特徴とする請求項7記載のICカード。   The third determination means stores the number of consecutive specific data by searching for specific data indicating a data unwritten state in the data written by the command when the previous command is received, and receives the current command By searching for specific data indicating a data non-written state in the data area sometimes, the specific data indicating the data non-written state continuously between the previous write start address and the write final address in the address storage means 8. The IC card according to claim 7, wherein when there are more than the stored number, it is determined that there has been a writing failure during the previous data writing process.
JP2006224323A 2006-08-21 2006-08-21 Portable electronic device and IC card Active JP4868979B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2006224323A JP4868979B2 (en) 2006-08-21 2006-08-21 Portable electronic device and IC card

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2006224323A JP4868979B2 (en) 2006-08-21 2006-08-21 Portable electronic device and IC card

Publications (2)

Publication Number Publication Date
JP2008047042A true JP2008047042A (en) 2008-02-28
JP4868979B2 JP4868979B2 (en) 2012-02-01

Family

ID=39180689

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2006224323A Active JP4868979B2 (en) 2006-08-21 2006-08-21 Portable electronic device and IC card

Country Status (1)

Country Link
JP (1) JP4868979B2 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
SG168456A1 (en) * 2009-07-15 2011-02-28 Toshiba Kk Portable electronic device, smartcard and control method for portable electronic device
US8698599B2 (en) 2008-04-16 2014-04-15 Sony Corporation Reader/writer, communication processing device, communication processing method, data management system and communication system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02110725A (en) * 1988-10-20 1990-04-23 Nec Corp System for recovering file on unrewritable medium
JP2008027070A (en) * 2006-07-19 2008-02-07 Toshiba Corp Portable electronic apparatus and control method of portable electronic apparatus

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02110725A (en) * 1988-10-20 1990-04-23 Nec Corp System for recovering file on unrewritable medium
JP2008027070A (en) * 2006-07-19 2008-02-07 Toshiba Corp Portable electronic apparatus and control method of portable electronic apparatus

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8698599B2 (en) 2008-04-16 2014-04-15 Sony Corporation Reader/writer, communication processing device, communication processing method, data management system and communication system
SG168456A1 (en) * 2009-07-15 2011-02-28 Toshiba Kk Portable electronic device, smartcard and control method for portable electronic device
US8645624B2 (en) 2009-07-15 2014-02-04 Kabushiki Kaisha Toshiba Portable electronic device, smartcard and control method for portable electronic device

Also Published As

Publication number Publication date
JP4868979B2 (en) 2012-02-01

Similar Documents

Publication Publication Date Title
US8645624B2 (en) Portable electronic device, smartcard and control method for portable electronic device
JP4776462B2 (en) Portable electronic device and method for controlling portable electronic device
JP4868979B2 (en) Portable electronic device and IC card
JP2008310596A (en) Portable electronic equipment and control method for potable electronic equipment
JP4836707B2 (en) Portable electronic device and IC card
JP6040895B2 (en) Microcomputer and non-volatile memory block management method
US7346730B2 (en) Mobile electronic device
JP4950730B2 (en) Portable electronic device, file access method and IC card in portable electronic device
JP2006293706A (en) Multi-application ic card with application updating function
JP4713878B2 (en) Portable electronic device
US8074023B2 (en) In-system programming to switch memory access from one area to another in memory cards
JP7468757B1 (en) ELECTRONIC INFORMATION STORAGE MEDIUM, IC CHIP, IC CARD, RESPONSE TRANSMISSION METHOD, AND PROGRAM
JP2006107363A (en) Portable electronic device and memory access method used in the same
JP2004334745A (en) Ic card
JP4738249B2 (en) Portable electronic device, IC card and IC module
JP2007114961A (en) Portable electronic device and ic card
JP5786702B2 (en) Security token, instruction execution method in security token, and computer program
JP4810108B2 (en) IC card and control method thereof
JP5050508B2 (en) Storage device, storage device program, and storage processing method
JP2006302130A (en) Ic card and program for ic card
JP5075404B2 (en) Portable electronic device, file access method and IC card in portable electronic device
JP2008152452A (en) Portable electronic device, control method for portable electronic device, and ic card
JP5492172B2 (en) Portable electronic device, IC card and IC module
JP2007122394A (en) Portable electronic device, and ic card
JP5038918B2 (en) Portable electronic device and method for controlling portable electronic device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20090817

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20111018

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

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20111115

R151 Written notification of patent or utility model registration

Ref document number: 4868979

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20141125

Year of fee payment: 3