Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP7397402B2 - Electronic information storage medium, data transmission method, and program - Google Patents
[go: Go Back, main page]

JP7397402B2 - Electronic information storage medium, data transmission method, and program - Google Patents

Electronic information storage medium, data transmission method, and program Download PDF

Info

Publication number
JP7397402B2
JP7397402B2 JP2019225123A JP2019225123A JP7397402B2 JP 7397402 B2 JP7397402 B2 JP 7397402B2 JP 2019225123 A JP2019225123 A JP 2019225123A JP 2019225123 A JP2019225123 A JP 2019225123A JP 7397402 B2 JP7397402 B2 JP 7397402B2
Authority
JP
Japan
Prior art keywords
block
length
data
transmission data
external device
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
JP2019225123A
Other languages
Japanese (ja)
Other versions
JP2021096495A (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 JP2019225123A priority Critical patent/JP7397402B2/en
Publication of JP2021096495A publication Critical patent/JP2021096495A/en
Application granted granted Critical
Publication of JP7397402B2 publication Critical patent/JP7397402B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Communication Control (AREA)

Description

本発明は、セキュアエレメント等の電子情報記憶媒体によるコマンドの送受信方法等の技術分野に関する The present invention relates to a technical field such as a command transmission/reception method using an electronic information storage medium such as a secure element.

近年、IoT(Internet of Things)の普及に伴い、組み込み型ICモジュールにおいても、セキュリティを担保するため、セキュアエレメントが用いられている。セキュアエレメントの通信には、国際規格ISO/IECISO7816-2で定義されるインターフェースのほか、SPI(Serial Peripheral Interface)やI2C(Inter-Integrated Circuit)などのインターフェースが利用されることが多い。これらのインターフェースで送受信される例えばコマンドAPDU(Application Protocol Data Unit)の長さは、コマンドAPDUを含むブロックのヘッダ(先頭フィールド)にて指定されることが多いが、ヘッダで指定可能な長さを超える長さのコマンドAPDUを送受信するためには、ヘッダ長を拡張するか、或いはコマンドAPDUを分割して送受信することが必要である。特許文献1には、データ容量の大きい平文を暗号化する際、一つのコマンドAPDUに含めることができるブロックサイズに平文を分割し、分割した平文ごとにコマンドAPDUを生成することなく、平文のみを送受信することで処理時間を短縮することができる発明が開示されている。 In recent years, with the spread of IoT (Internet of Things), secure elements are being used in embedded IC modules to ensure security. In addition to the interface defined by the international standard ISO/IECISO7816-2, interfaces such as SPI (Serial Peripheral Interface) and I 2 C (Inter-Integrated Circuit) are often used for secure element communication. For example, the length of a command APDU (Application Protocol Data Unit) sent and received over these interfaces is often specified in the header (first field) of the block containing the command APDU, but the length that can be specified in the header is In order to transmit/receive a command APDU with a longer length, it is necessary to extend the header length or to divide the command APDU and transmit/receive it. Patent Document 1 describes that when encrypting plaintext with a large amount of data, the plaintext is divided into block sizes that can be included in one command APDU, and only the plaintext is encoded without generating a command APDU for each divided plaintext. An invention is disclosed that can shorten processing time by transmitting and receiving information.

特許第4840012号Patent No. 4840012

しかしながら、特許文献1の技術では、特殊なモードを備える必要があるため、国際規格等で既に決まっているデータフォーマットが変わる可能性がある。データフォーマットが既に決まっているプロトコルを利用する場合、既存製品との互換性の関係上、ヘッダ長を拡張することなどのデータフォーマットを変更することは容易ではない。 However, since the technique disclosed in Patent Document 1 requires a special mode, there is a possibility that the data format already determined by international standards or the like may be changed. When using a protocol whose data format has already been determined, it is not easy to change the data format, such as by expanding the header length, due to compatibility with existing products.

そこで、本発明は、このような点等に鑑みてなされたものであり、既存のデータフォーマットを変更することなく、ヘッダで指定可能な長さを超えるデータ長を指定することが可能な電子情報記憶媒体、データ送信方法、及びプログラムを提供することを課題とする。 Therefore, the present invention has been made in view of the above points, and provides electronic information that allows specifying a data length exceeding the length that can be specified in the header without changing the existing data format. The objective is to provide a storage medium, a data transmission method, and a program.

上記課題を解決するために、請求項1に記載の発明は、送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、前記第1ブロックに含まれる前記レングスデータにより示される前記長さの前記送信データを1度に受信可能であるか否かを判定する判定手段と、前記判定手段により前記送信データを1度に受信可能でないと判定された場合に、前記第1ブロックに対する応答として、前記送信データを1度に受信可能な長さを示す長さ指定データを含む第2ブロックを前記外部装置へ送信する送信手段と、前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段と、を備えることを特徴とする。 In order to solve the above problem, the invention according to claim 1 provides a first receiving means for receiving a first block including length data indicating the length of transmission data to be transmitted from an external device; Holding means for holding the length data included in the block; and determining means for determining whether the transmission data of the length indicated by the length data included in the first block can be received at one time. and when the determination means determines that the transmission data cannot be received at one time, length designation data indicating the length of the transmission data that can be received at one time is sent as a response to the first block. a third block transmitted from the external device in response to the second block, the third block having the length indicated by the held length data; The apparatus is characterized by comprising: a second receiving means for receiving a third block including the transmission data from an external device; and an execution means for executing processing based on the transmission data included in the third block.

請求項に記載の発明は、請求項に記載の電子情報記憶媒体において、前記第2受信手段は、前記保持された前記レングスデータにより示される前記長さの前記送信データから分割された分割送信データを含む第3ブロックを外部装置から複数回にわたって受信し、前記実行手段は、複数回にわたって受信された前記分割送信データが連結されることにより前記レングスデータにより示される前記長さの前記送信データが得られた場合に、当該送信データに基づいて処理を実行することを特徴とする。 According to a second aspect of the invention, in the electronic information storage medium according to the first aspect, the second receiving means divides the transmitted data of the length indicated by the held length data. A third block including transmission data is received from an external device multiple times, and the execution means executes the transmission of the length indicated by the length data by concatenating the divided transmission data received multiple times. It is characterized in that when data is obtained, processing is executed based on the transmitted data.

請求項に記載の発明は、送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、前記第1ブロックに対する応答として第2ブロックを前記外部装置へ送信する送信手段と、前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段と、を備え前記第1ブロック及び前記第3ブロックは、それぞれ、所定のアプリケーションによりアプリケーション層で使用されるデータを格納するための情報フィールドと、前記情報フィールドの長さを指定するための所定バイトからなるLEN(Length byte)を含む先頭フィールドとを有する所定のデータフォーマットにより構成され、前記第1ブロックの前記情報フィールドには前記LENにより指定された長さの前記レングスデータが格納され、前記第3ブロックの前記情報フィールドには前記レングスデータにより示される前記長さの前記送信データが格納され、前記実行手段は、前記第3ブロックの前記先頭フィールドに含まれるLENを無視して前記第3ブロックに含まれる前記送信データに基づいて処理を実行することを特徴とする。 The invention according to claim 3 provides a first receiving means for receiving a first block including length data indicating a length of transmission data to be transmitted from an external device; a holding means for holding a second block; a sending means for sending a second block to the external device as a response to the first block; and a third block sent from the external device in response to the second block; a second receiving means for receiving from an external device a third block including the transmission data having the length indicated by the length data; and execution for executing processing based on the transmission data included in the third block. means , wherein the first block and the third block each include an information field for storing data used in an application layer by a predetermined application, and a means for specifying a length of the information field. The information field of the first block stores the length data of the length specified by the LEN, The transmission data having the length indicated by the length data is stored in the information field of the third block, and the execution means ignores the LEN included in the first field of the third block and stores the transmission data in the information field of the third block. The present invention is characterized in that processing is executed based on the transmission data included in three blocks.

請求項に記載の発明は、電子情報記憶媒体に含まれるコンピュータにより実行されるデータ受信方法であって、送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信するステップと、前記第1ブロックに含まれる前記レングスデータを保持するステップと、前記第1ブロックに含まれる前記レングスデータにより示される前記長さの前記送信データを1度に受信可能であるか否かを判定するステップと、前記送信データを1度に受信可能でないと判定された場合に、前記第1ブロックに対する応答として、前記送信データを1度に受信可能な長さを示す長さ指定データを含む第2ブロックを前記外部装置へ送信するステップと、前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信するステップと、前記第3ブロックに含まれる前記送信データに基づいて処理を実行するステップと、を含むことを特徴とする。請求項5に記載の発明は、電子情報記憶媒体に含まれるコンピュータにより実行されるデータ受信方法であって、送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信するステップと、前記第1ブロックに含まれる前記レングスデータを保持するステップと、前記第1ブロックに対する応答として第2ブロックを前記外部装置へ送信するステップと、前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信するステップと、前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行ステップと、を含み、前記第1ブロック及び前記第3ブロックは、それぞれ、所定のアプリケーションによりアプリケーション層で使用されるデータを格納するための情報フィールドと、前記情報フィールドの長さを指定するための所定バイトからなるLEN(Length byte)を含む先頭フィールドとを有する所定のデータフォーマットにより構成され、前記第1ブロックの前記情報フィールドには前記LENにより指定された長さの前記レングスデータが格納され、前記第3ブロックの前記情報フィールドには前記レングスデータにより示される前記長さの前記送信データが格納され、前記実行ステップにおいては、前記第3ブロックの前記先頭フィールドに含まれるLENを無視して前記第3ブロックに含まれる前記送信データに基づいて処理を実行することを特徴とする。 The invention according to claim 4 is a data receiving method executed by a computer included in an electronic information storage medium, wherein the first block including length data indicating the length of transmission data to be transmitted is sent from an external device. a step of receiving, a step of holding the length data included in the first block, and whether it is possible to receive the transmission data of the length indicated by the length data included in the first block at one time. a step of determining whether or not the transmission data can be received at one time; and when it is determined that the transmission data cannot be received at one time, a length specification indicating a length in which the transmission data can be received at one time as a response to the first block; transmitting a second block containing data to the external device; and a third block transmitted from the external device in response to the second block, the length of which is indicated by the retained length data. The method is characterized by comprising the steps of: receiving a third block including the transmission data from an external device; and executing processing based on the transmission data included in the third block. The invention according to claim 5 is a data receiving method executed by a computer included in an electronic information storage medium, in which a first block including length data indicating the length of transmission data to be transmitted is sent from an external device. receiving the length data; retaining the length data included in the first block; transmitting a second block to the external device as a response to the first block; receiving from an external device a third block transmitted from the device, the third block including the transmitted data having the length indicated by the held length data; an execution step of performing processing based on the transmitted data, wherein the first block and the third block each include an information field for storing data used in an application layer by a predetermined application; The information field is configured of a predetermined data format having a first field including a LEN (Length byte) consisting of a predetermined byte for specifying the length of the information field, and the information field of the first block has a length byte specified by the LEN. The length data of the length indicated by the length data is stored in the information field of the third block, and the transmission data of the length indicated by the length data is stored in the information field of the third block. The present invention is characterized in that processing is executed based on the transmission data contained in the third block, ignoring the LEN contained in the first field.

請求項6に記載の発明は、送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、前記第1ブロックに含まれる前記レングスデータにより示される前記長さの前記送信データを1度に受信可能であるか否かを判定する判定手段と、前記判定手段により前記送信データを1度に受信可能でないと判定された場合に、前記第1ブロックに対する応答として、前記送信データを1度に受信可能な長さを示す長さ指定データを含む第2ブロックを前記外部装置へ送信する送信手段と、前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段としてコンピュータを機能させることを特徴とする。請求項7に記載の発明は、送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、前記第1ブロックに対する応答として第2ブロックを前記外部装置へ送信する送信手段と、前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段としてコンピュータを機能させるプログラムであって、前記第1ブロック及び前記第3ブロックは、それぞれ、所定のアプリケーションによりアプリケーション層で使用されるデータを格納するための情報フィールドと、前記情報フィールドの長さを指定するための所定バイトからなるLEN(Length byte)を含む先頭フィールドとを有する所定のデータフォーマットにより構成され、前記第1ブロックの前記情報フィールドには前記LENにより指定された長さの前記レングスデータが格納され、前記第3ブロックの前記情報フィールドには前記レングスデータにより示される前記長さの前記送信データが格納され、前記実行手段は、前記第3ブロックの前記先頭フィールドに含まれるLENを無視して前記第3ブロックに含まれる前記送信データに基づいて処理を実行することを特徴とする。 The invention according to claim 6 provides a first receiving means for receiving a first block including length data indicating a length of transmission data to be transmitted from an external device; and a first receiving means for receiving the length data included in the first block. a holding means for holding, a determining means for determining whether or not the transmission data of the length indicated by the length data included in the first block can be received at one time; When it is determined that the data cannot be received at one time, the external device sends a second block including length designation data indicating the length of the transmission data that can be received at one time as a response to the first block. a third block transmitted from the external device in response to the second block, the third block including the transmission data having the length indicated by the held length data; The present invention is characterized in that the computer functions as a second receiving means for receiving data from an external device, and an execution means for executing processing based on the transmitted data included in the third block. The invention according to claim 7 provides a first receiving means for receiving a first block including length data indicating a length of transmission data to be transmitted from an external device; a holding means for holding a second block; a sending means for sending a second block to the external device as a response to the first block; and a third block sent from the external device in response to the second block; a second receiving means for receiving from an external device a third block including the transmission data having the length indicated by the length data; and execution for executing processing based on the transmission data included in the third block. A program that causes a computer to function as a means, wherein the first block and the third block each include an information field for storing data used in an application layer by a predetermined application, and a length of the information field. The information field of the first block includes the length specified by the LEN. data is stored, the transmission data having the length indicated by the length data is stored in the information field of the third block, and the execution means stores the LEN included in the first field of the third block. The present invention is characterized in that processing is executed based on the transmission data included in the third block while being ignored .

本発明によれば、既存のデータフォーマットを変更することなく、ヘッダで指定可能な長さを超えるデータ長を指定することができる。 According to the present invention, a data length that exceeds the length that can be specified in a header can be specified without changing the existing data format.

SE1の概要構成例を示す図である。It is a figure showing an example of a outline composition of SE1. SE1と外部装置2との間で送受信されるブロックBLnのデータフォーマット(構造)を示す図である。3 is a diagram showing a data format (structure) of a block BLn transmitted and received between SE1 and an external device 2. FIG. SE1と外部装置2との間で送受信されるブロックBLnのデータフォーマットの具体例を示す図である。3 is a diagram showing a specific example of a data format of a block BLn transmitted and received between SE1 and an external device 2. FIG. 実施例1において、外部装置2からのブロックBLnがSE1により受信されたときのCPU10の処理の一例を示すフローチャートである。7 is a flowchart illustrating an example of the processing of the CPU 10 when the block BLn from the external device 2 is received by the SE 1 in the first embodiment. 実施例2において、外部装置2からのブロックBLnがSE1により受信されたときのCPU10の処理の一例を示すフローチャートである。7 is a flowchart illustrating an example of the processing of the CPU 10 when the block BLn from the external device 2 is received by the SE 1 in the second embodiment.

以下、図面を参照して本発明の実施形態について詳細に説明する。以下に説明する実施形態は、セキュアエレメント(以下、「SE」という)に対して本発明を適用した場合の実施の形態である。 Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. The embodiment described below is an embodiment in which the present invention is applied to a secure element (hereinafter referred to as "SE").

[1.SE1の構成及び機能]
先ず、図1を参照して、本実施形態に係るSE1の構成及び機能について説明する。図1は、SE1の概要構成例を示す図である。SE1は、本発明の電子情報記憶媒体の一例である。図1に示すように、SE1は、CPU(Central Processing Unit)10、RAM(Random Access Memory)11、ROM(Read Only Memory)12、NVM(Nonvolatile Memory)13(不揮発性メモリ)、及びI/O回路14などを備えて構成される(ROM12は備えられない場合もある)。SE1は、例えばIoT製品やスマートフォン等の端末に搭載されて使用される。なお、SE1は、着脱可能なICカードとして端末に搭載されてもよいし、eUICC(Embedded Universal Integrated Circuit Card)として端末から容易に取り外しや取り換えができないように組み込み基盤上に搭載(つまり、端末と一体的に形成)されてもよい。
[1. SE1 configuration and functions]
First, with reference to FIG. 1, the configuration and functions of SE1 according to the present embodiment will be described. FIG. 1 is a diagram showing an example of a schematic configuration of SE1. SE1 is an example of the electronic information storage medium of the present invention. As shown in FIG. 1, the SE1 includes a CPU (Central Processing Unit) 10, a RAM (Random Access Memory) 11, a ROM (Read Only Memory) 12, an NVM (Nonvolatile Memory) 13 (nonvolatile memory), and an I/O It is configured to include a circuit 14, etc. (ROM 12 may not be included). SE1 is used by being installed in, for example, IoT products and terminals such as smartphones. Note that the SE1 may be installed in the terminal as a removable IC card, or it may be installed on the embedded board as an eUICC (Embedded Universal Integrated Circuit Card) so that it cannot be easily removed or replaced from the terminal (in other words, it is not connected to the terminal). integrally formed).

