Patent Description:
An IC card (portable electronic device) including an IC chip having a processor, a nonvolatile memory, a random access memory (RAM), and a communication interface has been put into practical use. Further, a dual interface card, which is an IC card having a contact communication interface for performing contact communication and a non-contact communication interface for performing non-contact communication, has been generally put into practical use.

The IC card transmits, to a host device, information indicating characteristics of the card, such as a manufacturer, information about a chip, the number of rewritable times, and a presence or absence of support for a format using an extended length (referred to as an extended format). The information indicating the characteristics of the card is, for example, historical bytes defined by ISO/IEC <NUM>. When the IC card performs contact communication with a host device, the IC card transmits an Answer To Reset (ATR) including a historical byte to the host device. When the IC card performs non-contact communication with a host device, the IC card transmits an Answer To Select (ATS) including historical bytes to the host device.

There are various methods for rewriting the historical bytes included in the ATR, such as "setATRHistBytes" defined in "GPSystem" of "globalplatform". However, in the above method, there is a problem in that the historical bytes included in the ATS cannot be rewritten.

<CIT> discloses an electronic equipment.

<CIT> discloses that an ATR sent during startup of a card may include characteristics of the card.

<CIT> discloses an IC card in which communication conditions can be set and changed by commands after the IC card is issued.

<CIT> discloses that an ATR frame comprises historical bytes including information indicating the characteristics of the card.

<CIT> is reflected in the preamble of claim <NUM> and discloses an IC card capable of performing contact communication according to ISO/IEC <NUM> and non-contact communication according to ISO/IEC1444. In contact communication, card data is stored in a historical character contained in an ATR frame. In non-contact communication, card data is stored in a historical character contained in an ATS frame.

An object of the present invention is to provide a highly convenient IC card and a control program for the IC card.

An IC card according to an embodiment is the IC card of claim <NUM>.

Hereinafter, the embodiments will be described with reference to the accompanying drawings.

<FIG> is an explanatory diagram for explaining an example of an IC card processing system <NUM>.

The IC card processing system <NUM> includes a host device <NUM>, an IC card <NUM> (portable electronic device), and the like. The host device <NUM> and the IC card <NUM> are configured to be able to communicate with each other in a contact or non-contact manner. Note that the IC card processing system <NUM> may include a configuration as necessary in addition to the configuration illustrated in <FIG>, or a specific configuration may be excluded from the IC card processing system <NUM>.

First, the configuration of the host device <NUM> will be described.

The host device <NUM> is an IC card processing device that processes the IC card <NUM>. The host device <NUM> controls the entire IC card processing system <NUM>. The host device <NUM> activates the IC card <NUM> by supplying electric power to the IC card <NUM>. In addition, the host device <NUM> causes the IC card <NUM> to execute various operations by transmitting various commands to the IC card <NUM>.

The host device <NUM> includes a controller <NUM>, a first card reader/writer <NUM>, a second card reader/writer <NUM>, a display <NUM>, an operation interface <NUM>, and the like.

The controller <NUM> controls various operations of the host device <NUM>. The controller <NUM> includes a processor <NUM> and a memory <NUM>.

The processor <NUM> includes an arithmetic element (for example, a CPU) that executes arithmetic processing. The processor <NUM> executes various operations by executing a program stored in the memory <NUM>.

The memory <NUM> stores the program, data for use in the program, and the like. The memory <NUM> includes, for example, a driver of the first card reader/writer <NUM>, a driver of the second card reader/writer <NUM>, a program for generating an image to be displayed on the display <NUM>, and a program for interpreting an operation input by the operation interface <NUM>. Further, the memory <NUM> includes a program for performing transmission of a command and reception of a response with the IC card <NUM>. That is, the memory <NUM> stores a control program for the IC card processing device that processes the IC card <NUM>.

The first card reader/writer <NUM> is an interface for performing contact communication with the IC card <NUM>. The first card reader/writer <NUM> includes a plurality of contact terminals physically and electrically connected to a contact pattern of the IC card <NUM>, and a slot into which the IC card <NUM> is inserted. The first card reader/writer <NUM> transmits and receives data to and from the IC card <NUM> via the contact terminals and the contact pattern. The first card reader/writer <NUM> supplies electric power and a clock to the IC card <NUM> via the contact terminals and the contact pattern.

