JP2021114157A - Electronic information storage medium, authentication code generation method, authentication code verification method, and program - Google Patents

Electronic information storage medium, authentication code generation method, authentication code verification method, and program Download PDF

Info

Publication number
JP2021114157A
JP2021114157A JP2020006741A JP2020006741A JP2021114157A JP 2021114157 A JP2021114157 A JP 2021114157A JP 2020006741 A JP2020006741 A JP 2020006741A JP 2020006741 A JP2020006741 A JP 2020006741A JP 2021114157 A JP2021114157 A JP 2021114157A
Authority
JP
Japan
Prior art keywords
authentication code
ciphertext
plaintext
command
pso
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2020006741A
Other languages
Japanese (ja)
Other versions
JP7397403B2 (en
Inventor
靖夫 木下
Yasuo Kinoshita
靖夫 木下
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 JP2020006741A priority Critical patent/JP7397403B2/en
Publication of JP2021114157A publication Critical patent/JP2021114157A/en
Application granted granted Critical
Publication of JP7397403B2 publication Critical patent/JP7397403B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

To provide an electronic information storage medium, an authentication code generation method, an authentication code verification method, and a program that can execute multiple types of security operations at the same timing.SOLUTION: When receiving an extended PSO command α that includes plaintext and designates encryption of the plaintext and generation of an authentication code from an external device 2, SE1 encrypts the plaintext and generates ciphertext according to the extended PSO command α, generates an authentication code based on the generated ciphertext, and transmits an extended PSO response β including the ciphertext and the authentication code to the external device 2.SELECTED DRAWING: Figure 6

Description

本発明は、セキュアエレメント等の電子情報記憶媒体によるデータの暗号化または復号処理方法等の技術分野に関する。 The present invention relates to a technical field such as a data encryption or decryption processing method using an electronic information storage medium such as a secure element.

従来、例えば特許文献1に開示されるように、通信ネットワークを介してサーバ装置と通信可能に接続される端末装置に備えられるセキュアエレメントが端末装置により受信されたデータの正当性を検証し、データが正当か否かを示す検証結果を出力する技術が知られている。特許文献1の技術によれば、データの検証は、当該データとともに受信された認証コードと、当該データとセキュアエレメント内に格納された共通鍵に基づいて導出された認証コードとが一致するか否かに基づいて行われるようになっている。また、従来から知られるAES(Advanced Encryption Standard)-GCM(Galois Counter Mode)においては、受信されたデータ(暗号化されたデータ)の復号に加えて、当該暗号化データとともに受信された認証コードと当該暗号化データに基づいて生成された認証コードとが一致するか否かの検証が行われるようになっている。 Conventionally, as disclosed in, for example, Patent Document 1, a secure element provided in a terminal device communicably connected to a server device via a communication network verifies the validity of data received by the terminal device and data. There is known a technique for outputting a verification result indicating whether or not is valid. According to the technique of Patent Document 1, in the verification of data, whether or not the authentication code received together with the data matches the authentication code derived based on the common key stored in the secure element and the data. It is designed to be based on the data. In addition, in the conventionally known AES (Advanced Encryption Standard) -GCM (Galois Counter Mode), in addition to decrypting the received data (encrypted data), the authentication code received together with the encrypted data is used. It is being verified whether or not the authentication code generated based on the encrypted data matches.

特開2019-96069号公報Japanese Unexamined Patent Publication No. 2019-96069

ところで、国際規格ISO7816-8において、セキュアエレメントに様々なセキュリティオペレーションを実行させることが可能なPSO(PERFORM SECURITY OPERATION)コマンドが定義されている。このようなセキュリティオペレーションとして、認証コード(電子署名)の生成、認証コードの検証、データの暗号化、及びデータの復号等をPSOコマンドのヘッダ部のコマンドパラメータ(P1及びP2)により指定可能になっている。しかしながら、1つのPSOコマンドに複数種類のセキュリティオペレーション(例えば、データの復号と認証コードの検証、またはデータの暗号化と認証コードの生成)を指定することができないため、セキュアエレメントは複数のセキュリティオペレーションを同時に実行することはできない。そのため、PSOコマンドにおいて、AES-GCMを利用した場合は相性が悪い。 By the way, the international standard ISO7816-8 defines a PSO (PERFORM SECURITY OPERATION) command that allows a secure element to perform various security operations. As such a security operation, it is possible to specify the generation of an authentication code (electronic signature), the verification of the authentication code, the encryption of data, the decryption of data, etc. by the command parameters (P1 and P2) in the header part of the PSO command. ing. However, a secure element can have multiple security operations because one PSO command cannot specify multiple types of security operations (eg, data decryption and authorization code verification, or data encryption and authorization code generation). Cannot be executed at the same time. Therefore, when AES-GCM is used in the PSO command, the compatibility is poor.

そこで、本発明は、このような点等に鑑みてなされたものであり、複数種類のセキュリティオペレーションを同タイミングで実行可能な電子情報記憶媒体、認証コード生成方法、認証コード検証方法、及びプログラムを提供することを課題とする。 Therefore, the present invention has been made in view of such points and the like, and provides an electronic information storage medium, an authentication code generation method, an authentication code verification method, and a program capable of executing a plurality of types of security operations at the same timing. The challenge is to provide.

上記課題を解決するために、請求項1に記載の発明は、平文を含み、当該平文の暗号化及び認証コードの生成を指定するコマンドを外部装置から受信する受信手段と、前記コマンドに応じて前記平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成する処理手段と、前記暗号文及び前記認証コードを含むレスポンスを前記外部装置へ送信する送信手段と、を備えることを特徴とする。 In order to solve the above problem, the invention according to claim 1 includes a plaintext, and a receiving means for receiving a command for specifying encryption of the plaintext and generation of an authentication code from an external device, and according to the command. A processing means for encrypting the plaintext to generate a ciphertext and generating an authentication code based on the generated ciphertext, and a transmission means for transmitting the ciphertext and a response including the authentication code to the external device. It is characterized by having.

請求項2に記載の発明は、請求項1に記載の電子情報記憶媒体において、前記受信手段は、複数に分割された平文のうちの1つの平文を含み、当該平文の暗号化及び前記認証コードの生成を指定するコマンドを複数回受信し、前記処理手段は、前記コマンドを受信するごとに、当該受信された平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成し、前記送信手段は、複数に分割された平文のうちの最後の平文以外の平文の暗号化においては前記生成された暗号文を含み且つ前記生成された認証コードを含まない前記レスポンスを送信し、最後の平文の暗号化においては前記生成された暗号文及び前記生成された認証コードを含む前記レスポンスを送信することを特徴とする。 The invention according to claim 2 is the electronic information storage medium according to claim 1, wherein the receiving means includes one plaintext among a plurality of divided plaintexts, and the encryption of the plaintexts and the authentication code. The processing means receives the command for specifying the generation of the command a plurality of times, and each time the processing means receives the command, the received plaintext is encrypted to generate a cipher, and the processing means is based on the generated cipher. The authentication code is generated, and the transmission means includes the generated ciphertext and does not include the generated authentication code in the encryption of the plaintext other than the last plaintext among the plaintext divided into a plurality of parts. The response is transmitted, and in the final plaintext encryption, the response including the generated ciphertext and the generated authentication code is transmitted.

請求項3に記載の発明は、請求項1または2に記載の電子情報記憶媒体において、前回生成されてメモリに記憶された認証コードを、今回生成された認証コードにより更新する更新手段を更に備えることを特徴とする。 The invention according to claim 3 further includes an updating means for updating the authentication code previously generated and stored in the memory in the electronic information storage medium according to claim 1 or 2 with the authentication code generated this time. It is characterized by that.

請求項4に記載の発明は、暗号文を含み、当該暗号文の復号及び認証コードの検証を指定するコマンドを外部装置から受信する受信手段と、前記コマンドに応じて前記暗号文を復号して平文を抽出し、且つ前記暗号文に基づいて認証コードを生成し当該認証コードを検証する処理手段と、前記平文及び前記認証コードの検証結果を含むレスポンスを前記外部装置へ送信する送信手段と、を備えることを特徴とする。 The invention according to claim 4 includes a ciphertext, a receiving means for receiving a command specifying decryption of the ciphertext and verification of an authentication code from an external device, and decrypting the ciphertext in response to the command. A processing means for extracting a plaintext and generating an authentication code based on the ciphertext to verify the authentication code, and a transmitting means for transmitting a response including the plaintext and the verification result of the authentication code to the external device. It is characterized by having.

請求項5に記載の発明は、請求項4に記載の電子情報記憶媒体において、前記受信手段は、複数に分割された暗号文のうちの1つの暗号文を含み、当該暗号文の復号及び前記認証コードの検証を指定するコマンドを複数回受信し、前記処理手段は、前記コマンドを受信するごとに、当該受信された暗号文を復号して平文を抽出し、且つ当該受信された暗号文に基づいて認証コードを生成し当該認証コードを検証し、前記送信手段は、複数に分割された暗号文のうちの最後の暗号文以外の暗号文の復号においては前記抽出された平文を含む前記レスポンスを送信する一方、最後の暗号文の復号においては抽出された平文及び前記認証コードの検証結果を含む前記レスポンスを送信することを特徴とする。 The invention according to claim 5 is the electronic information storage medium according to claim 4, wherein the receiving means includes one ciphertext among a plurality of divided ciphertexts, and decryption of the ciphertext and the above-mentioned The command for specifying the verification of the authentication code is received a plurality of times, and each time the processing means receives the command, the received ciphertext is decrypted to extract the plaintext, and the received ciphertext is used. Based on this, an authentication code is generated and the authentication code is verified, and the transmission means receives the response including the extracted plaintext in decrypting a ciphertext other than the last ciphertext among the ciphertexts divided into a plurality of parts. On the other hand, in the final decryption of the ciphertext, the response including the extracted plaintext and the verification result of the authentication code is transmitted.

請求項6に記載の発明は、請求項4または5に記載の電子情報記憶媒体において、前回生成されてメモリに記憶された認証コードを、今回生成された認証コードにより更新する更新手段を更に備えることを特徴とする。 The invention according to claim 6 further includes an updating means for updating the authentication code previously generated and stored in the memory in the electronic information storage medium according to claim 4 or 5 with the authentication code generated this time. It is characterized by that.

請求項7に記載の発明は、請求項4乃至6の何れか一項に記載の電子情報記憶媒体において、前記処理手段は、前記外部装置から受信されてメモリに保存された検証用認証コードと、前記n番目の暗号文を含む前記コマンドの受信において生成された前記認証コードとを比較することで検証することを特徴とする。 The invention according to claim 7 is the electronic information storage medium according to any one of claims 4 to 6, wherein the processing means is a verification authentication code received from the external device and stored in a memory. It is characterized in that the verification is performed by comparing with the authentication code generated in the reception of the command including the nth ciphertext.

請求項8に記載の発明は、平文を含み、当該平文の暗号化及び認証コードの生成を指定するコマンドを外部装置から受信するステップと、前記コマンドに応じて前記平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成するステップと、前記暗号文及び前記認証コードを含むレスポンスを前記外部装置へ送信するステップと、を含むことを特徴とする。 The invention according to claim 8 includes a plaintext, a step of receiving a command for specifying encryption of the plaintext and generation of an authentication code from an external device, and encrypting the plaintext in response to the command to obtain a ciphertext. It is characterized by including a step of generating and generating an authentication code based on the generated ciphertext, and a step of transmitting the ciphertext and a response including the authentication code to the external device.

請求項9に記載の発明は、暗号文を含み、当該暗号文の復号及び認証コードの検証を指定するコマンドを外部装置から受信するステップと、前記コマンドに応じて前記暗号文を復号して平文を抽出し、且つ前記暗号文に基づいて認証コードを生成し当該認証コードを検証するステップと、前記平文及び前記認証コードの検証結果を含むレスポンスを前記外部装置へ送信するステップと、を含むことを特徴とする。 The invention according to claim 9 includes a ciphertext, a step of receiving a command for specifying decryption of the ciphertext and verification of an authentication code from an external device, and a plaintext by decrypting the ciphertext in response to the command. Is included, and a step of generating an authentication code based on the ciphertext and verifying the authentication code, and a step of transmitting a response including the plaintext and the verification result of the authentication code to the external device are included. It is characterized by.

請求項10に記載の発明は、平文を含み、当該平文の暗号化及び認証コードの生成を指定するコマンドを外部装置から受信する受信手段と、前記コマンドに応じて前記平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成する処理手段と、前記暗号文及び前記認証コードを含むレスポンスを前記外部装置へ送信する送信手段として機能させることを特徴とする。 The invention according to claim 10 includes a plaintext, a receiving means for receiving a command specifying encryption of the plaintext and generation of an authentication code from an external device, and a ciphertext in which the plaintext is encrypted according to the command. It is characterized in that it functions as a processing means for generating an authentication code based on the generated ciphertext and a transmission means for transmitting the ciphertext and a response including the authentication code to the external device. ..

請求項11に記載の発明は、暗号文を含み、当該暗号文の復号及び認証コードの検証を指定するコマンドを外部装置から受信する受信手段と、前記コマンドに応じて前記暗号文を復号して平文を抽出し、且つ前記暗号文に基づいて認証コードを生成し当該認証コードを検証する処理手段と、前記平文及び前記認証コードの検証結果を含むレスポンスを前記外部装置へ送信する送信手段として機能させることを特徴とする。 The invention according to claim 11 includes a ciphertext, a receiving means for receiving a command specifying decryption of the ciphertext and verification of an authentication code from an external device, and decrypting the ciphertext in response to the command. It functions as a processing means for extracting plaintext and generating an authentication code based on the ciphertext to verify the authentication code, and a transmitting means for transmitting a response including the verification result of the plaintext and the authentication code to the external device. It is characterized by letting it.

本発明によれば、複数種類のセキュリティオペレーションを同タイミングで実行することができる。 According to the present invention, a plurality of types of security operations can be executed at the same timing.

SE1の概要構成例を示す図である。It is a figure which shows the outline structure example of SE1. (A)は、PSOコマンドの機能を拡張した拡張PSOコマンドαのデータ構造の一例を示す図であり、(B)は、拡張PSOレスポンスαのデータ構造の一例を示す図である。(A) is a diagram showing an example of the data structure of the extended PSO command α in which the function of the PSO command is extended, and (B) is a diagram showing an example of the data structure of the extended PSO response α. 平文がn個に分割され、且つAADが用いられる場合における平文、暗号文、及び認証コードとの関係の一例を示す概念図である。It is a conceptual diagram which shows an example of the relationship with the plaintext, the ciphertext, and the authentication code when the plaintext is divided into n pieces and AAD is used. (A)は、PSOコマンドの機能を拡張した拡張PSOコマンドβのデータ構造の一例を示す図であり、(B)は、拡張PSOレスポンスβのデータ構造の一例を示す図である。(A) is a diagram showing an example of the data structure of the extended PSO command β in which the function of the PSO command is extended, and (B) is a diagram showing an example of the data structure of the extended PSO response β. 暗号文がn個に分割され、且つAADが用いられる場合における平文、暗号文、及び認証コードとの関係を示す図である。It is a figure which shows the relationship with the plaintext, the ciphertext, and the authentication code when the ciphertext is divided into n pieces and AAD is used. 暗号化対象となる平文がn個に分割される場合において外部装置2とSE1との間における拡張PSOコマンドα及び拡張PSOレスポンスαのやり取りの一例を示すシーケンス図である。It is a sequence diagram which shows an example of the exchange of the extended PSO command α and the extended PSO response α between the external device 2 and SE1 when the plaintext to be encrypted is divided into n pieces. 暗号化対象となる平文がn個に分割される場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドα及び拡張PSOレスポンスαのデータ構造の一例を示す図である。It is a figure which shows an example of the data structure of the extended PSO command α and extended PSO response α exchanged between an external device 2 and SE1 when the plaintext to be encrypted is divided into n pieces. 暗号化対象となる平文が分割されない場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドα及び拡張PSOレスポンスαのデータ構造の一例を示す図である。It is a figure which shows an example of the data structure of the extended PSO command α and extended PSO response α exchanged between an external device 2 and SE1 when the plaintext to be encrypted is not divided. 復号対象となる暗号文がn個に分割される場合において外部装置2とSE1との間における拡張PSOコマンドβ及び拡張PSOレスポンスβのやり取りの一例を示すシーケンス図である。It is a sequence diagram which shows an example of the exchange of the extended PSO command β and extended PSO response β between the external device 2 and SE1 when the ciphertext to be decrypted is divided into n pieces. 復号対象となる暗号文がn個に分割される場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドβ及び拡張PSOレスポンスβのデータ構造の一例を示す図である。It is a figure which shows an example of the data structure of the extended PSO command β and extended PSO response β exchanged between an external device 2 and SE1 when the ciphertext to be decrypted is divided into n pieces. 復号対象となる暗号文が分割されない場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドβ及び拡張PSOレスポンスβのデータ構造の一例を示す図である。It is a figure which shows an example of the data structure of the extended PSO command β and extended PSO response β exchanged between an external device 2 and SE1 when the ciphertext to be decrypted is not divided.

以下、図面を参照して本発明の実施形態について詳細に説明する。以下に説明する実施形態は、セキュアエレメント(以下、「SE」という)に対して本発明を適用した場合の実施の形態である。 Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. The embodiments described below are embodiments when 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 function]
First, the configuration and function of SE1 according to the present embodiment will be described with reference to FIG. FIG. 1 is a diagram showing a schematic configuration example 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 and the like (the ROM 12 may not be provided). SE1 is mounted and used in terminals such as IoT products and smartphones, for example. The SE1 may be mounted on the terminal as a detachable IC card, or mounted on the embedded board as an eUICC (Embedded Universal Integrated Circuit Card) so that it cannot be easily removed or replaced from the terminal (that is, with the terminal). It may be integrally formed).

