JP5853590B2 - IC chip, IC chip processing method, IC chip processing program, IC card, etc. - Google Patents

IC chip, IC chip processing method, IC chip processing program, IC card, etc. Download PDF

Info

Publication number
JP5853590B2
JP5853590B2 JP2011235295A JP2011235295A JP5853590B2 JP 5853590 B2 JP5853590 B2 JP 5853590B2 JP 2011235295 A JP2011235295 A JP 2011235295A JP 2011235295 A JP2011235295 A JP 2011235295A JP 5853590 B2 JP5853590 B2 JP 5853590B2
Authority
JP
Japan
Prior art keywords
page
area
update
card
data
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
JP2011235295A
Other languages
Japanese (ja)
Other versions
JP2013092938A (en
Inventor
満里子 向田
満里子 向田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dai Nippon Printing Co Ltd
Original Assignee
Dai Nippon Printing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Dai Nippon Printing Co Ltd filed Critical Dai Nippon Printing Co Ltd
Priority to JP2011235295A priority Critical patent/JP5853590B2/en
Publication of JP2013092938A publication Critical patent/JP2013092938A/en
Application granted granted Critical
Publication of JP5853590B2 publication Critical patent/JP5853590B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Description

本発明は、データを管理する装置及び方法等の技術分野に関する。   The present invention relates to a technical field such as an apparatus and a method for managing data.

ICカードを用いた商取引等では、ICカードに搭載されたICチップの不揮発性メモリ等に記憶される種々の重要なデータ(例えば、決済処理に用いられる個人情報等)が、必要に応じて読み出され、消去され、又は、新たなデータに書き換えられる。   In a commercial transaction using an IC card, various important data (for example, personal information used for payment processing) stored in a non-volatile memory of an IC chip mounted on the IC card is read as necessary. Issued, erased, or rewritten with new data.

この不揮発性メモリは、電力を失ってもデータを保持し続ける特性があるが、ICカードの処理中、例えば、当該不揮発性メモリに対してデータが書き込まれている間は、書き込み中のデータを保障することができない。   This non-volatile memory has a characteristic of continuing to retain data even when power is lost, but during processing of an IC card, for example, while data is being written to the non-volatile memory, the data being written is retained. I can't guarantee it.

具体的には、ICカードがリーダライタ装置に挿入され、当該不揮発性メモリに対してデータが書き込まれている間に、利用者によってICカードがリーダライタ装置から強制的に引き抜かれた場合(所謂、利用者による引き抜き)や、ICカードとリーダライタ装置との端子間で接触不良が生じた場合等の瞬断が発生した場合には、ICカードにおける処理が中断され、カード内の大切なデータが破壊される虞がある。   Specifically, when the IC card is forcibly removed from the reader / writer device by the user while the IC card is inserted into the reader / writer device and data is being written to the nonvolatile memory (so-called “so-called”). In the case of a momentary interruption such as when a contact failure occurs between the terminals of the IC card and the reader / writer device, the processing in the IC card is interrupted and important data in the card May be destroyed.

このため、一般的なICカードは、瞬断によるデータの破壊を防止すべく、瞬断を考慮した保護機能(専用の保護機能)が搭載されている。   For this reason, a general IC card is equipped with a protection function (dedicated protection function) in consideration of instantaneous interruption in order to prevent data destruction due to instantaneous interruption.

そして、上述した瞬断を考慮した保護機能は、メモリ管理者としてカードOSの基本的な機能として提供されている。以下、この瞬断を考慮した保護機能を単に「カードOSによる非更新領域の保護機能」と称する。   And the protection function which considered the instantaneous interruption mentioned above is provided as a basic function of card | curd OS as a memory manager. Hereinafter, this protection function taking into account the instantaneous interruption is simply referred to as a “non-update area protection function by the card OS”.

この「カードOSによる非更新領域の保護機能」の概要は、更新されるデータ以外のデータである非更新領域のデータを保護するため、当該データのバックアップを、予め他の領域(例えば、不揮発性メモリに設定されたバックアップ領域等)に書き込んだ後、実際にデータの更新(書き込みを含む)を行う。更新作業が完了した場合は、バックアップ領域に更新が成功した情報を追加する。そして、バックアップ領域に記憶された当該データのバックアップを消去する。一方、更新の途中に処理が中断(瞬断)されたならば、次にカードが活性化した直後にバックアップ領域の内容を調べ、更新作業が完了していないデータに対して実際のデータ領域(この場合、非更新領域)に書き戻すようになっている。   The outline of the “non-update area protection function by the card OS” is to protect the data in the non-update area, which is data other than the data to be updated. After the data is written in the backup area set in the memory), the data is actually updated (including writing). When the update operation is completed, information indicating the successful update is added to the backup area. Then, the backup of the data stored in the backup area is deleted. On the other hand, if the processing is interrupted (instant interruption) during the update, the contents of the backup area are examined immediately after the next activation of the card, and the actual data area ( In this case, data is written back to the non-update area.

また、特許文献1では、書き込み領域縮小化及びバックアップの処理時間の短縮化の観点から、バックアップ対象として、非更新領域のデータのみを、予め他の領域にコピーする技術が開示されている。   Patent Document 1 discloses a technique for copying only data in a non-update area to another area in advance as a backup target from the viewpoint of reducing the write area and shortening the backup processing time.

一方、更新領域の保護に関しては、JAVA(登録商標)カードが有する機能において提供されている。   On the other hand, the protection of the update area is provided in the function of the JAVA (registered trademark) card.

JAVAカードは、公知の技術であるため詳しい説明は省略するが、一般的なICカードのOSの上にバーチャルマシン(Virtual Machine)をのせたICカードであり、所定のプラットフォームのもと、JAVA言語でICカードのアプリケーションを作成することが可能となっている。このプラットフォームは、例えば、JAVA CARD 3.0等で規格化されている。   The JAVA card is a well-known technique, and thus detailed description is omitted. However, a JAVA card is an IC card in which a virtual machine is placed on an OS of a general IC card. This makes it possible to create an IC card application. This platform is standardized by JAVA CARD 3.0, for example.

そして、JAVAカードでは、更新領域の保護に関してトランザクション(Transaction)という仕組みが利用されている。トランザクションとは、特定の一連の処理の開始前もしくは終了後の何れかの状態のみを取り得る仕組みをいう。   In the JAVA card, a mechanism called transaction is used to protect the update area. A transaction refers to a mechanism that can take only a state before or after the start of a specific series of processes.

上述した「カードOSの保護機能における非更新領域の保護機能」は、一度の更新(例えば、一のデータの書き込み)に対して有効であるのに対して、このトランザクションによる更新領域の保護では、予め定められた一又は複数の書き込み(以下、単に「連続した書き込み」と称する。)において、連続した書き込みの保障が可能である。この連続した書き込みの保障とは、更新前の更新領域の状態、又は更新後の更新領域の状態の何れかの状態を取り得ることができることをいう。以下、トランザクションにおける更新領域の保護について、単に、「トランザクションによる更新領域の保護機能」と称する。   The “non-update area protection function in the card OS protection function” described above is effective for one update (for example, writing of one data), whereas in the update area protection by this transaction, In one or a plurality of predetermined writings (hereinafter simply referred to as “continuous writing”), it is possible to guarantee continuous writing. This guarantee of continuous writing means that either the state of the update area before the update or the state of the update area after the update can be taken. Hereinafter, protection of an update area in a transaction is simply referred to as “update area protection function by transaction”.

この「トランザクションによる更新領域の保護機能」の一例として、上記更新前の更新領域の状態を取り得ることを可能とするため、不揮発性メモリに記憶されたデータのうち、更新される領域に既に記憶されているデータをバックアップ領域へ書き込む。そして、更新の途中に処理が中断されたならば、次にカードが活性化した直後にバックアップ領域の内容を調べ、更新作業が完了していないデータに対して、バックアップ領域へ書き込まれたデータを、実際のデータ領域(この場合、更新領域)へ書き戻すようになっている。一方、上記連続した書き込みが完了した場合には、バックアップ領域に記憶された当該データのバックアップが消去される。   As an example of the "update area protection function by transaction", in order to be able to take the state of the update area before the update, it is already stored in the area to be updated among the data stored in the nonvolatile memory. Write the stored data to the backup area. If the processing is interrupted during the update, the contents of the backup area are examined immediately after the next activation of the card, and the data written to the backup area is compared with the data that has not been updated. The data is written back to the actual data area (in this case, the update area). On the other hand, when the continuous writing is completed, the backup of the data stored in the backup area is erased.

また、従来のICカードでは、不揮発性メモリに対してページ単位でデータが更新されるのであるが、このページあたりに記憶されるデータの容量(単位)が1byte、2byte、又は4byte、と小さいことが通常であり、更新(データの書き込み及び消去等)される時間も短かった。   Further, in the conventional IC card, data is updated in units of pages in the nonvolatile memory, but the capacity (unit) of data stored per page is as small as 1 byte, 2 bytes, or 4 bytes. However, the update (data writing and erasing etc.) time is also short.

そのため、従来のICカードでは、「カードOSによる非更新領域の保護機能」(記憶領域の更新領域を保護する機能)と「トランザクションによる更新領域の保護機能」(非更新領域を保護する機能)が別々に定義されており、ICカードがデータを更新する際に、「カードOSによる非更新領域の保護機能」と、「トランザクションによる更新領域の保護機能」がそれぞれ機能するようになっていた。   For this reason, the conventional IC card has a “non-update area protection function by the card OS” (function to protect the update area of the storage area) and a “update area protection function by transaction” (a function to protect the non-update area). They are defined separately, and when the IC card updates data, the “non-update area protection function by the card OS” and the “update area protection function by the transaction” function respectively.

特開2008−134945号公報JP 2008-134945 A

近年、不揮発性メモリの大容量化が進み、ページあたりに記憶されるデータの容量が128byte、又は256byteと増加している。このページあたりに記憶されるデータの容量の増加に伴い、バックアップされる更新領域及び非更新領域のデータも拡大しており、更新やバックアップに要する処理時間が増加している。   In recent years, the capacity of non-volatile memories has increased, and the capacity of data stored per page has increased to 128 bytes or 256 bytes. As the capacity of data stored per page increases, the data in the update area and the non-update area to be backed up also expand, and the processing time required for updating and backup increases.

さらに、「カードOSによる非更新領域の保護機能」と、「トランザクションによる更新領域の保護機能」がそれぞれ機能すると、更新やバックアップに要する処理時間はさらに増加し、ユーザの利便性を損なうといった問題点がある。   Furthermore, when the “non-update area protection function by card OS” and the “update area protection function by transaction” function, the processing time required for updating and backup further increases, which impairs user convenience. There is.

そこで、「カードOSによる非更新領域の保護機能」と、「トランザクションによる更新領域の保護機能」を統合して、適切な保護機能によってデータを保護することにより、データの保護機能による処理時間の短縮を図るといった考え方もある。   Therefore, by integrating “Protection function of non-update area by card OS” and “Protection function of update area by transaction” and protecting data by appropriate protection function, processing time is shortened by data protection function. There is also a way of thinking.

この統合では、上記トランザクションの実行中に、「トランザクションによる更新領域の保護機能」によって、前記更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとしてカードOSに通知して、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   In this integration, during the execution of the above transaction, all areas of the page to which the update area and the non-update area before the update belong are stored as an update area by the “update area protection function by transaction”. All data is stored in the storage unit, the card OS is notified that there is no non-update area on the page, and the “non-update area protection function by the card OS” is not activated.

しかしながら、この統合は、上記トランザクションの実行中でなければ働かない。従って、連続した書き込みとして定義されない書き込み要求が、連続してなされた場合には、当該書き込み要求毎に「カードOSによる非更新領域の保護機能」が働き、バックアップ領域に対してデータの記憶及び当該データの消去が繰り返され、更新やバックアップに要する処理時間が増加するといった問題点がある。   However, this integration will not work unless the transaction is running. Therefore, when a write request that is not defined as continuous write is made continuously, the “non-update area protection function by the card OS” works for each write request, and data storage and There is a problem in that data erasure is repeated and processing time required for updating and backup increases.

そこで、本発明は、このような点等に鑑みてなされたものであり、データの保護機能を複数備えるICチップにおいて、適切な保護機能によってデータを保護することにより、データの保護機能による処理時間の短縮を図るICチップ、ICチップにおける処理方法、ICチップ用処理プログラム、及びICカード等を提供することを目的とする。   Therefore, the present invention has been made in view of the above points and the like, and in an IC chip having a plurality of data protection functions, the data is protected by an appropriate protection function, so that the processing time by the data protection function is increased. It is an object to provide an IC chip, a processing method for an IC chip, a processing program for an IC chip, an IC card, and the like.

上記課題を解決するために、請求項1に記載の発明は、所定の領域を一のページとして、一又は複数のページに区画される記憶部を備え、更新要求に基づいて、前記記憶部の指定されたページの指定された領域に記憶されるデータを更新するICチップであって、前記データを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータを保護する第1の保護手段と、特定の一連の更新処理の開始前又は終了後の何れかにおける記憶部に記憶されるデータを保護可能とするトランザクションの実行中に、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして第1の保護手段を機能させない第2の保護手段と、備え、前記第2の保護手段は、更新要求があった場合には、前記トランザクションの実行中であるものとして、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記第1の保護手段を機能させないことを特徴とする。 In order to solve the above problem, the invention described in claim 1 includes a storage unit that is partitioned into one or a plurality of pages with a predetermined area as one page, and based on an update request, An IC chip that updates data stored in a specified area of a specified page, and is a non-update area that is an area other than the update area of a page to which an update area that is an area for updating the data belongs. into a first protection means for protecting data stored during execution of a transaction to allow protection of data stored in the storage unit in any of before and after the start of a particular series of update processing or termination, further All the areas of the page to which the new update area and the non-update area belong are set as update areas, all the data stored in the page is stored in the storage unit, and there is no non-update area in the page. And second protection means that does not function the first protection means as things, wherein said second protection means, when a renewal request, as running of the transaction, update the previous All the areas of the page to which the update area and the non-update area belong are used as the update area, all the data stored in the page is stored in the storage unit, and the first area is assumed to have no non-update area in the page. The protection means is not allowed to function.

請求項2に記載の発明は、請求項1に記載のICチップであって、前記第1の保護手段は、ICチップの基本的な動作を管理するオペレーティングシステムが備える基本的な機能であって、当該オペレーティングシステムの制御に基づいて実行され、前記第2の保護手段は、前記オペレーティングシステム上で動作し、前記ICチップに所定の機能を実行させるアプリケーションの要求に応じた前記オペレーティングシステムの制御に基づいて実行されることを特徴とする。   A second aspect of the present invention is the IC chip according to the first aspect, wherein the first protection means is a basic function provided in an operating system that manages the basic operation of the IC chip. The second protection means operates on the operating system and controls the operating system in response to a request from an application that causes the IC chip to execute a predetermined function. It is performed based on.

請求項3に記載の発明は、請求項1又は2に記載のICチップであって、新が終了した場合には、前記第2の保護手段によって記憶されたデータを消去するバックアップデータ消去手段をさらに備えることを特徴とする。 According to a third aspect of the invention, an IC chip according to claim 1 or 2, when the update is completed, the backup data erasing means for erasing the data stored by said second protection means Is further provided.

請求項4に記載の発明は、請求項に記載のICチップであって、前記バックアップデータ消去手段は、前記第2の保護手段によって記憶されたデータが記憶される前記記憶部の記憶容量が上限に達した場合には、当該データを消去することを特徴とする。 The invention according to claim 4 is the IC chip according to claim 3 , wherein the backup data erasing unit has a storage capacity of the storage unit in which the data stored by the second protection unit is stored. When the upper limit is reached, the data is erased.

請求項5に記載の発明は、請求項1乃至4の何れか一項に記載のICチップと、ICカード基体と、を備えることを特徴とする。   According to a fifth aspect of the present invention, there is provided an IC chip according to any one of the first to fourth aspects, and an IC card base.

請求項6に記載の発明は、所定の領域を一のページとして、一又は複数のページに区画される記憶部を備え、更新要求に基づいて、前記記憶部の指定されたページの指定された領域に記憶されるデータを更新するICチップにおいて実行されるICチップにおける処理方法であって、前記ICチップは、前記データを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータを保護する第1の保護手段と、特定の一連の更新処理の開始前又は終了後の何れかにおける記憶部に記憶されるデータを保護可能とするトランザクションの実行中に、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとしてオペレーティングシステムに通知して、前記第1の保護手段を機能させない第2の保護手段と、備え、前記第2の保護手段が、更新要求があった場合には、前記トランザクションの実行中であるものとして、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記オペレーティングシステムに通知して、前記第1の保護手段を機能させない工程を含むことを特徴とする。 The invention according to claim 6 includes a storage unit that is partitioned into one or a plurality of pages with a predetermined area as one page, and the specified page of the storage unit is designated based on an update request A processing method in an IC chip executed in an IC chip that updates data stored in an area, wherein the IC chip is a page other than the update area in a page to which an update area that is an area in which the data is updated belongs. A first protection means for protecting data stored in a non-update area that is an area, and a transaction that enables protection of data stored in a storage unit either before or after the start of a specific series of update processing is during execution, all areas of the page update before the update area and the non-updated area belongs as the update region, all the data stored in the page in the storage unit storing , Notifies the operating system is assumed that the non-updated area to the page does not exist, and second protection means that does not function the first protection means, wherein said second protection means, an update request If there is, the assumption is being executed the transaction, as all area update area of the page where update before the update area and the non-updated area belongs, said all of the data stored in the page stored in the storage unit, and notifies the operating system as not non-updated area to the page is present, characterized in that it comprises a first protection means do not function process.

請求項7に記載の発明は、所定の領域を一のページとして、一又は複数のページに区画される記憶部を備え、更新要求に基づいて、前記記憶部の指定されたページの指定された領域に記憶されるデータを更新するICチップに含まれるコンピュータを、前記データを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータを保護する第1の保護手段、特定の一連の更新処理の開始前又は終了後の何れかにおける記憶部に記憶されるデータを保護可能とするトランザクションの実行中に、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記第1の保護手段を機能させない第2の保護手段、として機能させ、前記第2の保護手段は、更新要求があった場合には、前記トランザクションの実行中であるものとして、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記第1の保護手段を機能させないことを特徴とする。 The invention according to claim 7 includes a storage unit that is partitioned into one or a plurality of pages with a predetermined area as one page, and the specified page of the storage unit is designated based on an update request A computer included in an IC chip that updates data stored in an area is stored in a non-update area that is an area other than the update area, out of the pages to which the update area that is the data update area belongs. first protection means for protecting, during execution of a transaction to allow protection of data stored in the storage unit in any of before and after the start of a particular series of update processing or termination, update previous update region and non Assuming that all areas of the page to which the update area belongs are set as update areas, all data stored in the page is stored in the storage unit, and there is no non-update area in the page Second protection means that does not function the serial first protection means, to function as, the second protection means, when a renewal request, as running of the transaction, update the previous All the areas of the page to which the update area and the non-update area belong are used as the update area, all the data stored in the page is stored in the storage unit, and the first area is assumed to have no non-update area in the page. The protection means is not allowed to function.

本発明によれば、データの保護機能を複数備えるICチップにおいて、適切な保護機能によってデータを保護することにより、データの保護機能による処理時間の短縮を図ることができる。   According to the present invention, in an IC chip having a plurality of data protection functions, it is possible to reduce the processing time by the data protection function by protecting the data with an appropriate protection function.

本実施形態にかかるICカードの構成及び機能概要を示すブロック図である。It is a block diagram which shows the structure and function outline | summary of the IC card concerning this embodiment. ICカードのソフトウェア構成を模式的に示す図である。It is a figure which shows typically the software structure of an IC card. カードOSによる非更新領域の保護機能が適用される場合のCPU6の動作の概要を示すフローチャートである。It is a flowchart which shows the outline | summary of operation | movement of CPU6 when the protection function of the non-update area | region by card | curd OS is applied. 不揮発性メモリ5のデータ領域にデータが記憶される状態を示す概念図である。3 is a conceptual diagram showing a state in which data is stored in a data area of a nonvolatile memory 5. FIG. ページ単位で不揮発性メモリ5のデータ領域にデータが記憶される状態を示す概念図である。It is a conceptual diagram which shows the state in which data are memorize | stored in the data area of the non-volatile memory 5 per page. トランザクションによる更新領域の保護機能が適用される場合のCPU6の動作の概要を示すフローチャートである。It is a flowchart which shows the outline | summary of operation | movement of CPU6 when the protection function of the update area by a transaction is applied. ICカードによって更新されるデータを概念的に示す図である。It is a figure which shows notionally the data updated with an IC card. ページあたりに記憶されるデータの容量が大容量である場合に、ICカードによって更新されるデータを概念的に示す図である。It is a figure which shows notionally the data updated with an IC card, when the capacity | capacitance of the data memorize | stored per page is large capacity. 「バックアップ検索機能」が適用されない場合のバックアップ領域に書き込まれるデータ構造を概念的に示す図である。It is a figure which shows notionally the data structure written in the backup area | region when a "backup search function" is not applied. 連続した書き込みとして定義されない複数の更新要求があった場合のCPU6の動作を示すフローチャートである。It is a flowchart which shows operation | movement of CPU6 when there exist several update requests which are not defined as continuous writing. 複数の更新要求を概念的に示す図である。It is a figure which shows a several update request notionally. 複数の更新要求と「カードOSによる保護機能」の詳細を概念的に示す図である。It is a figure which shows notionally the detail of several update request | requirements and "the protection function by card | curd OS". 本実施形態のCPU6の動作の詳細を示すフローチャートである。It is a flowchart which shows the detail of operation | movement of CPU6 of this embodiment.

以下、図面を参照して本発明の実施形態について詳細に説明する。以下に説明する実施形態は、ICカードの一例としての上述したJAVAカードに対して本発明を適用した場合の実施の形態である。以下、JAVAカードに対応したICカードを、単にICカードと称する。   Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. In the embodiment described below, the present invention is applied to the above-described JAVA card as an example of an IC card. Hereinafter, an IC card corresponding to a JAVA card is simply referred to as an IC card.

[1.ICカードのハードウェア構成及び機能概要]
まず、図1を参照して、本願のICカードのハードウェア構成及び機能概要について説明する。本実施形態にかかるICカードの構成及び機能概要を示すブロック図である。
[1. IC card hardware configuration and function overview]
First, with reference to FIG. 1, the hardware configuration and functional outline of the IC card of the present application will be described. It is a block diagram which shows the structure and function outline | summary of the IC card concerning this embodiment.

図1は、本実施形態にかかるICカードの構成及び機能概要を示すブロック図である。   FIG. 1 is a block diagram showing an outline of the configuration and functions of the IC card according to the present embodiment.

図1に示すように、ICカード8は、ICチップ1をカード基体7に備えている。   As shown in FIG. 1, the IC card 8 includes an IC chip 1 on a card base 7.

そして、ICチップ1は、I/O回路2、ROM(Read Only Memory)3、RAM(Random Access Memory)4、本願の記憶部の一例としての不揮発性メモリ(例えば、EEPROM(Electrically Erasable and Programmable Read Only Memory))5、CPU(Central Processing Unit)6等を備えて構成されている。なお、I/O回路2を介した外部機器とのデータ通信は、接触方式と非接触方式の何れの方式であってもよい。   The IC chip 1 includes an I / O circuit 2, a ROM (Read Only Memory) 3, a RAM (Random Access Memory) 4, and a non-volatile memory (for example, an EEPROM (Electrically Erasable and Programmable Read) as an example of a storage unit of the present application. Only Memory)) 5, CPU (Central Processing Unit) 6 and the like. Note that data communication with an external device via the I / O circuit 2 may be either a contact method or a non-contact method.