The second card reader/writer <NUM> is an interface for performing non-contact communication with the IC card <NUM>. The second card reader/writer <NUM> includes an antenna (coil) and a modulation/demodulation circuit. The second card reader/writer <NUM> modulates a signal corresponding to data to be transmitted by the modulation/demodulation circuit and causes the modulated signal to flow to the antenna, thereby causing the antenna to output a radio wave corresponding to the data. The second card reader/writer <NUM> receives a radio wave from the IC card through the antenna, demodulates the received signal by the modulation/demodulation circuit, and acquires original data. Furthermore, the first card reader/writer <NUM> supplies electric power to the IC card <NUM> by the radio wave from the antenna.

The display <NUM> displays a screen based on data for display (screen data) supplied from the controller <NUM> or a graphic controller (not shown).

The operation interface <NUM> is a configuration to generate an operation signal based on an operation. The operation interface <NUM> receives or generates an operation signal based on an operation of an operation member, such as a mouse, a trackball, a keyboard, a track pad, or a touch sensor, and supplies the operation signal to the controller <NUM>.

In the example of <FIG>, the host device <NUM> includes both the first card reader/writer <NUM> and the second card reader/writer <NUM>, but the host device <NUM> may include at least one of the first card reader/writer <NUM> and the second card reader/writer <NUM>. Further, the host device <NUM> may be configured to include a communication interface to which the first card reader/writer <NUM> or the second card reader/writer <NUM> is connected.

Next, a configuration of the IC card <NUM> will be described.

The IC card <NUM> is activated by electric power supplied from the host device <NUM>. The IC card <NUM> receives a command from the host device <NUM> and executes various processing in accordance with the received command. In addition, the IC card <NUM> generates a response according to the processing and transmits the response to the host device <NUM>.

The IC card <NUM> has a card-shaped main body <NUM> formed of plastic or the like. The IC card <NUM> includes an IC module <NUM> in the main body <NUM>. The IC module <NUM> includes an IC chip <NUM>, a contact communication interface <NUM>, and a non-contact communication interface <NUM>. That is, the IC card <NUM> is a dual interface card having the contact communication interface <NUM> for performing contact communication and the non-contact communication interface <NUM> for performing non-contact communication with the host device <NUM>. The IC chip <NUM> includes a processor <NUM>, a nonvolatile memory <NUM>, and a RAM <NUM>. The IC card <NUM> may have an additional element other than those shown in <FIG>, or a part of the configuration shown in <FIG> may be excluded from the IC card <NUM>.

The processor <NUM> includes an arithmetic element (for example, a CPU) that executes arithmetic processing. The processor <NUM> executes various operations by executing a program stored in the nonvolatile memory <NUM>.

The nonvolatile memory <NUM> is a nonvolatile memory that stores a program, data for use in the program, and the like. The program stored in the nonvolatile memory <NUM> is, for example, an operating system (OS) and an application for performing various processing according to an operation form of the IC card <NUM>. The application is, for example, an IC card application managed by a card issuer (an entity that issued a card). The OS is an IC card control program for causing the processor <NUM> to realize control and information processing of each unit in the IC card <NUM>. The program and control data in the nonvolatile memory <NUM> are incorporated in advance in accordance with the specification of the IC card <NUM> and the like. Note that the IC card <NUM> may be configured to include a ROM that stores a control program for the IC card, such as an OS and applications.

A file structure defined by ISO/IEC <NUM> is configured in the nonvolatile memory <NUM>. For example, a master file (MF), a dedicated file (DF), an elementary file (EF), and the like are stored in the nonvolatile memory <NUM>.

The MF is a file that is the basis of the file structure.

The DF is created at an order below the MF. The DF is a file in which applications and data to be used by the applications are grouped and stored.

The EF is created at an order below the DF. The EF is a file for storing various data. The EF may be placed at an order immediately below the MF.

The RAM <NUM> is a volatile memory that temporarily stores data. The RAM <NUM> temporarily stores data that is being processed by the processor <NUM>, programs read from the nonvolatile memory <NUM>, and the like. For example, the RAM <NUM> functions as a calculation buffer, a reception buffer, and a transmission buffer. The calculation buffer is an area for temporarily holding results of various arithmetic processing executed by the processor <NUM>. The reception buffer is an area for temporarily holding a command (command data) or the like received from the host device <NUM>. The transmission buffer is an area for temporarily holding a response (response data) or the like to be transmitted to the host device <NUM>.

