Microcontroller and authentication method between the controllers

A microcontroller includes a program memory configured to store a program group and a first encryption key; a CPU; and an identification (ID) storage section configured to store an identification data peculiar to a user of the microcontroller. The CPU executes the program group to generate a second encryption key based on the identification data and the first encryption key and to encrypt a random number with the second encryption key.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a microcontroller, particularly to a microcontroller which performs authentication by using an encrypted random number.

2. Description of the Related Art

In apparatuses using replaceable accessories such as a battery of a mobile phone and an ink cartridge of a printer, there is a case that an unauthorized accessory and an ordinary accessory are used even though an authorized accessory should be preferably used. In order to prevent the usage of accessories other than authorized accessories as described above, there is a case that authentication is performed between a main body and an accessory. As one of the techniques related to the authentication between the main body and the accessory, the same random number is encrypted between an authenticating side and an authenticated side by an encryption program including the same encryption key and a comparison is performed to confirm coincidence.

A conventional technique to encrypt a random number is described in Japanese Laid Open Patent Application (JP-P2003-318894A) in which an authentication method between apparatuses of a challenge and response system. In this conventional authentication method, a challenge data is transmitted to a terminal from a server, and a response data decrypted from the challenge data is transmitted from the terminal to the server. Further, whether the response data is data decrypted from the challenge data is determined on the basis of encryption performed in the server. When the determination result is affirmative, this authentication method updates a parameter used for both encryption and decryption to a new parameter which is set as a parameter to be used in the next authentication.

If a conventional technique is applied to an application system on which a microcontroller is mounted, it is possible to perform encryption in an accessory other than an authorized accessory by making a copy of entire data of a program memory in which a user program is stored, because an encryption key used for encrypting a random number is directly written into the program or stored as data in a memory which is simultaneously used for storing the program. That is, if an authentication program is illegally obtained and the program is written into a program memory of the microcontroller which is composed of a flash memory or the like, an operation is performed even in an unauthorized accessory, causing a problem of a counterfeit product to be undetectable. In this way, if a microcontroller written by the same program is mounted on a counterfeit product imitating the authorized accessory, the same operation with the authorized accessory is exhibited.

SUMMARY OF THE INVENTION

In an aspect of the present invention, a microcontroller includes a program memory configured to store a program group and a first encryption key; a CPU; and an identification (ID) storage section configured to store an identification data peculiar to a user of the microcontroller. The CPU executes the program group to generate a second encryption key based on the identification data and the first encryption key and to encrypt a random number with the second encryption key.

Here, the CPU may execute a random number generating program of the program group to generate the random number. Also, the microcontroller may further include a random number generating circuit configured to generate the random number. Also, the microcontroller may further include a port configured to receive the random number.

Also, the CPU may execute the program group to compare the random number encrypted with the second encryption key and an encrypted random number received from an external device and to output the comparison result.

Also, the program memory and the ID storage section may be constituted by a nonvolatile memory. In this case, the microcontroller may further include a control section configured to carry out an erasing operation and a writing operation to the program memory in response to a write request of a program into the program memory. The control section may erase the identification data from the ID storage section when the erasing operation is carried out to the program memory.

Also, the program group may include a first encryption key supplying program adapted to supply the first encryption key; a second encryption key generating program adaptive to acquire the first encryption key and the identification data and to generate the second encryption key based on the first encryption key and the identification data; and an encrypting program adapted to encrypt the random number with the second encryption key. In this case, the program group may further include a comparing program adapted to compare the random number encrypted using the second encryption key and an encrypted random number received from an external device and to output the comparison result.

In another aspect of the present invention, an authentication method between first and second microcontrollers, is achieved by supplying a first encryption key through execution of a first encryption key supplying program stored in a first program memory of the first microcontroller; by holding a first identification data peculiar to the first microcontroller in a first identification (ID) storage section of the first microcontroller; by generating a second encryption key in the first microcontroller based on the first identification data and the first encryption key; by encrypting a random number with the second encryption key in the first microcontroller to generate a first encrypted random number; by receiving a second encrypted random number from the second microcontroller; and by comparing the first encrypted random number and the second encrypted random number to output the comparing result.

Here, the authentication method may be achieved by further reading the random number from the first program memory. In this case, the authentication method may be achieved by further generating the random number to store in the first program memory. The generating the random number is achieved by executing a random number generating program stored in the first program memory to generate the random number.