I/O回路2は、図示しない外部機器とデータ通信するための処理回路である。   The I / O circuit 2 is a processing circuit for data communication with an external device (not shown).

ROM3は、CPU6によって実行されるべきプログラムが記憶されており、CPU6は、このプログラムに基づいてICチップ1を統括的に制御する。   The ROM 3 stores a program to be executed by the CPU 6, and the CPU 6 comprehensively controls the IC chip 1 based on this program.

また、ROM3に記憶されるプログラムとしては、カードOS(本願のオペレーティングシステムの一例)、複数種類のアプリケーションプログラム、及び本発明のICチップ用処理プログラムがある。なお、本発明のICチップ用処理プログラムは、カードOS又はアプリケーションプログラムの一機能として組み込まれてもよい。また、これらのプログラムは、不揮発性メモリ5に記憶されるようにしてもよい。   The programs stored in the ROM 3 include a card OS (an example of the operating system of the present application), a plurality of types of application programs, and an IC chip processing program of the present invention. The IC chip processing program of the present invention may be incorporated as a function of the card OS or application program. Further, these programs may be stored in the nonvolatile memory 5.

RAM4は、CPU6がICチップ1を統括的に制御等するために作業領域として使用する記憶領域である。   The RAM 4 is a storage area used as a work area for the CPU 6 to control the IC chip 1 in an integrated manner.

不揮発性メモリ5は、不揮発性半導体メモリの一種であり、記憶領域に記憶されるデータを消去し、何度でも再記憶ができるPROM(Programmable Rom)である。   The non-volatile memory 5 is a kind of non-volatile semiconductor memory, and is a PROM (Programmable Rom) that can erase data stored in a storage area and re-store it any number of times.

また、本実施形態における不揮発性メモリ5は、各領域にアドレスが付されており、所定の領域を1のページとして、一又は複数のページに区画される。   In the nonvolatile memory 5 according to the present embodiment, each area is assigned an address, and the predetermined area is defined as one page, and is partitioned into one or a plurality of pages.

そして、不揮発性メモリ5は、CPU6により各種データが書き込まれる(記憶される)データ領域と、詳しくは後述するがバックアップデータが書き込まれるバックアップ領域を有する。   The nonvolatile memory 5 has a data area where various data are written (stored) by the CPU 6 and a backup area where backup data is written, as will be described in detail later.

CPU6は、上述したようにプログラムに基づいてICチップ1全体の動作を統括的に制御するとともに、その機能の一部として、データ領域の指定されたページの指定された領域のデータを更新し、さらに、本願の第1の保護手段、第2の保護手段、又は、バックアップデータ消去手段等として機能する。   The CPU 6 comprehensively controls the operation of the entire IC chip 1 based on the program as described above, and updates the data of the designated area of the designated page of the data area as a part of the function, Furthermore, it functions as the first protection means, the second protection means, or the backup data erasing means of the present application.

なお、更新といった場合には、少なくともデータ領域等に記憶されたデータを書き換えることのみならず、新たにデータを書き込むことを含むものとする。   Note that the update includes not only rewriting data stored at least in the data area but also writing new data.

[2.ICカードのソフトウェア構成及び機能概要]
次に、図2を参照して、ICカードのソフトウェア構成について説明する。
[2. IC card software configuration and function overview]
Next, the software configuration of the IC card will be described with reference to FIG.

図2は、ICカードのソフトウェア構成を模式的に示す図である。   FIG. 2 is a diagram schematically showing the software configuration of the IC card.

図2に示すように、ICカードのハードウェアを構成するRAM4、不揮発性メモリ5、及びCPU6等のハードウェア層21は、OS(オペレーティング)層22のカードOSによって制御される。   As shown in FIG. 2, the hardware layer 21 such as the RAM 4, the nonvolatile memory 5, and the CPU 6 constituting the hardware of the IC card is controlled by the card OS of the OS (operating) layer 22.

OS層22は、JAVAカードを動作させるための環境を含めたバーチャルマシン(Virtual Machine)、アプリケーション(アプレット)の管理をするI.S.D.(Issuer Security Domain)、アプレットの関数であるAPIといったモジュールがカードOSにのった状態となっていて、アプリケーション(アプレット)層23が最上位に位置する。   The OS layer 22 manages I.I., which manages a virtual machine and an application (applet) including an environment for operating a JAVA card. S. D. Modules such as (Issuer Security Domain) and API that is an applet function are on the card OS, and the application (applet) layer 23 is positioned at the top.

このカードOSは、当該ICカードの基本的な動作を管理するプログラムであり、ハードウェア層21の各ハードウェアを制御したり、各ハードウェアからの処理結果などの情報を受けて動作するプログラムである。   This card OS is a program for managing the basic operation of the IC card, and is a program that controls each hardware of the hardware layer 21 and operates by receiving information such as processing results from each hardware. is there.

そして、上述した「カードOSによる非更新領域の保護機能」は、メモリ管理者としてカードOSの基本的な機能として提供される。   The above-described “non-update area protection function by the card OS” is provided as a basic function of the card OS as a memory manager.

この「カードOSによる非更新領域の保護機能」は、CPU6を、本願の第1の保護手段として機能させ、本願のカードOSの制御に基づいて、不揮発性メモリ5に記憶されるデータを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータを保護するようになっている。   This “non-update area protection function by the card OS” causes the CPU 6 to function as the first protection means of the present application, and updates the data stored in the nonvolatile memory 5 based on the control of the card OS of the present application. Of the pages to which the update area that is the area belongs, the data stored in the non-update area that is an area other than the update area is protected.

アプリケーション層23は、カードOS上で動作し、CPU6に所定の機能を実行させるための各種のアプリケーション(アプリケーションA、アプリケーションB等。本願のアプリケーションの一例、以下単に「アプリケーション」とする。)から構成される。   The application layer 23 operates on the card OS and includes various applications (application A, application B, etc., which are examples of the application of the present application, hereinafter simply referred to as “applications”) for causing the CPU 6 to execute predetermined functions. Is done.

そして、上述した「トランザクションによる更新領域の保護機能」は、アプリケーション層23のアプリケーションの機能として提供されている。   The above-described “update function for protecting update area by transaction” is provided as an application function of the application layer 23.

この「トランザクションによる更新領域の保護機能」は、CPU6を、本願の第2の保護手段として機能させ、上記アプリケーションの要求に応じたカードOSの制御に基づいて、更新前の前記更新領域に記憶されるデータを保護するようになっている。   This "update area protection function by transaction" causes the CPU 6 to function as the second protection means of the present application, and is stored in the update area before update based on the control of the card OS according to the request of the application. Data is protected.

ここで、「カードOSによる非更新領域の保護機能」及び「トランザクションによる更新領域の保護機能」の詳細について説明する。   Here, the details of the “non-update area protection function by the card OS” and the “update area protection function by the transaction” will be described.

まず、図3を参照して、「カードOSによる非更新領域の保護機能」が適用される場合のCPU6の動作の概要について説明する。   First, an outline of the operation of the CPU 6 when the “non-update area protection function by the card OS” is applied will be described with reference to FIG.

図3は、カードOSによる非更新領域の保護機能が適用される場合のCPU6の動作の概要を示すフローチャートである。   FIG. 3 is a flowchart showing an outline of the operation of the CPU 6 when the non-update area protection function by the card OS is applied.

なお、カードOSが備える機能(例えば、後述する保護機能動作)、及びアプリケーションが備える機能(例えは、後述するコマンドの処理)は、当該カードOS又はアプリケーションの制御に基づいてCPU6によって実行される。すなわち、カードOSが備える機能、及びアプリケーションが備える機能が実行される場合の動作主体は、ICカードのCPU6である。しかし、本実施形態においては、説明の便宜上、カードOSが備える機能が実行される場合の動作主体をカードOSとし、アプリケーションが備える機能が実行される場合の動作主体をアプリケーションとする。   Note that a function (for example, a protection function operation described later) included in the card OS and a function (for example, command processing described later) included in the application are executed by the CPU 6 based on the control of the card OS or application. That is, the operation subject when the function of the card OS and the function of the application are executed is the CPU 6 of the IC card. However, in this embodiment, for convenience of explanation, the operating subject when the function provided in the card OS is executed is the card OS, and the operating subject when the function provided in the application is executed is the application.

図3に示すように、まず、カードOS(CPU6)が、例えばI/O回路2を介して、コマンドを受信すると(ステップS101)、カードOSは、受信したコマンドをどのアプリケーションへ渡すか決定する(ステップS102)。そして、カードOSは、受信したコマンドを、決定されたアプリケーションへ渡す。アプリケーション(CPU6)は、コマンドを取得すると(ステップS103)、コマンドを処理して(例えば、コマンド解釈等)(ステップS104)、必要があれば不揮発性メモリ5のデータを更新する(不揮発性メモリ5へデータを書き込ませる)(ステップS105)。   As shown in FIG. 3, first, when the card OS (CPU 6) receives a command via, for example, the I / O circuit 2 (step S101), the card OS determines to which application the received command is to be passed. (Step S102). Then, the card OS passes the received command to the determined application. Upon obtaining the command (step S103), the application (CPU 6) processes the command (for example, command interpretation) (step S104), and updates data in the nonvolatile memory 5 if necessary (nonvolatile memory 5). (Step S105).

この不揮発性メモリ5のデータを更新(不揮発性メモリ5への書き込み)は、カードOSが提供する機能の一部になっているので、実際には、カードOSへ、更新の依頼をする(ステップS106)。   Updating the data in the nonvolatile memory 5 (writing to the nonvolatile memory 5) is a part of the function provided by the card OS, so in fact, the card OS is requested to update (step). S106).

ここで、図4及び図5を参照して、一般的な不揮発性メモリに記憶されるデータの更新について説明する。   Here, with reference to FIG. 4 and FIG. 5, the update of the data memorize | stored in a general non-volatile memory is demonstrated.

図4は不揮発性メモリのデータ領域にデータが記憶される状態を示す概念図であり、図5はページ単位で不揮発性メモリのデータ領域にデータが記憶される状態を示す概念図である。   4 is a conceptual diagram showing a state where data is stored in the data area of the nonvolatile memory, and FIG. 5 is a conceptual diagram showing a state where data is stored in the data area of the nonvolatile memory in units of pages.

一般的に、ICカードの不揮発性メモリのデータの更新は、初期化を行ってから更新される。   In general, the data in the nonvolatile memory of the IC card is updated after initialization.

具体的に、この更新は、不揮発性メモリのデータ領域に記憶されるデータの値を、0から1、又は1から0へ、一方向へ値を書き込むことをいう。そして、不揮発性メモリでは、初期状態の値が0か1に必ず決定されている。即ち、この更新は、初期状態が0の場合は1へ、初期状態が1であれば0へ値を書き込むことをいう。   Specifically, this update refers to writing the value of data stored in the data area of the nonvolatile memory in one direction from 0 to 1, or from 1 to 0. In the nonvolatile memory, the initial value is always determined to be 0 or 1. That is, this update means writing a value to 1 when the initial state is 0, and writing a value to 0 when the initial state is 1.

初期状態の値にないもの、例えば、初期状態の値が0で、その領域に1の値が書き込まれているものに対して、さらにその値を0と書き込みたいときは、書き込みというよりも初期状態に戻すという(クリアする)概念になっている。   If you want to write a value of 0 for something that is not in the initial state value, for example, the value of the initial state is 0 and the value of 1 is written in the area, it is more initial than writing The concept is to return (clear) the state.

ここで、この書き込みについて図4を参照して説明すると、不揮発性メモリのデータ領域(記憶領域)に、0xAAの値が書き込まれているものに対して(図4(A))、0x55の値を書き込む場合(図4(C))には、初期化が行われて、0xFFという初期値に戻される(図4(B))。その上で改めて、0の値にしなければならないところに対して、0の値が書き込まれるため、書き込みの動作は、データを一度消去して、書き込むといった2段階の動作を伴うものとなっている。   Here, this writing will be described with reference to FIG. 4. When a value of 0xAA is written in the data area (storage area) of the nonvolatile memory (FIG. 4A), a value of 0x55 is written. Is written (FIG. 4C), initialization is performed and the initial value is returned to 0xFF (FIG. 4B). In addition, since a value of 0 is written to a place where the value must be set to 0 again, the writing operation involves a two-stage operation of erasing and writing data once. .

このとき、一度に初期化される領域を1ページとすると、図5に示すように更新領域X(データが書き込まれる領域)が3ページにわたる場合、上述したように不揮発性メモリのデータが更新される際には一度初期化が行われるため、ページA、ページB、及びページCの全てのデータが一度消去されることとなる。   At this time, assuming that the area initialized at one time is one page, when the update area X (area in which data is written) covers three pages as shown in FIG. 5, the data in the nonvolatile memory is updated as described above. Since initialization is performed once, all data of page A, page B, and page C are erased once.

このページA及びページCには、更新データ以外のデータY(非更新領域Y)が含まれているが、ページ単位でしか消去されないため、この非更新領域に記憶されるデータが消去の対象となり、もともと存在していたデータが消されてしまうこととなる。   Although this page A and page C include data Y (non-update area Y) other than the update data, the data stored in the non-update area is the object to be erased because it is erased only in page units. Data that originally existed will be erased.

この処理の最中、即ち、非更新領域が一度消されたときに瞬断が発生してしまうと、当該非更新領域のデータは消去されたまま(0xFFのまま)になってしまうので、こういった非更新領域を保護、即ち、消去される前の状態に戻そうというのが上述した「カードOSによる非更新領域の保護機能」である。   If an instantaneous interruption occurs during this process, that is, when the non-update area is erased, the data in the non-update area remains erased (0xFF). The above-mentioned “non-update area protection function by the card OS” is to protect such a non-update area, that is, to restore the state before being erased.

具体的に、図5においては、非更新領域のデータYは、ページA及びページCに記憶されている。従って、保護されるべきデータは、データYである。従って、ページA及びページCがページ単位で保護対象(バックアップ対象)として、例えば、バックアップ領域等に書き込まれる。以下に、保護対象としてバックアップ領域に書き込まれたデータを、バックアップデータと称する。   Specifically, in FIG. 5, data Y in the non-update area is stored in page A and page C. Therefore, the data to be protected is data Y. Accordingly, page A and page C are written as protection targets (backup targets) in page units, for example, in a backup area. Hereinafter, data written in the backup area as a protection target is referred to as backup data.