Some of the various functions realized by the processor <NUM> executing the program may be incorporated into the IC chip <NUM> as a hardware circuit. In this case, the processor <NUM> controls the functions performed by the hardware circuit.

The contact communication interface <NUM> is contact communication means for performing contact communication with the host device <NUM>. For example, the contact communication interface <NUM> is connected to a terminal of the IC chip <NUM> and includes a contact pattern exposed on the surface of the IC card <NUM>. The contact pattern is configured to be physically and electrically connected to the contact terminals when the IC card <NUM> is inserted into the slot of the first card reader/writer <NUM>. The contact communication interface <NUM> relays electric power supply and data transmission/reception between the host device <NUM> and the IC chip <NUM>.

The non-contact communication interface <NUM> is non-contact communication means for performing non-contact communication with the host device <NUM>. For example, the non-contact communication interface <NUM> includes an antenna (coil), a modulation/demodulation circuit, and a power supply circuit. The non-contact communication interface <NUM> modulates a signal corresponding to data to be transmitted by the modulation/demodulation circuit and causes the modulated signal to flow to the antenna, thereby causing the antenna to output a radio wave corresponding to the data. Further, the non-contact communication interface <NUM> receives a radio wave from the second card reader/writer <NUM> of the host device <NUM> through the antenna, demodulates the received signal by the modulation/demodulation circuit, and acquires the original data. In addition, the non-contact communication interface <NUM> rectifies and smooths, via a power supply circuit, an induced current generated in the antenna by a radio wave from the second card reader/writer <NUM> of the host device <NUM>, and supplies a predetermined power supply voltage to the IC chip <NUM>.

Next, operations such as activation and initial response of the IC card <NUM> according to the first embodiment will be described.

<FIG> is an explanatory diagram for explaining an initial response from the IC card <NUM>.

The nonvolatile memory <NUM> of the IC card <NUM> includes a storage area for storing information (hereinafter referred to as characteristic information) indicating characteristics of the card mainly based on the card operation method of the IC card <NUM>. The characteristic information is configured as historical bytes including, for example, "manufacturer identification information", "IC chip identification information", "number of rewritable times", and "presence or absence of support for an extended format". That is, the nonvolatile memory <NUM> includes the storage area in which the historical bytes are stored.

In the example of <FIG>, the historical bytes are stored in advance, for example, in a predetermined EF <NUM> at an order below the MF. The historical bytes may be stored, for example, in an EF at an order below the DF. The historical bytes may be stored in the nonvolatile memory <NUM> in a form other than the EF. For example, the historical bytes may be stored in any storage area of the nonvolatile memory <NUM> in a state in which a tag indicating the historical bytes is added.

When activated, the IC card <NUM> performs an initial response. In the initial response, the IC card <NUM> transmits to the host device <NUM> information for performing setting related to communication between the host device <NUM> and the IC card <NUM>.

First, the contact communication will be described.

In the contact communication, the IC card <NUM> is activated by a DC power supply voltage supplied from the host device <NUM> via the contact communication interface <NUM>. When the IC card <NUM> is activated, it performs an initial response based on ISO/IEC <NUM> regulations. Specifically, the IC card <NUM> reads necessary information from the nonvolatile memory <NUM>, and transmits to the host device <NUM> an answer to reset (ATR) whose frame format is defined by, for example, ISO/IEC <NUM>-<NUM>.

As shown in <FIG>, the ATRs include "TS", "T0", "Interface bytes", "Historical characters", "TSK", and the like. The "Interface bytes" and the "Historical characters" are optional information.

"TS (Initial character TS)" is information indicating a logic level of a signal and a bit transfer order.

"T0 (Format byte T0)" is information indicating the presence or absence of "TA1", "TB1", "TC1", and "TD1" in the first set of "Interface bytes" and the length of "Historical characters".

The "Interface bytes" indicate various parameters on the data transfer protocol. The "Interface bytes" are information indicating, for example, a data transfer rate.

The "Historical characters" are information (characteristic information) indicating a characteristic of the card mainly based on the card operation method of the IC card <NUM>. For example, the processor <NUM> of the IC card <NUM> reads the historical bytes from the EF <NUM> storing the historical bytes of the nonvolatile memory <NUM>, and sets the historical bytes in the field of "Historical characters". The "Historical characters" are data of <NUM> bytes at the maximum and are defined by ISO/IEC <NUM>-<NUM>.