Also, the program memory and the ID storage section are constituted by a nonvolatile memory, and the microcontroller may be achieved by further carrying out an erasing operation and a writing operation to the first program memory in response to a write request of a program into the first program memory; and carrying out the erasing operation to the ID storage section in response to the write request.

Also, the authentication method may be achieved by further supplying a third encryption key through execution of a second encryption key supplying program stored in a second program memory of the second microcontroller; holding a second identification data peculiar to the second microcontroller in a second identification (ID) storage section of the second microcontroller; generating a fourth encryption key in the second microcontroller based on the second identification data and the third encryption key; encrypting the random number from the first microcontroller with the fourth encryption key in the second microcontroller to generate the second encrypted random number; and transmitting the second encrypted random number to the first microcontroller. In this case, the authentication method may be achieved by further supplying power to the second microcontroller when a unit containing the second microcontroller is installed to a unit containing the first microcontroller. The supplying a third encryption key may be performed after the power is supplied to the second microcontroller.

Also, the authentication method may be achieved by further supplying a third encryption key through execution of a second encryption key supplying program stored in a second program memory of the second microcontroller; holding a second identification data peculiar to the second microcontroller in a second identification (ID) storage section of the second microcontroller; generating a fourth encryption key in the second microcontroller based on the second identification data and the third encryption key; encrypting the random number from the first microcontroller with the fourth encryption key in the second microcontroller to generate the second encrypted random number; and transmitting the second encrypted random number to the first microcontroller. In this case, the authentication method may be achieved by further supplying power to the first microcontroller when a unit containing the second microcontroller is installed to a unit containing the first microcontroller. The supplying a first encryption key may be performed after the power is supplied to the first microcontroller.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

Hereinafter, a microcontroller of the present invention will be described in detail with reference to the attached drawings.

FIG. 1is a block diagram showing a configuration of a microcontroller100according to the first embodiment of the present invention. Referring toFIG. 1, the microcontroller100of the first embodiment includes a CPU110, an ID storage section120, a program memory130and an input/output port140.

The CPU110controls each of sections in the microcontroller100. The CPU110also generates a random number required for encryption in the microcontroller100. At this time, the CPU110generates a random number by executing a random number generating program (not shown) stored in the program memory130. However, for a practical use, a random number generating function through execution of the program by the CPU itself or a hardware function such as a random number generating circuit (not shown) may also be used to generate the random number. That is, the random number may be generated in any methods. Also, the random number may be received from an external device. The generated or received random number may be stored in the program memory.

The ID storage section120is a storage region provided in the microcontroller100, and is accessed by a circuit or a program in the microcontroller. The ID storage section120also stores inherent identification data (ID) determined for each customer. In the ID storage section120, an ID inherent in a target customer (ex. 58679) is written to be shipped to a specific customer. In the ID storage section120for a product shipped to an ordinary customer, an initial value, e.g., all zero is written. The ID storage section120is readable but unrewritable by any programs in the program memory130. The ID storage section120is rewritable only in an exclusive mode in a manufacturing process of a manufacturer. The ID storage section120is a nonvolatile memory if the program memory130is a nonvolatile memory and the programs are rewritable.

In the program memory130, user programs are written therein. The programs include an encryption key A supplying program131, an encryption key B generating program132, an encrypting program133and a comparing program134. However, for a practical use, the functions of the encryption key A supplying program131, encryption key B generating program132, encrypting program133and comparing program134may also be achieved by a hardware circuit. Also, the program may include the random number generating program.

The encryption key A supplying program131is a program for supplying a first encryption key A and holding it in the program memory. The encryption key B generating program132is a program for newly generating an encryption key B based on the encryption key A supplied by the encryption key A supplying program131and the inherent identification data (ID) stored in the ID storage section120. The generation of the encryption key B may be notified to an external device. The encrypting program133is a program for encrypting a random number based on the encryption key B. The comparing program134is a program for comparing the random number encrypted based on the encryption key B, i.e., a first encrypted random number with a second encrypted random number obtained from another microcontroller and outputs the comparison result.

The program memory130is a mask ROM or a nonvolatile memory. If the program memory130is a nonvolatile memory such as a flash memory, the ID storage section120is preferably a nonvolatile memory. This is because it makes it possible to perform an erasing operation to the ID storage section120when the user program in the program memory130is rewritten. More details will be described below.