CPU10は、ROM12またはNVM13に記憶された各種プログラムを実行するプロセッサ(コンピュータ)である。CPU10は、本発明における受信手段、処理手段、更新手段、及び送信手段として機能する。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 the NVM 13. The CPU 10 functions as a receiving means, a processing means, an updating means, and a transmitting means in the present invention. The 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". Various programs (including the program of the present invention) and data (for example, key data) are stored in the NVM 13. Various programs include an operating system (OS), an application, and the like. A part of 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)、及びISO7816のインターフェースなどが挙げられる。外部装置2からのコマンドは、I/O回路14を通じて受信される。また、外部装置2へのレスポンスは、I/O回路14を通じて外部装置2へ送信される。なお、本実施形態では、ISO7816-3で定義されるコマンドAPDU(Application Protocol Data Unit)及びレスポンスAPDUがSE1と外部装置2との間で送受信されるものとする。 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 on which SE1 is mounted. However, the external device 2 may be a server connected to the network or a reader / writer capable of contact (or non-contact) communication. Examples of interfaces include SPI (Serial Peripheral Interface), I 2 C (Inter-Integrated Circuit), and ISO 7816 interfaces. The command from the external device 2 is received through the I / O circuit 14. Further, the response to the external device 2 is transmitted to the external device 2 through the I / O circuit 14. In this embodiment, the command APDU (Application Protocol Data Unit) and the response APDU defined in ISO7816-3 are transmitted and received between the SE1 and the external device 2.

コマンドAPDUは、例えば、CLA、INS、P1及びP2とから構成されるヘッダと、Lc、Data及びLeとから構成されるボディとからなる。ここで、CLAはコマンドクラスを示し、INSはコマンドコードを示し、P1及びP2はコマンドパラメータを示し、例えばセキュリティオペレーションが指定される。LcはDataの長さ(データ長)を示し、LeはレスポンスAPDU内のDATAに期待される最大長を示す。Data及びDATAは、TLV(Tag-Length-Value)構造で表されるとよい。一方、レスポンスAPDUは、例えば、DATA、SW(SW1,SW2)から構成される。ここで、SWは、ステータスワードであり、コマンドAPDUに基づいて実行されたコマンド処理(換言すると、コマンドAPDUに応じた処理)の結果を示す。例えば、SWが“9000(h)”である場合、正常終了を示し、SWが例えば“6281(h)”である場合、エラー(データに異常がある)を示す。 The command APDU consists of, for example, a header composed of CLA, INS, P1 and P2, and a body composed of Lc, Data and Le. Here, CLA indicates a command class, INS indicates a command code, P1 and P2 indicate command parameters, and security operations are specified, for example. Lc indicates the length of Data (data length), and Le indicates the maximum length expected for DATA in the response APDU. Data and DATA may be represented by a TLV (Tag-Length-Value) structure. On the other hand, the response APDU is composed of, for example, DATA and SW (SW1, SW2). Here, SW is a status word and indicates the result of command processing executed based on the command APDU (in other words, processing according to the command APDU). For example, when SW is "9000 (h)", it indicates normal termination, and when SW is "6281 (h)", for example, it indicates an error (there is an abnormality in the data).

本実施形態では、ISO7816-8に規定されたPSOコマンドの機能を拡張することで、平文の暗号化と認証コードの生成(複数種類のセキュリティオペレーション)とを同タイミングで実行させることを可能とし、また、暗号文の復号と認証コードの検証(複数種類のセキュリティオペレーション)とを同タイミングで実行させることを可能とした。ここで、同タイミングで実行させるとは、1つのコマンドAPDUの受信から当該コマンドAPDUに対するレスポンスAPDUの送信までの時間内に実行させることを意味する。なお、1つの平文から分割された各平文、或いは、1つの暗号文から分割された各暗号文がそれぞれのコマンドAPDUにより処理される場合、同タイミングで実行させるとは、複数のコマンドAPDUの中の少なくとも1つのコマンドAPDUの受信から当該コマンドAPDUに対するレスポンスAPDUの送信までの時間内に実行させるものとすればよい。 In this embodiment, by extending the function of the PSO command specified in ISO7816-8, it is possible to execute plaintext encryption and authentication code generation (multiple types of security operations) at the same timing. In addition, it is possible to execute the decryption of the ciphertext and the verification of the authentication code (multiple types of security operations) at the same timing. Here, to execute at the same timing means to execute within the time from the reception of one command APDU to the transmission of the response APDU for the command APDU. When each plaintext divided from one plaintext or each ciphertext divided from one ciphertext is processed by each command APDU, it is said that the execution is performed at the same timing among a plurality of command APDUs. It may be executed within the time from the reception of at least one command APDU of the above to the transmission of the response APDU in response to the command APDU.