"TCK" is information indicating an exclusive OR of each character from "T0" to "TCK". "TCK" is data of <NUM> bytes at the maximum.

By transmitting the ATR to the host device <NUM>, the IC card <NUM> becomes able to perform contact communication with the host device <NUM>.

Next, non-contact communication will be described.

In the non-contact communication, the host device <NUM> periodically performs polling (transmission of an initial response request command) while outputting radio waves for activating the IC card <NUM> through the antenna of the second card reader/writer <NUM>.

The initial response request command is, for example, Request command type B (REQB) or Request command type A (REQA) defined by ISO/IEC <NUM>.

The IC card <NUM> rectifies and smooths an induced current generated in the antenna of the non-contact communication interface <NUM> by radio waves through the antenna of the second card reader/writer <NUM>, and obtains a DC power supply voltage. The IC card <NUM> is activated by a DC power supply voltage. When the IC card <NUM> is activated and receives an initial response request command from the host device <NUM>, the IC card <NUM> transmits an initial response to the host device <NUM>.

To be more specific, the IC card <NUM> transmits an Answer To Request command type B (ATQB) or an Answer To Request command type A (ATQA) defined by, for example, ISO/IEC <NUM> to the host device <NUM> as an initial response. The initial response includes a parameter indicating a response (initial response) to the initial response request command, a pseudo-unique IC card (PICC) identifier, application data indicating what application is written, protocol information indicating a supported protocol, a cyclic redundancy check code, and the like.

Upon receipt of the initial response, the host device <NUM> transmits to the IC card <NUM> a command for requesting the IC card <NUM> to provide information (characteristic information) indicating the characteristics of the card. Specifically, the host device <NUM> transmits a Request for Answer To Select (RATS) for requesting the IC card <NUM> to transmit an Answer To Select (ATS) to the IC card <NUM>. Frame formats of the ATS and the RATS are defined by ISO/IEC <NUM>.

When the transmission of the characteristic information is requested, the IC card <NUM> reads necessary information from the nonvolatile memory <NUM> and transmits the characteristic information to the host device <NUM>. Specifically, upon receipt of the RATS, the IC card <NUM> reads the historical bytes from the EF <NUM> of the nonvolatile memory <NUM> and transmits to the host device <NUM> the ATS to which the historical bytes are added.

As illustrated in <FIG>, the ATS includes "TL", "T0", "TA", "TB", "TC", "historical bytes", "cyclic redundancy check (CRC)", and the like.

"TL" is information indicating the length of the ATS (length byte). The length indicated by "TL" does not include the byte of "CRC".

"T0" is a format byte. "T0" indicates information, such as a presence or absence of subsequent "TA", "TB", "TC", and "historical bytes", and a receivable maximum frame length.

"TA", "TB", and "TC" are interface bytes. "TA" indicates information on a communication speed. "TB" indicates information such as a frame waiting time and a start frame guard time. "TC" indicates whether "Card Identifier (CID)" or "Node Address (NAD)" is supported.

The "historical bytes" are information (characteristic information) indicating a characteristic of the card mainly based on a card operation method of the IC card <NUM>. For example, the processor <NUM> of the IC card <NUM> reads the historical bytes from the EF <NUM> storing the historical bytes in the nonvolatile memory <NUM>, and sets the read historical bytes to the "historical bytes" of the ATS.

"CRC" is a code for use in error detection.

When the IC card <NUM> is of type A defined by ISO/IEC <NUM>, the IC card <NUM> transmits the aforementioned ATS to the host device <NUM>, thereby enabling normal command processing by non-contact communication with the host device <NUM>. In this case, the host device <NUM> can execute an arbitrary application stored in the DF by transmitting a SELECT command to the IC card <NUM>.

When the IC card <NUM> is of type B defined by ISO/IEC <NUM>, the host device <NUM> transmits ATTRIB to the IC card <NUM>. The IC card <NUM> adds the ATS or the historical bytes to an Answer To ATTRIB (ATA), which is a response to the ATTRIB to the host device, and transmits the ATA or the historical bytes to the host device <NUM>. Thus, normal command processing by non-contact communication is enabled between the IC card <NUM> and the host device <NUM>.