このようにして、「カードOSによる非更新領域の保護機能」によって、非更新領域が保護されるようになっている。   In this way, the non-update area is protected by the “non-update area protection function by the card OS”.

図3のフローチャートの説明に戻り、カードOSは、この保護機能を使って、瞬断に備えた更新を行う(ステップS106)。   Returning to the description of the flowchart of FIG. 3, the card OS uses this protection function to perform an update in preparation for an instantaneous interruption (step S106).

そして、アプリケーションは、残りの処理があれば、コマンド処理をして(ステップS107)、レスポンスデータを送信するのはカードOSの処理となるため、カードOSへレスポンスデータを通知する(ステップS108)。そして、カードOSはレスポンスデータを取得すると(ステップS109)、例えば、外部装置(リーダライタ装置等)へレスポンスデータを送信する(ステップS110)。   If there is remaining processing, the application processes the command (step S107), and the response data is transmitted to the card OS, so the response data is notified to the card OS (step S108). When the card OS acquires the response data (step S109), for example, the card OS transmits the response data to an external device (such as a reader / writer device) (step S110).

次に、図6を参照して、「トランザクションによる更新領域の保護機能」が適用される場合のCPU6の動作の概要について説明する。   Next, with reference to FIG. 6, an outline of the operation of the CPU 6 in the case where the “update area protection function by transaction” is applied will be described.

図6は、「トランザクションによる更新領域の保護機能」が適用される場合のCPU6の動作の概要を示すフローチャートである。   FIG. 6 is a flowchart showing an outline of the operation of the CPU 6 in the case where the “update area protection function by transaction” is applied.

上述したように、「トランザクションによる更新領域の保護機能」は、トランザクションにより実現されており、このトランザクションは例えば、上記アプリケーションの機能として提供されている。   As described above, the “update area protection function by transaction” is realized by a transaction, and this transaction is provided as a function of the application, for example.

この「トランザクションによる更新領域の保護機能」について説明すると、あるコマンド処理の中で、不揮発性メモリに対して、3回の連続した書き込み(書き込み1、書き込み2、書き込み3)が行われる場合を考える。そして、書き込み1及び書き込み2が、連続した書き込みとして定義されているとする。   Explaining this "transaction area protection function by transaction", consider a case where three consecutive writes (write 1, write 2, write 3) are performed to a nonvolatile memory in a certain command process. . It is assumed that writing 1 and writing 2 are defined as continuous writing.

この場合、「トランザクションによる更新領域の保護機能」として連続した書き込みの保障がなされる。具体的に、書き込み1及び書き込み2は、連続した書き込みの保障として、書き込み1と書き込み2の両方を更新する前の更新領域の状態、又は、書き込み1と書き込み2の両方を更新した後の更新領域の状態何れかの状態が保障される。   In this case, continuous writing is assured as a “transaction area protection function by transaction”. Specifically, writing 1 and writing 2 are updates after updating both writing 1 and writing 2 or the state of the update area before updating both writing 1 and writing 2 to guarantee continuous writing. Any state of the region is guaranteed.

具体的には、書き込み2の途中で引き抜き等の瞬断が発生した場合、書き込み1を実施する前の書き込み1と書き込み2の更新領域の状態へ戻るようになっている。一方、書き込み3は、予め定められた書き込みとして定義されていないため、連続した書き込みの保障に含まれない。従って、書き込み3の途中に引き抜き等の瞬断が発生しても、書き込み3が書き込まれる前の状態に戻るだけである。   Specifically, when an interruption such as extraction occurs in the middle of writing 2, the state is returned to the state of the update area of writing 1 and writing 2 before writing 1 is performed. On the other hand, the write 3 is not defined as a predetermined write and is not included in the guarantee of continuous writing. Therefore, even if a momentary interruption such as drawing occurs in the middle of the writing 3, it only returns to the state before the writing 3 is written.

ここで、図6のフローチャートを説明する。   Here, the flowchart of FIG. 6 will be described.

図6に示すフローチャートでは、書き込み1及び書き込み2が連続した書き込みとして定義されているものとする。この連続した書き込みとは、例えば、会員登録において氏名と会員番号に関連性を持たせてカードOSに登録させる場合が想定できる。会員登録における氏名と会員番号の登録は、関連した処理であると想定でき、これらの登録を統括して管理するために、連続した書き込みとして定義するのである。   In the flowchart shown in FIG. 6, it is assumed that writing 1 and writing 2 are defined as continuous writing. This continuous writing can be assumed, for example, in the case of registering the card OS with a name and a member number having a relevance in member registration. Registration of name and member number in member registration can be assumed to be related processing, and is defined as continuous writing in order to manage these registrations in an integrated manner.

図6で示すフローチャートの説明として、まず、カードOSが、例えばインターフェースを介して、コマンドを受信すると(ステップS201)、カードOSは、受信したコマンドをどのアプリケーションへ渡すか決定する。そして、カードOSは、受信したコマンドを、決定されたアプリケーションへ渡す(ステップS202)。アプリケーションは、コマンドを取得すると(ステップS203)、コマンドを処理(例えば、コマンド解釈等)する(ステップS204)。   As an explanation of the flowchart shown in FIG. 6, first, when the card OS receives a command via, for example, an interface (step S201), the card OS determines to which application the received command is to be passed. Then, the card OS passes the received command to the determined application (step S202). When the application acquires the command (step S203), the application processes the command (for example, interprets the command) (step S204).

そして、アプリケーションは、取得したコマンドが連続した書き込みとして定義された書き込み命令であると判断した場合には、カードOSへ、"Begin transaction"と称されるトランザクション機能を開始させる指示を与える(ステップS205)。   If the application determines that the acquired command is a write command defined as continuous writing, the application instructs the card OS to start a transaction function called “Begin transaction” (step S205). ).

このトランザクション機能とは、上述した「トランザクションによる更新領域の保護機能」のことをいい、カードOSへ、上述した連続した書き込みの保障させるものである。以下、カードOSによって連続した書き込みの保障が開始された状態を、「transaction開始」と称する。   This transaction function refers to the above-described “update area protection function by transaction”, and guarantees the above-mentioned continuous writing to the card OS. Hereinafter, the state in which continuous writing is guaranteed by the card OS is referred to as “transaction start”.

カードOSによる「transaction開始」の状態では(ステップS206)、記憶領域のうち、連続した書き込みとしての書き込み1(ステップS207)及び書き込み2(ステップS209)が書き込まれる領域(更新領域)のデータがバックアップ(予め他の領域にコピー)される。そして、トランザクション機能が終了した状態である「Commit transaction」の状態にある場合には(ステップS211)、カードOSは、トランザクション機能を停止する(ステップS212)。   In the state of “transaction start” by the card OS (step S206), the data in the area (update area) in which writing 1 (step S207) and writing 2 (step S209) as continuous writing are written is backed up. (Copied in advance to another area). When the transaction function is in a “Commit transaction” state (step S211), the card OS stops the transaction function (step S212).

このステップS205〜ステップS212のアプリケーション及びカードOSの処理の一例としては、書き込み1(ステップS207)及び書き込み2(ステップS209)が行われる間に、引き抜き等の瞬断が発生すると、「transaction開始」の前の状態、又は、トランザクション機能が終了した状態である「Commit transaction」の状態にある場合にはトランザクション機能が終了した状態の何れかの状態となる(ステップS208及びステップS209のtransaction機能/保護機能動作。)。   As an example of the processing of the application and the card OS in steps S205 to S212, if a momentary interruption such as withdrawal occurs during writing 1 (step S207) and writing 2 (step S209), “transaction start” If the transaction function is in the “Commit transaction” state before the transaction function is completed, the transaction function is terminated (transaction function / protection in steps S208 and S209). Functional operation.)

ここで、「transaction開始」の前の状態とは、バックアップされた書き込み1及び書き込み2が書き込まれる領域のデータが読み込まれ、例えば、データ領域に書き込まれることをいう。また、「transaction開始」の前の状態とは、書き込み1及び書き込み2が書き込まれた後(即ち更新された後)に、データ領域に書き込まれたデータが維持されることをいう。   Here, the state before “transaction start” means that the data in the area to which the backed-up writing 1 and writing 2 are written is read, for example, written in the data area. The state before “transaction start” means that data written in the data area is maintained after writing 1 and writing 2 are written (that is, after updating).

次に、アプリケーションは、他に受信したコマンドがあれば、コマンドを処理する(ステップS213)。ここでは、コマンドの処理Bとして、連続した書き込みとして定義されていない書き込み命令が実行される場合を説明する。   Next, if there is another received command, the application processes the command (step S213). Here, a case where a write command not defined as continuous writing is executed as the command processing B will be described.

この場合、「トランザクションによる更新領域の保護機能」は働かず、通常の「カードOSによる非更新領域の保護機能」が働くこととなる。   In this case, the “update area protection function by transaction” does not work, and the normal “non-update area protection function by card OS” works.

そして、アプリケーションは、カードOSへ、書き込みの依頼をする(ステップS214)。カードOSは、この保護機能を使って、瞬断に備えた書き込みを行う(ステップS215の保護機能動作)。   Then, the application requests the card OS to write (step S214). The card OS uses this protection function to perform writing in preparation for an instantaneous interruption (protection function operation in step S215).

そして、アプリケーションは、処理が終了すると、カードOSへレスポンスデータを通知する(ステップS216)。そして、カードOSは、レスポンスデータを取得すると(ステップS217)、例えば、外部装置(リーダライタ装置等)へレスポンスデータを送信する(ステップS218)。   Then, when the processing is completed, the application notifies the card OS of response data (step S216). When the card OS acquires the response data (step S217), for example, the card OS transmits the response data to an external device (a reader / writer device or the like) (step S218).

このように、従来のICカードでは、「カードOSによる非更新領域の保護機能」(記憶領域の更新領域を保護する機能)と「トランザクションによる更新領域の保護機能」(非更新領域を保護する機能)が別々に定義されていた。   As described above, in the conventional IC card, “a function for protecting the non-update area by the card OS” (function for protecting the update area of the storage area) and “a function for protecting the update area by the transaction” (function for protecting the non-update area) ) Was defined separately.

そして、従来のICカードでは、ICカードがデータを更新する際に、「カードOSによる非更新領域の保護機能」と、「トランザクションによる更新領域の保護機能」がそれぞれ機能するようになっていた。   In the conventional IC card, when the IC card updates data, the “non-update area protection function by card OS” and the “update area protection function by transaction” function, respectively.

ここで、図7を参照して、「カードOSによる非更新領域の保護機能」と、「トランザクションによる更新領域の保護機能」がそれぞれ機能する場合のCPU6の動作の詳細について説明する。   Here, with reference to FIG. 7, the details of the operation of the CPU 6 when the “non-update area protection function by the card OS” and the “update area protection function by the transaction” function respectively will be described.

図7は、ICカードによって更新されるデータを概念的に示す図である。   FIG. 7 is a diagram conceptually showing data updated by the IC card.

図7では、不揮発性メモリ5のデータ領域が概念的に示されている。この図7では、1byteを1ブロックとして2つのブロックに区切られた領域を一のページ(例えば、Page−a等)、として、複数のページに区画されたICカードの不揮発性メモリ5のデータ領域が示されている。図7では、複数のページの一例として、Page−aからPage−eが示されている。   In FIG. 7, the data area of the nonvolatile memory 5 is conceptually shown. In FIG. 7, the data area of the non-volatile memory 5 of the IC card divided into a plurality of pages, where an area divided into two blocks with 1 byte as one block is defined as one page (for example, Page-a). It is shown. In FIG. 7, Page-a to Page-e are shown as an example of a plurality of pages.

そして、この不揮発性メモリ5に対する更新として、A)書き込み1、B)書き込み2、及び、C)書き込み3、が行われる場合を説明する。   A case where A) Write 1, B) Write 2, and C) Write 3 are performed as updates to the nonvolatile memory 5 will be described.

これらの書き込みは、不揮発性メモリ5の指定されたページ(Page−a等)の指定された領域(1ブロック目か2ブロック目等)に記憶されるデータを更新するものである。また、書き込み1及び書き込み2は、上述した連続した書き込みとして定義されているものとする。   These writings are to update data stored in a specified area (first block or second block) of a specified page (Page-a or the like) of the nonvolatile memory 5. Further, it is assumed that writing 1 and writing 2 are defined as the continuous writing described above.

具体的には、書き込み1はPage−aの2ブロック目からPage−bの1ブロック目までの2ページにわたる2byteの領域の書き込み(図7の11及び12参照)を、書き込み2はPage−c全体に対して2byteの領域の書き込み(図7の21及び22参照)を、書き込み3はPage−dの2ブロック目からPage−e全体に対して2ページにわたる3byteの領域の書き込み(図7の31、32、及び33参照)を、それぞれ実施させるものとする。   Specifically, write 1 is a 2-byte area write (see 11 and 12 in FIG. 7) over two pages from the second block of Page-a to the first block of Page-b, and write 2 is Page-c Write the 2-byte area for the whole (see 21 and 22 in FIG. 7), and write 3 writes the 3-byte area for 2 pages from the second block of Page-d to the entire Page-e (see FIG. 7). 31, 32, and 33).

A)書き込み1について
A−1)「トランザクションによる更新領域の保護機能」について
書き込み1及び書き込み2は、連続した書き込みとして定義されているため、上述した「トランザクションによる更新領域の保護機能」が働く。この場合、アプリケーションは、書き込み1を実施する前の書き込み1と書き込み2の更新領域の状態を取り得ることを可能とするため、書き込み1が実施される前のPage−aの2ブロック目からPage−bの1ブロック目までに記憶されたデータをバックアップさせる。
A) About Write 1 A-1) About “Protection Function for Update Area by Transaction” Since Write 1 and Write 2 are defined as continuous writes, the above-mentioned “Protect function for update area by transaction” operates. In this case, the application can acquire the state of the update area of the write 1 and the write 2 before the write 1 is executed. Therefore, the page is started from the second block of the page-a before the write 1 is executed. The data stored up to the first block of -b is backed up.

具体的には、例えば、アプリケーションは、書き込み1が実施される前のPage−aの2ブロック目からPage−bの1ブロック目までに記憶されたデータ(図7の11及び12参照)をRAM4に一時的に記憶し、その後バックアップ領域へ当該データを、カードOSに書き込ませる。   Specifically, for example, the application stores data (refer to 11 and 12 in FIG. 7) stored in the RAM 4 from the second block of Page-a to the first block of Page-b before writing 1 is performed. Is temporarily stored, and then the data is written to the card OS in the backup area.

A−2)「カードOSによる非更新領域の保護機能」について
次に、「カードOSによる非更新領域の保護機能」が働く。具体的には、カードOSは、以下のa)〜j)の動作を実施する。
A-2) “Protection function of non-update area by card OS” Next, “Protection function of non-update area by card OS” works. Specifically, the card OS performs the following operations a) to j).

a)まず、カードOSは、Page−aにおける非更新領域のデータを保護するため、Page−aに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−aRとする。   a) First, the card OS writes the data stored in the Page-a to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-a. For convenience of explanation, the data written in the RAM 4 is referred to as Page-aR.

b)次に、カードOSは、Page−aRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−aRを書き込む。   b) Next, the card OS backs up the Page-aR. Specifically, the card OS writes Page-aR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−aRの2ブロック目に、書き込み1で書き込まれるべきデータを書き込む(図7の11のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−aRを更新する。   c) Next, the card OS writes the data to be written in the write 1 in the second block of Page-aR (updates the data 11 in FIG. 7). That is, the card OS updates the Page-aR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−aRを、不揮発性メモリ5のPage−aへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−aを更新する。   d) Next, the card OS writes the updated Page-aR into the Page-a of the nonvolatile memory 5. That is, the card OS updates Page-a stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−aRを消去する。   e) Next, the card OS erases the Page-aR written in the backup area.

f)次に、カードOSは、Page−bにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−bRとする。   f) Next, the card OS writes the data stored in the Page-b to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-b. For convenience of explanation, the data written in the RAM 4 is referred to as Page-bR.

g)次に、カードOSは、Page−bRをバックアップする。具体的には、カードOSは、バックアップ領域へPage−bRを書き込む。   g) Next, the card OS backs up the Page-bR. Specifically, the card OS writes Page-bR into the backup area.

h)次に、カードOSは、Page−bRの1ブロック目に、書き込み1で書き込まれるべきデータを書き込む(図7の12のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−bRを更新する。   h) Next, the card OS writes the data to be written in the write 1 in the first block of the Page-bR (updates the data 12 in FIG. 7). That is, the card OS updates the Page-bR stored in the RAM 4.

i)次に、カードOSは、更新されたPage−bRを、不揮発性メモリ5のPage−bへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−bを更新する。   i) Next, the card OS writes the updated Page-bR into the Page-b of the nonvolatile memory 5. That is, the card OS updates Page-b stored in the nonvolatile memory 5.

j)次に、カードOSは、バックアップ領域に書き込まれたPage−bRを消去する。   j) Next, the card OS erases the Page-bR written in the backup area.

以上で、書き込み1が実施されたこととなる。   Thus, writing 1 is performed.

B)書き込み2について
B−1)「トランザクションによる更新領域の保護機能」について
書き込み2も同様に、連続した書き込みとして定義されているため、上述した「トランザクションによる更新領域の保護機能」が働く。この場合、アプリケーションは、書き込み1を実施する前の書き込み1と書き込み2の更新領域の状態を取り得ることを可能とするため、書き込み2が実施される前のPage−cの全てに記憶されたデータをバックアップさせる。
B) Regarding Write 2 B-1) “Protection Function for Update Area by Transaction” Similarly, since Write 2 is also defined as continuous write, the above-mentioned “Protection Function for Update Area by Transaction” operates. In this case, the application can store the states of the update areas of the write 1 and the write 2 before the write 1 is executed, so that it is stored in all of the Page-c before the write 2 is executed. Back up your data.

具体的には、例えば、アプリケーションは、書き込み1が実施される前のPage−cに記憶されたデータ(図7の21及び22のデータ)をRAM4に一時的に記憶し、バックアップ領域へ当該データを、カードOSに書き込ませる。   Specifically, for example, the application temporarily stores the data (data 21 and 22 in FIG. 7) stored in Page-c before the writing 1 is performed in the RAM 4, and stores the data in the backup area. Are written in the card OS.

B−2)「カードOSによる非更新領域の保護機能」について
書き込み2ではPage−cに記憶される全てのデータが更新対象であるため、Page−cには非更新領域が存在しない。従って、「カードOSによる非更新領域の保護機能」は働かないこととなる。この場合、カードOSは、以下のa)〜c)の動作を実施する。
B-2) “Protection function of non-update area by card OS” Since all data stored in Page-c is to be updated in Write 2, there is no non-update area in Page-c. Therefore, the “non-update area protection function by the card OS” does not work. In this case, the card OS performs the following operations a) to c).

a)まず、カードOSは、Page−cに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−cRとする。ここでは、例えば、A−2)「カードOSによる非更新領域の保護機能」でPage−aR及びPage−bRがバックアップされたのとは異なり、Page−cRはバックアップされないこととなる。   a) First, the card OS writes the data stored in the Page-c to the RAM 4 in units of pages. For convenience of explanation, the data written in the RAM 4 is referred to as Page-cR. Here, for example, Page-aR and Page-bR are not backed up in “A-2)“ Protection function of non-update area by card OS ”, and Page-cR is not backed up.