ところで、従来技術では、ICカードが外部からのコマンドAPDUに応じて、暗号文と、当該暗号文の改竄等をチェックするための認証コードとを外部装置2へ提供するためには、先ずはP1及びP2により暗号化(ENCIPHER)が指定されたPSOコマンドに応じて平文を暗号化して暗号文を生成し当該暗号文を含むレスポンスを送信し、その後、当該暗号文を含みP1及びP2により認証コード生成(COMPUTE DIGITAL SIGNATURE)が指定されたPSOコマンドに応じて当該暗号文から認証コードを生成し当該認証コードを含むレスポンスを送信するようになっていた。この場合、特に、暗号化対象となる平文が長いと、SE1と外部装置2との間の暗号文のやり取りに無駄な時間を費やしてしまい効率が悪い。このことは、暗号文の復号(DECIPHER)と認証コードの検証(VERIFY DIGITAL SIGNATURE)においても同様のことが言える。本実施形態によれば、このように無駄な時間を費やすことを低減して時間の効率化を図ることができる。 By the way, in the prior art, in order for the IC card to provide the external device 2 with the encryption text and the authentication code for checking the falsification of the encryption text in response to the command APDU from the outside, first, P1 And P2 encrypts (ENCIPHER) in response to the specified PSO command, encrypts the plain text, generates a cipher, sends a response containing the cipher, and then sends the response including the cipher, and then the authentication code by P1 and P2 including the cipher. An authentication code was generated from the cipher statement in response to the PSO command for which generation (COMPUTE DIGITAL SIGNATURE) was specified, and a response including the authentication code was sent. In this case, in particular, if the plaintext to be encrypted is long, wasteful time is wasted in exchanging the ciphertext between the SE1 and the external device 2, resulting in inefficiency. The same can be said for the decryption of ciphertext (DECIPHER) and the verification of authentication code (VERIFY DIGITAL SIGNATURE). According to the present embodiment, it is possible to reduce such wasted time and improve time efficiency.

図2(A)は、PSOコマンドの機能を拡張した拡張PSOコマンドαのデータ構造の一例を示す図であり、図2(B)は、拡張PSOレスポンスαのデータ構造の一例を示す図である。拡張PSOコマンドαは、図2(A)に示すように、INSによりPSOコマンドが示され、P1及びP2によりセキュリティオペレーションとしての平文の暗号化及び認証コードの生成が指定され、Dataに平文が含まれて構成される。また、拡張PSOレスポンスαは、図2(B)に示すように、DATAに暗号文及び認証コードが含まれて構成される。なお、拡張PSOコマンドαに応じた処理が正常に行われた場合、拡張PSOレスポンスαにおけるSWにより正常終了(9000(h))が示される。 FIG. 2A is a diagram showing an example of the data structure of the extended PSO command α in which the function of the PSO command is extended, and FIG. 2B is a diagram showing an example of the data structure of the extended PSO response α. .. As shown in Fig. 2 (A), the extended PSO command α indicates the PSO command by INS, and P1 and P2 specify plaintext encryption and authentication code generation as security operations, and the data contains plaintext. Is composed of. Further, as shown in FIG. 2B, the extended PSO response α is configured by including a ciphertext and an authentication code in DATA. If the processing according to the extended PSO command α is performed normally, the SW in the extended PSO response α indicates a normal end (9000 (h)).

CPU10は、外部装置2からI/O回路14を通じて拡張PSOコマンドαを受信すると、拡張PSOコマンドαに応じて、拡張PSOコマンドαに含まれる平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成し、生成された暗号文及び認証コードを含む拡張PSOレスポンスαをI/O回路14を通じて外部装置2へ送信する。ここで、平文の暗号化及び認証コードの生成は、例えば、AES-GCMやAES-CBC(Cipher Block Chaining)等のアルゴリズムにより行われるとよい。なお、平文の暗号化にはIV(Initialization Vector)が用いられ、認証コードの生成にはAAD(Additional Authenticated Data)が用いられるとよい。IVにより同一の平文及び同一の鍵データから異なる暗号文が生成可能となる。同様に、AADにより同一の平文及び同一の鍵データから異なる暗号文が生成可能となる。ここで、AES-GCMのアルゴリズムが用いられる場合、平文の暗号化と認証コードの生成とは、同一の鍵データ(1本の鍵)が使用される。一方、AES-CBCのアルゴリズムが用いられる場合、平文の暗号化では鍵データには暗号化用の暗号鍵が使用され、認証コードの生成では鍵データには認証コード生成用の認証鍵が使用される(つまり、平文の暗号化と認証コードの生成とで鍵データが分けられる)。 When the CPU 10 receives the extended PSO command α from the external device 2 through the I / O circuit 14, the CPU 10 encrypts the plaintext included in the extended PSO command α in response to the extended PSO command α to generate a ciphertext, and generates the ciphertext. An authentication code is generated based on the generated ciphertext, and an extended PSO response α including the generated ciphertext and the authentication code is transmitted to the external device 2 through the I / O circuit 14. Here, plaintext encryption and authentication code generation may be performed by, for example, an algorithm such as AES-GCM or AES-CBC (Cipher Block Chaining). It is recommended that IV (Initialization Vector) is used for plaintext encryption, and AAD (Additional Authenticated Data) is used for generating the authentication code. IV makes it possible to generate different ciphertexts from the same plaintext and the same key data. Similarly, AAD allows different ciphertexts to be generated from the same plaintext and the same key data. Here, when the AES-GCM algorithm is used, the same key data (one key) is used for plaintext encryption and authentication code generation. On the other hand, when the AES-CBC algorithm is used, the encryption key for encryption is used for the key data in plain text encryption, and the authentication key for authentication code generation is used for the key data in the generation of the authentication code. (That is, the key data is divided between plain text encryption and authentication code generation).

また、平文の長さが1回分の拡張PSOコマンドαのDataに含めることが可能な長さ(つまり、Lcにより指定可能なデータ長)を超える場合、または平文から生成される暗号文の長さが1回分の拡張PSOレスポンスαのDATAに含めることが可能の長さ(つまり、Leにより指定可能なデータ長)を超える場合、当該平文は外部装置2により複数に分割されることになる。この場合、CPU10は、n(例えば、n>3)個に分割された平文1〜nのうちの1つの平文を含み、当該平文の暗号化及び認証コードの生成を指定する拡張PSOコマンドαを外部装置2から複数回受信(各拡張PSOコマンドα間には拡張PSOレスポンスαの送信が介在)する。そして、CPU10は、拡張PSOコマンドαを受信するごとに、当該受信された平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コード(例えば、MAC(Message Authentication Code))を生成することになる。 Also, if the plaintext length exceeds the length that can be included in the Data of one extended PSO command α (that is, the data length that can be specified by Lc), or the length of the ciphertext generated from the plaintext. If exceeds the length that can be included in the DATA of the extended PSO response α for one time (that is, the data length that can be specified by Le), the plaintext is divided into a plurality of parts by the external device 2. In this case, the CPU 10 includes an extended PSO command α that includes one of the plaintexts 1 to n divided into n (for example, n> 3) and specifies the encryption of the plaintext and the generation of the authentication code. Received multiple times from the external device 2 (transmission of extended PSO response α intervenes between each extended PSO command α). Then, each time the CPU 10 receives the extended PSO command α, the received plaintext is encrypted to generate a ciphertext, and an authentication code (for example, MAC (Message Authentication Code)) is generated based on the generated ciphertext. )) Will be generated.

例えば、CPU10は、2番目の平文2を含む拡張PSOコマンドαから最後の平文nを含む拡張PSOコマンドαのそれぞれの受信においては今回受信された平文と前回生成された暗号文と鍵データとを用いて新たな暗号文を生成すれば、セキュリティを高めることができる。例えば、AES-GCMのアルゴリズムの場合、暗号文1を鍵データ(鍵データとIVとから生成された鍵データでもよい)で暗号化した値と平文2とのXORがとられることで暗号文2が生成される。また、AES-CBCのアルゴリズムの場合、平文2と暗号文1とのXORの値が暗号鍵で暗号化されることで暗号文2が生成される。ただし、平文2が鍵データで暗号化されることで暗号文2が生成されてもよいし、或いは、暗号化には公知の演算処理が追加されてもよい。一方、最初(1番目)の平文1を含む拡張PSOコマンドαの受信においては前回生成された暗号文がないため、CPU10は、今回受信された平文1とIVと鍵データとを用いて暗号文1を生成すれば、セキュリティを高めることができる。例えば、AES-GCMのアルゴリズムの場合、IVを鍵データで暗号化した値と平文1とのXORがとられることで暗号文1が生成される。また、AES-CBCのアルゴリズムの場合、平文1とIVとのXORの値が暗号鍵で暗号化されることで暗号文1が生成される。ただし、IVを用いずに暗号文1が生成されてもよく、この場合、平文1が鍵データで暗号化されることで暗号文1が生成されるとよいし、或いは、暗号化には公知の演算処理が追加されてもよい。なお、平文が分割されない場合であっても、IVを鍵データで暗号化した値と平文とのXORから暗号文が生成されてもよいし、受信された平文とIVとのXORの値が鍵データで暗号化されることで暗号文が生成されてもよいし、或いは、平文が鍵データで暗号化されることで暗号文が生成されてもよい。 For example, in each reception of the extended PSO command α including the second plaintext 2 to the extended PSO command α including the last plaintext n, the CPU 10 uses the plaintext received this time, the ciphertext generated last time, and the key data. Security can be enhanced by using it to generate new ciphertext. For example, in the case of the AES-GCM algorithm, ciphertext 2 is obtained by taking the XOR of plaintext 2 and the value obtained by encrypting ciphertext 1 with key data (key data generated from key data and IV may be used). Is generated. In the case of the AES-CBC algorithm, ciphertext 2 is generated by encrypting the XOR values of plaintext 2 and ciphertext 1 with an encryption key. However, the ciphertext 2 may be generated by encrypting the plaintext 2 with the key data, or a known arithmetic process may be added to the encryption. On the other hand, in the reception of the extended PSO command α including the first (first) plaintext 1, there is no ciphertext generated last time, so the CPU 10 uses the plaintext 1, IV, and key data received this time to generate the ciphertext. If you generate 1, you can increase security. For example, in the case of the AES-GCM algorithm, ciphertext 1 is generated by XORing the value obtained by encrypting IV with key data and plaintext 1. In the case of the AES-CBC algorithm, ciphertext 1 is generated by encrypting the XOR values of plaintext 1 and IV with an encryption key. However, ciphertext 1 may be generated without using IV. In this case, ciphertext 1 may be generated by encrypting plaintext 1 with key data, or known for encryption. Arithmetic processing may be added. Even if the plaintext is not divided, the ciphertext may be generated from the XOR of the plaintext and the value obtained by encrypting the IV with the key data, and the received plaintext and the XOR value of the IV are the keys. The ciphertext may be generated by being encrypted with data, or the ciphertext may be generated by encrypting the plaintext with key data.