CPU10は、ROM12またはNVM13に記憶された各種プログラムを実行するプロセッサ(コンピュータ)である。CPU10は、本発明における第1受信手段、保持手段、送信手段、第2受信手段、判定手段、及び実行手段として機能する。RAM11は、作業用メモリとして利用される。NVM13には、例えばフラッシュメモリが適用される。NVM13は、「Electrically Erasable Programmable Read-Only Memory」であってもよい。NVM13には、各種プログラム(本発明のプログラムを含む)及びデータが記憶される。各種プログラムには、オペレーティングシステム(OS)及びアプリケーションなどが含まれる。なお、NVM13に記憶される各種プログラム及びデータの一部は、ROM12に記憶されてもよい。 The CPU 10 is a processor (computer) that executes various programs stored in the ROM 12 or NVM 13. The CPU 10 functions as a first receiving means, a holding means, a transmitting means, a second receiving means, a determining means, and an executing means in the present invention. RAM 11 is used as a working memory. For example, a flash memory is applied to the NVM 13. The NVM 13 may be an "Electrically Erasable Programmable Read-Only Memory". The NVM 13 stores various programs (including the program of the present invention) and data. The various programs include an operating system (OS), applications, and the like. Note that some of the various programs and data stored in the NVM 13 may be stored in the ROM 12.