As described above, when transmitting the ATR to the host device <NUM> via the contact communication interface <NUM>, the processor <NUM> of the IC card <NUM> reads the historical bytes from the EF <NUM> storing the historical bytes, adds the historical bytes to the ATR, and transmits the ATR.

When transmitting the ATS to the host device <NUM> via the non-contact communication interface <NUM>, the processor <NUM> of the IC card <NUM> reads the historical bytes from the EF <NUM> storing the historical bytes, adds the historical bytes to the ATS, and transmits the ATS.

As described above, the processor <NUM> of the IC card <NUM> adds the historical bytes in the predetermined storage area (EF <NUM>) of the nonvolatile memory <NUM> to the ATR in the contact communication and the ATS in the non-contact communication. That is, the processor <NUM> of the IC card <NUM> generates the ATR and the ATS using the historical bytes stored in the same storage area in the nonvolatile memory <NUM> both when transmitting the ATR and when transmitting the ATS.

Next, rewriting of the historical bytes in the first embodiment will be described.

<FIG> is an explanatory diagram for explaining rewriting of historical bytes stored in the nonvolatile memory <NUM> of the IC card <NUM>. In <FIG>, programs (OS, applications, and the like) executed by the processor <NUM> of the IC card <NUM> are illustrated in blocks.

The host device <NUM> transmits a predetermined command, to which historical bytes for rewriting are added, to the IC card <NUM> through the first card reader/writer <NUM> or the second card reader/writer <NUM>. Thus, the host device <NUM> causes the historical bytes of the nonvolatile memory <NUM> of the IC card <NUM> to be rewritten. The command to which the historical bytes for rewriting are added may be any arbitrary command.

The format of the command transmitted from the host device <NUM> to the IC cards <NUM> is defined by ISO/IEC <NUM>, and includes fields such as "CLA", "INS", "P1", "P2", "Lc", "Data", and "Le".

"CLA" is information indicating the type of the command. "INS" is information indicating the type of the command. The type of the command is indicated by "CLA" and "INS".

"P1" and "P2" are information indicating parameters corresponding to "INS". "P1" and "P2" indicate, for example, command option designation. For example, "P1" and "P2" indicate IDs of files to be processed.

"Lc" is information indicating the data length (number of bytes) of "Data".

"Data" is information indicating the data body of the command. "Data" stores, for example, data to be used in command processing based on the command.

"Le" is information indicating a data length (maximum length) of a response to the command.

The host device <NUM> adds historical bytes for rewriting to "Data". That is, the host device <NUM> transmits to the IC card <NUM> a command in which historical bytes for rewriting are added to "Data".

The OS of the IC card <NUM> recognizes the type of the received command by analyzing the values of "CLA" and "INS" of the received command. The OS of the IC card <NUM> executes processing according to the received command. For example, when receiving a command to which historical bytes for rewriting are added, the OS of the IC card <NUM> passes the received command to an application managed by the card issuer.

The application of the IC card <NUM> sets the historical bytes for rewriting that have been added to "Data" of the command in, for example, a buffer area of the RAM <NUM>. Furthermore, the application calculates an offset value of a storage area in the nonvolatile memory <NUM> in which the historical bytes are stored and a length of the historical bytes in the nonvolatile memory <NUM>. That is, the application calculates an offset value to the head of the EF <NUM> in which the historical bytes for use in generating the ATR and the ATS are stored, and a length of the historical bytes in the EF <NUM> (or a length of the EF <NUM>) in the nonvolatile memory <NUM>.

The application of the IC card <NUM> sets (overwrites) the historical bytes for rewriting that have been added to the command in the nonvolatile memory <NUM> using an application programming interface (API). The API recognizes the storage area to be overwritten based on the calculation result of the offset value and the calculation result of the length of the historical bytes, and overwrites the recognized storage area with the historical bytes for rewriting that have been added to the command. The application transmits a return value (response) indicating the processing result to the OS in accordance with the processing result. Note that the API may be configured as a part of the application or may be configured as a part of the OS.

The OS confirms the return value from the application and transmits a response to the host device <NUM> in accordance with the result. The format of the response transmitted from the IC card <NUM> to the host device <NUM> is defined by ISO/IEC <NUM>, and has fields such as "SW1" and "SW2".

"SW1" and "SW2" are information (status bytes) indicating a processing result in the IC card <NUM>. When "SW1" and "SW2" are values indicating a normal end, the host device <NUM> recognizes that the rewriting of the historical bytes has been normally performed in the IC card <NUM>.