また、CPU10は、2番目の平文2を含む拡張PSOコマンドαから最後の平文nを含む拡張PSOコマンドαのそれぞれの受信においては今回(つまり、当該受信の際に)生成された暗号文と前回生成された認証コードとを用いて新たな認証コードを生成すれば、セキュリティを高めることができる。例えば、AES-GCMのアルゴリズムの場合、今回生成された暗号文2を鍵データで暗号化した値と前回生成された認証コードとのXORがとられることで新たな認証コードが生成される。また、AES-CBCのアルゴリズムの場合、例えば、今回生成された暗号文2を認証鍵で暗号した値と前回生成された認証コードとのXORがとられることで新たな認証コードが生成される。一方、最初の平文1を含む拡張PSOコマンドαの受信においては前回生成された認証コードがないため、CPU10は、今回生成された暗号文1とAADとを用いて認証コードを生成すれば、セキュリティを高めることができる。例えば、今回生成された暗号文1にADDが連結されることで認証コードが生成される。ただし、AADを用いずに認証コードが生成されてもよく、この場合、暗号文1が認証コードとして生成されるとよい。なお、平文が分割されない場合であっても、暗号文にADDが連結されることで認証コードが生成されてもよいし、暗号文1が認証コードとして生成されてもよい。 Further, the CPU 10 receives the ciphertext generated this time (that is, at the time of the reception) and the previous time in each reception of the extended PSO command α including the second plaintext 2 to the extended PSO command α including the last plaintext n. Security can be enhanced by generating a new authentication code using the generated authentication code. For example, in the case of the AES-GCM algorithm, a new authentication code is generated by XORing the value obtained by encrypting the ciphertext 2 generated this time with the key data and the authentication code generated last time. Further, in the case of the AES-CBC algorithm, for example, a new authentication code is generated by taking an XOR between the value obtained by encrypting the ciphertext 2 generated this time with the authentication key and the authentication code generated last time. On the other hand, when receiving the extended PSO command α including the first plaintext 1, there is no authentication code generated last time, so if the CPU 10 generates an authentication code using the ciphertext 1 and AAD generated this time, security Can be enhanced. For example, an authentication code is generated by concatenating ADD with the ciphertext 1 generated this time. However, the authentication code may be generated without using AAD, and in this case, the ciphertext 1 may be generated as the authentication code. Even when the plaintext is not divided, the authentication code may be generated by concatenating the ADD with the ciphertext, or the ciphertext 1 may be generated as the authentication code.

以上のように生成された認証コードは例えばRAM11の一時保持領域に記憶され、その後、順次生成される認証コードにより更新(例えば、上書き更新)される。つまり、前回生成されてRAM11に記憶された認証コードは、今回生成された認証コードにより更新(時系列で順次更新)される。図3は、平文がn個に分割され、且つAADが用いられる場合における平文、暗号文、及び認証コードとの関係の一例を示す概念図である。図3に示すように、結果的には、平文1〜nを結合した平文Nから、暗号文1〜nを結合した暗号文Nが生成され、当該暗号文NとAADとから認証コードが生成されることになる。 The authentication code generated as described above is stored in, for example, a temporary holding area of the RAM 11, and is subsequently updated (for example, overwritten and updated) by the sequentially generated authentication code. That is, the authentication code generated last time and stored in the RAM 11 is updated (sequentially updated in chronological order) by the authentication code generated this time. FIG. 3 is a conceptual diagram showing an example of the relationship between the plaintext, the ciphertext, and the authentication code when the plaintext is divided into n pieces and AAD is used. As shown in FIG. 3, as a result, the ciphertext N in which the ciphertexts 1 to n are combined is generated from the plaintext N in which the plaintexts 1 to n are combined, and the authentication code is generated from the ciphertext N and the AAD. Will be done.

そして、CPU10は、複数に分割された平文のうちの最後の平文以外の平文の暗号化においては生成された暗号文を含み且つ生成された認証コードを含まない拡張PSOレスポンスαを外部装置2を送信する。一方、CPU10は、最後の平文の暗号化においては生成された暗号文及び生成された認証コードを含む拡張PSOレスポンスαを外部装置2を送信する。つまり、最後の拡張PSOコマンドαが受信された場合に限り、拡張PSOコマンドαに応じて生成された暗号文に加えて、生成された認証コードが含まれる拡張PSOレスポンスαが外部装置2へ送信されることになるので、時間の効率化を図ることができる。 Then, the CPU 10 provides the external device 2 with an extended PSO response α that includes the generated ciphertext and does not include the generated authentication code in the encryption of the plaintext other than the last plaintext among the plaintext divided into a plurality of parts. Send. On the other hand, in the final plaintext encryption, the CPU 10 transmits the extended PSO response α including the generated ciphertext and the generated authentication code to the external device 2. That is, only when the last extended PSO command α is received, the extended PSO response α including the generated authentication code is transmitted to the external device 2 in addition to the ciphertext generated in response to the extended PSO command α. Therefore, it is possible to improve the efficiency of time.

一方、図4(A)は、PSOコマンドの機能を拡張した拡張PSOコマンドβのデータ構造の一例を示す図であり、図4(B)は、拡張PSOレスポンスβのデータ構造の一例を示す図である。拡張PSOコマンドβは、図4(A)に示すように、INSによりPSOコマンドが示され、P1及びP2によりセキュリティオペレーションとしての暗号文の復号及び認証コードの検証が指定され、Dataに暗号文が含まれて構成される。また、拡張PSOレスポンスβは、拡張PSOコマンドβに応じた処理が正常に行われた場合、図4(B)に示すように、DATAに平文が含まれて構成される。なお、拡張PSOコマンドβに応じた処理が正常に行われ、認証コードの検証結果が検証成功である場合、拡張PSOレスポンスβにおけるSWにより正常終了(9000(h))が示される。一方、拡張PSOコマンドβに応じた処理が正常に行われ、認証コードの検証結果が検証失敗である場合、拡張PSOレスポンスβにおけるSWによりエラー(6281(h))が示されることになる。 On the other hand, FIG. 4 (A) is a diagram showing an example of the data structure of the extended PSO command β in which the function of the PSO command is extended, and FIG. 4 (B) is a diagram showing an example of the data structure of the extended PSO response β. Is. In the extended PSO command β, as shown in FIG. 4 (A), the PSO command is indicated by INS, the decryption of the ciphertext and the verification of the authentication code as security operations are specified by P1 and P2, and the ciphertext is stored in Data. Included and composed. Further, the extended PSO response β is configured by including plaintext in DATA as shown in FIG. 4B when the processing according to the extended PSO command β is normally performed. If the processing according to the extended PSO command β is performed normally and the verification result of the authentication code is verified successfully, the SW in the extended PSO response β indicates a normal end (9000 (h)). On the other hand, if the processing according to the extended PSO command β is performed normally and the verification result of the authentication code fails, the SW in the extended PSO response β will indicate an error (6281 (h)).

CPU10は、外部装置2からI/O回路14を通じて拡張PSOコマンドβを受信すると、拡張PSOコマンドβに応じて、拡張PSOコマンドβに含まれる暗号文を復号して平文を抽出し、且つ当該暗号文に基づいて認証コードを生成し当該認証コードを検証し、抽出された平文及び認証コードの検証結果を含む拡張PSOレスポンスβをI/O回路14を通じて外部装置2へ送信する。ここで、暗号文の復号は、例えば、AES-GCMやAES-CBC等のアルゴリズムにより行われるとよい。なお、暗号文の復号にはIVが用いられるとよい。 When the CPU 10 receives the extended PSO command β from the external device 2 through the I / O circuit 14, the CPU 10 decrypts the ciphertext included in the extended PSO command β in response to the extended PSO command β, extracts the plaintext, and performs the ciphertext. An authentication code is generated based on the statement, the authentication code is verified, and an extended PSO response β including the extracted plaintext and the verification result of the authentication code is transmitted to the external device 2 through the I / O circuit 14. Here, the decryption of the ciphertext may be performed by, for example, an algorithm such as AES-GCM or AES-CBC. It is preferable that IV is used for decrypting the ciphertext.

また、暗号文の長さが1回分の拡張PSOコマンドβのDataに含めることが可能の長さ(つまり、Lcにより指定可能なデータ長)を超える場合、当該暗号文は外部装置2により複数に分割されることになる。この場合、CPU10は、n(例えば、n>3)個に分割された暗号文1〜nのうちの1つの暗号文を含み、当該暗号文の復号及び認証コードの検証を指定する拡張PSOコマンドβを複数回受信(各拡張PSOコマンドβ間には拡張PSOレスポンスβの送信が介在)する。そして、CPU10は、拡張PSOコマンドβを受信するごとに、受信された暗号文を復号して平文を抽出し、且つ当該受信された暗号文に基づいて認証コードを生成することになる。 If the length of the ciphertext exceeds the length that can be included in the Data of the extended PSO command β for one time (that is, the data length that can be specified by Lc), the ciphertext is divided into a plurality by the external device 2. It will be divided. In this case, the CPU 10 includes an extended PSO command that includes one of the ciphertexts 1 to n divided into n (for example, n> 3) and specifies the decryption of the ciphertext and the verification of the authentication code. Receive β multiple times (transmission of extended PSO response β intervenes between each extended PSO command β). Then, each time the CPU 10 receives the extended PSO command β, the received ciphertext is decrypted to extract the plaintext, and the authentication code is generated based on the received ciphertext.

例えば、CPU10は、2番目の暗号文2を含む拡張PSOコマンドβから最後の暗号文nを含む拡張PSOコマンドβのそれぞれの受信においては今回受信された暗号文と前回生成された暗号文と鍵データを用いて平文を抽出する。例えば、AES-GCMのアルゴリズムの場合、暗号文1を鍵データで復号した値と暗号文2とのXORがとられることで平文2が抽出される。また、AES-CBCのアルゴリズムの場合、暗号文2を暗号鍵で復号した値と暗号文1とのXORがとられることで平文2が抽出される。ただし、暗号文2を鍵データで復号することにより平文2が抽出されてもよいし、或いは、復号には公知の演算処理が追加されてもよい。一方、最初の暗号文1を含む拡張PSOコマンドβの受信においては前回受信された暗号文がないため、CPU10は、今回受信された暗号文とIVと鍵データとを用いて平文を抽出する。例えば、AES-GCMのアルゴリズムの場合、IV(暗号化されたIV)を暗号データで復号した値と暗号文1とのXORがとられることで平文1が抽出される。また、AES-CBCのアルゴリズムの場合、暗号文1を暗号鍵で復号した値とIVとのXORがとられることで平文1が抽出される。ただし、暗号文1を鍵データで復号することにより平文1が抽出されてもよいし、或いは、復号には公知の演算処理が追加されてもよい。なお、暗号文が分割されない場合であってもIV(暗号化されたIV)を暗号データで復号した値と暗号文とのXORから平文が抽出されてもよいし、暗号文を鍵データで復号した値とIVとのXORから平文が抽出されてもよいし、或いは、受信された暗号文が鍵データで復号されることにより平文が抽出されてもよい。 For example, in each reception of the extended PSO command β including the second ciphertext 2 to the extended PSO command β including the last ciphertext n, the CPU 10 receives the ciphertext received this time, the ciphertext generated last time, and the key. Extract plaintext using the data. For example, in the case of the AES-GCM algorithm, plaintext 2 is extracted by taking the XOR of the value obtained by decrypting ciphertext 1 with the key data and ciphertext 2. In the case of the AES-CBC algorithm, plaintext 2 is extracted by taking the XOR between the value obtained by decrypting ciphertext 2 with the encryption key and ciphertext 1. However, the plaintext 2 may be extracted by decrypting the ciphertext 2 with the key data, or a known arithmetic processing may be added to the decryption. On the other hand, in the reception of the extended PSO command β including the first ciphertext 1, since there is no ciphertext received last time, the CPU 10 extracts the plaintext using the ciphertext received this time, the IV, and the key data. For example, in the case of the AES-GCM algorithm, plaintext 1 is extracted by taking the XOR of the value obtained by decrypting IV (encrypted IV) with encrypted data and ciphertext 1. In the case of the AES-CBC algorithm, plaintext 1 is extracted by taking the XOR of the value obtained by decrypting ciphertext 1 with the encryption key and IV. However, the plaintext 1 may be extracted by decrypting the ciphertext 1 with the key data, or a known arithmetic processing may be added to the decryption. Even if the ciphertext is not divided, the plaintext may be extracted from the XOR of the value obtained by decrypting the IV (encrypted IV) with the encrypted data and the ciphertext, or the ciphertext is decrypted with the key data. The plaintext may be extracted from the XOR of the value obtained and the IV, or the plaintext may be extracted by decrypting the received ciphertext with the key data.