I/O回路14は、外部装置2との間のインターフェースを担う。外部装置2は、例えば、SE1が搭載される端末のコントローラである。ただし、外部装置2は、ネットワークに接続されたサーバや、接触(または非接触)で通信可能なリーダライタであってもよい。インターフェースの例として、SPI(Serial Peripheral Interface) 、I2C(Inter-Integrated Circuit)、及びISO/IEC7816のインターフェースなどが挙げられる。 The I/O circuit 14 serves as an interface with the external device 2. The external device 2 is, for example, a controller of a terminal in which SE1 is installed. However, the external device 2 may be a server connected to a network or a reader/writer capable of contact (or non-contact) communication. Examples of the interface include SPI (Serial Peripheral Interface), I 2 C (Inter-Integrated Circuit), and ISO/IEC7816 interface.

I/O回路14がSPIを担う場合、シフトレジスタ及び4つの信号線等がI/O回路14に備えられる。4つの信号線とは、SCLK(Serial Clock)、MOSI(Master-Out Slave-In)、MISO(Master-In Slave-Out)、及びSLS(SLave Select)である。例えばマスターとしての外部装置2がSLSをローアクティブにすることで通信が開始される。また、I/O回路14がISO/IEC7816のインターフェースを担う場合、公知のC1~C8の8個の端子がI/O回路14に備えられる。 When the I/O circuit 14 is responsible for SPI, the I/O circuit 14 is equipped with a shift register, four signal lines, and the like. The four signal lines are SCLK (Serial Clock), MOSI (Master-Out Slave-In), MISO (Master-In Slave-Out), and SLS (SLave Select). For example, communication is started when the external device 2 as a master makes SLS low active. Further, when the I/O circuit 14 serves as an ISO/IEC7816 interface, the I/O circuit 14 is provided with eight known terminals C1 to C8.

本実施形態において、SE1と外部装置2との通信における下層(物理層)ではSPIが用いられ、中層ではTPDU(Transmission Protocol Data Unit)プロトコル(例えば、T=1)が用いられ、上層(アプリケーション層)ではAPDU(Application Protocol Data Unit)プロトコルが用いられるものとする。ただし、これに限定されるものではない。なお、SPIは、複数のスレーブを持つことが可能であり、本実施形態では1つのSE1をスレーブとして通信が行われる場合を例にとるが、外部装置2が複数のスレーブと通信してもよい。 In this embodiment, SPI is used in the lower layer (physical layer) in communication between the SE 1 and the external device 2, the TPDU (Transmission Protocol Data Unit) protocol (for example, T=1) is used in the middle layer, and the upper layer (application layer) is used in the middle layer. ), it is assumed that the APDU (Application Protocol Data Unit) protocol is used. However, it is not limited to this. Note that SPI can have multiple slaves, and in this embodiment, a case where communication is performed with one SE1 as a slave is taken as an example, but the external device 2 may also communicate with multiple slaves. .

APDUプロトコルは、ISO/IEC7816-3で定義されるコマンドAPDU及びレスポンスAPDUを送受信するためのプロトコルである。ここで、コマンドAPDUは、例えば、CLA、INS、P1及びP2から構成(ヘッダのみから構成)される(Case1)。CLAはコマンドクラスを示し、INSはコマンドコードを示し、P1及びP2はコマンドパラメータを示す。或いは、コマンドAPDUは、CLA、INS、P1及びP2と、Leとから構成(ヘッダーとボディから構成)される(Case2)。LeはレスポンスAPDUの最大長を示す。或いは、コマンドAPDUは、CLA、INS、P1及びP2と、Lc及びDataとから構成される(Case3)。LcはDataの長さを示す。或いは、コマンドAPDUは、CLA、INS、P1及びP2と、Lc、Data及びLeとから構成される(Case4)。一方、レスポンスAPDUは、例えば、SW1及びSW2から構成される(Case1,Case3)。SW1及びSW2は、ステータスワードであり、コマンドAPDUに基づいて実行されたコマンド処理(換言すると、コマンドAPDUに応じた処理)の結果を示す。例えば、SW1及びSW2が“0009(h)”である場合、正常終了を示し、SW1及びSW2が“6???(h)”である場合、“?”の数値に応じたエラーを示す。或いは、レスポンスAPDUは、例えば、DATA、SW1及びSW2から構成される(Case2,Case4)。 The APDU protocol is a protocol for transmitting and receiving command APDUs and response APDUs defined in ISO/IEC7816-3. Here, the command APDU is composed of, for example, CLA, INS, P1, and P2 (consisted only of a header) (Case 1). CLA indicates a command class, INS indicates a command code, and P1 and P2 indicate command parameters. Alternatively, the command APDU is composed of CLA, INS, P1 and P2, and Le (composed of a header and a body) (Case 2). Le indicates the maximum length of the response APDU. Alternatively, the command APDU is composed of CLA, INS, P1 and P2, and Lc and Data (Case 3). Lc indicates the length of Data. Alternatively, the command APDU is composed of CLA, INS, P1 and P2, and Lc, Data and Le (Case 4). On the other hand, the response APDU is composed of, for example, SW1 and SW2 (Case1, Case3). SW1 and SW2 are status words and indicate the results of command processing executed based on the command APDU (in other words, processing according to the command APDU). For example, when SW1 and SW2 are "0009(h)", it indicates a normal end, and when SW1 and SW2 are "6???(h)", it indicates an error corresponding to the numerical value of "?". Alternatively, the response APDU is composed of, for example, DATA, SW1, and SW2 (Case 2, Case 4).

また、TPDUプロトコルに従う通信では、I(Information)ブロック(情報ブロック)、R(Receive Ready)ブロック(受信準備完了ブロック)、またはS(Supervisory)ブロック(管理ブロック)が用いられる。ここで、Iブロックは、所定のアプリケーションによりアプリケーション層で使用されるデータ(例えば、コマンドAPDU及びレスポンスAPDU)を伝達するために用いられる。Rブロックは、例えば、肯定応答(ACK)や否定応答(NAK)を伝達するために用いられる。Sブロックは、制御情報を伝達するために用いられる。ISO/IEC7816-3には、制御情報として、WTX要求、WTX応答、IFS変更要求、IFS変更応答、ABORT要求、及びABORT応答等が規定されているが、本実施形態では、新たな制御情報として、Iブロックにより送信されるべき送信データ(例えば、コマンドAPDU及びレスポンスAPDU)の長さ(データ長)を指定するLEN要求、及びLEN要求に対するLEN応答を定義する。 Further, in communication according to the TPDU protocol, an I (Information) block, an R (Receive Ready) block, or an S (Supervisory) block (management block) is used. Here, the I block is used to convey data (eg, command APDU and response APDU) used in the application layer by a predetermined application. The R block is used, for example, to convey an acknowledgment (ACK) or a negative acknowledgment (NAK). S blocks are used to convey control information. ISO/IEC7816-3 stipulates WTX request, WTX response, IFS change request, IFS change response, ABORT request, ABORT response, etc. as control information, but in this embodiment, new control information , a LEN request that specifies the length (data length) of transmission data (eg, command APDU and response APDU) to be transmitted by the I block, and a LEN response to the LEN request.