b)次に、カードOSは、Page−cRに、書き込み2で書き込まれるべきデータを書き込む(図7の21及び22のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−cRを更新する。   b) Next, the card OS writes the data to be written in the write 2 to the Page-cR (updates the data 21 and 22 in FIG. 7). That is, the card OS updates the Page-cR stored in the RAM 4.

c)次に、カードOSは、更新されたPage−cRを、不揮発性メモリ5のPage−cへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−cを更新する。   c) Next, the card OS writes the updated Page-cR into the Page-c of the nonvolatile memory 5. That is, the card OS updates Page-c stored in the nonvolatile memory 5.

以上で、書き込み2が実施されたこととなる。   Thus, writing 2 is performed.

そして、書き込み2が実施されたことで、「トランザクションによる更新領域の保護機能」は終了する。従って、カードOSは、バックアップ領域に記憶された書き込み1が実施される前のPage−aからPage−cに記憶された更新領域のデータ(図7の11、12、21、及び22)を消去する。   Then, when the writing 2 is performed, the “update area protection function by transaction” is completed. Therefore, the card OS deletes the data (11, 12, 21, and 22 in FIG. 7) stored in the page-c from the page-a before the writing 1 stored in the backup area is performed. To do.

C)書き込み3について
C−1)「トランザクションによる更新領域の保護機能」について
書き込み3では、連続した書き込みとして定義されていないため、上述した「トランザクションによる更新領域の保護機能」は働かず、「カードOSによる非更新領域の保護機能」のみが働くこととなる。
C) About Write 3 C-1) “Protection Function for Update Area by Transaction” Since Write 3 is not defined as a continuous write, the above-mentioned “Protection Function for Update Area by Transaction” does not work, and “Card Only the OS non-update area protection function "works.

C−2)「カードOSによる非更新領域の保護機能」について
具体的に、カードOSは、以下のa)〜h)の動作を実施する。
C-2) “Protection function of non-updated area by card OS” Specifically, the card OS performs the following operations a) to h).

a)まず、カードOSは、Page−dにおける非更新領域のデータを保護するため、Page−dに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−dRとする。   a) First, the card OS writes the data stored in the Page-d to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-d. For convenience of explanation, the data written in the RAM 4 is referred to as Page-dR.

b)次に、カードOSは、Page−dRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−dRを書き込む。   b) Next, the card OS backs up the Page-dR. Specifically, the card OS writes Page-dR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−dRの2ブロック目に、書き込み2で書き込まれるべきデータを書き込む(図7の21及び22のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−dRを更新する。   c) Next, the card OS writes the data to be written in the write 2 in the second block of Page-dR (updates the data 21 and 22 in FIG. 7). That is, the card OS updates the Page-dR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−dRを、不揮発性メモリ5のPage−dへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−dを更新する。   d) Next, the card OS writes the updated Page-dR into the Page-d of the nonvolatile memory 5. That is, the card OS updates Page-d stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−dRを消去する。   e) Next, the card OS erases the Page-dR written in the backup area.

また、書き込み3のうちPage−eに記憶されるデータを更新する場合には、Page−eに記憶される全てのデータが更新対象であるため、Page−eには非更新領域が存在しない。従って、「カードOSによる非更新領域の保護機能」は働かないこととなる。この場合、カードOSは、以下のf)〜h)の動作を実施する。   Further, when updating the data stored in Page-e in Write 3, all data stored in Page-e are to be updated, and therefore there is no non-update area in Page-e. Therefore, the “non-update area protection function by the card OS” does not work. In this case, the card OS performs the following operations f) to h).

f)まず、カードOSは、Page−eに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−eRとする。   f) First, the card OS writes the data stored in the Page-e to the RAM 4 in units of pages. For convenience of explanation, the data written in the RAM 4 is referred to as Page-eR.

b)次に、カードOSは、Page−eRに、書き込み3で書き込まれるべきデータを書き込む。すなわち、カードOSは、RAM4に記憶されたPage−eRを更新する。   b) Next, the card OS writes the data to be written in the write 3 to the Page-eR. That is, the card OS updates the Page-eR stored in the RAM 4.

ここでは、Page−eRはバックアップされないこととなる。   Here, Page-eR is not backed up.

c)次に、カードOSは、更新されたPage−eRを、不揮発性メモリ5のPage−eへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−eを更新する。   c) Next, the card OS writes the updated Page-eR into the Page-e of the nonvolatile memory 5. That is, the card OS updates Page-e stored in the nonvolatile memory 5.

以上で、書き込み3が実施されたこととなる。   Thus, writing 3 is performed.

また、不揮発性メモリ5のページあたりに記憶されるデータの容量が、128byte、又は256byteと大容量である場合がある。このページあたりに記憶されるデータの容量の増加に伴い、同一ページ内に対する更新が連続したり、複数のページに跨る更新が発生するケースが増加する。   In addition, the capacity of data stored per page of the nonvolatile memory 5 may be as large as 128 bytes or 256 bytes. As the capacity of data stored per page increases, the number of cases in which updates within the same page continue or updates across a plurality of pages increase.

ここで、図8を参照して、ページあたりに記憶されるデータの容量が大容量である場合に、「カードOSによる非更新領域の保護機能」と、「トランザクションによる更新領域の保護機能」がそれぞれ機能する場合のCPU6の動作の詳細について説明する。   Here, referring to FIG. 8, when the capacity of data stored per page is large, “non-update area protection function by card OS” and “update area protection function by transaction” are provided. Details of the operation of the CPU 6 in the case of functioning will be described.

図8は、ページあたりに記憶されるデータの容量が大容量である場合に、ICカードによって更新されるデータを概念的に示す図である。   FIG. 8 is a diagram conceptually showing data updated by the IC card when the capacity of data stored per page is large.

図8では、不揮発性メモリ5の領域が概念的に示されている。この図8では、1byteを1ブロックとして256のブロックに区切られた領域を一のページ(例えば、Page−x等)、として、複数のページに区画されたICカードの不揮発性メモリ5が示されている。図8では、複数のページの一例として、Page−xとPage−yが示されている。   In FIG. 8, the area | region of the non-volatile memory 5 is shown notionally. In FIG. 8, the non-volatile memory 5 of the IC card divided into a plurality of pages is shown with an area divided into 256 blocks with 1 byte as one block and one page (eg, Page-x). ing. In FIG. 8, Page-x and Page-y are shown as an example of a plurality of pages.

そして、この不揮発性メモリ5に対する更新として、A)書き込み1、B)書き込み2、及び、C)書き込み3、が行われる場合を説明する。   A case where A) Write 1, B) Write 2, and C) Write 3 are performed as updates to the nonvolatile memory 5 will be described.

これらの書き込みは、不揮発性メモリ5の指定されたページ(Page−x等)の指定された領域(1ブロック目か2ブロック目等)に記憶されるデータを更新するものである。また、書き込み1及び書き込み2は、上述した連続した書き込みとして定義されているものとする。   These writings are to update data stored in a specified area (first block or second block) of a specified page (Page-x, etc.) of the nonvolatile memory 5. Further, it is assumed that writing 1 and writing 2 are defined as the continuous writing described above.

具体的には、書き込み1は、Page−xの領域のうち連続する2ブロックに対して、2byteの領域の書き込み(図8の11及び12参照)を、書き込み2は、Page−xの256ブロック目からPage−yの1ブロック目までの2ページにわたる2byteの領域の書き込み(図8の21及び22参照)を、書き込み3は、Page−yの領域のうち連続する3ブロックに対して、3byteの領域の書き込み(図8の31、32、及び33参照)を、それぞれ実施させるものとする。   Specifically, the write 1 is a 2-byte area write (see 11 and 12 in FIG. 8) with respect to two consecutive blocks in the Page-x area, and the write 2 is a Page-x 256 block. The writing of 2 bytes area (see 21 and 22 in FIG. 8) over two pages from the first to the first block of Page-y is performed, and the writing 3 is 3 bytes for 3 consecutive blocks in the Page-y area. It is assumed that the writing of these areas (see 31, 32 and 33 in FIG. 8) is performed, respectively.

A)書き込み1について
A−1)「トランザクションによる更新領域の保護機能」について
書き込み1及び書き込み2は、連続した書き込みとして定義されているため、上述した「トランザクションによる更新領域の保護機能」が働く。この場合、アプリケーションは、書き込み1を実施する前の書き込み1と書き込み2の更新領域の状態を取り得ることを可能とするため、書き込み1が実施される前のデータであるPage−xの領域のうち連続する2ブロックに記憶されたデータ(図8の11及び12参照)をバックアップする。
A) About Write 1 A-1) About “Protection Function for Update Area by Transaction” Since Write 1 and Write 2 are defined as continuous writes, the above-mentioned “Protect function for update area by transaction” operates. In this case, the application can obtain the state of the update areas of the write 1 and the write 2 before the write 1 is executed, so that the page-x area, which is the data before the write 1 is executed, can be obtained. Data stored in two consecutive blocks (see 11 and 12 in FIG. 8) is backed up.

具体的には、例えば、アプリケーションは、書き込み1が実施される前のPage−xの領域のうち連続する2ブロックに記憶されたデータをRAM4に一時的に記憶し、バックアップ領域へ当該データを、カードOSに書き込ませる。   Specifically, for example, the application temporarily stores the data stored in two consecutive blocks in the area of Page-x before the writing 1 is performed in the RAM 4, and stores the data in the backup area. Write to the card OS.

A−2)「カードOSによる非更新領域の保護機能」について
次に、「カードOSによる非更新領域の保護機能」が働く。具体的には、カードOSは、以下のa)〜j)の動作を実施する。
A-2) “Protection function of non-update area by card OS” Next, “Protection function of non-update area by card OS” works. Specifically, the card OS performs the following operations a) to j).

a)まず、カードOSは、Page−xにおける非更新領域のデータを保護するため、Page−xに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−xRとする。   a) First, the card OS writes the data stored in the Page-x to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-x. For convenience of explanation, the data written in the RAM 4 is referred to as Page-xR.

b)次に、カードOSは、Page−xRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−xRを書き込む。   b) Next, the card OS backs up the Page-xR. Specifically, the card OS writes Page-xR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−xRの領域のうち連続する2ブロックに、書き込み1で書き込まれるべきデータを書き込む(図8の11及び12のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−xRを更新する。   c) Next, the card OS writes the data to be written in the write 1 in two consecutive blocks in the Page-xR area (updates the data 11 and 12 in FIG. 8). That is, the card OS updates Page-xR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−xRを、不揮発性メモリ5のPage−xへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−xを更新する。   d) Next, the card OS writes the updated Page-xR into the Page-x of the nonvolatile memory 5. That is, the card OS updates Page-x stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−xRを消去する。   e) Next, the card OS erases the Page-xR written in the backup area.

以上で、書き込み1が実施されたこととなる。   Thus, writing 1 is performed.

B)書き込み2について
B−1)「トランザクションによる更新領域の保護機能」について
書き込み2も同様に、連続した書き込みとして定義されているため、上述した「トランザクションによる更新領域の保護機能」が働く。従って、アプリケーションは、書き込み1が実施される前のPage−xの256ブロック目からPage−yの1ブロック目までに記憶されたデータ(図8の21及び22のデータを更新する)を、RAM4に一時的に記憶し、その後不揮発性メモリ5に設定されたバックアップ領域へ当該データを書き込む。
B) Regarding Write 2 B-1) “Protection Function for Update Area by Transaction” Similarly, since Write 2 is also defined as continuous write, the above-mentioned “Protection Function for Update Area by Transaction” operates. Therefore, the application stores the data (updates data 21 and 22 in FIG. 8) stored in the RAM 4 from the 256th block of Page-x to the first block of Page-y before writing 1 is performed. Is temporarily stored, and then the data is written to the backup area set in the nonvolatile memory 5.

B−2)「カードOSによる非更新領域の保護機能」について
次に、「カードOSによる非更新領域の保護機能」が働く。具体的には、カードOSは、以下のa)〜j)の動作を実施する。
B-2) “Protection function of non-update area by card OS” Next, “Protection function of non-update area by card OS” works. Specifically, the card OS performs the following operations a) to j).

a)まず、カードOSは、Page−xにおける非更新領域のデータを保護するため、Page−xに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−xRとする。   a) First, the card OS writes the data stored in the Page-x to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-x. For convenience of explanation, the data written in the RAM 4 is referred to as Page-xR.

b)次に、カードOSは、Page−xRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−xRを書き込む。   b) Next, the card OS backs up the Page-xR. Specifically, the card OS writes Page-xR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−xRの256ブロック目に、書き込み2で書き込まれるべきデータを書き込む(図8の21のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−xRを更新する。   c) Next, the card OS writes the data to be written in the write 2 in the 256 block of Page-xR (updates the data 21 in FIG. 8). That is, the card OS updates Page-xR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−xRを、不揮発性メモリ5のPage−xへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−xを更新する。   d) Next, the card OS writes the updated Page-xR into the Page-x of the nonvolatile memory 5. That is, the card OS updates Page-x stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−xRを消去する。   e) Next, the card OS erases the Page-xR written in the backup area.

f)次に、カードOSは、Page−yにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−yRとする。   f) Next, the card OS writes the data stored in Page-b to the RAM 4 in units of pages in order to protect the data in the non-update area in Page-y. For convenience of explanation, data written in the RAM 4 is referred to as Page-yR.

g)次に、カードOSは、Page−yRをバックアップする。具体的には、カードOSは、バックアップ領域へPage−yRを書き込む。   g) Next, the card OS backs up the Page-yR. Specifically, the card OS writes Page-yR in the backup area.

h)次に、カードOSは、Page−yRの1ブロック目に、書き込み2で書き込まれるべきデータを書き込む(図8の22のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−yRを更新する。   h) Next, the card OS writes the data to be written in the write 2 in the first block of Page-yR (updates the data 22 in FIG. 8). That is, the card OS updates the Page-yR stored in the RAM 4.

i)次に、カードOSは、更新されたPage−yRを、不揮発性メモリ5のPage−yへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−yを更新する。   i) Next, the card OS writes the updated Page-yR into the Page-y of the nonvolatile memory 5. That is, the card OS updates Page-y stored in the nonvolatile memory 5.

以上で、書き込み2が実施されたこととなる。   Thus, writing 2 is performed.

そして、書き込み2が実施されたことで、「トランザクションによる更新領域の保護機能」は終了する。従って、カードOSは、バックアップ領域に記憶された書き込み1が実施される前のPage−xからPage−yに記憶された更新領域のデータ(図8の11、12、21、及び22)を消去する。   Then, when the writing 2 is performed, the “update area protection function by transaction” is completed. Accordingly, the card OS erases the data (11, 12, 21, and 22 in FIG. 8) in the update area stored in Page-y from Page-x before the execution of Write 1 stored in the backup area. To do.

C)書き込み3について
C−1)「トランザクションによる更新領域の保護機能」について
書き込み3は、連続した書き込みとして定義されていないため、上述した「トランザクションによる更新領域の保護機能」は働かず、「カードOSによる非更新領域の保護機能」のみが働くこととなる。
C) About Write 3 C-1) “Protection Function for Update Area by Transaction” Since Write 3 is not defined as continuous write, the above-mentioned “Protection Function for Update Area by Transaction” does not work, and “Card Only the OS non-update area protection function "works.

C−2)「カードOSによる非更新領域の保護機能」について
具体的に、カードOSは、以下のa)〜e)の動作を実施する。
C-2) “Protection function of non-updated area by card OS” Specifically, the card OS performs the following operations a) to e).

a)まず、カードOSは、Page−yにおける非更新領域のデータを保護するため、Page−yに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−yRとする。   a) First, the card OS writes the data stored in the Page-y to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-y. For convenience of explanation, the data written in the RAM 4 is referred to as Page-yR.

b)次に、カードOSは、Page−yRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−yRを書き込む。   b) Next, the card OS backs up the Page-yR. Specifically, the card OS writes Page-yR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−yRの2ブロック目に、書き込み3で書き込まれるべきデータ(図8の31、32、及び33)を書き込む。すなわち、カードOSは、RAM4に記憶されたPage−yRを更新する。   c) Next, the card OS writes the data (31, 32, and 33 in FIG. 8) to be written in the write 3 in the second block of Page-yR. That is, the card OS updates the Page-yR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−yRを、不揮発性メモリ5のPage−yへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−yを更新する。   d) Next, the card OS writes the updated Page-yR into the Page-y of the nonvolatile memory 5. That is, the card OS updates Page-y stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−yRを消去する。   e) Next, the card OS erases the Page-yR written in the backup area.

以上で、書き込み3が実施されたこととなる。   Thus, writing 3 is performed.

[3.「カードOSによる非更新領域の保護機能」と、「トランザクションによる更新領域の保護機能」の統合について]
上述したように、「カードOSによる非更新領域の保護機能」及び「トランザクションによる更新領域の保護機能」では、更新毎(例えば、上記書き込み1、又は上記書き込み2毎)に、当該更新の対象となるデータが属するページの非更新領域及び更新領域のデータがバックアップされる。従って、同一のページに記憶されたデータに対して連続する個別の更新が行われる場合には、同一のページのバックアップが重複して行われることとなる。また、隣り合うページに記憶されたデータに対して一の更新(例えば、上記書き込み1のみ)が行われる場合には、2ページ分の非更新領域及び更新領域のデータがバックアップされることとなる。不揮発性メモリのページあたりに記憶されるデータの容量が、128byte、又は256byteと大容量である場合には、RAM4や不揮発性メモリ5への書き込み、バックアップ、消去等のページ操作が非常に重い処理になってくる(CPU6等の処理負担の増加を招く)。
[3. About the integration of “Protection function of non-update area by card OS” and “Protection function of update area by transaction”]
As described above, in the “non-update area protection function by the card OS” and the “update area protection function by transaction”, the update target is set for each update (for example, for each write 1 or write 2). The data in the non-update area and the update area of the page to which the data belongs is backed up. Accordingly, when continuous individual updates are performed on the data stored in the same page, the same page is backed up redundantly. In addition, when one update (for example, only the above-described write 1) is performed on data stored in adjacent pages, the data in the non-update area and the update area for two pages are backed up. . When the capacity of data stored per page in the nonvolatile memory is a large capacity of 128 bytes or 256 bytes, processing for page operations such as writing to the RAM 4 and the nonvolatile memory 5, backup, and erasing are very heavy. (Increases the processing load on the CPU 6 and the like).

そこで、本実施形態においては、「カードOSによる非更新領域の保護機能」と「トランザクションによる更新領域の保護機能」が働くICカード8において、「カードOSによる非更新領域の保護機能」と「トランザクションによる更新領域の保護機能」と、を統合させるようにした。   Therefore, in the present embodiment, in the IC card 8 in which the “non-update area protection function by the card OS” and the “update area protection function by the transaction” work, the “non-update area protection function by the card OS” and the “transaction” "Update area protection function by".