また、CPU10は、上記と同様、2番目の暗号文2を含む拡張PSOコマンドβから最後の暗号文nを含む拡張PSOコマンドβの受信においては今回受信された暗号文と前回生成された認証コードとを用いて新たな認証コードを生成するとよい。例えば、AES-GCMのアルゴリズムの場合、今回受信された暗号文2を鍵データで復号した値と前回生成された認証コードとのXORがとられることで新たな認証コードが生成される。また、AES-CBCのアルゴリズムの場合、今回受信された暗号文2を認証鍵で復号した値と前回生成された認証コードとのXORがとられることで新たな認証コードが生成される。一方、最初の暗号文1を含む拡張PSOコマンドβの受信においては前回生成された認証コードがないため、上記と同様、CPU10は、今回受信された暗号文1とAADと用いて認証コードを生成するとよい。例えば、今回生成された暗号文1にADDが連結されることで認証コードが生成される。なお、暗号文が分割されない場合であっても、暗号文にADDが連結されることで認証コードが生成されてもよい。以上のように生成された認証コードは例えばRAM11の一時保持領域に記憶され、その後、順次生成される認証コードにより更新される。 Further, similarly to the above, the CPU 10 receives the ciphertext received this time and the authentication code generated last time when receiving the extended PSO command β including the last ciphertext n from the extended PSO command β including the second ciphertext 2. It is advisable to generate a new authentication code using and. For example, in the case of the AES-GCM algorithm, a new authentication code is generated by taking the XOR of the value obtained by decrypting the ciphertext 2 received this time with the key data and the authentication code generated last time. In the case of the AES-CBC algorithm, a new authentication code is generated by taking the XOR of the value obtained by decrypting the ciphertext 2 received this time with the authentication key and the authentication code generated last time. On the other hand, since there is no previously generated authentication code when receiving the extended PSO command β including the first ciphertext 1, the CPU 10 generates an authentication code using the ciphertext 1 and AAD received this time as in the above. It is good to do it. For example, an authentication code is generated by concatenating ADD with the ciphertext 1 generated this time. Even if the ciphertext is not divided, the authentication code may be generated by concatenating the ADD with the ciphertext. The authentication code generated as described above is stored in, for example, a temporary holding area of the RAM 11, and is subsequently updated by the sequentially generated authentication code.

さらに、CPU10は、最後の暗号文を含む拡張PSOコマンドβの受信においては、このとき生成された認証コードを検証する。例えば、外部装置2から受信されて例えばRAM11に保存された検証用認証コードと、最後の暗号文を含む拡張PSOコマンドβの受信において生成された認証コードとが比較されることで検証(例えば、検証用認証コードと認証コードとが一致するか否かが判定)される。図5は、暗号文がn個に分割され、且つAADが用いられる場合における平文、暗号文、及び認証コードとの関係を示す図である。図5に示すように、結果的には、暗号文1〜nを結合した暗号文Nから、平文1〜nを結合した平文Nが生成され、当該暗号文NとAADとから認証コードが生成され、当該生成された認証コードと検証用認証コードとが比較されることになる。 Further, the CPU 10 verifies the authentication code generated at this time when receiving the extended PSO command β including the last ciphertext. For example, verification is performed by comparing the verification authentication code received from the external device 2 and stored in, for example, RAM 11 with the authentication code generated in the reception of the extended PSO command β including the last ciphertext (for example,). It is determined whether or not the verification authentication code and the authentication code match). FIG. 5 is a diagram showing the relationship between the plaintext, the ciphertext, and the authentication code when the ciphertext is divided into n pieces and AAD is used. As shown in FIG. 5, as a result, the plaintext N in which the plaintexts 1 to n are combined is generated from the ciphertext N in which the ciphertexts 1 to n are combined, and the authentication code is generated from the ciphertext N and the AAD. Then, the generated authentication code and the verification authentication code are compared.

そして、CPU10は、複数に分割された暗号文のうちの最後の暗号文以外の暗号文の復号においては抽出された平文を含む拡張PSOレスポンスβを外部装置2へ送信する。一方、CPU10は、最後の暗号文の復号においては抽出された平文及び認証コードの検証結果(例えば、検証成功、または検証失敗)を含む拡張PSOレスポンスβを外部装置2へ送信する。つまり、最後の拡張PSOコマンドβが受信された場合に限り、拡張PSOコマンドβに応じて最後の平文の抽出及び認証コードの検証が行われ、当該抽出された平文に加えて、認証コードの検証結果が含まれる拡張PSOレスポンスβが外部装置2へ送信されることになるので、時間の効率化を図ることができる。 Then, the CPU 10 transmits an extended PSO response β including the extracted plaintext to the external device 2 in decrypting the ciphertext other than the last ciphertext among the ciphertexts divided into a plurality of parts. On the other hand, the CPU 10 transmits the extended PSO response β including the verification result (for example, verification success or verification failure) of the extracted plaintext and the authentication code to the external device 2 in the decryption of the final ciphertext. That is, only when the last extended PSO command β is received, the last plaintext is extracted and the authentication code is verified according to the extended PSO command β, and the authentication code is verified in addition to the extracted plaintext. Since the extended PSO response β including the result is transmitted to the external device 2, time efficiency can be improved.

[2.SE1と外部装置2との間で実施される動作]
次に、SE1と外部装置2との間で実施される動作について説明する。
[2. Operation performed between SE1 and external device 2]
Next, the operation performed between the SE 1 and the external device 2 will be described.

(2.1.平文の暗号化と認証コードの生成)
先ず、図6〜図8を参照して、外部装置2が平文の暗号化及び認証コードの生成をSE1に実行させる際の動作について説明する。なお、以下の動作においては、平文の暗号化、暗号文の復号、及び認証コードの生成には、IV及びAADが用いられる場合を例にとるものとする。図6は、暗号化対象となる平文がn個に分割される場合において外部装置2とSE1との間における拡張PSOコマンドα及び拡張PSOレスポンスαのやり取りの一例を示すシーケンス図である。図7は、暗号化対象となる平文がn個に分割される場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドα及び拡張PSOレスポンスαのデータ構造の一例を示す図である。
(2.1. Plaintext encryption and authentication code generation)
First, with reference to FIGS. 6 to 8, the operation when the external device 2 causes the SE1 to execute plaintext encryption and authentication code generation will be described. In the following operations, the case where IV and AAD are used for plaintext encryption, ciphertext decryption, and authentication code generation shall be taken as an example. FIG. 6 is a sequence diagram showing an example of the exchange of the extended PSO command α and the extended PSO response α between the external device 2 and the SE1 when the plaintext to be encrypted is divided into n pieces. FIG. 7 is a diagram showing an example of the data structure of the extended PSO command α and the extended PSO response α exchanged between the external device 2 and the SE1 when the plaintext to be encrypted is divided into n pieces. ..

外部装置2は、暗号化対象となる平文の長さとして平文長を取得し、当該平文をn(n>3)個に分割する。そして、外部装置2は、拡張PSOコマンドα-0をSE1へ送信する(ステップS1)。図7(A)に示すように、拡張PSOコマンドα-0におけるCLA“10(h)”は後に拡張PSOコマンドαが連鎖する(つまり、チェイニング中である)ことを示しており、また、拡張PSOコマンドα-0におけるDataにはAAD及び平文長がTLV構造で含まれている。 The external device 2 acquires the plaintext length as the length of the plaintext to be encrypted, and divides the plaintext into n (n> 3) pieces. Then, the external device 2 transmits the extended PSO command α-0 to SE1 (step S1). As shown in FIG. 7 (A), CLA “10 (h)” in the extended PSO command α-0 indicates that the extended PSO command α is later chained (that is, in chaining), and also. Data in the extended PSO command α-0 contains AAD and plaintext length in TLV structure.

SE1は、外部装置2からの拡張PSOコマンドα-0を受信すると、当該拡張PSOコマンドα-0からAAD及び平文長を取得して例えばRAM11の一時保持領域に記憶し、拡張PSOレスポンスα-0を外部装置2へ送信する(ステップS2)。図7(B)に示すように、拡張PSOレスポンスα-0におけるDATAには暗号文長がTLV構造で含まれており、拡張PSOレスポンスα-0におけるSWは正常終了(9000(h))を示している。 When the SE1 receives the extended PSO command α-0 from the external device 2, it acquires the AAD and the plaintext length from the extended PSO command α-0, stores them in the temporary holding area of the RAM 11, for example, and stores the extended PSO response α-0. Is transmitted to the external device 2 (step S2). As shown in FIG. 7B, the DATA in the extended PSO response α-0 contains the ciphertext length in a TLV structure, and the SW in the extended PSO response α-0 terminates normally (9000 (h)). Shown.

外部装置2は、SE1からの拡張PSOレスポンスα-0を受信すると、拡張PSOレスポンスα-0から暗号文長を取得し、拡張PSOコマンドα-1をSE1へ送信する(ステップS3)。図7(C)に示すように、拡張PSOコマンドα-1におけるDataにはn個に分割された平文1〜nのうち最初の平文1が含まれている。 When the external device 2 receives the extended PSO response α-0 from the SE1, it acquires the ciphertext length from the extended PSO response α-0 and transmits the extended PSO command α-1 to the SE1 (step S3). As shown in FIG. 7C, the Data in the extended PSO command α-1 includes the first plaintext 1 of the n-divided plaintexts 1 to n.

SE1は、外部装置2からの拡張PSOコマンドα-1を受信すると、当該拡張PSOコマンドα-1から平文1を取得し、当該取得された平文1とIVと鍵データとを用いた暗号化により暗号文1を生成する(ステップS4)。ここで、IVはSE1内で生成されてもよいし、拡張PSOコマンドα-0におけるDataに含まれて(つまり、PSOコマンドα-0から取得されて)もよい。次いで、SE1は、RAM11の一時保持領域に記憶されたAADとステップS4で生成された暗号文1とを用いて認証コードを生成する(ステップS5)。こうして生成された認証コードは、例えばRAM11の一時保持領域に記憶される。 When the SE1 receives the extended PSO command α-1 from the external device 2, it acquires the plaintext 1 from the extended PSO command α-1 and encrypts the acquired plaintext 1 and IV using the key data. Generate the ciphertext 1 (step S4). Here, the IV may be generated in SE1 or included in the Data in the extended PSO command α-0 (that is, obtained from the PSO command α-0). Next, SE1 generates an authentication code using the AAD stored in the temporary holding area of the RAM 11 and the ciphertext 1 generated in step S4 (step S5). The authentication code generated in this way is stored in, for example, a temporary holding area of the RAM 11.