The IC card <NUM> may be configured such that the OS sets the historical bytes for rewriting that have been added to "Data" of the command in the buffer. Further, the IC card <NUM> may be configured such that the OS calculates the offset value of the storage area in the nonvolatile memory <NUM> in which the historical bytes are stored and calculates the length of the historical bytes in the nonvolatile memory <NUM>. In this case, the OS passes to the application the address at which the historical bytes in the buffer are set, the calculation result of the offset value, and the calculation result of the length of the historical byte.

As described above, the storage area in which historical bytes are stored is provided in the nonvolatile memory <NUM> of the IC card <NUM>. The processor <NUM> of the IC card <NUM> sets the ATR and the ATS based on the historical bytes in the nonvolatile memory <NUM>. That is, the processor <NUM> reads the historical bytes from the storage area in which the historical bytes are stored in the nonvolatile memory <NUM>, and adds the historical bytes to the ATR and the ATS. When the processor <NUM> of the IC card <NUM> receives the predetermined command to which the historical bytes for rewriting are added, the processor <NUM> overwrites the historical bytes for rewriting on the storage area in which the historical bytes are stored in the nonvolatile memory <NUM>.

Thus, the historical bytes added to the ATR in the contact communication and the historical bytes added to the ATS in the non-contact communication are set based on the predetermined command including the historical bytes for rewriting. That is, both the historical bytes added to the ATR and the historical bytes added to the ATS are changed by one command. This eliminates the need to individually change the historical bytes added to the ATR and the historical bytes added to the ATS. As a result, the convenience of the IC card can be improved.

Next, operations such as activation and initial response of the IC card <NUM> according to the second embodiment will be described. In the first embodiment, the historical bytes are described as being read from the storage area in which the historical bytes are stored in the nonvolatile memory <NUM>, and used for both generation of the ATR and generation of the ATS. The second embodiment is different from the first embodiment in that a storage area in which historical bytes for the ATR are stored and a storage area in which historical bytes for the ATS are stored are provided in the nonvolatile memory <NUM>. The same components as those of the first embodiment are denoted by the same reference numerals, and redundant explanations will be omitted.

As shown in <FIG>, the nonvolatile memory <NUM> of the IC card <NUM> according to the second embodiment is provided with a first EF <NUM> (first storage area) and a second EF <NUM> (second storage area). Historical bytes (historical bytes for the ATR) to be used when generating the ATR are stored in, for example, a first EF <NUM> at an order below a DF. Historical bytes (historical bytes for the ATS) to be used when generating the ATS are stored in, for example, a second EF <NUM> different from the first EF <NUM>. The historical bytes for the ATR and the historical bytes for the ATS are data having the same contents.

Further, the first EF <NUM> and the second EF <NUM> may be provided at an order below the MF. Furthermore, the historical bytes may be stored in the nonvolatile memory <NUM> in a form other than the EF. For example, the historical bytes may be stored in any storage area of the nonvolatile memory <NUM> in a state in which a tag indicating that the historical bytes are historical bytes for the ATR or historical bytes for the ATS is added.

For example, in contact communication, when the IC card <NUM> is activated, it performs an initial response based on ISO/IEC <NUM> regulations. Specifically, the IC card <NUM> reads the historical bytes for the ATR from the first EF <NUM> of the nonvolatile memory <NUM>, and transmits to the host device <NUM> the ATR to which the historical bytes for the ATR are added. As a result, the IC card <NUM> becomes able to perform contact communication with the host device <NUM>.

For example, in the non-contact communication, when the IC card <NUM> is activated, it transmits an initial response to the host device <NUM> based on the ISO/IEC <NUM> regulations.

Upon receipt of the initial response, the host device <NUM> transmits a command for requesting feature information to the IC card <NUM>.

Upon receipt of the command for requesting the feature information, the IC card <NUM> reads the historical bytes for the ATS from the second EF <NUM> of the nonvolatile memory <NUM>, and transmits to the host device <NUM> the ATS to which the historical bytes for the ATS are added. Thus, normal command processing by non-contact communication is enabled between the host device <NUM> and the IC card <NUM>.

The command for requesting the characteristic information is RATS when the IC card <NUM> is of type A defined by ISO/IEC <NUM>. In this case, the IC card <NUM> transmits the ATS to the host device <NUM> in response to the reception of the RATS.