上述したように、「カードOSによる非更新領域の保護機能」では、ページにおいて非更新領域が存在しない場合(ページ全てのデータを更新する場合)には、「カードOSによる非更新領域の保護機能」は働かない。また、「トランザクションによる更新領域の保護機能」では、バックアップされるデータは、ページにおいて更新領域のデータのみである。   As described above, in the “non-update area protection function by the card OS”, when there is no non-update area in the page (when all data of the page is updated), the “non-update area protection function by the card OS” Does not work. In addition, in the “update area protection function by transaction”, the data to be backed up is only the data in the update area in the page.

そこで、上記の点に着目し、アプリケーションが、更新の対象となるページにおいて、当該ページに記憶されるデータ全てを更新するものとしてカードOSへ通知して、「カードOSによる非更新領域の保護機能」を機能させないようにする。そして、アプリケーションが、更新の対象となるページに記憶されるデータ全て(ページ全て)を、バックアップするようにした。   Therefore, paying attention to the above points, the application notifies the card OS that all the data stored in the page is to be updated in the page to be updated, and the “non-update area protection function by the card OS” "Will not work. The application backs up all data (all pages) stored in the page to be updated.

具体的には、本発明のICチップ用処理プログラムの制御によって、第2の保護手段としてのCPU6は、上記トランザクションの実行中に、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを不揮発性メモリ5に書き込み(記憶し)、当該ページに非更新領域が存在しないものとしてカードOSに通知して、「カードOSによる非更新領域の保護機能」を機能させないようになっている。以下、この動作を、「transaction機能/保護機能付き書き込み」と称する。   Specifically, under the control of the IC chip processing program of the present invention, the CPU 6 as the second protection means allows all areas of the page to which the update area and the non-update area before update belong during execution of the transaction. Is used as an update area, all data stored in the page is written (stored) in the nonvolatile memory 5, and the card OS is notified that there is no non-update area in the page. The “area protection function” is not allowed to function. Hereinafter, this operation is referred to as “transaction function / protective writing”.

これによって、一のバックアップ処理のみが行われるため、データの保護機能による処理時間の短縮を図ることができる。   As a result, only one backup process is performed, so that the processing time by the data protection function can be shortened.

ここで、図8を参照して、「transaction機能/保護機能付き書き込み」が適用された場合のCPU6の動作の詳細について説明する。   Here, with reference to FIG. 8, the details of the operation of the CPU 6 when “transaction function / protective writing” is applied will be described.

なお、ここでは、上述した本発明のICチップ用処理プログラムが備える機能が実行される場合の動作主体をCPU6として説明する。   Here, the operation subject when the function of the above-described IC chip processing program of the present invention is executed will be described as the CPU 6.

また、ここで説明する例では、図8で定義される不揮発性メモリ5に対する更新として、A)書き込み1、B)書き込み2、及び、C)書き込み3、が行われるものとし、これらの書き込み条件(例えば、上述した連続した書き込みとして定義されていること等)は、図8で定義された条件と同一の条件を適用するものとする。   In the example described here, A) Write 1, B) Write 2, and C) Write 3 are performed as updates to the nonvolatile memory 5 defined in FIG. It is assumed that the same conditions as those defined in FIG. 8 are applied (for example, defined as continuous writing described above).

A)書き込み1について
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜d)の動作を実施する。
A) Write 1 “Transaction function / protective write” works. Specifically, the CPU 6 performs the following operations a) to d).

a)まず、CPU6は、Page−xに記憶される全てのデータを保護するため、Page−xに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−xRとする。   a) First, the CPU 6 writes the data stored in the Page-x to the RAM 4 in units of pages in order to protect all the data stored in the Page-x. For convenience of explanation, the data written in the RAM 4 is referred to as Page-xR.

この場合、CPU6は、書き込み1で更新の対象となるPage−xに記憶される全てのデータをRAM4へ書き込み、その後、不揮発性メモリ5へ書き込むことで、Page−xに記憶される全てのデータを更新の対象とし、非更新領域が存在しないものとしてカードOSへ通知する。   In this case, the CPU 6 writes all the data stored in the Page-x to be updated in the writing 1 to the RAM 4 and then writes it in the nonvolatile memory 5, so that all the data stored in the Page-x is written. And the card OS is notified that there is no non-update area.

この通知を受けたカードOSは、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Upon receiving this notification, the card OS does not allow the “non-update area protection function by the card OS” to function.

b)次に、CPU6は、Page−xRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−xRを書き込む。   b) Next, the CPU 6 backs up the Page-xR. Specifically, the CPU 6 writes Page-xR into the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−xRの領域のうち連続する2ブロックに、書き込み1で書き込まれるべきデータを書き込む(図8の11及び12のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−xRを更新する。   c) Next, the CPU 6 writes the data to be written in the write 1 into two consecutive blocks in the Page-xR area (updates the data 11 and 12 in FIG. 8). That is, the CPU 6 updates the Page-xR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−xRを、不揮発性メモリ5のPage−xへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−xを更新する。   d) Next, the CPU 6 writes the updated Page-xR into the Page-x of the nonvolatile memory 5. That is, the CPU 6 updates the Page-x stored in the nonvolatile memory 5.

以上で、書き込み1が実施されたこととなる。   Thus, writing 1 is performed.

B)書き込み2について
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜h)の動作を実施する。
B) Write 2 "Transaction function / Protected write" works. Specifically, the CPU 6 performs the following operations a) to h).

a)まず、CPU6は、Page−xに記憶される全てのデータを保護するため、Page−xに記憶されるデータを、ページ単位でRAM4へ書き込む。   a) First, the CPU 6 writes the data stored in the Page-x to the RAM 4 in units of pages in order to protect all the data stored in the Page-x.

なお、ここで書き込まれたPage−xに記憶されるデータは、上述した書き込み1で更新されたもの(図8の11及び12が更新されたもの)である。従って、上述したA)書き込み1についてa)で、RAM4に書き込まれたPage−xとは異なるデータである。以後、説明の便宜上、B)書き込み2についてa)でPage−xに記憶される全てのデータをPage−x´と、RAM4に書き込まれるデータを、Page−x´Rとする。   Note that the data stored in the page-x written here is the data updated by the above-described writing 1 (the data 11 and 12 in FIG. 8 are updated). Therefore, the above-mentioned A) Write 1 is data different from Page-x written in the RAM 4 in a). Hereinafter, for convenience of explanation, B) Write 2 is referred to as “page-x ′” as all data stored in Page-x in a), and “Page-x′R” as data written to the RAM 4.

b)次に、CPU6は、Page−x´Rをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−x´Rを書き込む。   b) Next, the CPU 6 backs up the Page-x′R. Specifically, the CPU 6 writes Page-x′R to the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−x´Rの256ブロック目に、書き込み2で書き込まれるべきデータを書き込む(図8の21のデータを更新する)。すなわち、カードOSは、RAM4に記憶されたPage−x´Rを更新する。   c) Next, the CPU 6 writes the data to be written in the write 2 in the 256 block of Page-x′R (updates the data 21 in FIG. 8). That is, the card OS updates Page-x′R stored in the RAM 4.

d)次に、カードOSは、更新されたPage−x´Rを、不揮発性メモリ5のPage−x´へ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−aを更新する。   d) Next, the card OS writes the updated Page-x′R into the Page-x ′ of the nonvolatile memory 5. That is, the card OS updates Page-a stored in the nonvolatile memory 5.

e)次に、CPU6は、Page−yにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−yRとする。   e) Next, the CPU 6 writes the data stored in the Page-b to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-y. For convenience of explanation, the data written in the RAM 4 is referred to as Page-yR.

f)次に、CPU6は、Page−yRをバックアップする。具体的には、CPU6は、バックアップ領域へPage−yRを書き込む。   f) Next, the CPU 6 backs up the Page-yR. Specifically, the CPU 6 writes Page-yR in the backup area.

g)次に、CPU6は、Page−yRの1ブロック目に、書き込み2で書き込まれるべきデータを書き込む(図8の22のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−yRを更新する。   g) Next, the CPU 6 writes the data to be written in the write 2 in the first block of Page-yR (updates the data 22 in FIG. 8). That is, the CPU 6 updates the Page-yR stored in the RAM 4.

h)次に、CPU6は、更新されたPage−yRを、不揮発性メモリ5のPage−yへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−yを更新する。   h) Next, the CPU 6 writes the updated Page-yR into the Page-y of the nonvolatile memory 5. That is, the CPU 6 updates the Page-y stored in the nonvolatile memory 5.

以上で、書き込み2が実施されたこととなる。   Thus, writing 2 is performed.

そして、書き込み2が実施されたことで、「トランザクションによる更新領域の保護機能」は終了する。   Then, when the writing 2 is performed, the “update area protection function by transaction” is completed.

そこで、CPU6は、バックアップ領域に記憶された書き込み1が実施される前のPage−xに記憶された全てのデータであるPage−xR、書き込み2が実施される前のPage−x´に記憶された全てのデータであるPage−x´R、書き込み2が実施される前のPage−yに記憶された全てのデータであるPage−yRをそれぞれ消去する。   Therefore, the CPU 6 stores in the Page-xR, which is all data stored in the Page-x before the writing 1 stored in the backup area, and the Page-x ′ before the writing 2 is performed. All of the data, Page-x′R, which is all data, and Page-yR, which is all the data stored in Page-y before execution of writing 2, are deleted.

C)書き込み3について
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜e)の動作を実施する。
C) Write 3 “Transaction function / Protected write” works. Specifically, the CPU 6 performs the following operations a) to e).

a)まず、CPU6は、Page−yに記憶される全てのデータを保護するため、Page−yに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−yRとする。   a) First, the CPU 6 writes the data stored in the Page-y to the RAM 4 in page units in order to protect all the data stored in the Page-y. For convenience of explanation, the data written in the RAM 4 is referred to as Page-yR.

b)次に、CPU6は、Page−yRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−yRを書き込む。   b) Next, the CPU 6 backs up the Page-yR. Specifically, the CPU 6 writes Page-yR to the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−yRの2ブロック目に、書き込み3で書き込まれるべきデータ(図8の31、32、及び33)を書き込む。すなわち、CPU6は、RAM4に記憶されたPage−yRを更新する。   c) Next, the CPU 6 writes the data (31, 32, and 33 in FIG. 8) to be written in the write 3 in the second block of Page-yR. That is, the CPU 6 updates the Page-yR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−yRを、不揮発性メモリ5のPage−yへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−yを更新する。   d) Next, the CPU 6 writes the updated Page-yR into the Page-y of the nonvolatile memory 5. That is, the CPU 6 updates the Page-y stored in the nonvolatile memory 5.

e)次に、CPU6は、バックアップ領域に書き込まれたPage−yRを消去する。   e) Next, the CPU 6 erases the Page-yR written in the backup area.

以上で、書き込み3が実施されたこととなる。   Thus, writing 3 is performed.

なお、上述した「transaction機能/保護機能付き書き込み」は、連続した書き込みとして定義された書き込みの間(即ち、上記トランザクションが実行されている間)、働かせるようにしてもよい。   It should be noted that the above-described “transaction function / protective writing” may be performed during writing defined as continuous writing (that is, while the transaction is being executed).

この場合、CPU6は、トランザクションの実行状態、即ち、連続した書き込みとして定義された書き込みが行われているか否かを監視する。   In this case, the CPU 6 monitors the execution state of the transaction, that is, whether or not writing defined as continuous writing is being performed.

そして、CPU6は、連続した書き込みとして定義された書き込みが行われている間、「transaction機能/保護機能付き書き込み」を働かせるようになっている。   Then, the CPU 6 operates the “transaction function / write with protection function” while the write defined as the continuous write is being performed.

なお、上述した例では、「transaction機能/保護機能付き書き込み」は、ICチップ用処理プログラムの制御によりCPU6が実行することとして説明したが、これに限られず、例えば、「transaction機能/保護機能付き書き込み」は、「トランザクションによる更新領域の保護機能」をCPU6に実行させるアプリケーションによって実行させるようにしてもよい。   In the above-described example, the “transaction function / protection function write” has been described as being executed by the CPU 6 under the control of the IC chip processing program. However, the present invention is not limited to this. “Write” may be executed by an application that causes the CPU 6 to execute the “protection function of update area by transaction”.

次に、図8及び図9を参照して、「バックアップ検索機能」について説明する。   Next, the “backup search function” will be described with reference to FIGS. 8 and 9.

この「バックアップ検索機能」とは、これから更新されるページと同一のページのバックアップデータが既に書き込まれているか否かを検索し、既に書き込まれている場合には、これから更新されるページのバックアップデータを書き込まない構成を追加した点である。以下、この構成を「バックアップ検索機能」と称する。   This “backup search function” searches whether or not backup data of the same page as the page to be updated has already been written, and if it has already been written, the backup data of the page to be updated from now on This is the point where a configuration that does not write is added. Hereinafter, this configuration is referred to as a “backup search function”.

まず、図9を参照して、「バックアップ検索機能」が適用されない場合のバックアップ領域に書き込まれるデータについて説明する。   First, data written in the backup area when the “backup search function” is not applied will be described with reference to FIG.

図9は、「バックアップ検索機能」が適用されない場合のバックアップ領域に書き込まれるデータ構造を概念的に示す図である。   FIG. 9 is a diagram conceptually showing a data structure written in the backup area when the “backup search function” is not applied.

なお、既に説明した実施形態と少なくとも同様の機能を果たす部分には、同一の符号を付して、重複する説明や図面を省略する。   In addition, the part which fulfill | performs the function similar to already demonstrated embodiment is attached | subjected with the same code | symbol, and the overlapping description and drawing are abbreviate | omitted.

図9に示すように、「バックアップ検索機能」が適用されない場合のバックアップ領域に書き込まれるデータは、Page−xのバックアップデータとしてのPage−xR(A)書き込み1についてb)参照)と、Page−x´(図8の11及び12が更新されたもの)のバックアップデータとしてのPage−x´R(B)書き込み2についてb)参照)と、Page−yのバックアップデータとしてのPage−yR(B)書き込み2についてb)参照)の3つである。   As shown in FIG. 9, the data written in the backup area when the “backup search function” is not applied is referred to as “b) for Page-xR (A) writing 1 as backup data of Page-x” and Page- x ′ (see page-x′R (B) write 2 b) as backup data of x ′ (updated 11 and 12 in FIG. 8)) and Page-yR (B 3) Write 2 (see b)).

ここで、「トランザクションによる更新領域の保護機能」として保障されるのは、連続した書き込みの保証として、書き込み1と書き込み2の両方を更新する前の更新領域の状態である。   Here, what is guaranteed as the “update area protection function by transaction” is the state of the update area before both writing 1 and writing 2 are updated, as a guarantee of continuous writing.

そして、例えば、書き込み1で瞬断が発生した場合には、書き込み1と書き込み2の両方を更新する前の更新領域の状態として、Page−xRとPage−yRが不揮発性メモリ5に書き込まれることとなる。   For example, when an interruption occurs in writing 1, Page-xR and Page-yR are written in the nonvolatile memory 5 as the state of the update area before updating both writing 1 and writing 2. It becomes.

ここで、Page−xRは、と同一のページであり、Page−x´Rは「トランザクションによる更新領域の保護機能」を機能させる際に省略することができるバックアップデータであることに気が付く。   Here, it is noted that Page-xR is the same page as Page-xR, and that Page-x′R is backup data that can be omitted when the “function for protecting update area by transaction” is performed.

そこで、「バックアップ検索機能」が適用される場合には、CPU6は、更新領域が属するページが、バックアップ管理領域を参照して、バックアップ領域に既に書き込まれている(記憶されている)か否かを検索し、前記更新領域が属するページが、バックアップ領域に既に書き込まれていることが検索されなかった場合には、第2の保護手段としてのCPU6は、当該更新領域が属するページに記憶される全てのデータを、バックアップ領域に記憶するようになっている。   Therefore, when the “backup search function” is applied, the CPU 6 refers to the backup management area to determine whether or not the page to which the update area belongs has already been written (stored) in the backup area. If it is not found that the page to which the update area belongs has already been written in the backup area, the CPU 6 as the second protection means stores it in the page to which the update area belongs. All data is stored in the backup area.

ここで、図8及び図9を参照して、「バックアップ検索機能」が適用された場合のCPU6の動作の詳細について説明する。   Details of the operation of the CPU 6 when the “backup search function” is applied will be described with reference to FIGS. 8 and 9.

また、ここで説明する例では、図8で定義される不揮発性メモリ5に対する更新として、A)書き込み1、B)書き込み2、及び、C)書き込み3、が行われるものとし、これらの書き込み条件(例えば、上述した連続した書き込みとして定義されていること等)は、図8で定義された条件と同一の条件を適用するものとする。   In the example described here, A) Write 1, B) Write 2, and C) Write 3 are performed as updates to the nonvolatile memory 5 defined in FIG. It is assumed that the same conditions as those defined in FIG. 8 are applied (for example, defined as continuous writing described above).

A)書き込み1について
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜d)の動作を実施する。
A) Write 1 “Transaction function / protective write” works. Specifically, the CPU 6 performs the following operations a) to d).

a)まず、CPU6は、Page−xに記憶される全てのデータを保護するため、Page−xに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−xRとする。   a) First, the CPU 6 writes the data stored in the Page-x to the RAM 4 in units of pages in order to protect all the data stored in the Page-x. For convenience of explanation, data written in the RAM 4 is referred to as Page-xR.

この場合、CPU6は、書き込み1で更新の対象となるPage−xに記憶される全てのデータをRAM4へ書き込み、その後、不揮発性メモリ5へ書き込むことで、Page−xに記憶される全てのデータを更新の対象とし、非更新領域が存在しないものとしてカードOSへ通知するのは、第1の実施形態の場合と同様である。   In this case, the CPU 6 writes all the data stored in the Page-x to be updated in the writing 1 to the RAM 4 and then writes it in the nonvolatile memory 5, so that all the data stored in the Page-x is written. As in the first embodiment, the card OS is notified that the non-update area does not exist.

この通知を受けたカードOSは、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Upon receiving this notification, the card OS does not allow the “non-update area protection function by the card OS” to function.

b)次に、CPU6は、Page−xRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−xRを書き込む。   b) Next, the CPU 6 backs up the Page-xR. Specifically, the CPU 6 writes Page-xR into the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−xRの領域のうち連続する2ブロックに、書き込み1で書き込まれるべきデータを書き込む(図8の11及び12のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−xRを更新する。   c) Next, the CPU 6 writes the data to be written in the write 1 into two consecutive blocks in the Page-xR area (updates the data 11 and 12 in FIG. 8). That is, the CPU 6 updates the Page-xR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−xRを、不揮発性メモリ5のPage−xへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−xを更新する。   d) Next, the CPU 6 writes the updated Page-xR into the Page-x of the nonvolatile memory 5. That is, the CPU 6 updates the Page-x stored in the nonvolatile memory 5.

以上で、書き込み1が実施されたこととなる。   Thus, writing 1 is performed.