次いで、SE1は、拡張PSOレスポンスα-1を外部装置2へ送信する(ステップS6)。図7(D)に示すように、拡張PSOレスポンスα-1におけるDATAにはステップS4で生成された暗号文1が含まれており、拡張PSOレスポンスα-1におけるSWは正常終了(9000(h))を示している。 Next, SE1 transmits the extended PSO response α-1 to the external device 2 (step S6). As shown in FIG. 7 (D), the DATA in the extended PSO response α-1 includes the ciphertext 1 generated in step S4, and the SW in the extended PSO response α-1 ends normally (9000 (h)). )) Is shown.

こうして拡張PSOレスポンスα-1が外部装置2により受信された後、外部装置2から拡張PSOコマンドα-2から拡張PSOコマンドα-(n-1)がSE1へ順次送信され、上記と同様に処理が行われる。そして、外部装置2は、SE1からの拡張PSOレスポンスα-(n-1)を受信すると、拡張PSOレスポンスα-(n-1)から暗号文n-1を取得し、最後の拡張PSOコマンドα-nをSE1へ送信する(ステップS7)。図7(E)に示すように、拡張PSOコマンドα-nにおけるCLA“00(h)”は後に拡張PSOコマンドαが連鎖しないことを示しており、また、拡張PSOコマンドα-nにおけるDataには最後の平文nが含まれている。なお、最後の拡張PSOコマンドα-nに対する拡張PSOレスポンスα-nには暗号文nに加えてIV及び認証コードが含まれることになるため、このことを考慮して、平文nの上限長が設けられるとよい。 After the extended PSO response α-1 is received by the external device 2 in this way, the extended PSO command α- (n-1) is sequentially transmitted from the external device 2 to the SE1 from the extended PSO command α-2, and is processed in the same manner as above. Is done. Then, when the external device 2 receives the extended PSO response α- (n-1) from SE1, the external device 2 acquires the ciphertext n-1 from the extended PSO response α- (n-1), and the last extended PSO command α. -n is transmitted to SE1 (step S7). As shown in FIG. 7 (E), CLA “00 (h)” in the extended PSO command α-n indicates that the extended PSO command α is not chained later, and the Data in the extended PSO command α-n Contains the last plaintext n. Since the extended PSO response α-n to the last extended PSO command α-n includes the IV and the authentication code in addition to the ciphertext n, the upper limit length of the plaintext n is set in consideration of this. It is good to be provided.

SE1は、外部装置2からの拡張PSOコマンドα-nを受信すると、当該拡張PSOコマンドα-nから平文nを取得し、当該取得された平文nと前回生成された暗号文n-1と鍵データとを用いた暗号化により暗号文nを生成する(ステップS8)。次いで、SE1は、ステップS8で生成された暗号文nと前回生成された認証コードとを用いて新たな認証コードを生成する(ステップS9)。こうして生成された認証コードは、例えばRAM11の一時保持領域に前回記憶された認証コードに対して上書き記憶される。 When the SE1 receives the extended PSO command α-n from the external device 2, it acquires the plaintext n from the extended PSO command α-n, and the acquired plaintext n, the previously generated ciphertext n-1, and the key. Ciphertext n is generated by encryption using data (step S8). Next, SE1 generates a new authentication code by using the ciphertext n generated in step S8 and the previously generated authentication code (step S9). The authentication code generated in this way is overwritten and stored, for example, over the authentication code previously stored in the temporary holding area of the RAM 11.

次いで、SE1は、拡張PSOレスポンスα-nを外部装置2へ送信する(ステップS10)。図7(F)に示すように、拡張PSOレスポンスα-nにおけるDATAにはステップS8で生成された暗号文n、ステップS4で暗号化に用いられたIV、及びステップS9で生成された認証コードがTLV構造で含まれており、拡張PSOレスポンスα-nにおけるSWは正常終了(9000(h))を示している。なお、IVが拡張PSOコマンドα-0から取得された場合、当該IVは拡張PSOレスポンスα-nに含まれる必要はない。また、IVは拡張PSOレスポンスα-nではなく初回の拡張PSOレスポンスα-0に含まれてもよい。 Next, SE1 transmits the extended PSO response α-n to the external device 2 (step S10). As shown in FIG. 7 (F), the DATA in the extended PSO response α-n includes the ciphertext n generated in step S8, the IV used for encryption in step S4, and the authentication code generated in step S9. Is included in the TLV structure, and SW in the extended PSO response α-n indicates normal termination (9000 (h)). When the IV is acquired from the extended PSO command α-0, the IV does not need to be included in the extended PSO response α-n. Also, IV may be included in the initial extended PSO response α-0 instead of the extended PSO response α-n.

外部装置2は、SE1からの拡張PSOレスポンスα-nを受信すると、拡張PSOレスポンスα-nから暗号文n、IV及び認証コードを取得し、暗号文1〜nを結合した暗号文Nと当該暗号文Nの改竄等をチェックするための認証コードとIVのセット(組)を不揮発性メモリに記憶する。暗号文Nと認証コードとIVのセットは、例えば外部装置2から所定のサーバへアップロードされる。ここで、IVは、外部装置2側で暗号文Nを復号するために必要となる。なお、図7において、拡張PSOコマンドα-0には先頭の平文1が含まれてもよい。この場合、平文2〜nは順次繰り上がり、拡張PSOコマンドα-(n-1)が最後に送信される拡張PSOコマンドとなる。 When the external device 2 receives the extended PSO response α-n from SE1, it acquires the ciphertexts n, IV and the authentication code from the extended PSO response α-n, and the ciphertext N in which the ciphertexts 1 to n are combined and the corresponding ciphertext N. A set (set) of an authentication code and IV for checking for tampering with the ciphertext N is stored in the non-volatile memory. The set of the ciphertext N, the authentication code, and the IV is uploaded from, for example, the external device 2 to a predetermined server. Here, IV is required to decrypt the ciphertext N on the external device 2 side. In FIG. 7, the extended PSO command α-0 may include the first plaintext 1. In this case, plaintexts 2 to n are sequentially carried forward, and the extended PSO command α- (n-1) becomes the extended PSO command to be transmitted last.

一方、図8は、暗号化対象となる平文が分割されない場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドα及び拡張PSOレスポンスαのデータ構造の一例を示す図である。平文が分割されない場合、図8(A)に示すように、拡張PSOコマンドαにおけるCLA“00(h)”は後に拡張PSOコマンドαが連鎖しないことを示し、また、拡張PSOコマンドαにおけるDataにはAAD及び平文がTLV構造で含まれることになる。そして、拡張PSOコマンドαに含まれる平文とIVと鍵データとを用いた暗号化により暗号文が生成され、当該生成された暗号文とAADとから認証コードが生成されて拡張PSOレスポンスαが外部装置2へ送信される。この場合、図8(B)に示すように、拡張PSOレスポンスαにおけるDATAには暗号文と認証コードとIVとがTLV構造で含まれ、拡張PSOレスポンスαにおけるSWは正常終了(9000(h))を示すことになる。 On the other hand, FIG. 8 is a diagram showing an example of the data structure of the extended PSO command α and the extended PSO response α exchanged between the external device 2 and the SE1 when the plaintext to be encrypted is not divided. When the plaintext is not divided, as shown in FIG. 8A, CLA “00 (h)” in the extended PSO command α indicates that the extended PSO command α is not chained later, and the Data in the extended PSO command α Will include AAD and plaintext in TLV structure. Then, a ciphertext is generated by encryption using the plaintext, IV, and key data included in the extended PSO command α, an authentication code is generated from the generated ciphertext and the AAD, and the extended PSO response α is external. It is transmitted to the device 2. In this case, as shown in FIG. 8B, the DATA in the extended PSO response α contains the ciphertext, the authentication code, and the IV in a TLV structure, and the SW in the extended PSO response α ends normally (9000 (h)). ) Will be shown.

(2.2.暗号文の復号と認証コードの検証)
次に、図9〜図11を参照して、外部装置2が暗号文の復号及び認証コードの検証をSE1に実行させる際の動作について説明する。図9は、復号対象となる暗号文がn個に分割される場合において外部装置2とSE1との間における拡張PSOコマンドβ及び拡張PSOレスポンスβのやり取りの一例を示すシーケンス図である。図10は、復号対象となる暗号文がn個に分割される場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドβ及び拡張PSOレスポンスβのデータ構造の一例を示す図である。
(2.2. Ciphertext decryption and authentication code verification)
Next, with reference to FIGS. 9 to 11, the operation when the external device 2 causes the SE1 to decrypt the ciphertext and verify the authentication code will be described. FIG. 9 is a sequence diagram showing an example of the exchange of the extended PSO command β and the extended PSO response β between the external device 2 and the SE 1 when the ciphertext to be decrypted is divided into n pieces. FIG. 10 is a diagram showing an example of the data structure of the extended PSO command β and the extended PSO response β exchanged between the external device 2 and the SE1 when the ciphertext to be decrypted is divided into n pieces. ..

外部装置2は、復号対象となる暗号文の長さとして暗号文長を取得し、当該暗号文をn(n>3)個に分割する。そして、外部装置2は、拡張PSOコマンドβをSE1へ送信する(ステップS21)。図10(A)に示すように、拡張PSOコマンドβ-0におけるCLA“10(h)”は後に拡張PSOコマンドβが連鎖する(つまり、チェイニング中である)ことを示しており、また、拡張PSOコマンドβ-0におけるDataには検証用認証コード、AAD及び暗号文長がTLV構造で含まれている。 The external device 2 acquires the ciphertext length as the length of the ciphertext to be decrypted, and divides the ciphertext into n (n> 3) pieces. Then, the external device 2 transmits the extended PSO command β to SE1 (step S21). As shown in FIG. 10 (A), CLA “10 (h)” in the extended PSO command β-0 indicates that the extended PSO command β is later chained (that is, in chaining), and also. Data in the extended PSO command β-0 contains the verification code, AAD, and ciphertext length in TLV structure.

SE1は、外部装置2からの拡張PSOコマンドβ-0を受信すると、当該拡張PSOコマンドβ-0から検証用認証コード、AAD及び暗号文長を取得して例えばRAM11の一時保持領域に記憶し、拡張PSOレスポンスβ-0を外部装置2へ送信する(ステップS22)。図10(B)に示すように、拡張PSOレスポンスβ-0におけるDATAには平文長がTLV構造で含まれており、拡張PSOレスポンスβ-0におけるSWは正常終了(9000(h))を示している。 When the SE1 receives the extended PSO command β-0 from the external device 2, it acquires the verification authentication code, AAD, and ciphertext length from the extended PSO command β-0 and stores them in, for example, the temporary holding area of the RAM 11. The extended PSO response β-0 is transmitted to the external device 2 (step S22). As shown in FIG. 10B, the DATA in the extended PSO response β-0 contains the plaintext length in a TLV structure, and the SW in the extended PSO response β-0 indicates normal termination (9000 (h)). ing.

外部装置2は、SE1からの拡張PSOレスポンスβ-0を受信すると、拡張PSOレスポンスβ-0から平文長を取得し、拡張PSOコマンドβ-1をSE1へ送信する(ステップS23)。図10(C)に示すように、拡張PSOコマンドβ-1におけるDataにはn個に分割された暗号文1〜nのうち最初の暗号文1が含まれている。 When the external device 2 receives the extended PSO response β-0 from SE1, it acquires the plaintext length from the extended PSO response β-0 and transmits the extended PSO command β-1 to SE1 (step S23). As shown in FIG. 10C, the Data in the extended PSO command β-1 includes the first ciphertext 1 among the ciphertexts 1 to n divided into n pieces.