The command for requesting the characteristic information is ATTRIB when the IC card <NUM> is of type B defined by ISO/IEC <NUM>. In this case, the IC card <NUM> generates an ATA in response to the reception of the ATTRIB, adds the ATS to the ATA, and transmits the ATA to the host device <NUM>.

Next, rewriting of the historical bytes in the second embodiment will be described.

The host device <NUM> transmits a predetermined command, to which historical bytes for rewriting are added, to the IC card <NUM> through the first card reader/writer <NUM> or the second card reader/writer <NUM>.

The OS of the IC card <NUM> recognizes the type of the received command by analyzing the values of "CLA" and "INS" of the received command. The OS of the IC card <NUM> executes processing according to the received command. For example, when receiving a predetermined command to which historical bytes for rewriting are added, the OS of the IC card <NUM> passes the received command to an application managed by the card issuer.

The application of the IC card <NUM> sets the historical bytes for rewriting that have been added to "Data" of the command in, for example, a buffer area of the RAM <NUM>. In addition, the application calculates an offset value of a storage area in the nonvolatile memory <NUM> in which the historical bytes for the ATR are stored and a length of the historical bytes for the ATR in the nonvolatile memory <NUM>. In addition, the application calculates an offset value of a storage area in the nonvolatile memory <NUM> in which the historical bytes for the ATS are stored and a length of the historical bytes for the ATS in the nonvolatile memory <NUM>. That is, the application calculates an offset value to the head of each of the first EF <NUM> and the second EF <NUM> in which the historical bytes for the ATR and the historical bytes for the ATS are stored, and a length of the historical bytes in the nonvolatile memory <NUM>.

The application of the IC card <NUM> acquires the historical bytes for rewriting from "Data" of the command, and sets (overwrites) the acquired historical bytes for rewriting to the historical bytes for the ATR of the first EF <NUM> and the historical bytes for the ATS of the second EF <NUM>. The application transmits a return value (response) indicating the processing result to the OS in accordance with the processing result.

The OS confirms the return value from the application and transmits a response to the host device <NUM> in accordance with the result.

As described above, in the nonvolatile memory <NUM> of the IC card <NUM> according to the second embodiment, the first storage area for storing the historical bytes for the ATR and the second storage area for storing the historical bytes for the ATS are separately provided. The processor <NUM> of the IC card <NUM> rewrites both the first storage area and the second storage area based on a predetermined command including historical bytes for rewriting. That is, the processor <NUM> overwrites both the historical bytes for the ATR in the first storage area and the historical bytes for the ATS in the second storage area with the historical bytes for rewriting included in the predetermined command. The processor <NUM> adds the historical bytes for the ATR in the first storage area to the ATR in the contact communication. Further, the processor <NUM> of the IC card <NUM> adds the historical bytes for the ATS in the second storage area to the ATS in the non-contact communication.

According to the above configuration, the historical bytes added to the ATR in the contact communication and the historical bytes added to the ATS in the non-contact communication are also changed based on the predetermined command including the historical bytes for rewriting. That is, both the historical bytes added to the ATR and the historical bytes added to the ATS are changed by one command. This eliminates the need to individually change the historical bytes added to the ATR and the historical bytes added to the ATS. As a result, the convenience of the IC card can be improved.

The functions described above for each of the embodiments are not only limited to those configured using hardware, and may be implemented using software by causing a computer to read a program in which each function is described. In addition, each function may be configured by appropriately selecting either software or hardware.

Claim 1:
An IC card (<NUM>) comprising:
a contact communication interface (<NUM>) configured to perform contact communication with a reader/writer (<NUM>, <NUM>);
a non-contact communication interface (<NUM>) configured to perform non-contact communication with the reader/writer (<NUM>, <NUM>);
a nonvolatile memory (<NUM>) including a storage area in which historical bytes (<NUM>) are stored,
and
a processor (<NUM>) configured to add the historical bytes (<NUM>) in the storage area of the nonvolatile memory (<NUM>) to an Answer To Reset (ATR) in the contact communication and an Answer To Select (ATS) in the non-contact communication,
characterized in that
the processor (<NUM>) is configured to rewrite the historical bytes (<NUM>) in the storage area of the nonvolatile memory (<NUM>) based on a predetermined command from the reader/writer (<NUM>, <NUM>) to which command historical bytes for rewriting are added.