B)書き込み2について
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜g)の動作を実施する。
B) Write 2 "Transaction function / Protected write" works. Specifically, the CPU 6 performs the following operations a) to g).

a)まず、CPU6は、Page−xに記憶される全てのデータを保護するため、Page−xに記憶されるデータを、ページ単位でRAM4へ書き込む。   a) First, the CPU 6 writes the data stored in the Page-x to the RAM 4 in units of pages in order to protect all the data stored in the Page-x.

ここで、CPU6は、バックアップ管理領域を参照して、更新領域が属するページとしてのPage−xがバックアップ領域に既に記憶されているか否かを検索する。   Here, the CPU 6 refers to the backup management area and searches whether Page-x as a page to which the update area belongs is already stored in the backup area.

ここでは、バックアップ管理領域に、A)書き込み1についてb)において、既にPage−xのバックアップデータが記憶されていることが示されている。   Here, it is shown that Page-x backup data is already stored in the backup management area in b) for A) Write 1.

そこで、CPU6は、現在のPage−xに記憶されるデータである書き込み1で更新された(図8の11及び12が更新された)Page−x´のバックアップデータを書き込まないようになっている。   Therefore, the CPU 6 does not write the backup data of Page-x ′ updated by writing 1 (data updated in 11 and 12 in FIG. 8) which is data stored in the current Page-x. .

b)次に、CPU6は、Page−x´Rの256ブロック目に、書き込み2で書き込まれるべきデータを書き込む(図8の21のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−x´Rを更新する。   b) Next, the CPU 6 writes the data to be written in the write 2 in the 256 block of Page-x′R (updates the data 21 in FIG. 8). That is, the CPU 6 updates Page-x′R stored in the RAM 4.

c)次に、カードOSは、更新されたPage−x´Rを、不揮発性メモリ5のPage−x´へ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−aを更新する。   c) Next, the card OS writes the updated Page-x′R into the Page-x ′ of the nonvolatile memory 5. That is, the card OS updates Page-a stored in the nonvolatile memory 5.

d)次に、CPU6は、Page−yにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−yRとする。   d) Next, the CPU 6 writes the data stored in the Page-b to the RAM 4 in page units in order to protect the data in the non-update area in the Page-y. For convenience of explanation, the data written in the RAM 4 is referred to as Page-yR.

e)次に、CPU6は、Page−yRをバックアップする。具体的には、CPU6は、バックアップ領域へPage−yRを書き込む。   e) Next, the CPU 6 backs up the Page-yR. Specifically, the CPU 6 writes Page-yR in the backup area.

f)次に、CPU6は、Page−yRの1ブロック目に、書き込み2で書き込まれるべきデータを書き込む(図8の22のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−yRを更新する。   f) Next, the CPU 6 writes the data to be written in the write 2 in the first block of Page-yR (updates the data 22 in FIG. 8). That is, the CPU 6 updates the Page-yR stored in the RAM 4.

g)次に、CPU6は、更新されたPage−yRを、不揮発性メモリ5のPage−yへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−yを更新する。   g) Next, the CPU 6 writes the updated Page-yR into the Page-y of the nonvolatile memory 5. That is, the CPU 6 updates the Page-y stored in the nonvolatile memory 5.

以上で、書き込み2が実施されたこととなる。   Thus, writing 2 is performed.

そして、書き込み2が実施されたことで、「トランザクションによる更新領域の保護機能」は終了する。   Then, when the writing 2 is performed, the “update area protection function by transaction” is completed.

そこで、CPU6は、バックアップ領域に記憶された書き込み1が実施される前のPage−xに記憶された全てのデータであるPage−xR、書き込み2が実施される前のPage−x´に記憶された全てのデータであるPage−x´R、書き込み2が実施される前のPage−yに記憶された全てのデータであるPage−yRをそれぞれ消去する。   Therefore, the CPU 6 stores in the Page-xR, which is all data stored in the Page-x before the writing 1 stored in the backup area, and the Page-x ′ before the writing 2 is performed. All of the data, Page-x′R, which is all data, and Page-yR, which is all the data stored in Page-y before execution of writing 2, are deleted.

C)書き込み3について
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜e)の動作を実施する。
C) Write 3 “Transaction function / Protected write” works. Specifically, the CPU 6 performs the following operations a) to e).

a)まず、CPU6は、Page−yに記憶される全てのデータを保護するため、Page−yに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−yRとする。   a) First, the CPU 6 writes the data stored in the Page-y to the RAM 4 in page units in order to protect all the data stored in the Page-y. For convenience of explanation, data written in the RAM 4 is referred to as Page-yR.

b)次に、CPU6は、Page−yRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−yRを書き込む。   b) Next, the CPU 6 backs up the Page-yR. Specifically, the CPU 6 writes Page-yR to the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−yRの2ブロック目に、書き込み3で書き込まれるべきデータ(図8の31、32、及び33)を書き込む。すなわち、CPU6は、RAM4に記憶されたPage−yRを更新する。   c) Next, the CPU 6 writes the data (31, 32, and 33 in FIG. 8) to be written in the write 3 in the second block of Page-yR. That is, the CPU 6 updates the Page-yR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−yRを、不揮発性メモリ5のPage−yへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−yを更新する。   d) Next, the CPU 6 writes the updated Page-yR into the Page-y of the nonvolatile memory 5. That is, the CPU 6 updates the Page-y stored in the nonvolatile memory 5.

e)次に、CPU6は、バックアップ領域に書き込まれたPage−yRを消去する。   e) Next, the CPU 6 erases the Page-yR written in the backup area.

以上で、書き込み3が実施されたこととなる。   Thus, writing 3 is performed.

[4.第1の実施形態]
上述した統合では、上記トランザクションの実行中に、「トランザクションによる更新領域の保護機能」によって、前記更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとしてカードOSに通知して、「カードOSによる非更新領域の保護機能」を機能させないようになっている。
[4. First Embodiment]
In the above-described integration, during the execution of the transaction, all the areas of the page to which the update area and the non-update area before the update belong are stored in the page as an update area by the "update area protection function by transaction". All the data to be stored in the storage unit is notified to the card OS that the non-update area does not exist on the page, so that the “non-update area protection function by the card OS” does not function.

しかしながら、この統合は、上記トランザクションの実行中でなければ働かない。従って、連続した書き込みとして定義されない書き込み要求が、複数連続してあった場合には、当該書き込み要求毎に「カードOSによる非更新領域の保護機能」が働き、書き込み要求毎に、バックアップ領域に対してデータの記憶及び当該データの消去が繰り返され、更新やバックアップに要する処理時間が増加する。   However, this integration will not work unless the transaction is running. Therefore, when there are a plurality of write requests that are not defined as continuous write, the “non-update area protection function by the card OS” works for each write request, and the backup area is Thus, data storage and data erasure are repeated, and the processing time required for updating and backup increases.

ここで、図10〜図12を参照して、上述した統合が適用された場合に、連続した書き込みとして定義されない複数の書き込み要求(更新要求)があった場合のCPU6の動作の詳細について説明する。   Here, with reference to FIGS. 10 to 12, details of the operation of the CPU 6 when there are a plurality of write requests (update requests) that are not defined as continuous writing when the above-described integration is applied will be described. .

図10は連続した書き込みとして定義されない複数の更新要求があった場合のCPU6の動作を示すフローチャートであり、図11は複数の更新要求を概念的に示す図であり、図12は複数の更新要求と「カードOSによる保護機能」の詳細を概念的に示す図である。   FIG. 10 is a flowchart showing the operation of the CPU 6 when there are a plurality of update requests that are not defined as continuous writing, FIG. 11 is a diagram conceptually showing a plurality of update requests, and FIG. 12 is a diagram showing a plurality of update requests. FIG. 3 is a diagram conceptually illustrating details of “protection function by card OS”.

なお、ここでも図3と同様に、説明の便宜上、カードOSが備える機能が実行される場合の動作主体をカードOSとし、アプリケーションが備える機能が実行される場合の動作主体をアプリケーションとする。   Here, as in FIG. 3, for convenience of explanation, the operating subject when the function provided by the card OS is executed is the card OS, and the operating subject when the function provided by the application is executed is the application.

図10に示すように、まず、カードOS(CPU6)が、例えばI/O回路2を介して、コマンドを受信すると(ステップS301)、カードOSは、受信したコマンドをどのアプリケーションへ渡すか決定する(ステップS302)。そして、カードOSは、受信したコマンドを、決定されたアプリケーションへ渡す。アプリケーション(CPU6)は、コマンドを取得すると(ステップS303)、コマンドを処理して(例えば、コマンド解釈等)(ステップS304)、必要があれば不揮発性メモリ5のデータを更新する(不揮発性メモリ5へデータを書き込ませる)。   As shown in FIG. 10, first, when the card OS (CPU 6) receives a command via, for example, the I / O circuit 2 (step S301), the card OS determines to which application the received command is passed. (Step S302). Then, the card OS passes the received command to the determined application. Upon obtaining the command (step S303), the application (CPU 6) processes the command (for example, command interpretation) (step S304), and updates the data in the nonvolatile memory 5 if necessary (nonvolatile memory 5). To write data).

ここでは、コマンドの処理A(ステップS304)及びコマンドの処理B(ステップS311)において、連続した書き込みとして定義されない更新要求としての書き込み1〜書き込み5が要求されたことを解釈したものとする。   Here, it is assumed that writing 1 to writing 5 as update requests that are not defined as continuous writing are requested in command processing A (step S304) and command processing B (step S311).

この書き込み1〜書き込み5の詳細は、図11に示すように、書き込み1は不揮発性メモリ5のPage−aの所定の領域のデータを更新するものであり、書き込み2は不揮発性メモリ5のPage−bの所定の領域のデータを更新するものであり、書き込み3は不揮発性メモリ5のPage−bの所定の領域のデータを更新するものであり、書き込み4は不揮発性メモリのPage−cの所定の領域のデータを更新するものであり、書き込み5は不揮発性メモリのPage−cの所定の領域のデータを更新するものである。   As shown in FIG. 11, the details of the writing 1 to writing 5 are as follows. Writing 1 updates data in a predetermined area of Page-a of the nonvolatile memory 5, and Writing 2 is Page of the nonvolatile memory 5. -B is for updating data in a predetermined area, write 3 is for updating data in a predetermined area of Page-b in the nonvolatile memory 5, and write 4 is for data in Page-c of the nonvolatile memory. Data in a predetermined area is updated. Write 5 is to update data in a predetermined area of Page-c of the nonvolatile memory.

そして、この書き込み1〜書き込み5(ステップS305等)は、連続した書き込みとして定義されていないため、「トランザクションによる更新領域の保護機能」は働かず、通常の「カードOSによる非更新領域の保護機能」が働く(ステップS306の保護機能等)。   Since the writing 1 to writing 5 (step S305, etc.) are not defined as continuous writing, the “update area protection function by transaction” does not work, and the normal “non-update area protection function by the card OS” "Works (protection function of step S306, etc.).

ここで、図12を参照して、A)書き込み1〜E)書き込み5と「カードOSによる保護機能」の詳細について、図10のフローチャートと対比して説明する。   Here, with reference to FIG. 12, the details of A) Write 1 to E) Write 5 and “Protection Function by Card OS” will be described in comparison with the flowchart of FIG.

A)書き込み1について(ステップS305)
A−1)「トランザクションによる更新領域の保護機能」について
書き込み1は、連続した書き込みとして定義されていないため、上述した「トランザクションによる更新領域の保護機能」は働かず、「カードOSによる非更新領域の保護機能」のみが働くこととなる。
A) Write 1 (step S305)
A-1) Regarding “Protection function of update area by transaction” Since write 1 is not defined as continuous writing, the above-described “protection function of update area by transaction” does not work, and “non-update area by card OS” Only the "protection function" will work.

A−2)「カードOSによる非更新領域の保護機能」について(ステップS306)
具体的に、カードOSは、以下のa)〜e)の動作を実施する。
A-2) “Protection function of non-update area by card OS” (step S306)
Specifically, the card OS performs the following operations a) to e).

a)まず、カードOSは、Page−aにおける非更新領域のデータを保護するため、Page−aに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−aRとする。   a) First, the card OS writes the data stored in the Page-a to the RAM 4 in units of pages in order to protect the data in the non-update area in the Page-a. For convenience of explanation, the data written in the RAM 4 is referred to as Page-aR.

b)次に、カードOSは、Page−aRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−aRを書き込む。   b) Next, the card OS backs up the Page-aR. Specifically, the card OS writes Page-aR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−aRの所定の領域に、書き込み1で書き込まれるべきデータ(図12の1)を書き込む。すなわち、カードOSは、RAM4に記憶されたPage−aRを更新する。   c) Next, the card OS writes the data to be written by writing 1 (1 in FIG. 12) in a predetermined area of Page-aR. That is, the card OS updates the Page-aR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−aRを、不揮発性メモリ5のPage−aへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−yを更新する。   d) Next, the card OS writes the updated Page-aR into the Page-a of the nonvolatile memory 5. That is, the card OS updates Page-y stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−aRを消去する。   e) Next, the card OS erases the Page-aR written in the backup area.

以上で、書き込み1が実施されたこととなる。   Thus, writing 1 is performed.

B)書き込み2について(ステップS307)
B−1)「トランザクションによる更新領域の保護機能」について
書き込み1は、連続した書き込みとして定義されていないため、上述した「トランザクションによる更新領域の保護機能」は働かず、「カードOSによる非更新領域の保護機能」のみが働くこととなる。
B) Write 2 (step S307)
B-1) “Protection function for update area by transaction” Since write 1 is not defined as continuous writing, the above-mentioned “protection function for update area by transaction” does not work, and “non-update area by card OS” Only the "protection function" will work.

B−2)「カードOSによる非更新領域の保護機能」について(ステップS308)
具体的に、カードOSは、以下のa)〜e)の動作を実施する。
B-2) “Protection function of non-update area by card OS” (step S308)
Specifically, the card OS performs the following operations a) to e).

a)まず、カードOSは、Page−bにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−bRとする。   a) First, the card OS writes the data stored in Page-b to the RAM 4 in units of pages in order to protect the data in the non-update area in Page-b. For convenience of explanation, the data written in the RAM 4 is referred to as Page-bR.

b)次に、カードOSは、Page−bRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−bRを書き込む。   b) Next, the card OS backs up the Page-bR. Specifically, the card OS writes Page-bR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−bRの所定の領域に、書き込み2で書き込まれるべきデータ(図12の2)を書き込む。すなわち、カードOSは、RAM4に記憶されたPage−bRを更新する。   c) Next, the card OS writes the data to be written by writing 2 (2 in FIG. 12) in a predetermined area of Page-bR. That is, the card OS updates the Page-bR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−bRを、不揮発性メモリ5のPage−bへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−bを更新する。   d) Next, the card OS writes the updated Page-bR into the Page-b of the nonvolatile memory 5. That is, the card OS updates Page-b stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−bRを消去する。   e) Next, the card OS erases the Page-bR written in the backup area.

以上で、書き込み2が実施されたこととなる。   Thus, writing 2 is performed.

C)書き込み3について(ステップS309)
B−1)「トランザクションによる更新領域の保護機能」について
書き込み1は、連続した書き込みとして定義されていないため、上述した「トランザクションによる更新領域の保護機能」は働かず、「カードOSによる非更新領域の保護機能」のみが働くこととなる。
C) Write 3 (step S309)
B-1) “Protection function for update area by transaction” Since write 1 is not defined as continuous writing, the above-mentioned “protection function for update area by transaction” does not work, and “non-update area by card OS” Only the "protection function" will work.

C−2)「カードOSによる非更新領域の保護機能」について(ステップS310)
具体的に、カードOSは、以下のa)〜e)の動作を実施する。
C-2) “Protection function of non-update area by card OS” (step S310)
Specifically, the card OS performs the following operations a) to e).

a)まず、カードOSは、Page−bにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−bRとする。   a) First, the card OS writes the data stored in Page-b to the RAM 4 in units of pages in order to protect the data in the non-update area in Page-b. For convenience of explanation, the data written in the RAM 4 is referred to as Page-bR.

b)次に、カードOSは、Page−bRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−bRを書き込む。   b) Next, the card OS backs up the Page-bR. Specifically, the card OS writes Page-bR into the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−bRの所定の領域に、書き込み3で書き込まれるべきデータ(図12の3)を書き込む。すなわち、カードOSは、RAM4に記憶されたPage−bRを更新する。   c) Next, the card OS writes the data (3 in FIG. 12) to be written in the write 3 in a predetermined area of the Page-bR. That is, the card OS updates the Page-bR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−bRを、不揮発性メモリ5のPage−bへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−bを更新する。   d) Next, the card OS writes the updated Page-bR into the Page-b of the nonvolatile memory 5. That is, the card OS updates Page-b stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−bRを消去する。   e) Next, the card OS erases the Page-bR written in the backup area.

以上で、書き込み3が実施されたこととなる。   Thus, writing 3 is performed.

D)書き込み4について(ステップS312)
D−1)「トランザクションによる更新領域の保護機能」について
書き込み1は、連続した書き込みとして定義されていないため、上述した「トランザクションによる更新領域の保護機能」は働かず、「カードOSによる非更新領域の保護機能」のみが働くこととなる。
D) Write 4 (step S312)
D-1) “Protection function of update area by transaction” Since write 1 is not defined as continuous writing, the above-mentioned “protection function of update area by transaction” does not work, and “non-update area by card OS” Only the "protection function" will work.

D−2)「カードOSによる非更新領域の保護機能」について(ステップS313)
具体的に、カードOSは、以下のa)〜e)の動作を実施する。
D-2) “Protection function of non-update area by card OS” (step S313)
Specifically, the card OS performs the following operations a) to e).

a)まず、カードOSは、Page−cにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−cRとする。   a) First, the card OS writes the data stored in Page-b to the RAM 4 in units of pages in order to protect the data in the non-update area in Page-c. For convenience of explanation, the data written in the RAM 4 is referred to as Page-cR.

b)次に、カードOSは、Page−cRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−cRを書き込む。   b) Next, the card OS backs up the Page-cR. Specifically, the card OS writes Page-cR to the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−cRの所定の領域に、書き込み4で書き込まれるべきデータ(図12の4)を書き込む。すなわち、カードOSは、RAM4に記憶されたPage−cRを更新する。   c) Next, the card OS writes the data (4 in FIG. 12) to be written into the predetermined area of Page-cR. That is, the card OS updates the Page-cR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−cRを、不揮発性メモリ5のPage−cへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−cを更新する。   d) Next, the card OS writes the updated Page-cR into the Page-c of the nonvolatile memory 5. That is, the card OS updates Page-c stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−cRを消去する。   e) Next, the card OS erases the Page-cR written in the backup area.

以上で、書き込み4が実施されたこととなる。   Thus, writing 4 is performed.

E)書き込み5について(ステップS314)
E−1)「トランザクションによる更新領域の保護機能」について
書き込み1は、連続した書き込みとして定義されていないため、上述した「トランザクションによる更新領域の保護機能」は働かず、「カードOSによる非更新領域の保護機能」のみが働くこととなる。
E) About writing 5 (step S314)
E-1) About “Protection function of update area by transaction” Since write 1 is not defined as continuous writing, the above-mentioned “protection function of update area by transaction” does not work, and “non-update area by card OS” Only the "protection function" will work.