SE1は、外部装置2からの拡張PSOコマンドβ-1を受信すると、当該拡張PSOコマンドβ-1から暗号文1を取得し、当該取得された暗号文1とIVと鍵データとを用いた復号により平文1を抽出する(ステップS24)。ここで、IVはSE1内で生成されてもよいし、拡張PSOコマンドβ-0におけるDataに含まれて(つまり、拡張PSOコマンドβ-0から取得されて)もよい。次いで、SE1は、RAM11の一時保持領域に記憶されたAADとステップS24で取得された暗号文1とを用いて認証コードを生成する(ステップS25)。こうして生成された認証コードは、例えばRAM11の一時保持領域に記憶される。 When the SE1 receives the extended PSO command β-1 from the external device 2, it acquires the ciphertext 1 from the extended PSO command β-1, and decrypts the obtained ciphertext 1 and IV using the key data. The plaintext 1 is extracted by (step S24). Here, the IV may be generated in SE1 or included in the Data in the extended PSO command β-0 (that is, obtained from the extended PSO command β-0). Next, SE1 generates an authentication code using the AAD stored in the temporary holding area of the RAM 11 and the ciphertext 1 acquired in step S24 (step S25). The authentication code generated in this way is stored in, for example, a temporary holding area of the RAM 11.

次いで、SE1は、拡張PSOレスポンスβ-1を外部装置2へ送信する(ステップS26)。図10(D)に示すように、拡張PSOレスポンスβ-1におけるDATAにはステップS24で抽出された平文1が含まれており、拡張PSOレスポンスβ-1におけるSWは正常終了(9000(h))を示している。 Next, SE1 transmits the extended PSO response β-1 to the external device 2 (step S26). As shown in FIG. 10 (D), the DATA in the extended PSO response β-1 includes the plaintext 1 extracted in step S24, and the SW in the extended PSO response β-1 ends normally (9000 (h)). ) Is shown.

こうして拡張PSOレスポンスβ-1が外部装置2により受信された後、外部装置2から拡張PSOコマンドβ-2から拡張PSOコマンドβ-(n-1)がSE1へ順次送信され、上記と同様に処理が行われる。そして、外部装置2は、SE1からの拡張PSOレスポンスβ-(n-1)を受信すると、拡張PSOレスポンスβ-(n-1)から平文n-1を取得し、最後の拡張PSOコマンドβ-nをSE1へ送信する(ステップS27)。図10(E)に示すように、拡張PSOコマンドβ-nにおけるCLA“00(h)”は後に拡張PSOコマンドβが連鎖しないことを示しており、また、拡張PSOコマンドβ-nにおけるDataには最後の暗号文nが含まれている。なお、拡張PSOコマンドβ-nにおけるDataには最後の暗号文n及び検証用認証コードがTLV構造で含まれてもよい(この場合、拡張PSOコマンドβ-0に検証用認証コードが含まれなくてよい)。 After the extended PSO response β-1 is received by the external device 2 in this way, the extended PSO command β- (n-1) is sequentially transmitted from the external device 2 to the SE1 from the extended PSO command β-2, and is processed in the same manner as above. Is done. Then, when the external device 2 receives the extended PSO response β- (n-1) from SE1, it acquires the plaintext n-1 from the extended PSO response β- (n-1), and the last extended PSO command β- n is transmitted to SE1 (step S27). As shown in FIG. 10 (E), CLA “00 (h)” in the extended PSO command β-n indicates that the extended PSO command β is not chained later, and the Data in the extended PSO command β-n Contains the last ciphertext n. Note that the Data in the extended PSO command β-n may include the last ciphertext n and the verification authentication code in the TLV structure (in this case, the extended PSO command β-0 does not include the verification authentication code. You can).

SE1は、外部装置2からの拡張PSOコマンドβ-nを受信すると、当該拡張PSOコマンドβ-nから暗号文nを取得し、当該取得された暗号文nと前回生成された暗号文n-1と鍵データとを用いた復号により平文nを抽出する(ステップS28)。次いで、SE1は、ステップS28で取得された暗号文nと前回生成された認証コードとを用いて新たな認証コードを生成する(ステップS29)。こうして生成された認証コードは、例えばRAM11の一時保持領域に前回記憶された認証コードに対して上書き記憶される。 When the SE1 receives the extended PSO command β-n from the external device 2, it acquires the ciphertext n from the extended PSO command β-n, and the acquired ciphertext n and the previously generated ciphertext n-1. The plaintext n is extracted by decryption using the key data and the key data (step S28). Next, SE1 generates a new authentication code by using the ciphertext n acquired in step S28 and the previously generated authentication code (step S29). The authentication code generated in this way is overwritten and stored, for example, over the authentication code previously stored in the temporary holding area of the RAM 11.