図2は、SE1と外部装置2との間でやり取りされるブロックBLnのデータフォーマット(構造)を示す図である。図2に示すように、ブロックBLnは、先頭フィールド(Prologue field)、情報フィールド(Information field)、及び最終フィールド(Epilogue field)を有する所定のデータフォーマットにより構成される。ここで、情報フィールドは、所定のアプリケーションによりアプリケーション層で使用されるデータを格納するためのフィールドである。最終フィールドは、チェックコード(例えば、LRCまたはCRC等の誤り検出符号)を格納するためのフィールドである。 FIG. 2 is a diagram showing the data format (structure) of block BLn exchanged between SE1 and external device 2. As shown in FIG. As shown in FIG. 2, the block BLn is configured with a predetermined data format having a first field (Prologue field), an information field (Information field), and a last field (Epilogue field). Here, the information field is a field for storing data used in the application layer by a predetermined application. The final field is a field for storing a check code (for example, an error detection code such as LRC or CRC).

先頭フィールドは、ブロックBLnのヘッダに相当するフィールドであり、ブロックBLnの送信先アドレス等を示すNAD(Node Address Byte)、データフォーマットの種別(つまり、ブロックBLnの種別)を示すPCB(Protocol Control Byte)、及び情報フィールドの長さを指定するためのLEN(Length Byte)を含んで構成される。NAD、PCB、及びLENは、それぞれ、例えば、1バイト(つまり、256ビット)からなる。なお、外部装置2が複数のスレーブとSPIを介して通信する場合、外部装置2からブロックBLnがブロードキャストされるが、ブロックBLnの送信先(宛先)がSE1のみである場合、ブロックBLnのNADには、SE1に固有のアドレス(例えば、識別情報)が含まれる。 The first field is a field corresponding to the header of block BLn, and includes a NAD (Node Address Byte) indicating the destination address of block BLn, and a PCB (Protocol Control Byte) indicating the data format type (that is, the type of block BLn). ), and LEN (Length Byte) for specifying the length of the information field. NAD, PCB, and LEN each consist of, for example, 1 byte (ie, 256 bits). Note that when the external device 2 communicates with multiple slaves via SPI, the block BLn is broadcast from the external device 2, but if the transmission destination (destination) of the block BLn is only SE1, the block BLn is broadcast to the NAD of the block BLn. contains an address (for example, identification information) unique to SE1.

PCBは、先頭の2ビット(b8b7)によってブロックBLnがIブロック、Rブロック、またはSブロックであるかを示し、残りの6ビット(b6~b1)によって制御情報を示す。例えば、PCBにおけるb8b7=00はIブロックを示し、PCBにおけるb8b7=10はRブロックを示す。なお、PCBにおけるb8b7=00である場合(つまり、Iブロックの場合)において、b6はブロック連鎖ビット(チェイニングングビット)であり、b1=1の場合のIブロックは次のIブロックに連鎖する一方、b1=0の場合のIブロックは次のIブロックに連鎖しない。一方、PCBにおけるb8b7=11はSブロックを示し、この場合、b6~b1=000011はWTX要求を示し、b6~b1=100011はWTX応答を示し、b6~b1=0000001はIFS変更要求を示し、b6~b1=100001はIFS変更応答を示し、b6~b1=000010はABORT要求を示し、b6~b1=100010はABORT応答を示す。本実施形態では、PCBにおけるb6~b1でLEN要求、及びLEN応答を示すように新たに定義される。例えば、PCBにおけるb6~b1=000101(ISO/IEC7816-3で使用されていないビット列)にLEN要求が割り当てられ、PCBにおけるb6~b1=100101(ISO/IEC7816-3で使用されていないビット列)にLEN応答が割り当てられる。 The first two bits (b8b7) of the PCB indicate whether the block BLn is an I block, R block, or S block, and the remaining six bits (b6 to b1) indicate control information. For example, b8b7=00 on the PCB indicates an I block, and b8b7=10 on the PCB indicates an R block. In addition, when b8b7=00 in the PCB (that is, in the case of an I block), b6 is a block chaining bit (chaining bit), and when b1=1, the I block is chained to the next I block. On the other hand, an I block in the case of b1=0 is not chained to the next I block. On the other hand, b8b7=11 in the PCB indicates an S block, in this case, b6 to b1=000011 indicates a WTX request, b6 to b1=100011 indicates a WTX response, b6 to b1=0000001 indicates an IFS change request, b6-b1=100001 indicates an IFS change response, b6-b1=000010 indicates an ABORT request, and b6-b1=100010 indicates an ABORT response. In this embodiment, b6 to b1 on the PCB are newly defined to indicate a LEN request and a LEN response. For example, the LEN request is assigned to b6~b1=000101 (bit string not used in ISO/IEC7816-3) on the PCB, and the LEN request is assigned to b6~b1=100101 (bit string not used in ISO/IEC7816-3) on the PCB. A LEN response is assigned.

図3は、SE1と外部装置2との間で送受信されるブロックBLnのデータフォーマットの具体例を示す図である。図3(A)は、外部装置2からSE1へ最初に送信されるブロックBL1(第1ブロックの一例)のデータフォーマットを示し、図3(B)は、ブロックBL1に対する応答としてSE1から外部装置2へ送信されるブロックBL2(第2ブロックの一例)を示す。図3(C)は、ブロックBL2に応じて外部装置2からSE1へ次に送信されるブロックBL3(第3ブロックの一例)のデータフォーマットを示し、図3(D)は、ブロックBL3に対する応答としてSE1から外部装置2へ送信されるブロックBL4を示す。 FIG. 3 is a diagram showing a specific example of the data format of block BLn transmitted and received between SE1 and external device 2. As shown in FIG. 3(A) shows the data format of block BL1 (an example of the first block) that is first transmitted from the external device 2 to SE1, and FIG. 3(B) shows the data format from SE1 to the external device 2 as a response to block BL1. A block BL2 (an example of a second block) is shown. FIG. 3(C) shows the data format of block BL3 (an example of the third block) that is next transmitted from the external device 2 to SE1 in response to block BL2, and FIG. 3(D) shows the data format of block BL3 (an example of the third block) as a response to block BL3. It shows block BL4 transmitted from SE1 to external device 2.

外部装置2からSE1へ最初に送信されるブロックBL1においては、図3(A)に示すように、PCBがSブロック且つLEN要求を示すように設定され、当該ブロックBL1の情報フィールドには当該ブロックBL1のLENにより指定される長さのレングスデータが格納される。このレングスデータは、後から送信されるべき送信データ(例えば、コマンドAPDU)の長さを示す。なお、ブロックBL1のNADには、SE1に固有のアドレス(例えば、識別情報)が含まれる。そして、ブロックBL1に対する応答としてSE1から外部装置2へ送信されるブロックBL2においては、図3(B)に示すように、PCBがSブロック且つLEN応答を示すように設定され、当該ブロックBL2の情報フィールドには意味のあるデータが格納されなくてもよい。なお、ブロックBL2のNADには、外部装置2に固有のアドレス(例えば、識別情報)が含まれる。 In the block BL1 that is first transmitted from the external device 2 to the SE1, as shown in FIG. 3(A), the PCB is set to indicate the S block and LEN request, and the information field of the block BL1 contains Length data of the length specified by LEN of BL1 is stored. This length data indicates the length of transmission data (for example, command APDU) to be transmitted later. Note that the NAD of block BL1 includes an address (for example, identification information) unique to SE1. In block BL2 transmitted from SE1 to external device 2 as a response to block BL1, as shown in FIG. Fields do not need to store meaningful data. Note that the NAD of block BL2 includes an address (for example, identification information) unique to the external device 2.