If the program memory130is a nonvolatile memory, the first microcontroller100further includes a control unit150.

The control section150performs a write/erase control to the program memory130. Specifically, in the write operation, the control section150generates a voltage required for the write operation to the nonvolatile memory and performs the write control in accordance with a write address and data to be written. Also, the control section150generates a voltage required for an erasing operation to the nonvolatile memory and performs the erase operation. If a rewrite request is supplied to the first microcontroller100from a program writing device (not shown) in order to rewrite the content of the program memory130, the control section150controls an erasing operation to the program memory130and the ID storage section120before writing a new program. That is, the control section150erases or writes the program memory130in response to the rewrite request, and simultaneously initializes the ID held in the ID storage section120, e.g., writes zero in all addresses.

If the program memory130is a mask ROM, there is no possibility of a program change.

The input/output port140is a port for performing communication with an external device. The input/output port140is used for acquiring an encrypted random number generated by another microcontroller and for outputting the comparison result from the comparing program134. If a random number used for encryption is not generated in the microcontroller100internally, the input/output port140is used to acquire the random number from the external device.

As shown inFIG. 2, an authentication system using the microcontroller of the present invention has a first microcontroller100and a second microcontroller200. The first microcontroller100is connected to the second microcontroller200by a communication line.

In the first embodiment of the present invention, it is considered that the first microcontroller100is a main body (authenticating side) and the second microcontroller200is an accessory (authenticated side), as shown inFIG. 2. Both the first microcontroller100and the second microcontroller200have the same configuration and function as those of the microcontroller shown inFIG. 1. In order to identify the configuration between the first microcontroller100and the second microcontroller200, the second microcontroller200is composed of a CPU210, an ID storage section220, a program memory230and an input/output port240. That is, in the second microcontroller200, the CPU110, the ID storage section120, the program memory130and the input/output port140inFIG. 1are read as the CPU210, the ID storage section220, the program memory230and the input/output port240, respectively.

The CPU210controls each of sections in the microcontroller. Because the second microcontroller200acquires the random number from the first microcontroller100, the CPU210does not generate a random number.

The ID storage section220stores inherent identification data (ID) determined for each customer. This identification data is same as identification data stored in the ID storage section120in the first microcontroller100. That is, the ID storage section120and the ID storage section220store the same identification data.

In the program memory230, user programs are written. The programs include an encryption key A supplying program231, an encryption key B generating program232, an encrypting program233and a comparing program234. The encryption key A supplying program231, the encryption key B generating program232and the encrypting program233are same as the encryption key A supplying program131, the encryption key B generating program132and the encrypting program133inFIG. 1, respectively. However, for a practical use, the encryption key A supplying program231, the encryption key B generating program232, the encrypting program233and the comparing program234may be achieved by hardware circuits.

Although the comparing program234may be same as the comparing program134inFIG. 1, the comparing program234transmits a random number encrypted by the encrypting program233(a second encrypted random number) to the first microcontroller100, if respective random numbers are compared on the main body side (authenticating side). If the first microcontroller100can acquire the encrypted random number from the second microcontroller200through acquisition of the second encrypted random number by using the comparing program134or through transmission of the second encrypted random number by using the encrypting program233, the comparing program234may be omitted.

If the program memory230is a nonvolatile memory, the second microcontroller200further includes a control unit250. The control unit250is same as the control section150inFIG. 1.

The input/output port240is a port for performing communication with an external device. The input/output port240is used to acquire the random number from the first microcontroller100and transmit the second encrypted random number to the first microcontroller100.

Although the first microcontroller100is the main body (authenticating side) and the second microcontroller200is the accessory (authenticated side) in the first embodiment of the present invention shown inFIG. 2, the accessory may be the authenticating side and the main body may be the authenticated side for a practical use. This is the authentication system according to the second embodiment of the present invention.

In the third embodiment of the present invention, it is also possible to perform authentication by both the main body and the accessory. The authentication performed in both the main body and the accessory allows a further firm security to be secured. In this case, the first microcontroller100and the second microcontroller200perform the same operation. That is, the CPU210in the second microcontroller200generates the random number. At this time, the CPU210generates the random number by executing a random number generating program (not shown) stored in the program memory230. However, the random number may be generated by a random number generating function of the CPU itself and a hardware function such as a random number generating circuit (not shown). The random number may be obtained by any methods. For example, it is possible to acquire the random number from an external random number generating device (not shown) in both the first microcontroller100and the second microcontroller200. In this case, the first microcontroller100and the second microcontroller200have a plurality of input/output ports not only for communication with each other but also for communication with the external random number generating device.