次いで、SE1は、検証用認証コードと認証コード(つまり、最新の認証コード)とを比較することで検証する(ステップS30)。次いで、SE1は、拡張PSOレスポンスβ-nを外部装置2へ送信する(ステップS31)。図10(F)に示すように、拡張PSOレスポンスβ-nにおけるDATAにはステップS28で抽出された平文nが含まれており、拡張PSOレスポンスβ-nにおけるSWは、検証成功(認証コードが一致)の場合には正常終了(9000(h))を示し、検証失敗(認証コードが不一致)の場合にはエラー(6281(h))を示すことになる。 Next, SE1 verifies by comparing the verification authentication code with the authentication code (that is, the latest authentication code) (step S30). Next, SE1 transmits the extended PSO response β-n to the external device 2 (step S31). As shown in FIG. 10 (F), the DATA in the extended PSO response β-n includes the plaintext n extracted in step S28, and the SW in the extended PSO response β-n is verified successfully (authentication code is In the case of (match), normal termination (9000 (h)) is indicated, and in the case of verification failure (authentication code mismatch), an error (6281 (h)) is indicated.

外部装置2は、SE1からの拡張PSOレスポンスβ-nを受信すると、拡張PSOレスポンスβ-nが正常終了(9000(h))を示す(つまり、認証コードの検証結果が検証成功である)場合、平文1〜nを結合して平文Nを生成して不揮発性メモリに記憶する。なお、図10において、拡張PSOコマンドβ-0には先頭の暗号文1が含まれてもよい。この場合、暗号文2〜nは順次繰り上がり、拡張PSOコマンドβ-(n-1)が最後に送信される拡張PSOコマンドとなる。 When the external device 2 receives the extended PSO response β-n from SE1, the extended PSO response β-n indicates a normal end (9000 (h)) (that is, the verification result of the authentication code is the verification successful). , Plaintexts 1 to n are combined to generate plaintext N and stored in the non-volatile memory. In FIG. 10, the extended PSO command β-0 may include the first ciphertext 1. In this case, the ciphertexts 2 to n are sequentially carried forward, and the extended PSO command β- (n-1) becomes the extended PSO command to be transmitted last.

一方、図11は、復号対象となる暗号文が分割されない場合において外部装置2とSE1との間でやり取りされる拡張PSOコマンドβ及び拡張PSOレスポンスβのデータ構造の一例を示す図である。暗号文が分割されない場合、図11(A)に示すように、拡張PSOコマンドβにおけるCLA“00(h)”は後に拡張PSOコマンドβが連鎖しないことを示し、また、拡張PSOコマンドβにおけるDataには検証用認証コード、AAD及び暗号文がTLV構造で含まれている。そして、拡張PSOコマンドβに含まれる暗号文とIVと鍵データとを用いた復号により平文が抽出され、当該暗号文とAADから認証コードが生成され当該認証コードが検証されて拡張PSOレスポンスβが外部装置2へ送信される。この場合、図11(B)に示すように、拡張PSOレスポンスβにおけるDATAには平文が含まれ、拡張PSOレスポンスβにおけるSWは、検証成功の場合には正常終了(9000(h))を示し、検証失敗の場合にはエラー(6281(h))を示すことになる。 On the other hand, FIG. 11 is a diagram showing an example of the data structure of the extended PSO command β and the extended PSO response β exchanged between the external device 2 and the SE1 when the ciphertext to be decrypted is not divided. When the ciphertext is not split, as shown in FIG. 11 (A), CLA “00 (h)” in the extended PSO command β indicates that the extended PSO command β is not chained later, and Data in the extended PSO command β. Includes verification authorization code, AAD and ciphertext in TLV structure. Then, the plaintext is extracted by decryption using the ciphertext, IV, and key data included in the extended PSO command β, an authentication code is generated from the ciphertext and AAD, the authentication code is verified, and the extended PSO response β is obtained. It is transmitted to the external device 2. In this case, as shown in FIG. 11 (B), the DATA in the extended PSO response β contains a plaintext, and the SW in the extended PSO response β indicates a normal end (9000 (h)) when the verification is successful. , If the verification fails, an error (6281 (h)) will be displayed.

以上説明したように、上記実施形態によれば、SE1は、平文を含み、当該平文の暗号化及び認証コードの生成を指定する拡張PSOコマンドαを外部装置2から受信すると、当該拡張PSOコマンドαに応じて平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成し、当該暗号文及び当該認証コードを含む拡張PSOレスポンスβを外部装置2へ送信するように構成したので、複数種類のセキュリティオペレーションを同タイミングで実行することができる。 As described above, according to the above embodiment, when the SE1 receives the extended PSO command α including the plaintext and specifies the encryption of the plaintext and the generation of the authentication code from the external device 2, the extended PSO command α The plaintext is encrypted according to the above to generate a ciphertext, and an authentication code is generated based on the generated ciphertext, and the ciphertext and the extended PSO response β including the authentication code are transmitted to the external device 2. Since it is configured in this way, multiple types of security operations can be executed at the same timing.

また、上記実施形態によれば、SE1は、暗号文を含み、当該暗号文の復号及び認証コードの検証を指定する拡張PSOコマンドβを外部装置2から受信すると、当該拡張PSOコマンドβに応じて暗号文を復号して平文を抽出し、且つ暗号文に基づいて認証コードを生成し当該認証コードを検証し、平文及び認証コードの検証結果を含む拡張PSOレスポンスβを外部装置2へ送信するように構成したので、複数種類のセキュリティオペレーションを同タイミングで実行することができる。 Further, according to the above embodiment, when the SE1 receives the extended PSO command β including the ciphertext and specifies the decryption of the ciphertext and the verification of the authentication code from the external device 2, the SE1 responds to the extended PSO command β. Decrypt the ciphertext to extract the plaintext, generate an authentication code based on the ciphertext, verify the authentication code, and send the extended PSO response β containing the verification result of the plaintext and the authentication code to the external device 2. Since it is configured in, multiple types of security operations can be executed at the same timing.

1 SE
10 CPU
11 RAM
12 ROM
13 NVM
14 I/O回路
1 SE
10 CPU
11 RAM
12 ROM
13 NVM
14 I / O circuit

Claims (11)

平文を含み、当該平文の暗号化及び認証コードの生成を指定するコマンドを外部装置から受信する受信手段と、
前記コマンドに応じて前記平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成する処理手段と、
前記暗号文及び前記認証コードを含むレスポンスを前記外部装置へ送信する送信手段と、
を備えることを特徴とする電子情報記憶媒体。
A receiving means that receives a command from an external device that includes plaintext and specifies the encryption of the plaintext and the generation of the authentication code.
A processing means that encrypts the plaintext in response to the command to generate a ciphertext and generates an authentication code based on the generated ciphertext.
A transmission means for transmitting a response including the ciphertext and the authentication code to the external device, and
An electronic information storage medium comprising.
前記受信手段は、複数に分割された平文のうちの1つの平文を含み、当該平文の暗号化及び前記認証コードの生成を指定するコマンドを複数回受信し、
前記処理手段は、前記コマンドを受信するごとに、当該受信された平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成し、
前記送信手段は、複数に分割された平文のうちの最後の平文以外の平文の暗号化においては前記生成された暗号文を含み且つ前記生成された認証コードを含まない前記レスポンスを送信し、最後の平文の暗号化においては前記生成された暗号文及び前記生成された認証コードを含む前記レスポンスを送信することを特徴とする請求項1に記載の電子情報記憶媒体。
The receiving means includes one of the plaintexts divided into a plurality of plaintexts, and receives a command specifying the encryption of the plaintexts and the generation of the authentication code a plurality of times.
Each time the processing means receives the command, the received plaintext is encrypted to generate a ciphertext, and an authentication code is generated based on the generated ciphertext.
The transmitting means transmits the response including the generated ciphertext and not including the generated authentication code in the encryption of the plaintext other than the last plaintext among the plaintext divided into a plurality of parts, and finally. The electronic information storage medium according to claim 1, wherein in the plaintext encryption of the above, the response including the generated ciphertext and the generated authentication code is transmitted.
前回生成されてメモリに記憶された認証コードを、今回生成された認証コードにより更新する更新手段を更に備えることを特徴とする請求項1または2に記載の電子情報記憶媒体。 The electronic information storage medium according to claim 1 or 2, further comprising an updating means for updating the authentication code generated last time and stored in the memory by the authentication code generated this time. 暗号文を含み、当該暗号文の復号及び認証コードの検証を指定するコマンドを外部装置から受信する受信手段と、
前記コマンドに応じて前記暗号文を復号して平文を抽出し、且つ前記暗号文に基づいて認証コードを生成し当該認証コードを検証する処理手段と、
前記平文及び前記認証コードの検証結果を含むレスポンスを前記外部装置へ送信する送信手段と、
を備えることを特徴とする電子情報記憶媒体。
A receiving means that receives a command from an external device that includes a ciphertext and specifies the decryption of the ciphertext and the verification of the authentication code.
A processing means for decrypting the ciphertext in response to the command, extracting the plaintext, generating an authentication code based on the ciphertext, and verifying the authentication code.
A transmission means for transmitting a response including the plaintext and the verification result of the authentication code to the external device, and
An electronic information storage medium comprising.
前記受信手段は、複数に分割された暗号文のうちの1つの暗号文を含み、当該暗号文の復号及び前記認証コードの検証を指定するコマンドを複数回受信し、
前記処理手段は、前記コマンドを受信するごとに、当該受信された暗号文を復号して平文を抽出し、且つ当該受信された暗号文に基づいて認証コードを生成し当該認証コードを検証し、
前記送信手段は、複数に分割された暗号文のうちの最後の暗号文以外の暗号文の復号においては前記抽出された平文を含む前記レスポンスを送信する一方、最後の暗号文の復号においては抽出された平文及び前記認証コードの検証結果を含む前記レスポンスを送信することを特徴とする請求項4に記載の電子情報記憶媒体。
The receiving means includes one of the ciphertexts divided into a plurality of ciphertexts, and receives a command specifying the decryption of the ciphertext and the verification of the authentication code a plurality of times.
Each time the processing means receives the command, the received ciphertext is decrypted to extract the plaintext, and an authentication code is generated based on the received ciphertext to verify the authentication code.
The transmitting means transmits the response including the extracted plaintext in decrypting a ciphertext other than the last ciphertext among the ciphertexts divided into a plurality of parts, while extracting in decrypting the last ciphertext. The electronic information storage medium according to claim 4, wherein the response including the plaintext and the verification result of the authentication code is transmitted.
前回生成されてメモリに記憶された認証コードを、今回生成された認証コードにより更新する更新手段を更に備えることを特徴とする請求項4または5に記載の電子情報記憶媒体。 The electronic information storage medium according to claim 4 or 5, further comprising an updating means for updating the authentication code generated last time and stored in the memory by the authentication code generated this time. 前記処理手段は、前記外部装置から受信されてメモリに保存された検証用認証コードと、前記n番目の暗号文を含む前記コマンドの受信において生成された前記認証コードとを比較することで検証することを特徴とする請求項4乃至6の何れか一項に記載の電子情報記憶媒体。 The processing means verifies by comparing the verification authentication code received from the external device and stored in the memory with the authentication code generated in the reception of the command including the nth ciphertext. The electronic information storage medium according to any one of claims 4 to 6, wherein the electronic information storage medium is characterized by the above. 平文を含み、当該平文の暗号化及び認証コードの生成を指定するコマンドを外部装置から受信するステップと、
前記コマンドに応じて前記平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成するステップと、
前記暗号文及び前記認証コードを含むレスポンスを前記外部装置へ送信するステップと、
を含むことを特徴とする認証コード生成方法。
A step of receiving a command from an external device that includes plaintext and specifies the encryption of the plaintext and the generation of an authentication code, and
A step of encrypting the plaintext in response to the command to generate a ciphertext and generating an authentication code based on the generated ciphertext.
A step of transmitting a response including the ciphertext and the authentication code to the external device, and
An authentication code generation method characterized by including.
暗号文を含み、当該暗号文の復号及び認証コードの検証を指定するコマンドを外部装置から受信するステップと、
前記コマンドに応じて前記暗号文を復号して平文を抽出し、且つ前記暗号文に基づいて認証コードを生成し当該認証コードを検証するステップと、
前記平文及び前記認証コードの検証結果を含むレスポンスを前記外部装置へ送信するステップと、
を含むことを特徴とする認証コード検証方法。
A step of receiving a command from an external device that includes a ciphertext and specifies decryption of the ciphertext and verification of the authentication code, and
A step of decrypting the ciphertext in response to the command, extracting the plaintext, generating an authentication code based on the ciphertext, and verifying the authentication code.
A step of transmitting a response including the plaintext and the verification result of the authentication code to the external device, and
An authentication code verification method characterized by including.
平文を含み、当該平文の暗号化及び認証コードの生成を指定するコマンドを外部装置から受信する受信手段と、
前記コマンドに応じて前記平文を暗号化して暗号文を生成し、且つ当該生成された暗号文に基づいて認証コードを生成する処理手段と、
前記暗号文及び前記認証コードを含むレスポンスを前記外部装置へ送信する送信手段として機能させることを特徴とするプログラム。
A receiving means that receives a command from an external device that includes plaintext and specifies the encryption of the plaintext and the generation of the authentication code.
A processing means that encrypts the plaintext in response to the command to generate a ciphertext and generates an authentication code based on the generated ciphertext.
A program characterized by functioning as a transmission means for transmitting a response including the ciphertext and the authentication code to the external device.
暗号文を含み、当該暗号文の復号及び認証コードの検証を指定するコマンドを外部装置から受信する受信手段と、
前記コマンドに応じて前記暗号文を復号して平文を抽出し、且つ前記暗号文に基づいて認証コードを生成し当該認証コードを検証する処理手段と、
前記平文及び前記認証コードの検証結果を含むレスポンスを前記外部装置へ送信する送信手段として機能させることを特徴とするプログラム。
A receiving means that receives a command from an external device that includes a ciphertext and specifies the decryption of the ciphertext and the verification of the authentication code.
A processing means for decrypting the ciphertext in response to the command, extracting the plaintext, generating an authentication code based on the ciphertext, and verifying the authentication code.
A program characterized in that it functions as a transmission means for transmitting a response including the verification result of the plain text and the authentication code to the external device.
JP2020006741A 2020-01-20 2020-01-20 Electronic information storage medium, authentication code generation method, authentication code verification method, and program Active JP7397403B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2020006741A JP7397403B2 (en) 2020-01-20 2020-01-20 Electronic information storage medium, authentication code generation method, authentication code verification method, and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2020006741A JP7397403B2 (en) 2020-01-20 2020-01-20 Electronic information storage medium, authentication code generation method, authentication code verification method, and program

Publications (2)

Publication Number Publication Date
JP2021114157A true JP2021114157A (en) 2021-08-05
JP7397403B2 JP7397403B2 (en) 2023-12-13

Family

ID=77077622

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2020006741A Active JP7397403B2 (en) 2020-01-20 2020-01-20 Electronic information storage medium, authentication code generation method, authentication code verification method, and program

Country Status (1)

Country Link
JP (1) JP7397403B2 (en)

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4736729B2 (en) 2005-11-14 2011-07-27 株式会社日立製作所 Secure terminal system using IC card and method thereof
JP5103803B2 (en) 2006-06-26 2012-12-19 大日本印刷株式会社 IC card with mode change function and IC card program
US9705674B2 (en) 2013-02-12 2017-07-11 Amazon Technologies, Inc. Federated key management

Also Published As

Publication number Publication date
JP7397403B2 (en) 2023-12-13

Similar Documents

Publication Publication Date Title
CN106464498B (en) Method for authenticating a first electronic entity by a second electronic entity and electronic entity
JP2901767B2 (en) Cryptographic communication system and portable electronic device
CN108377190B (en) Authentication equipment and working method thereof
WO2022060471A2 (en) Secure communication with two post-quantum cryptography key encapsulations and authentication
EP1977552B1 (en) Method and system for personalizing smart cards using asymmetric key cryptography
JP4763368B2 (en) COMMUNICATION CARD, CONFIDENTIAL INFORMATION PROCESSING SYSTEM, CONFIDENTIAL INFORMATION TRANSFER METHOD, AND PROGRAM
EP2506488B1 (en) Secure dynamic on-chip key programming
US9787663B2 (en) Replaying a batch of secure commands in a secure channel
CN111639348B (en) Management method and device of database keys
JP4763447B2 (en) Authentication system and authentication target device
US20210351942A1 (en) Embedding protected memory access into a rfid authentication process based on a challenge-response mechanism
US20230171100A1 (en) Personalization of a secure element
CN112016103A (en) Method and apparatus for cryptographic alignment and binding of a secure element with a host device
CN112400294B (en) Secure communications from within a non-volatile memory device
JP6888122B2 (en) Semiconductor device, update data provision method, update data reception method and program
CN112703500A (en) Protecting data stored in memory of IoT devices during low power mode
JP7397403B2 (en) Electronic information storage medium, authentication code generation method, authentication code verification method, and program
JP2008124987A (en) Cipher communication apparatus and cipher communication system and cipher communication method and program
JP7052616B2 (en) Communication devices, data transmission methods, and programs
CN113158218A (en) Data encryption method and device and data decryption method and device
JP6965790B2 (en) Electronic information storage media, command processing methods, and programs
JP6436794B2 (en) Information processing apparatus, control method thereof, and program
JP3310989B2 (en) Data communication method
JP7105894B2 (en) Mutual authentication method and communication system
KR101663852B1 (en) Device of conducting electric transaction using sam card directly performing electric transaction process and method thereof

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20221129

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20230712

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20230718

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20230911

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

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150