一方、外部装置2からSE1へ次に送信されるブロックBL3においては、図3(C)に示すように、PCBがIブロックを示すように設定され、当該ブロックBL3の情報フィールドには最初に受信されたブロックBL1の情報フィールドに格納されたレングスデータにより示される長さの送信データ(例えば、コマンドAPDU)が格納される。なお、ブロックBL3のNADには、SE1に固有のアドレス(例えば、識別情報)が含まれる。そして、ブロックBL3に対する応答としてSE1から外部装置2へ送信されるブロックBL4においては、図3(D)に示すように、PCBがIブロックを示すように設定され、当該ブロックBL4の情報フィールドには例えばレスポンスAPDUが格納される。なお、ブロックBL4のNADには、外部装置2に固有のアドレス(例えば、識別情報)が含まれる。 On the other hand, in the block BL3 that is next transmitted from the external device 2 to the SE1, the PCB is set to indicate the I block, as shown in FIG. Transmission data (for example, command APDU) of the length indicated by the length data stored in the information field of block BL1 is stored. Note that the NAD of block BL3 includes an address (for example, identification information) unique to SE1. In block BL4 sent from SE1 to external device 2 as a response to block BL3, the PCB is set to indicate the I block, as shown in FIG. 3(D), and the information field of block BL4 is For example, a response APDU is stored. Note that the NAD of block BL4 includes an address (for example, identification information) unique to the external device 2.

図3に示すように構成することで、例えば1バイトのLENにより指定可能な長さ(最大255バイト)を超える長さをレングスデータで指定可能となる。例えば、1バイトのLENより指定された長さ(つまり、レングスデータの長さ)が2バイト(つまり、65536ビット)である場合、当該2バイトのレングスデータにより送信データ(例えば、コマンドAPDU)の長さを指定することができる。これにより、既存のデータフォーマットを変更することなく、先頭フィールドのLENで指定可能な長さを超えるデータ長を指定することができる。なお、ブロックBBL2のLENは使用されない(SE1により無視される)ので、例えば“00(h)”または“FF(h)”に設定されてもよい。 By configuring as shown in FIG. 3, it becomes possible to specify a length using length data that exceeds the length that can be specified by, for example, a 1-byte LEN (maximum 255 bytes). For example, if the length specified by the 1-byte LEN (i.e. length data length) is 2 bytes (i.e. 65536 bits), the 2-byte length data can be used to transmit data (e.g. command APDU). You can specify the length. This makes it possible to specify a data length that exceeds the length that can be specified by the LEN of the first field, without changing the existing data format. Note that since LEN of block BBL2 is not used (ignored by SE1), it may be set to, for example, "00(h)" or "FF(h)".

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

(実施例1)
先ず、図4を参照して、実施例1に係るSE1の動作について説明する。図4は、実施例1において、外部装置2からのブロックBLnがSE1により受信されたときのCPU10(例えば、OS)の処理の一例を示すフローチャートである。
(Example 1)
First, with reference to FIG. 4, the operation of SE1 according to the first embodiment will be described. FIG. 4 is a flowchart showing an example of the processing of the CPU 10 (for example, the OS) when the block BLn from the external device 2 is received by the SE 1 in the first embodiment.

図4に示す処理が開始されると、CPU10は、受信されたブロックBLnの直前にLEN要求を含むブロックBL1が受信済であるか否かを判定する(ステップS1)。CPU10は、ブロックBL1が受信済でないと判定した場合(ステップS1:NO)、ステップS2へ進む。一方、CPU10は、ブロックBL1が受信済であると判定した場合(ステップS1:YES)、つまり、受信されたブロックBLnがブロックBL2に応じて外部装置2から送信されたブロックBL3である場合、ステップS7へ進む。 When the process shown in FIG. 4 is started, the CPU 10 determines whether a block BL1 including a LEN request has been received immediately before the received block BLn (step S1). If the CPU 10 determines that the block BL1 has not been received (step S1: NO), the process proceeds to step S2. On the other hand, if the CPU 10 determines that block BL1 has been received (step S1: YES), that is, if the received block BLn is block BL3 transmitted from the external device 2 in response to block BL2, then step Proceed to S7.

ステップS2では、CPU10は、受信されたブロックBLnがLEN要求を含むブロックBL1であるか否かを、PCBを参照することで判定する。CPU10は、受信されたブロックBLnがLEN要求を含むブロックBL1であると判定した場合(ステップS2:YES)、ブロックBL1に含まれるレングスデータを保持する(ステップS3)。例えば、ブロックBL1の先頭フィールドに含まれるLENにより指定された長さ分のレングスデータが、ブロックBL1の情報フィールドから取得され、当該取得されたレングスデータがRAMの保持領域に記憶されることで保持される。次いで、CPU10は、ブロックBL1に対する応答として、LEN応答を含むブロックBL2を外部装置2へ送信する(ステップS4)。 In step S2, the CPU 10 determines whether the received block BLn is the block BL1 including the LEN request by referring to the PCB. When the CPU 10 determines that the received block BLn is the block BL1 including the LEN request (step S2: YES), the CPU 10 retains the length data included in the block BL1 (step S3). For example, length data for the length specified by LEN included in the first field of block BL1 is acquired from the information field of block BL1, and the acquired length data is stored in the retention area of RAM and retained. be done. Next, the CPU 10 transmits the block BL2 including the LEN response to the external device 2 as a response to the block BL1 (step S4).

一方、ステップS2において、CPU10は、受信されたブロックBLnがLEN要求を含むブロックBL1でないと判定した場合(ステップS2:NO)、つまり、通常のブロックBL5である場合、ブロックBL5の情報フィールドに含まれる例えばコマンドAPDUに基づいて通常のコマンド処理を実行し(OSがアプリケーションにコマンドAPDUに応じた処理を実行させる)(ステップS5)、ブロックBL5に対する応答として、ブロックBL6(コマンド処理の結果を示すレスポンスAPDUを含む)を外部装置2へ送信する(ステップS6)。 On the other hand, in step S2, if the CPU 10 determines that the received block BLn is not the block BL1 including the LEN request (step S2: NO), that is, if it is a normal block BL5, the CPU 10 determines that the received block BLn is not included in the information field of the block BL5. For example, normal command processing is executed based on the command APDU (the OS causes the application to execute processing according to the command APDU) (step S5), and as a response to block BL5, block BL6 (response indicating the result of command processing) is executed. (including APDU) to the external device 2 (step S6).

ステップS7では、CPU10は、受信されたブロックBL3に含まれる送信データ(例えば、コマンドAPDU)に基づいて処理(例えば、コマンド処理)を実行する。例えば、ステップS3で保持されたレングスデータにより示される長さ分のコマンドAPDUが、ブロックBL3の情報フィールドから取得され(ブロックBL3の先頭フィールドに含まれるLENは無視される)、当該取得されたコマンドAPDUに基づいてコマンド処理が実行される(OSがアプリケーションにコマンドAPDUに応じた処理を実行させる)。次いで、CPU10は、ブロックBL3に対する応答として、ブロックBL4(例えば、コマンド処理の結果を示すレスポンスAPDUを含む)を外部装置2へ送信する(ステップS8)。 In step S7, the CPU 10 executes processing (for example, command processing) based on the transmission data (for example, command APDU) included in the received block BL3. For example, a command APDU with a length indicated by the length data held in step S3 is obtained from the information field of block BL3 (LEN included in the first field of block BL3 is ignored), and the obtained command Command processing is executed based on the APDU (the OS causes the application to execute processing according to the command APDU). Next, the CPU 10 transmits a block BL4 (including, for example, a response APDU indicating the result of command processing) to the external device 2 as a response to the block BL3 (step S8).

なお、実施例1の変形例として、CPU10は、図4のステップS2において、受信されたブロックBLnがLEN要求を含むブロックBL1であると判定した場合(ステップS2:YES)、ステップS3へ移行する前に、ブロックBL1に含まれるレングスデータにより示される長さの送信データ(例えば、コマンドAPDU)を1度に受信可能であるか否かを判定してもよい。例えば、ブロックBL1に含まれるレングスデータにより示される長さが、送信データを一時記憶するためのバッファ領域の記憶容量以下である場合に当該送信データを1度に受信可能であると判定されて当該レングスデータを保持され(ステップS3)、ステップS4へ進む。一方、送信データを1度に受信可能でないと判定された場合、当該送信データを1度に受信可能な長さを示す長さ指定データを含むブロックBL2(例えば、長さ指定データは情報フィールドに格納される)が外部装置2へ送信される。そして、外部装置2は、送信データの長さを、ブロックBL2に含まれる長さ指定データにより示される長さ以下に変更し、当該変更された長さを示すレングスデータを含むブロックBL1が再度SE1へ送信され、図4に示す処理が実行される。 As a modification of the first embodiment, when the CPU 10 determines in step S2 of FIG. 4 that the received block BLn is the block BL1 including the LEN request (step S2: YES), the CPU 10 moves to step S3. Beforehand, it may be determined whether transmission data (for example, command APDU) of the length indicated by the length data included in block BL1 can be received at one time. For example, if the length indicated by the length data included in block BL1 is less than or equal to the storage capacity of the buffer area for temporarily storing the transmitted data, it is determined that the transmitted data can be received at once, and the corresponding The length data is held (step S3), and the process advances to step S4. On the other hand, if it is determined that the transmission data cannot be received at one time, block BL2 containing length specification data indicating the length of the transmission data that can be received at one time (for example, the length specification data is written in the information field). stored) is transmitted to the external device 2. Then, the external device 2 changes the length of the transmission data to be less than or equal to the length indicated by the length specification data included in the block BL2, and the block BL1 including the length data indicating the changed length is again set to SE1. The process shown in FIG. 4 is executed.