Moreover, the second microcontroller200acquires an encrypted random number from the first microcontroller100(the first encrypted random number) and compares the random number decrypted from the encrypted random number with the random number generated in the second microcontroller200by the comparing program234.

Next, referring toFIG. 3, an operation of the authentication system according to the present invention will be described below. As an example, it is assumed that the first microcontroller100is the main body (authenticating side) and the second microcontroller200is the accessory (authenticated side) here.

The CPU110reads an identification data (ID) from the ID storage section120.

The CPU110reads the encryption key A from the encryption key A supplying program131in the program memory130.

The CPU110generates the encryption key B based on the encryption key A and the ID by using the encryption key B generating program132.

The CPU210reads an identification data (ID) from the ID storage section220.

The CPU210reads the encryption key A from the encryption key A supplying program231in the program memory230.

The CPU210generates the encryption key B based on the encryption key A and the ID by using the encryption key B generating program232.

The CPU110generates a random number to output (notify) the accessory (the second microcontroller200).

The CPU110encrypts the random number with the encryption key B by using the encrypting program133to generate a first encrypted random number.

The CPU210encrypts the random number received from the main body (the first microcontroller100) with the encryption key B by using the encrypting program233to generate a second encrypted random number, and then transmits the second encrypted random number to the main body (the first microcontroller100).

The CPU110compares the first encrypted random number with the second encrypted random number by using the comparing program134to output the comparison result.

The timing to start the above operation (operation starting trigger) is a time of starting the main body and the accessory (a time of power on/off), a time of connecting the accessory to the main body, a time of receiving a request signal from an external device, or periodically. The accessory may start the operation after receiving the random number from the main body. Also, in both the main body and the accessory, the operations to the generation of the encryption key B may be performed when the identification data (ID) and the program are set previously. However, a practical use is not limited to the above examples.

Next, two examples of the first embodiment and the second embodiment will be described below.

Referring toFIG. 4, the authentication system in the first embodiment of a printer (main body) and an ink cartridge (accessory) will be described.

A power supply is turned on in the printer main body.

The microcontroller on the main body side reads the identification data (ID) on the main body side.

The microcontroller on the main body side reads the encryption key A on the main body side.

The microcontroller on the main body side generates the encryption key B based on the encryption key A and the identification data (ID).

Thereafter, the microcontroller on the main body side recognizes the cartridge to be mounted on the main body and supplies the power to the cartridge.

When the power supplied is turned on, the microcontroller on the cartridge side reads the identification data (ID) on the cartridge side.

The microcontroller on the cartridge side reads the encryption key A on the cartridge side.

The microcontroller on the cartridge side generates the encryption key B based on the encryption. key A and the identification data (ID), and then transmits a notice of generation of the encryption key B to the main body.

In response to the notice of generation of the encryption key B, the microcontroller on the main body side generates a random number and transmits it to the cartridge.

The microcontroller on the cartridge side encrypts the random number received from the main body based on the encryption key B to generate the second encrypted random number, and transmits the second encrypted random number to the main body.

The microcontroller on the main body side encrypts the random number based on the encryption key B to obtain the first encrypted random number.

The microcontroller on the main body side compares the first encrypted random number with the second encrypted random number.

If the result indicates coincidence, the main body starts operating as a printer.

If the result does not indicate coincidence, the main body suspends to operate as the printer.

Next, referring toFIG. 5, the operation of the authentication system in the second embodiment will be described in case of a portable terminal (main body) and a battery (accessory).

A battery cell is connected to or mounted in a battery pack.

The microcontroller on the battery side reads the identification data (ID) on the battery side.

The microcontroller on the battery side reads the encryption key A on the battery side.

The microcontroller on the battery side generates the encryption key B based on the encryption key A and the identification data (ID).

Thereafter, the battery pack is mounted on the main body side so that the battery cell provides power to the main body.

When the power supply is turned on, the microcontroller on the main body side reads the identification data (ID) on the main body side.

The microcontroller on the main body side reads the encryption key A on the main body side.