E−2)「カードOSによる非更新領域の保護機能」について(ステップS315)
具体的に、カードOSは、以下のa)〜e)の動作を実施する。
E-2) “Protection function of non-update area by card OS” (step S315)
Specifically, the card OS performs the following operations a) to e).

a)まず、カードOSは、Page−cにおける非更新領域のデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−cRとする。   a) First, the card OS writes the data stored in Page-b to the RAM 4 in units of pages in order to protect the data in the non-update area in Page-c. For convenience of explanation, the data written in the RAM 4 is referred to as Page-cR.

b)次に、カードOSは、Page−cRをバックアップする。具体的には、カードOSは、不揮発性メモリ5に設定されたバックアップ領域へPage−cRを書き込む。   b) Next, the card OS backs up the Page-cR. Specifically, the card OS writes Page-cR to the backup area set in the nonvolatile memory 5.

c)次に、カードOSは、Page−cRの所定の領域に、書き込み4で書き込まれるべきデータ(図12の5)を書き込む。すなわち、カードOSは、RAM4に記憶されたPage−cRを更新する。   c) Next, the card OS writes the data to be written by writing 4 (5 in FIG. 12) in a predetermined area of Page-cR. That is, the card OS updates the Page-cR stored in the RAM 4.

d)次に、カードOSは、更新されたPage−cRを、不揮発性メモリ5のPage−cへ書き込む。すなわち、カードOSは、不揮発性メモリ5に記憶されたPage−cを更新する。   d) Next, the card OS writes the updated Page-cR into the Page-c of the nonvolatile memory 5. That is, the card OS updates Page-c stored in the nonvolatile memory 5.

e)次に、カードOSは、バックアップ領域に書き込まれたPage−cRを消去する。   e) Next, the card OS erases the Page-cR written in the backup area.

以上で、書き込み5が実施されたこととなる。   Thus, writing 5 is performed.

そして、アプリケーションは、処理が終了すると、カードOSへレスポンスデータを通知する(ステップS316)。そして、カードOSは、レスポンスデータを取得すると(ステップS317)、例えば、外部装置(リーダライタ装置等)へレスポンスデータを送信する(ステップS318)。   Then, when the process ends, the application notifies the card OS of the response data (step S316). When the card OS acquires the response data (step S317), for example, the card OS transmits the response data to an external device (a reader / writer device or the like) (step S318).

このように、連続した書き込みとして定義されない複数の書き込み要求がなされると、上述した統合は、上記トランザクションの実行中でなければ働かない。従って、当該書き込み要求毎に「カードOSによる非更新領域の保護機能」が働き、バックアップ領域に対してデータの記憶及び当該データの消去が繰り返され、更新やバックアップに要する処理時間が増加する。   Thus, when a plurality of write requests that are not defined as consecutive writes are made, the integration described above will not work unless the transaction is being executed. Accordingly, the “non-update area protection function by the card OS” works for each write request, and data storage and deletion of the data are repeated in the backup area, thereby increasing the processing time required for update and backup.

上述した例では、書き込み毎(書き込み1〜5)に、カードOSは、バックアップ領域に書き込まれたPage−aR〜Page−aRを消去(上記A−2)e)等)しているため、不要な消去が繰り返しなされている。   In the above-described example, the card OS erases the Page-aR to Page-aR written in the backup area (Each A-2) e) or the like every time writing (writing 1 to 5) is unnecessary. Erasing has been repeated.

そこで、本実施形態では、更新要求があった場合には、CPU6に「transaction機能/保護機能付き書き込み」を実行させるようになっている。   Therefore, in the present embodiment, when there is an update request, the CPU 6 is caused to execute “transaction function / protection function write”.

具体的には、本発明のICチップ用処理プログラムの制御によって、第2の保護手段としてのCPU6は、更新要求としての書き込み要求があった場合には、当該書き込みを連続した書き込みとして定義されたものとしてトランザクションを実行させる。そして、CPU6は、更新前の更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを不揮発性メモリ5に書き込み(記憶し)、当該ページに非更新領域が存在しないものとしてカードOSに通知して、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Specifically, under the control of the IC chip processing program of the present invention, the CPU 6 as the second protection means is defined as a continuous write when there is a write request as an update request. Make transactions run as things. Then, the CPU 6 writes (stores) all data stored in the page to the non-volatile memory 5 using all areas of the page to which the update area before the update belongs as an update area, and there is a non-update area in the page. The card OS is notified that it does not exist, and the “non-update area protection function by the card OS” is not allowed to function.

ここで、図10及び図13を参照して、本実施形態のCPU6の動作の詳細について説明する。なお、ここでは、上述した本発明のICチップ用処理プログラムが備える機能が実行される場合の動作主体をCPU6として説明する。   Here, the details of the operation of the CPU 6 of this embodiment will be described with reference to FIGS. 10 and 13. Here, the operation subject when the function of the above-described IC chip processing program of the present invention is executed will be described as the CPU 6.

また、ここで説明する例では、図10で定義される不揮発性メモリ5に対する更新として、A)書き込み1〜E)書き込み5、が行われるものとし、これらの書き込み条件(例えば、連続した書き込みとして定義されない更新要求としての書き込み1〜書き込み5が要求されること等)は、図10で定義された条件と同一の条件を適用するものとする。   In the example described here, A) writing 1 to E) writing 5 are performed as updates to the nonvolatile memory 5 defined in FIG. 10, and these writing conditions (for example, continuous writing) are performed. For example, writing 1 to writing 5 as update requests that are not defined are applied under the same conditions as those defined in FIG.

図13は、本実施形態のCPU6の動作の詳細を示すフローチャートである。   FIG. 13 is a flowchart showing details of the operation of the CPU 6 of the present embodiment.

図13に示すように、まず、カードOS(CPU6)が、例えばI/O回路2を介して、コマンドを受信すると(ステップS401)、カードOSは、受信したコマンドをどのアプリケーションへ渡すか決定する(ステップS402)。そして、カードOSは、受信したコマンドを、決定されたアプリケーションへ渡す。アプリケーション(CPU6)は、コマンドを取得すると(ステップS403)、コマンドを処理して(例えば、コマンド解釈等)(ステップS404)、必要があれば不揮発性メモリ5のデータを更新する(不揮発性メモリ5へデータを書き込ませる)。   As shown in FIG. 13, first, when the card OS (CPU 6) receives a command via, for example, the I / O circuit 2 (step S401), the card OS determines to which application the received command is to be passed. (Step S402). Then, the card OS passes the received command to the determined application. Upon obtaining the command (step S403), the application (CPU 6) processes the command (for example, command interpretation) (step S404), and updates the data in the nonvolatile memory 5 if necessary (nonvolatile memory 5). To write data).

ここでは、コマンドの処理A(ステップS404)及びコマンドの処理B(ステップS413)において、連続した書き込みとして定義されない更新要求としての書き込み1〜書き込み5が要求されたものとする。   Here, it is assumed that writing 1 to writing 5 as update requests not defined as continuous writing are requested in command processing A (step S404) and command processing B (step S413).

すると、CPU6は、トランザクションの実行中であるか否かを、カードOSへ問い合わせる(ステップS406)。   Then, the CPU 6 inquires to the card OS whether or not a transaction is being executed (step S406).

そして、トランザクションの実行中でない場合には(ステップS406:NO)、CPU6は、トランザクションを強制的に実行させる(ステップS407)。すなわち、CPU6は、A)書き込み1〜E)書き込み5を、連続して定義された書き込みと擬制し、「transaction機能/保護機能付き書き込み」を実行する(ステップS408等)。   If the transaction is not being executed (step S406: NO), the CPU 6 forcibly executes the transaction (step S407). In other words, the CPU 6 simulates A) writing 1 to E) writing 5 as continuously defined writing, and executes “transaction function / protecting function writing” (step S408, etc.).

ここで、図12を参照して、A)書き込み1〜E)書き込み5と「transaction機能/保護機能付き書き込み」の詳細について、図13のフローチャートと対比して説明する。   Here, with reference to FIG. 12, the details of A) Write 1 to E) Write 5 and “write with transaction function / protection function” will be described in comparison with the flowchart of FIG.

A)書き込み1について(ステップS405)
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜d)の動作を実施する(ステップ408)。
A) About writing 1 (step S405)
"Transaction function / Protected writing" works. Specifically, the CPU 6 performs the following operations a) to d) (step 408).

a)まず、CPU6は、Page−aに記憶される全てのデータを保護するため、Page−aに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−aRとする。   a) First, the CPU 6 writes the data stored in the Page-a to the RAM 4 in units of pages in order to protect all the data stored in the Page-a. For convenience of explanation, the data written in the RAM 4 is referred to as Page-aR.

この場合、CPU6は、書き込み1で更新の対象となるPage−aに記憶される全てのデータをRAM4へ書き込み、その後、不揮発性メモリ5へ書き込むことで、Page−aに記憶される全てのデータを更新の対象とし、非更新領域が存在しないものとしてカードOSへ通知する。   In this case, the CPU 6 writes all data stored in the Page-a to be updated in Write 1 to the RAM 4 and then writes to the nonvolatile memory 5 so that all data stored in the Page-a is written. And the card OS is notified that there is no non-update area.

この通知を受けたカードOSは、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Upon receiving this notification, the card OS does not allow the “non-update area protection function by the card OS” to function.

b)次に、CPU6は、Page−aRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−aRを書き込む。   b) Next, the CPU 6 backs up the Page-aR. Specifically, the CPU 6 writes Page-aR into the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−aRの所定の領域に、書き込み1で書き込まれるべきデータを書き込む(図12の1のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−aRを更新する。   c) Next, the CPU 6 writes the data to be written in the write 1 in a predetermined area of the Page-aR (updates the data 1 in FIG. 12). That is, the CPU 6 updates the Page-aR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−aRを、不揮発性メモリ5のPage−aへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−aを更新する。   d) Next, the CPU 6 writes the updated Page-aR into the Page-a of the nonvolatile memory 5. That is, the CPU 6 updates the Page-a stored in the nonvolatile memory 5.

以上で、書き込み1が実施されたこととなる。   Thus, writing 1 is performed.

B)書き込み2について(ステップS409)
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜d)の動作を実施する(ステップ410)。
B) Write 2 (step S409)
"Transaction function / Protected writing" works. Specifically, the CPU 6 performs the following operations a) to d) (step 410).

a)まず、CPU6は、Page−bに記憶される全てのデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−bRとする。   a) First, the CPU 6 writes the data stored in Page-b to the RAM 4 in page units in order to protect all data stored in Page-b. For convenience of explanation, the data written in the RAM 4 is referred to as Page-bR.

この場合、CPU6は、書き込み2で更新の対象となるPage−bに記憶される全てのデータをRAM4へ書き込み、その後、不揮発性メモリ5へ書き込むことで、Page−bに記憶される全てのデータを更新の対象とし、非更新領域が存在しないものとしてカードOSへ通知する。   In this case, the CPU 6 writes all the data stored in the page-b to be updated in the write 2 to the RAM 4 and then writes the data to the nonvolatile memory 5 to thereby store all the data stored in the page-b. And the card OS is notified that there is no non-update area.

この通知を受けたカードOSは、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Upon receiving this notification, the card OS does not allow the “non-update area protection function by the card OS” to function.

b)次に、CPU6は、Page−bRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−bRを書き込む。   b) Next, the CPU 6 backs up the Page-bR. Specifically, the CPU 6 writes Page-bR into the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−bRの所定の領域に、書き込み2で書き込まれるべきデータを書き込む(図12の2のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−bRを更新する。   c) Next, the CPU 6 writes the data to be written in the write 2 in a predetermined area of the Page-bR (updates the data 2 in FIG. 12). That is, the CPU 6 updates the Page-bR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−bRを、不揮発性メモリ5のPage−bへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−bを更新する。   d) Next, the CPU 6 writes the updated Page-bR into the Page-b of the nonvolatile memory 5. That is, the CPU 6 updates Page-b stored in the nonvolatile memory 5.

以上で、書き込み2が実施されたこととなる。   Thus, writing 2 is performed.

C)書き込み3について(ステップS411)
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜d)の動作を実施する(ステップ412)。
C) Write 3 (step S411)
"Transaction function / Protected writing" works. Specifically, the CPU 6 performs the following operations a) to d) (step 412).

a)まず、CPU6は、Page−bに記憶される全てのデータを保護するため、Page−bに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−bRとする。   a) First, the CPU 6 writes the data stored in Page-b to the RAM 4 in page units in order to protect all data stored in Page-b. For convenience of explanation, the data written in the RAM 4 is referred to as Page-bR.

この場合、CPU6は、書き込み3で更新の対象となるPage−bに記憶される全てのデータをRAM4へ書き込み、その後、不揮発性メモリ5へ書き込むことで、Page−bに記憶される全てのデータを更新の対象とし、非更新領域が存在しないものとしてカードOSへ通知する。   In this case, the CPU 6 writes all the data stored in the Page-b to be updated in Write 3 to the RAM 4 and then writes it in the non-volatile memory 5 to thereby store all the data stored in the Page-b. And the card OS is notified that there is no non-update area.

この通知を受けたカードOSは、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Upon receiving this notification, the card OS does not allow the “non-update area protection function by the card OS” to function.

b)次に、CPU6は、Page−bRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−bRを書き込む。   b) Next, the CPU 6 backs up the Page-bR. Specifically, the CPU 6 writes Page-bR into the backup area set in the nonvolatile memory 5.

なお、上述した「バックアップ検索機能」が働く場合には、Page−bRのバックアップは、既に、B)書き込み2b)で記憶されているため、ここでは、CPU6は、Page−bRをバックアップしない。   Note that when the above-described “backup search function” works, the backup of the Page-bR is already stored in B) Write 2b), so the CPU 6 does not back up the Page-bR here.

c)次に、CPU6は、Page−bRの所定の領域に、書き込み3で書き込まれるべきデータを書き込む(図12の3のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−bRを更新する。   c) Next, the CPU 6 writes the data to be written in the write 3 in a predetermined area of the Page-bR (updates the data 3 in FIG. 12). That is, the CPU 6 updates the Page-bR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−bRを、不揮発性メモリ5のPage−bへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−bを更新する。   d) Next, the CPU 6 writes the updated Page-bR into the Page-b of the nonvolatile memory 5. That is, the CPU 6 updates Page-b stored in the nonvolatile memory 5.

以上で、書き込み3が実施されたこととなる。   Thus, writing 3 is performed.

D)書き込み4について(ステップS414)
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜d)の動作を実施する(ステップ415)。
D) Write 4 (step S414)
"Transaction function / Protected writing" works. Specifically, the CPU 6 performs the following operations a) to d) (step 415).

a)まず、CPU6は、Page−cに記憶される全てのデータを保護するため、Page−cに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−cRとする。   a) First, the CPU 6 writes the data stored in the Page-c to the RAM 4 in units of pages in order to protect all the data stored in the Page-c. For convenience of explanation, the data written in the RAM 4 is referred to as Page-cR.

この場合、CPU6は、書き込み4で更新の対象となるPage−cに記憶される全てのデータをRAM4へ書き込み、その後、不揮発性メモリ5へ書き込むことで、Page−cに記憶される全てのデータを更新の対象とし、非更新領域が存在しないものとしてカードOSへ通知する。   In this case, the CPU 6 writes all the data stored in the page-c to be updated in the write 4 to the RAM 4 and then writes it in the nonvolatile memory 5 so that all the data stored in the page-c is written. And the card OS is notified that there is no non-update area.

この通知を受けたカードOSは、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Upon receiving this notification, the card OS does not allow the “non-update area protection function by the card OS” to function.

b)次に、CPU6は、Page−cRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−cRを書き込む。   b) Next, the CPU 6 backs up the Page-cR. Specifically, the CPU 6 writes Page-cR into the backup area set in the nonvolatile memory 5.

c)次に、CPU6は、Page−cRの所定の領域に、書き込み4で書き込まれるべきデータを書き込む(図12の4のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−cRを更新する。   c) Next, the CPU 6 writes the data to be written in the write 4 in a predetermined area of the Page-cR (updates the data 4 in FIG. 12). That is, the CPU 6 updates the Page-cR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−cRを、不揮発性メモリ5のPage−cへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−cを更新する。   d) Next, the CPU 6 writes the updated Page-cR into the Page-c of the nonvolatile memory 5. That is, the CPU 6 updates Page-c stored in the nonvolatile memory 5.

以上で、書き込み4が実施されたこととなる。   Thus, writing 4 is performed.

E)書き込み5について(ステップS416)
「transaction機能/保護機能付き書き込み」が働く。具体的には、CPU6は、以下のa)〜d)の動作を実施する(ステップ417)。
E) Write 5 (step S416)
"Transaction function / Protected writing" works. Specifically, the CPU 6 performs the following operations a) to d) (step 417).

a)まず、CPU6は、Page−cに記憶される全てのデータを保護するため、Page−cに記憶されるデータを、ページ単位でRAM4へ書き込む。説明の便宜上、このRAM4に書き込まれたデータを、Page−cRとする。   a) First, the CPU 6 writes the data stored in the Page-c to the RAM 4 in units of pages in order to protect all the data stored in the Page-c. For convenience of explanation, the data written in the RAM 4 is referred to as Page-cR.

この場合、CPU6は、書き込み5で更新の対象となるPage−cに記憶される全てのデータをRAM4へ書き込み、その後、不揮発性メモリ5へ書き込むことで、Page−cに記憶される全てのデータを更新の対象とし、非更新領域が存在しないものとしてカードOSへ通知する。   In this case, the CPU 6 writes all the data stored in the Page-c to be updated in the writing 5 to the RAM 4 and then writes it in the nonvolatile memory 5 so that all the data stored in the Page-c is written. And the card OS is notified that there is no non-update area.

この通知を受けたカードOSは、「カードOSによる非更新領域の保護機能」を機能させないようになっている。   Upon receiving this notification, the card OS does not allow the “non-update area protection function by the card OS” to function.

b)次に、CPU6は、Page−cRをバックアップする。具体的には、CPU6は、不揮発性メモリ5に設定されたバックアップ領域へPage−cRを書き込む。   b) Next, the CPU 6 backs up the Page-cR. Specifically, the CPU 6 writes Page-cR into the backup area set in the nonvolatile memory 5.

なお、上述した「バックアップ検索機能」が働く場合には、Page−cRのバックアップは、既に、D)書き込み4b)で記憶されているため、ここでは、CPU6は、Page−cRをバックアップしない。   When the above-described “backup search function” works, the backup of Page-cR has already been stored in D) Write 4b), and therefore the CPU 6 does not back up Page-cR here.

c)次に、CPU6は、Page−cRの所定の領域に、書き込み5で書き込まれるべきデータを書き込む(図12の5のデータを更新する)。すなわち、CPU6は、RAM4に記憶されたPage−cRを更新する。   c) Next, the CPU 6 writes the data to be written in the write 5 in a predetermined area of the Page-cR (updates the data 5 in FIG. 12). That is, the CPU 6 updates the Page-cR stored in the RAM 4.