(実施例2)
次に、図5を参照して、実施例2に係るSE1の動作について説明する。実施例1の変形例では、送信データの長さを変更する必要があるが当該送信データの長さを変更できない場合もある。かかる場合に鑑み、実施例2は、外部装置2により送信データが1度に受信可能な長さに分割されてSE1へ送信されるように構成される。図5は、実施例2において、外部装置2からのブロックBLnがSE1により受信されたときのCPU10の処理の一例を示すフローチャートである。
(Example 2)
Next, with reference to FIG. 5, the operation of SE1 according to the second embodiment will be described. In the modified example of the first embodiment, it is necessary to change the length of the transmission data, but there are cases where the length of the transmission data cannot be changed. In view of this, the second embodiment is configured such that the external device 2 divides the transmission data into lengths that can be received at one time and transmits the divided data to the SE1. FIG. 5 is a flowchart showing an example of the processing of the CPU 10 when the block BLn from the external device 2 is received by the SE 1 in the second embodiment.

図5に示す処理が開始されると、CPU10は、受信されたブロックBLnの前(この場合、直前でなくともよく、過去所定時間内であってもよい)にLEN要求を含むブロックBL1が受信済であるか否かを判定する(ステップS11)。CPU10は、ブロックBL1が受信済でないと判定した場合(ステップS11:NO)、ステップS12へ進む。一方、CPU10は、ブロックBL1が受信済であると判定した場合(ステップS11:YES)、つまり、受信されたブロックBLnがブロックBL2に応じて外部装置2から送信されたブロックBL3である場合、ステップS19へ進む。 When the process shown in FIG. 5 is started, the CPU 10 receives a block BL1 including a LEN request before the received block BLn (in this case, it does not have to be immediately before, and may be within a predetermined time in the past). It is determined whether it has been completed (step S11). If the CPU 10 determines that the block BL1 has not been received (step S11: NO), the process proceeds to step S12. On the other hand, if the CPU 10 determines that the block BL1 has been received (step S11: YES), that is, if the received block BLn is the block BL3 transmitted from the external device 2 in accordance with the block BL2, the CPU 10 Proceed to S19.

ステップS12では、CPU10は、受信されたブロックBLnがLEN要求を含むブロックBL1であるか否かを判定する。CPU10は、受信されたブロックBLnがLEN要求を含むブロックBL1であると判定した場合(ステップS12:YES)、ブロックBL1に含まれるレングスデータを保持する(ステップS13)。次いで、CPU10は、ステップS13で保持されたレングスデータにより示される長さの送信データを1度に受信可能であるか否かを判定する(ステップS14)。 In step S12, the CPU 10 determines whether the received block BLn is a block BL1 including a LEN request. When the CPU 10 determines that the received block BLn is the block BL1 including the LEN request (step S12: YES), the CPU 10 retains the length data included in the block BL1 (step S13). Next, the CPU 10 determines whether transmission data of the length indicated by the length data held in step S13 can be received at one time (step S14).

CPU10は、送信データを1度に受信可能であると判定した場合(ステップS14:YES)、ブロックBL1に対する応答として、LEN応答を含むブロックBL2を外部装置2へ送信する(ステップS15)。一方、CPU10は、送信データを1度に受信可能でないと判定した場合(ステップS14:NO)、ブロックBL1に対する応答として、送信データを1度に受信可能な長さを示す長さ指定データを含むブロックBL2を外部装置2へ送信する(ステップS16)。 If the CPU 10 determines that the transmission data can be received at one time (step S14: YES), the CPU 10 transmits the block BL2 including the LEN response to the external device 2 as a response to the block BL1 (step S15). On the other hand, if the CPU 10 determines that the transmission data cannot be received at one time (step S14: NO), the CPU 10 includes length specification data indicating the length of the transmission data that can be received at one time as a response to the block BL1. Block BL2 is transmitted to external device 2 (step S16).

これにより、外部装置2は、ブロックBL2に含まれる長さ指定データにより示される長さ以下になるように送信データを2以上に分割し、当該送信データから分割された分割送信データを含むブロックBL3をSE1へ順次送信することになる。例えば、送信データがn(n>2)個に分割される場合、1番目に送信される分割送信データを含むブロックBL3からn-1番目に送信される分割送信データを含むブロックBL3のそれぞれのPCBにおけるブロック連鎖ビットb6は“1”に設定される。一方、n番目に(つまり、最後に)送信される分割送信データを含むブロックBL3のPCBにおけるブロック連鎖ビットb6は“0”に設定される。 Thereby, the external device 2 divides the transmission data into two or more pieces so that the length is less than or equal to the length indicated by the length specification data included in the block BL2, and blocks BL3 containing the divided transmission data divided from the transmission data. will be sequentially transmitted to SE1. For example, when transmission data is divided into n (n>2) pieces, each block BL3 containing the divided transmission data to be transmitted first to the block BL3 containing the divided transmission data to be transmitted at the (n-1)th The block chain bit b6 in the PCB is set to "1". On the other hand, the block chain bit b6 in the PCB of the block BL3 containing the n-th (that is, the last) transmitted divided transmission data is set to "0".

一方、ステップS12において、CPU10は、受信されたブロックBLnがLEN要求を含むブロックBL1でないと判定した場合(ステップS12:NO)、つまり、通常のブロックBL5である場合、当該ブロックBL5の情報フィールドに含まれる例えばコマンドAPDUに基づいて通常のコマンド処理を実行し(OSがアプリケーションにコマンドAPDUに応じた処理を実行させる)(ステップS17)、当該ブロックBL5に対する応答としてブロックBL6(当該コマンド処理の結果を示すレスポンスAPDUを含む)を外部装置2へ送信する(ステップS18)。 On the other hand, in step S12, if the CPU 10 determines that the received block BLn is not the block BL1 including the LEN request (step S12: NO), that is, if it is a normal block BL5, the information field of the block BL5 is For example, normal command processing is executed based on the command APDU included (the OS causes the application to execute processing according to the command APDU) (step S17), and as a response to the block BL5, the block BL6 (the result of the command processing is including the response APDU shown) to the external device 2 (step S18).

ステップS19では、CPU10は、ステップS13で保持されたレングスデータにより示される長さの送信データが揃った(送信データが分割されて送信される場合、全ての分割送信データが揃った)か否かを判定する。ここで、送信データが分割されてブロックBL3により送信される場合、それぞれのブロックBL3に含まれる分割送信データがバッファ領域に記憶される度に、当該バッファ領域から例えばRAM上の送信データ再生領域に分割送信データが移行されて(書き込まれて)連結される。そして、送信データ再生領域において連結された分割送信データの長さが累計され、当該累計された長さが、ステップS13で保持されたレングスデータにより示される長さと一致した場合に(つまり、複数回にわたって受信された分割送信データが連結されることによりレングスデータにより示される長さの送信データが得られた場合に)、全ての分割送信データが揃ったと判定される。 In step S19, the CPU 10 determines whether the transmission data of the length indicated by the length data held in step S13 has been completed (if the transmission data is divided and transmitted, all divided transmission data have been completed). Determine. Here, when the transmission data is divided and transmitted by block BL3, each time the divided transmission data included in each block BL3 is stored in the buffer area, it is transferred from the buffer area to the transmission data reproduction area on the RAM, for example. The divided transmission data is migrated (written) and concatenated. Then, the lengths of the concatenated divided transmission data in the transmission data reproduction area are accumulated, and when the accumulated length matches the length indicated by the length data held in step S13 (that is, the length is If the transmission data of the length indicated by the length data is obtained by concatenating the divided transmission data received over the period of time), it is determined that all the divided transmission data have been completed.