The microcontroller on the main body side generates the encryption key B based on the encryption key A and the identification data (ID).

The microcontroller on the main body further generates the random number and transmits it to the battery pack.

The microcontroller on the battery side encrypts the random number received from the main body by using the encryption key B to generate the second encrypted random number, and transmits the second encrypted random number to the main body.

The main body encrypts the random number by using the encryption key B to obtain the first encrypted random number.

The main body compares the first encrypted random number with the second encrypted random number.

If the result indicates coincidence, the main body starts operating as the portable equipment.

If the result does not indicate coincidence, the main body suspends to operate as the portable equipment.

Here, a case that program of the microcontroller is illegally acquired will be described. In this case, the ID written into the ID storage section of the main body is inherent in a customer.

When an authorized program has been written in the microcontroller in the accessory side (a customer limited product), that is, in case of normal usage, the main body and the accessory are supposed to use the same encryption key B prepared on the basis of the first encryption key A and the ID, and the same random number, thereby the encrypted random number will remain the same.

However, if an illegally acquired program is copied into a program memory of the microcontroller for an ordinary customer other than a specific customer without any processing, the ID of the microcontroller mounted on the counterfeit product is initialized, e.g., is all set to zeros which is different from the customer inherent ID. Thus, the encryption key B is different. As a result, random numbers encrypted in the main body and the accessory are different from each other. Thus, it makes it possible to confirm that the accessory connected to the main body is a counterfeit product.

If the program memory of the microcontroller is a nonvolatile memory, a means for acquiring the ID with malicious intent by writing and executing a simple program for reading and outputting the ID is considered. However, because an erasing operation and a writing operation to the nonvolatile memory are carried when a data or a program is written in the nonvolatile memory, the data held in the ID storage section can be initialized, which prevents the usage of the above means.

As described above, the microcontroller according to the present invention includes the CPU for generating the random number by executing a random number generating program or a hardware function, the ID storage section for storing inherent identification data, and the first program memory for storing the first encryption key and generating the second encryption key on the basis of the identification data and the first encryption key so as to store the program for encrypting the random number based on the second encryption key.

In the authentication system using the microcontroller of the present invention, the first microcontroller of the main body (authenticating side) and the second microcontroller of the accessory (authenticating side) are used. The first microcontroller is connected to the second microcontroller by a communication line.

The first microcontroller includes the program memory, the ID storage section and the CPU. The second microcontroller includes the program memory and the ID storage section. If a nonvolatile memory is used for the ID storage sections in the respective microcontrollers, the control unit is further provided.

User programs have been written into the program memory. More specifically, the programs include the encryption key A supplying program, the encryption key B generating program, the encrypting program and the comparing program (exclusive to the authenticating side). The program memory is classified into a case of a mask ROM and a case of a nonvolatile memory. The ID storage section has an ID storage section. For a specific customer, an ID inherent to a target customer is written to be shipped. In the ID storage section in a product shipped to an ordinary customer, an initial value, e.g., of all zeros is written. The ID storage section is readable but unrewritable from the user memory program. The ID storage section is a nonvolatile memory if the program memory is a nonvolatile memory with programs rewritable. The encryption key B generating program generates the encryption key B on the basis of the encryption key A and the ID. The CPU generates the random number. The encrypting program encrypts the random number based on the encryption key B. The comparing program compares the encrypted random number produced in the main body with the encrypted random number supplied from the accessory, and outputs the comparison result. The control unit is provided to be a component (exists) if the program memory is a nonvolatile memory. The control unit erases/writes the program memory in response to a write request. The ID held in the encryption key A supplying program is simultaneously initialized to, for example, all zeros.

The flow of the authentication process in the present invention is as described below.

Both the main body and the accessory initially generate the encryption key B by using the encryption key A and the ID. The main body generates the random number to output to the accessory. The main body encrypts the random number based on the encryption key B to obtain the first encrypted random number. The accessory encrypts the random number received from the main body based on the encryption key B, and generates the second encrypted random number to transmit to the main body. The main body compares the first encrypted random number with the second encrypted random number to output the comparison result.

When a program of a microcontroller is illegally acquired, a normal operation can be prevented even if a counterfeit product is used in which the illegally acquired program is written into a program memory. Therefore, it is possible to eliminate counterfeiting accessories by simply copying a program memory.