d)次に、CPU6は、更新されたPage−cRを、不揮発性メモリ5のPage−cへ書き込む。すなわち、CPU6は、不揮発性メモリ5に記憶されたPage−cを更新する。   d) Next, the CPU 6 writes the updated Page-cR into the Page-c of the nonvolatile memory 5. That is, the CPU 6 updates Page-c stored in the nonvolatile memory 5.

以上で、書き込み5が実施されたこととなる。   Thus, writing 5 is performed.

このように、本実施形態におけるCPU6は、図10のフローチャートのステップS306の説明におけるA−2)e)、図10のフローチャートのステップS308の説明におけるB−2)e)、図10のフローチャートのステップS310の説明におけるC−2)e)、図10のフローチャートのステップS312の説明におけるD−2)e)、図10のフローチャートのステップS314の説明におけるE−2)e)のように、書き込み毎(書き込み1〜5)に、カードOSは、バックアップ領域に書き込まれたPage−aR〜Page−aRを消去するといった不要な消去が繰り返しなされることはないため、更新やバックアップに要する処理時間が短縮される。   As described above, the CPU 6 according to the present embodiment performs A-2) e) in the description of step S306 in the flowchart of FIG. 10, B-2) e) in the description of step S308 in the flowchart of FIG. As in C-2) e) in the description of step S310, D-2) e) in the description of step S312 in the flowchart of FIG. 10, and E-2) e) in the description of step S314 in the flowchart of FIG. Every time (writing 1 to 5), the card OS does not repeat unnecessary erasure such as erasing Page-aR to Page-aR written in the backup area. Shortened.

そして、アプリケーションは、処理が終了すると、カードOSへレスポンスデータを通知する(ステップS418)。そして、カードOSは、レスポンスデータを取得すると(ステップS419)、トランザクションの開始状態にあるかないか判断し(ステップS420)、トランザクションの開始状態にない場合には(ステップS420:NO)、トランザクションを停止して(ステップS421)、例えば、外部装置(リーダライタ装置等)へレスポンスデータを送信する(ステップS422)。   Then, when the process ends, the application notifies the card OS of the response data (step S418). When the card OS acquires the response data (step S419), the card OS determines whether or not the transaction is in the start state (step S420). If the card OS is not in the transaction start state (step S420: NO), the transaction is stopped. (Step S421), for example, response data is transmitted to an external device (a reader / writer device or the like) (Step S422).

なお、これらの更新が終了した場合に、バックアップデータ消去手段としてのCPU6は、バックアップ領域に記憶されたバックアップデータを消去するように構成してもよい。   Note that when these updates are completed, the CPU 6 as the backup data erasing means may be configured to erase the backup data stored in the backup area.

また、バックアップデータ消去手段としてのCPU6は、バックアップ領域に記憶可能な情報量である記憶容量を監視し、バックアップ領域の記憶容量が上限(任意に設定可能)に達した場合には、バックアップデータを消去するように構成してもよい。   The CPU 6 as the backup data erasing means monitors the storage capacity that is the amount of information that can be stored in the backup area. If the storage capacity of the backup area reaches the upper limit (can be set arbitrarily), the backup data is stored. You may comprise so that it may erase | eliminate.

この消去の方法としては種々の方法を適用することができ、例えば、バックアップ領域に記憶されたバックアップデータのうち、当該記憶された日時(バックアップ領域に追加された日時)が古いものから順に消去するようにしてもよいし、当該バックアップデータのうち、データのサイズ(ファイルサイズ)に応じて(例えば、データのサイズが大きいものを優先的に消去等)消去するようにしてもよい。また、バックアップ領域に記憶されたバックアップデータが所定の数量に達した場合に、消去するようにしてもよい。   Various methods can be applied as the erasing method. For example, among the backup data stored in the backup area, the stored date and time (date and time added to the backup area) are deleted in order from the oldest. Alternatively, the backup data may be deleted according to the data size (file size) (for example, data having a large data size is deleted preferentially). Further, when the backup data stored in the backup area reaches a predetermined quantity, it may be deleted.

以上説明したように、本実施形態におけるICチップ1は、所定の領域を一のページとして、一又は複数のページに区画される不揮発性メモリ5を備え、更新要求に基づいて、不揮発性メモリ5の指定されたページの指定された領域に記憶されるデータを更新し、ICチップの基本的な動作を管理するカードOSが備える基本的な機能であって、当該カードOSの制御に基づいて、前記データを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータをバックアップ領域へ書き込む「カードOSによる非更新領域の保護機能」と、上記トランザクションの実行中に、前記カードOS上で動作し前記CPU6に所定の機能を実行させるアプリケーションの要求に応じた前記カードOSの制御に基づいて、更新前の前記更新領域に記憶されるデータをバックアップ領域へ書き込む「トランザクションによる更新領域の保護機能」とを備え、「トランザクションによる更新領域の保護機能」は、更新要求があった場合には、前記更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記バックアップ領域に書き込み、当該ページに非更新領域が存在しないものとして前記カードOSに通知して、「カードOSによる非更新領域の保護機能」を機能させないように構成したので、適切な保護機能によってデータをバックアップすることにより、不要なバックアップ処理を行わないため、データの保護機能による処理時間の短縮を図ることができる。   As described above, the IC chip 1 according to the present embodiment includes the nonvolatile memory 5 that is partitioned into one or a plurality of pages with a predetermined area as one page, and the nonvolatile memory 5 is based on the update request. Is a basic function of the card OS that updates the data stored in the specified area of the specified page and manages the basic operation of the IC chip, based on the control of the card OS, Of the pages to which the update area, which is an area for updating the data, belongs, a “non-update area protection function by the card OS” for writing data stored in a non-update area, which is an area other than the update area, During the execution of the transaction, the card OS responding to an application request that operates on the card OS and causes the CPU 6 to execute a predetermined function. Based on the control, it is equipped with a "transaction area protection function by transaction" that writes data stored in the update area before update to the backup area, and the "update area protection function by transaction" has an update request In this case, all the areas of the page to which the update area and the non-update area before the update belong are set as the update area, all the data stored in the page is written to the backup area, and the non-update area exists in the page. The card OS is notified that the card OS is not to be used, and the “non-update area protection function by the card OS” is configured not to function. Therefore, unnecessary backup processing is not performed by backing up data with an appropriate protection function. Therefore, it is possible to shorten the processing time by the data protection function.

なお、上述した例では、CPU6を本願の第2の保護手段として機能させる「トランザクションによる更新領域の保護機能」は、アプリケーションが備える機能として説明したが、これに限定されることはなく、種々の形態を採ることができる。例えば、上記「トランザクションによる更新領域の保護機能」を、カードOSが備える機能とするようにしても良いし、バーチャルマシン(図2参照)や、OS層22(図2参照)に新たに設けられるモジュールに備えるようにしても良い。   In the above-described example, the “transaction area protection function by transaction” that causes the CPU 6 to function as the second protection unit of the present application has been described as a function provided by the application. Can take form. For example, the above-mentioned “update function for updating area by transaction” may be a function provided in the card OS, or newly provided in the virtual machine (see FIG. 2) or the OS layer 22 (see FIG. 2). You may make it prepare for a module.

同様に、CPU6を本願の第1の保護手段として機能させる「カードOSによる非更新領域の保護機能」は、カードOSが備える機能として説明したが、これに限定されることはなく、種々の形態を採ることができる。例えば、上記「カードOSによる非更新領域の保護機能」を、アプリケーションが備える機能とするようにしても良いし、バーチャルマシン(図2参照)や、OS層22(図2参照)に新たに設けられるモジュールに備えるようにしても良い。   Similarly, the “non-update area protection function by the card OS” that causes the CPU 6 to function as the first protection means of the present application has been described as a function provided in the card OS. Can be taken. For example, the above-mentioned “function for protecting the non-update area by the card OS” may be a function provided by the application, or newly provided in the virtual machine (see FIG. 2) or the OS layer 22 (see FIG. 2). You may make it prepare for the module to be provided.

また、上記実施形態においては、JAVAカードに対応したICカード8を適用したがこれに限られず、カードOS上で所定の機能を実行するアプリケーションが搭載できるICカードであれば種々のICカードを適用することができる。   In the above embodiment, the IC card 8 corresponding to the JAVA card is applied. However, the present invention is not limited to this, and various IC cards can be used as long as the application can execute an application that executes a predetermined function on the card OS. can do.

1 ICチップ
2 I/O回路
3 ROM
4 RAM
5 不揮発性メモリ
6 CPU
7 カード基体
8 ICカード
1 IC chip 2 I / O circuit 3 ROM
4 RAM
5 Nonvolatile memory 6 CPU
7 Card base 8 IC card

Claims (7)

所定の領域を一のページとして、一又は複数のページに区画される記憶部を備え、更新要求に基づいて、前記記憶部の指定されたページの指定された領域に記憶されるデータを更新するICチップであって、
前記データを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータを保護する第1の保護手段と、
特定の一連の更新処理の開始前又は終了後の何れかにおける記憶部に記憶されるデータを保護可能とするトランザクションの実行中に、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして第1の保護手段を機能させない第2の保護手段と、
を備え、
前記第2の保護手段は、
更新要求があった場合には、前記トランザクションの実行中であるものとして、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記第1の保護手段を機能させないことを特徴とするICチップ。
A storage unit that is partitioned into one or a plurality of pages with a predetermined area as one page, and updates data stored in a specified area of a specified page of the storage unit based on an update request An IC chip,
A first protection unit that protects data stored in a non-update area that is an area other than the update area of a page to which an update area that is an area for updating the data belongs;
During execution of a transaction to allow protection of data stored in the storage unit in either before or after the end the start of a particular series of update processing, all of the pages that update previous update area and the non-updated area belongs An area as an update area, a second protection means for storing all data stored in the page in the storage unit, and not causing the first protection means to function as a non-update area does not exist in the page;
With
The second protection means includes
If there is update request, as running of the transaction, all the area of the page where update before the update area and the non-updated area belongs as an update area, all the data stored in the page Is stored in the storage unit, and the first protection means does not function on the assumption that a non-update area does not exist in the page.
請求項1に記載のICチップであって、
前記第1の保護手段は、ICチップの基本的な動作を管理するオペレーティングシステムが備える基本的な機能であって、当該オペレーティングシステムの制御に基づいて実行され、
前記第2の保護手段は、前記オペレーティングシステム上で動作し、前記ICチップに所定の機能を実行させるアプリケーションの要求に応じた前記オペレーティングシステムの制御に基づいて実行されることを特徴とするICチップ。
The IC chip according to claim 1,
The first protection means is a basic function of an operating system that manages basic operations of the IC chip, and is executed based on control of the operating system,
The second protection means operates on the operating system, and is executed based on the control of the operating system in response to an application request that causes the IC chip to execute a predetermined function. .
請求項1又は2に記載のICチップであって、
新が終了した場合には、前記第2の保護手段によって記憶されたデータを消去するバックアップデータ消去手段をさらに備えることを特徴とするICチップ。
The IC chip according to claim 1 or 2,
When the update is completed, IC chip further comprising a backup data erasing means for erasing the data stored by said second protection means.
請求項に記載のICチップであって、
前記バックアップデータ消去手段は、前記第2の保護手段によって記憶されたデータが記憶される前記記憶部の記憶容量が上限に達した場合には、当該データを消去することを特徴とするICチップ。
The IC chip according to claim 3 ,
The IC chip according to claim 1, wherein the backup data erasing unit erases the data when the storage capacity of the storage unit storing the data stored by the second protection unit reaches an upper limit.
請求項1乃至4の何れか一項に記載のICチップと、ICカード基体と、を備えることを特徴とするICカード。   An IC card comprising the IC chip according to any one of claims 1 to 4 and an IC card substrate. 所定の領域を一のページとして、一又は複数のページに区画される記憶部を備え、更新要求に基づいて、前記記憶部の指定されたページの指定された領域に記憶されるデータを更新するICチップにおいて実行されるICチップにおける処理方法であって、
前記ICチップは、
前記データを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータを保護する第1の保護手段と、
特定の一連の更新処理の開始前又は終了後の何れかにおける記憶部に記憶されるデータを保護可能とするトランザクションの実行中に、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとしてオペレーティングシステムに通知して、前記第1の保護手段を機能させない第2の保護手段と、
を備え、
前記第2の保護手段が、更新要求があった場合には、前記トランザクションの実行中であるものとして、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記オペレーティングシステムに通知して、前記第1の保護手段を機能させない工程を含むことを特徴とするICチップにおける処理方法。
A storage unit that is partitioned into one or a plurality of pages with a predetermined area as one page, and updates data stored in a specified area of a specified page of the storage unit based on an update request A processing method in an IC chip executed in the IC chip,
The IC chip is
A first protection unit that protects data stored in a non-update area that is an area other than the update area of a page to which an update area that is an area for updating the data belongs;
During execution of a transaction to allow protection of data stored in the storage unit in either before or after the end the start of a particular series of update processing, all of the pages that update previous update area and the non-updated area belongs the region as the update region, all the data stored in the page is stored in the storage unit, and notifies the operating system is assumed that the non-updated area to the page does not exist, the first protection means A second protection means that does not function,
With
Said second protection means, when an update request, as running of the transaction, as all area update area of the page where update before the update area and the non-updated area belongs, the all data stored in the page is stored in the storage unit, and notifies the operating system as not non-updated area to the page is present, characterized in that it comprises a first protection means do not function step A processing method in an IC chip.
所定の領域を一のページとして、一又は複数のページに区画される記憶部を備え、更新要求に基づいて、前記記憶部の指定されたページの指定された領域に記憶されるデータを更新するICチップに含まれるコンピュータを、
前記データを更新する領域である更新領域が属するページのうち、当該更新領域以外の領域である非更新領域に記憶されるデータを保護する第1の保護手段、
特定の一連の更新処理の開始前又は終了後の何れかにおける記憶部に記憶されるデータを保護可能とするトランザクションの実行中に、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記第1の保護手段を機能させない第2の保護手段、
として機能させ、
前記第2の保護手段は、
更新要求があった場合には、前記トランザクションの実行中であるものとして、更新前の更新領域及び非更新領域が属するページの全ての領域を更新領域として、当該ページに記憶される全てのデータを前記記憶部に記憶させ、当該ページに非更新領域が存在しないものとして前記第1の保護手段を機能させないことを特徴とするICチップ用処理プログラム。
A storage unit that is partitioned into one or a plurality of pages with a predetermined area as one page, and updates data stored in a specified area of a specified page of the storage unit based on an update request The computer included in the IC chip
A first protection means for protecting data stored in a non-update area, which is an area other than the update area, of a page to which an update area that is an area for updating the data belongs;
During execution of a transaction to allow protection of data stored in the storage unit in either before or after the end the start of a particular series of update processing, all of the pages that update previous update area and the non-updated area belongs A second protection means for storing all data stored in the page as an update area in the storage unit, and not allowing the first protection means to function as a non-update area does not exist in the page;
Function as
The second protection means includes
If there is update request, as running of the transaction, all the area of the page where update before the update area and the non-updated area belongs as an update area, all the data stored in the page Is stored in the storage unit, and the first protection means is not allowed to function on the assumption that a non-update area does not exist on the page.
JP2011235295A 2011-10-26 2011-10-26 IC chip, IC chip processing method, IC chip processing program, IC card, etc. Active JP5853590B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011235295A JP5853590B2 (en) 2011-10-26 2011-10-26 IC chip, IC chip processing method, IC chip processing program, IC card, etc.

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011235295A JP5853590B2 (en) 2011-10-26 2011-10-26 IC chip, IC chip processing method, IC chip processing program, IC card, etc.

Publications (2)

Publication Number Publication Date
JP2013092938A JP2013092938A (en) 2013-05-16
JP5853590B2 true JP5853590B2 (en) 2016-02-09

Family

ID=48616010

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011235295A Active JP5853590B2 (en) 2011-10-26 2011-10-26 IC chip, IC chip processing method, IC chip processing program, IC card, etc.

Country Status (1)

Country Link
JP (1) JP5853590B2 (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4066991B2 (en) * 1999-02-19 2008-03-26 三菱電機株式会社 Information processing device
JP2003216511A (en) * 2002-01-23 2003-07-31 Matsushita Electric Ind Co Ltd Non-volatile memory device, data updating method, data updating program and computer readable recording medium with recorded program
JP2008071224A (en) * 2006-09-15 2008-03-27 Sony Corp Information processing apparatus, information processing method and program
KR101336258B1 (en) * 2007-05-29 2013-12-03 삼성전자 주식회사 Apparatus and method of processing data of non-volatile memory

Also Published As

Publication number Publication date
JP2013092938A (en) 2013-05-16

Similar Documents

Publication Publication Date Title
US6622200B1 (en) Method of performing reliable updates in a symmetrically blocked nonvolatile memory having a bifurcated storage architecture
US6088759A (en) Method of performing reliable updates in a symmetrically blocked nonvolatile memory having a bifurcated storage architecture
KR100484485B1 (en) Method for storing data in non-volatile memory and apparatus therefor
US6311290B1 (en) Methods of reliably allocating, de-allocating, re-allocating, and reclaiming objects in a symmetrically blocked nonvolatile memory having a bifurcated storage architecture
JP4037605B2 (en) Nonvolatile memory unit controller, memory system having the controller, and nonvolatile memory unit control method
US7694094B2 (en) Transaction method for managing the storing of persistent data in a transaction stack
EP2955633B1 (en) Data erasing method and device for flash memory
US5937434A (en) Method of managing a symmetrically blocked nonvolatile memory having a bifurcated storage architecture
EP0686976A2 (en) Data management system for programming-limited type semiconductor memory and IC memory card having the data management system
JPH117505A (en) Card type storage medium
CN113785275B (en) Flash data power-down protection method and device
EP2366152A2 (en) Ruggedized memory device
CN101833482A (en) The power management block that is used for Nonvolatile memory system
CN107003864A (en) Recover system-on-chip apparatus
KR20100107453A (en) Storage sub-system for a computer comprising write-once memory devices and write-many memory devices and related method
JP2003216511A (en) Non-volatile memory device, data updating method, data updating program and computer readable recording medium with recorded program
JP5853590B2 (en) IC chip, IC chip processing method, IC chip processing program, IC card, etc.
JP5853559B2 (en) IC chip, processing method in IC chip, IC chip processing program, and IC card
WO2010145967A1 (en) Memory device for managing the recovery of a non volatile memory
JP3818130B2 (en) Data management method and apparatus, data management program, and storage medium storing data management program
EP1344224B1 (en) Method for the secure updating of data areas in a non volatile memory and device to perform such a method
JP7322923B2 (en) Secure element, transaction control method and device
JP6915437B2 (en) Update method and update program using electronic information storage medium, IC card, electronic information storage medium
CN100392765C (en) Secure writing of data
JP3863479B2 (en) IC card

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20140822

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20150526

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20150630

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20150828

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20151123

R150 Certificate of patent or registration of utility model

Ref document number: 5853590

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150