CPU10は、ステップS13で保持されたレングスデータにより示される長さの送信データが揃っていないと判定した場合(ステップS19:NO)、ブロックBL3に対する応答として、ブロックBL4(例えば、次の分割送信データの要求を含む)を外部装置2へ送信する(ステップS20)。一方、CPU10は、ステップS13で保持されたレングスデータにより示される長さの送信データが揃ったと判定した場合(ステップS19:YES)、当該送信データ(例えば、コマンドAPDU)に基づいて処理(例えば、コマンド処理)を実行し(OSがアプリケーションにコマンドAPDUに応じた処理を実行させる)(ステップS21)、ブロックBL3に対する応答として、ブロックBL4(例えば、当該コマンド処理の結果を示すレスポンスAPDUを含む)を外部装置2へ送信する(ステップS22)。 If the CPU 10 determines that the transmission data of the length indicated by the length data held in step S13 is not complete (step S19: NO), the CPU 10 sends the block BL4 (for example, the next divided transmission data) as a response to the block BL3. (including the request) to the external device 2 (step S20). On the other hand, if the CPU 10 determines that the transmission data of the length indicated by the length data held in step S13 is complete (step S19: YES), the CPU 10 performs processing (for example, command processing) (the OS causes the application to execute processing according to the command APDU) (step S21), and as a response to block BL3, block BL4 (including, for example, a response APDU indicating the result of the command processing) is executed. It is transmitted to the external device 2 (step S22).

以上説明したように、上記実施形態によれば、SE1は、送信されるべき送信データの長さを示すレングスデータを含むブロックBL1を外部装置2から受信すると、ブロックBL1に含まれるレングスデータを保持し、ブロックBL1に対する応答としてブロックBL2を外部装置2へ送信し、ブロックBL2に応じて上記レングスデータにより示される長さの送信データを含むブロックBL3を外部装置2から受信した場合に、ブロックBL3に含まれる送信データに基づいて処理を実行するように構成したので、既存のデータフォーマットを変更することなく、ヘッダで指定可能な長さを超えるデータ長を指定することができる。 As explained above, according to the above embodiment, when SE1 receives block BL1 including length data indicating the length of transmission data to be transmitted from external device 2, SE1 retains the length data included in block BL1. Then, when block BL2 is transmitted to external device 2 as a response to block BL1, and block BL3 containing transmission data of the length indicated by the above length data is received from external device 2 in response to block BL2, block BL3 is Since the configuration is configured to execute processing based on the included transmission data, it is possible to specify a data length that exceeds the length that can be specified in the header without changing the existing data format.

1 SE
2 外部装置
10 CPU
11 RAM
12 ROM
13 NVM
14 I/O回路
1 SE
2 External device 10 CPU
11 RAM
12 ROM
13 NVM
14 I/O circuit

Claims (7)

送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、
前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、
前記第1ブロックに含まれる前記レングスデータにより示される前記長さの前記送信データを1度に受信可能であるか否かを判定する判定手段と、
前記判定手段により前記送信データを1度に受信可能でないと判定された場合に、前記第1ブロックに対する応答として、前記送信データを1度に受信可能な長さを示す長さ指定データを含む第2ブロックを前記外部装置へ送信する送信手段と、
前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、
前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段と、
を備えることを特徴とする電子情報記憶媒体。
first receiving means for receiving a first block including length data indicating a length of transmission data to be transmitted from an external device;
holding means for holding the length data included in the first block;
determining means for determining whether the transmission data of the length indicated by the length data included in the first block can be received at one time;
When the determination means determines that the transmission data cannot be received at one time, as a response to the first block , the first block includes length designation data indicating the length of the transmission data that can be received at one time. transmitting means for transmitting two blocks to the external device;
A third block that is transmitted from the external device in response to the second block and that includes the transmission data of the length indicated by the held length data from the external device. 2 receiving means;
Executing means for executing processing based on the transmission data included in the third block;
An electronic information storage medium comprising:
前記第2受信手段は、前記保持された前記レングスデータにより示される前記長さの前記送信データから分割された分割送信データを含む第3ブロックを外部装置から複数回にわたって受信し、
前記実行手段は、複数回にわたって受信された前記分割送信データが連結されることにより前記レングスデータにより示される前記長さの前記送信データが得られた場合に、当該送信データに基づいて処理を実行することを特徴とする請求項に記載の電子情報記憶媒体。
The second receiving means receives a third block including divided transmission data divided from the transmission data of the length indicated by the held length data from an external device multiple times,
The execution means executes processing based on the transmission data when the transmission data having the length indicated by the length data is obtained by concatenating the divided transmission data received a plurality of times. The electronic information storage medium according to claim 1 , characterized in that:
送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、
前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、
前記第1ブロックに対する応答として第2ブロックを前記外部装置へ送信する送信手段と、
前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、
前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段と、
を備え
前記第1ブロック及び前記第3ブロックは、それぞれ、所定のアプリケーションによりアプリケーション層で使用されるデータを格納するための情報フィールドと、前記情報フィールドの長さを指定するための所定バイトからなるLEN(Length byte)を含む先頭フィールドとを有する所定のデータフォーマットにより構成され、
前記第1ブロックの前記情報フィールドには前記LENにより指定された長さの前記レングスデータが格納され、前記第3ブロックの前記情報フィールドには前記レングスデータにより示される前記長さの前記送信データが格納され、
前記実行手段は、前記第3ブロックの前記先頭フィールドに含まれるLENを無視して前記第3ブロックに含まれる前記送信データに基づいて処理を実行することを特徴とする電子情報記憶媒体。
first receiving means for receiving a first block including length data indicating a length of transmission data to be transmitted from an external device;
holding means for holding the length data included in the first block;
Transmitting means for transmitting a second block to the external device as a response to the first block;
A third block that is transmitted from the external device in response to the second block and that includes the transmission data of the length indicated by the held length data from the external device. 2 receiving means;
Executing means for executing processing based on the transmission data included in the third block;
Equipped with
The first block and the third block each include an information field for storing data used in the application layer by a predetermined application, and a LEN (LEN) consisting of a predetermined byte for specifying the length of the information field. It consists of a predetermined data format with a first field including (Length byte),
The information field of the first block stores the length data specified by the LEN, and the information field of the third block stores the transmission data of the length indicated by the length data. stored,
The electronic information storage medium is characterized in that the execution means executes the process based on the transmission data included in the third block, ignoring LEN included in the first field of the third block.
電子情報記憶媒体に含まれるコンピュータにより実行されるデータ受信方法であって、
送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信するステップと、
前記第1ブロックに含まれる前記レングスデータを保持するステップと、
前記第1ブロックに含まれる前記レングスデータにより示される前記長さの前記送信データを1度に受信可能であるか否かを判定するステップと、
前記送信データを1度に受信可能でないと判定された場合に、前記第1ブロックに対する応答として、前記送信データを1度に受信可能な長さを示す長さ指定データを含む第2ブロックを前記外部装置へ送信するステップと、
前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信するステップと、
前記第3ブロックに含まれる前記送信データに基づいて処理を実行するステップと、
を含むことを特徴とするデータ受信方法。
A data receiving method performed by a computer included in an electronic information storage medium, the method comprising:
receiving from an external device a first block including length data indicating the length of the transmission data to be transmitted;
retaining the length data included in the first block;
determining whether the transmission data of the length indicated by the length data included in the first block can be received at one time;
If it is determined that the transmission data cannot be received at one time, the second block including length designation data indicating the length of the transmission data that can be received at one time is sent as a response to the first block. transmitting to an external device;
receiving from an external device a third block that is transmitted from the external device in response to the second block and includes the transmitted data having the length indicated by the held length data; and,
performing processing based on the transmission data included in the third block;
A data receiving method characterized by comprising:
電子情報記憶媒体に含まれるコンピュータにより実行されるデータ受信方法であって、A data receiving method performed by a computer included in an electronic information storage medium, the method comprising:
送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信するステップと、receiving from an external device a first block including length data indicating the length of the transmission data to be transmitted;
前記第1ブロックに含まれる前記レングスデータを保持するステップと、retaining the length data included in the first block;
前記第1ブロックに対する応答として第2ブロックを前記外部装置へ送信するステップと、transmitting a second block to the external device as a response to the first block;
前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信するステップと、receiving from an external device a third block transmitted from the external device in response to the second block, the third block including the transmitted data having the length indicated by the held length data; and,
前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行ステップと、an execution step of executing processing based on the transmission data included in the third block;
を含み、including;
前記第1ブロック及び前記第3ブロックは、それぞれ、所定のアプリケーションによりアプリケーション層で使用されるデータを格納するための情報フィールドと、前記情報フィールドの長さを指定するための所定バイトからなるLEN(Length byte)を含む先頭フィールドとを有する所定のデータフォーマットにより構成され、The first block and the third block each include an information field for storing data used in the application layer by a predetermined application, and a LEN (LEN) consisting of a predetermined byte for specifying the length of the information field. It consists of a predetermined data format with a first field including (Length byte),
前記第1ブロックの前記情報フィールドには前記LENにより指定された長さの前記レングスデータが格納され、前記第3ブロックの前記情報フィールドには前記レングスデータにより示される前記長さの前記送信データが格納され、The information field of the first block stores the length data specified by the LEN, and the information field of the third block stores the transmission data of the length indicated by the length data. stored,
前記実行ステップにおいては、前記第3ブロックの前記先頭フィールドに含まれるLENを無視して前記第3ブロックに含まれる前記送信データに基づいて処理を実行することを特徴とするデータ受信方法。The data receiving method is characterized in that, in the execution step, processing is executed based on the transmission data included in the third block, ignoring LEN included in the first field of the third block.
送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、
前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、
前記第1ブロックに含まれる前記レングスデータにより示される前記長さの前記送信データを1度に受信可能であるか否かを判定する判定手段と、
前記判定手段により前記送信データを1度に受信可能でないと判定された場合に、前記第1ブロックに対する応答として、前記送信データを1度に受信可能な長さを示す長さ指定データを含む第2ブロックを前記外部装置へ送信する送信手段と、
前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、
前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段としてコンピュータを機能させることを特徴とするプログラム。
first receiving means for receiving a first block including length data indicating a length of transmission data to be transmitted from an external device;
holding means for holding the length data included in the first block;
determining means for determining whether the transmission data of the length indicated by the length data included in the first block can be received at one time;
When the determination means determines that the transmission data cannot be received at one time, as a response to the first block , the first block includes length designation data indicating the length of the transmission data that can be received at one time. transmitting means for transmitting two blocks to the external device;
A third block that is transmitted from the external device in response to the second block and that includes the transmission data of the length indicated by the held length data from the external device. 2 receiving means;
A program that causes a computer to function as an execution means for executing processing based on the transmission data included in the third block.
送信されるべき送信データの長さを示すレングスデータを含む第1ブロックを外部装置から受信する第1受信手段と、
前記第1ブロックに含まれる前記レングスデータを保持する保持手段と、
前記第1ブロックに対する応答として第2ブロックを前記外部装置へ送信する送信手段と、
前記第2ブロックに応じて前記外部装置から送信された第3ブロックであって、前記保持された前記レングスデータにより示される前記長さの前記送信データを含む第3ブロックを外部装置から受信する第2受信手段と、
前記第3ブロックに含まれる前記送信データに基づいて処理を実行する実行手段としてコンピュータを機能させるプログラムであって、
前記第1ブロック及び前記第3ブロックは、それぞれ、所定のアプリケーションによりアプリケーション層で使用されるデータを格納するための情報フィールドと、前記情報フィールドの長さを指定するための所定バイトからなるLEN(Length byte)を含む先頭フィールドとを有する所定のデータフォーマットにより構成され、
前記第1ブロックの前記情報フィールドには前記LENにより指定された長さの前記レングスデータが格納され、前記第3ブロックの前記情報フィールドには前記レングスデータにより示される前記長さの前記送信データが格納され、
前記実行手段は、前記第3ブロックの前記先頭フィールドに含まれるLENを無視して前記第3ブロックに含まれる前記送信データに基づいて処理を実行することを特徴とするプログラム。
first receiving means for receiving a first block including length data indicating a length of transmission data to be transmitted from an external device;
holding means for holding the length data included in the first block;
Transmitting means for transmitting a second block to the external device as a response to the first block;
A third block that is transmitted from the external device in response to the second block and that includes the transmission data of the length indicated by the held length data from the external device. 2 receiving means;
A program that causes a computer to function as an execution means for executing processing based on the transmission data included in the third block,
The first block and the third block each include an information field for storing data used in the application layer by a predetermined application, and a LEN (LEN) consisting of a predetermined byte for specifying the length of the information field. It consists of a predetermined data format with a first field including (Length byte),
The information field of the first block stores the length data specified by the LEN, and the information field of the third block stores the transmission data of the length indicated by the length data. stored,
The program is characterized in that the execution means executes the process based on the transmission data included in the third block, ignoring LEN included in the first field of the third block .
JP2019225123A 2019-12-13 2019-12-13 Electronic information storage medium, data transmission method, and program Active JP7397402B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2019225123A JP7397402B2 (en) 2019-12-13 2019-12-13 Electronic information storage medium, data transmission method, and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2019225123A JP7397402B2 (en) 2019-12-13 2019-12-13 Electronic information storage medium, data transmission method, and program

Publications (2)

Publication Number Publication Date
JP2021096495A JP2021096495A (en) 2021-06-24
JP7397402B2 true JP7397402B2 (en) 2023-12-13

Family

ID=76431384

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2019225123A Active JP7397402B2 (en) 2019-12-13 2019-12-13 Electronic information storage medium, data transmission method, and program

Country Status (1)

Country Link
JP (1) JP7397402B2 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002101127A (en) 2000-09-25 2002-04-05 Fujitsu Ltd PPP connection control method
JP2008033669A (en) 2006-07-28 2008-02-14 Dainippon Printing Co Ltd IC card with mode change function and IC card program
JP2015184692A (en) 2014-03-20 2015-10-22 大日本印刷株式会社 Information processing apparatus, information processing method, and information processing program

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002101127A (en) 2000-09-25 2002-04-05 Fujitsu Ltd PPP connection control method
JP2008033669A (en) 2006-07-28 2008-02-14 Dainippon Printing Co Ltd IC card with mode change function and IC card program
JP2015184692A (en) 2014-03-20 2015-10-22 大日本印刷株式会社 Information processing apparatus, information processing method, and information processing program

Also Published As

Publication number Publication date
JP2021096495A (en) 2021-06-24

Similar Documents

Publication Publication Date Title
EP3252605B1 (en) Vehicle-mounted control device, program writing device, program generating device and program
US5252812A (en) Program control system for portable data storage device
JP3028815B2 (en) Transmission method of portable electronic device and portable electronic device
JP7559916B1 (en) ELECTRONIC INFORMATION STORAGE MEDIUM, IC CHIP, IC CARD, ELEMENT DATA STORAGE METHOD, AND PROGRAM
JP6986835B2 (en) Electronic information storage, data processing methods, and data processing programs
JP7397402B2 (en) Electronic information storage medium, data transmission method, and program
JP5085254B2 (en) Portable electronic device, IC card, and command processing method in portable electronic device
JP7468754B1 (en) ELECTRONIC INFORMATION STORAGE MEDIUM, IC CHIP, IC CARD, RECEPTION BLOCK PROCESSING METHOD, AND PROGRAM
KR100782113B1 (en) Memory card system and its host identification information transmission method
JP7468757B1 (en) ELECTRONIC INFORMATION STORAGE MEDIUM, IC CHIP, IC CARD, RESPONSE TRANSMISSION METHOD, AND PROGRAM
JP4318494B2 (en) IC card and IC card program
JP7005934B2 (en) Electronic information storage medium, IC card, data transmission method, data writing method, data transmission program and data writing program
JP2005301657A (en) IC card storing a plurality of command tables in rewritable memory and command execution method
JP7501808B2 (en) IC chip
JP7439847B2 (en) Electronic information storage medium, key data setting method, and program
JP7017185B2 (en) Electronic information storage, data processing methods, and data processing programs
JP5991119B2 (en) COMMUNICATION SYSTEM, IC CARD, IC CARD PROCESSING PROGRAM, EXTERNAL DEVICE, AND COMMUNICATION METHOD
JP7501764B1 (en) ELECTRONIC INFORMATION STORAGE MEDIUM, IC CHIP, IC CARD, DATA TRANSMISSION/RECEPTION METHOD, AND PROGRAM
JP7420179B1 (en) Electronic information storage medium, IC card, issuance processing method, and program
JP7533142B2 (en) Electronic information storage medium, initialization sequence execution method, and program
JP2026054830A (en) Electronic information storage medium, IC chip, IC card, terminal device, data rewriting method, data transmission method, medium program, and terminal program
JP6823289B2 (en) IC card and computer program
JP2006172271A (en) Multi-application ic card, and program for ic card
JP4549731B2 (en) Multi-application IC card with command code that is commonly used by applications
JPH103430A (en) Ic card and password processing program execution method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20221027

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20230821

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20230823

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20231019

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20231114

R150 Certificate of patent or registration of utility model

Ref document number: 7397402

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150