The present invention relates to a security circuit which protects data that is written in a read only memory (ROM) internal to a microcomputer, and which is used in single-chip microcomputers.
The problem of security of data written to ROM that are internal to single-chip microcomputers has been under investigation for a long time and methods such as prohibiting the reading of data in ROM have been thought of. In the conventional technology, a writing by the user of "0" or "1" in an electrically programmable ROM (EPROM) that stores the (1 bit) security code performs a security operation to operate a security circuit and prohibit the reading of data (programs) inside a ROM.
In this conventional technology, once the security circuit has operated, it is not possible for the data that are stored in the ROM to be read by the user for the purpose of maintenance and management.
Summary of the Invention
In the light of this problem, the present invention has as an object the provision of a security circuit that enables the user who applied the security, to read data such as programs and the like that are stored in the memory, and that disables reading by other users.
The present invention is a security circuit for the protection of data that is stored in a memory internal to a microcomputer. The security circuit is provided with a first memory to store and input a security code, a latch circuit to latch a key code that is input in order to read the data that is stored in the internal memory, and a comparator circuit to compare whether or not the security code that is stored in the first memory and the key code that is latched by the latch circuit are in agreement. The security circuit according to the invention also has a second memory to store the comparison results compared by the comparator circuit, and a read control circuit that uses the results of comparison stored in the second memory as the basis to prohibit the reading of data stored in the internal memory when the security code and the key code are not in agreement and that uses an externally input output control signal when there is agreement as the basis for controlling the reading of data that is stored in the internal memory.
According to a security circuit of the present invention having the configuration described above, inputting a security code causes that security code to be stored in a non-volatile first memory, for example. Then, the key code to read the data that is stored in the internal memory is input and this key code is latched by the latch circuit. Also, this latched key code is compared in a comparator circuit with a security code which is stored in a non-volatile first memory. The results of this comparison are stored in a non-volatile second memory.
Then, the results of the comparison which are stored in the second memory, are used as the basis to prohibit the reading of data stored in the internal memory when the security code and the key code are not in agreement, and when there is agreement an externally applied output control signal is used as the basis to control the reading of data that are stored in the internal memory. In this way, for as long as the correct key code is not inputted, it is not possible to read that data from the internal memory, and it is possible for the user who has applied the key code to read that data of the program and the like that are stored in the internal memory, but it is not possible for this to be read by other users .
Brief Description of the Drawings
In the appended drawings,
FIG. 1 is a block diagram showing the configuration of a security circuit according to an embodiment of the present invention; and
FIG. 2 is a flow chart for describing the operation of the security circuit shown in FIG. 1.
Detailed Description of the Preferred Embodiments
FIG. 1 is a block diagram showing the configuration of a security circuit according to an embodiment of the present invention. The security circuit of this embodiment is provided with a first memory 2, a latch circuit 4, a comparator circuit 6, an AND circuit 7, a flip-flop 8, a NOT circuit 9, a NAND circuit 10, a second memory 12 and a read control circuit 20. The data that are stored in an internal memory such as an EPROM (not indicated in the figure) that is internal to the microcomputer or the like, is protected. The first memory 2 is for example, a non-volatile memory comprising an EPROM and stores the security code that is inputted from external. The latch circuit 4 latches the key code that is input, in order to read the data that are stored in the memory internal to the microcomputer or the like. The comparator circuit 6 compares the key code that is latched to the latch circuit 4, with the security code that is stored in the first memory 2. The second memory 12 is a non-volatile memory comparing a 1-bit EPROM for example, and stores the comparison results that were compared by the comparator circuit 6. The read control circuit 20 has an AND circuit 21, an OR circuit 22, a NOT circuit 23 and an AND circuit 24, and controls the reading of data that is stored in the memory (EPROM) internal to the microcomputer not indicated in the figure. Numeral 15 shows a NOT circuit that supplies to a reset terminal R of the flip-flop 8 a reset signal RESEThaving a negative level, and numeral 30 indicates an address decoder for decoding coded address data.
The following is a description of the configuration and operation of the present embodiment, with reference to FIG. 1 and FIG. 2.
First, when security has not been applied, that is, when the security code has been inputted, the step ST1 in FIG. 2 becomes NO, and the signal S.sub.3 that is sent from the first memory 2 to the OR circuit 22 of the read control circuit 20 becomes the "1" status (refer to step ST2). At this time, the signal S.sub.13 (shown in FIG. 1) that controls the reading of the data stored in the internal memory (EPROM) not indicated in the figure, is output in accordance with the externally applied output control signal OE (step ST3 and step ST4). More specifically, when the signal OE is "1", the output of the NOT circuit 23 becomes "0" and accordingly, the signal S.sub.13 that is the output of the AND circuit 23 becomes "0" and reading of data from the internal memory (EPROM) not indicated in the figure is performed. Also, when the signal OE is "0", the output of the NOT circuit 23 becomes "1" and so the read enable signal which is the output of the AND circuit 24 becomes "1" (step ST6) and it is possible to read the data from the memory not indicated in the figure (step ST7).
The following is a description of the case when security is applied i.e., when a security code has been entered. When the security code and the address of the memory 2 are input (YES for step ST1), the signal S.sub.1 sent from the address decoder 30 to the first memory 2 becomes "0" and the first memory 2 enters the status where data writing is possible. The security code is sent to the first memory 2 via the data bus and stored. When this occurs, the signal S.sub.3 sent from the memory 2 to the OR circuit 22 of the read control circuit 20 becomes "0" (step ST8).
After the security code has been input in this manner, and the data that are stored in the memory (not indicated in the figure) internal to the microcomputer or the like are to be read, it is necessary to input the security code and the address of the latch circuit 4. Accordingly, this is judged in step ST9. When the key code and the address of the latch circuit 4 are input, the signal S.sub.2 is sent from the address decoder 30 to the first memory 2, the latch circuit 4, and the flip-flop 8. The first memory 2 enters the read mode, the flip-flop 8 enters the set status and the key code is latched to the latch circuit 4 (step ST10).
Then, the security code that is stored in the memory 2 and the key code that is latched to the latch circuit 4 are compared in the comparator circuit 6 (step ST11) and if they are in agreement, the signal S.sub.4 that is sent from the comparator circuit 6 to the AND circuit 7 becomes "1" (step ST12) and "0" (step ST20) if they are not in agreement. The signal S.sub.5 that is sent on the external write voltage line to the AND circuit 7 becomes "1" when the write voltage V.sub.pp is impressed (step ST14 ) and becomes "0" when the write voltage V.sub.pp is not impressed (step ST19). Accordingly, in step ST13, the write voltage V.sub.pp is determined as to whether or not it is impressed.
The following will consider the case when the signal S.sub.5 is "1" and the security code and the key code are in agreement, that is, the case for when the signal S.sub.4 is "1". When this occurs, the output signal S.sub.6 of the AND circuit 7 becomes "1" (step ST15) and the output signal S.sub.7 of the NOT circuit 9 becomes "0". By this, the output signal S.sub.9 of the NAND circuit 10 becomes "1" and writing to the second memory 12 is performed. Moreover, the output signal S.sub.8 of the flip-flop 8 is in the set status and is therefore "1". The signal S.sub.10 sent from the memory 12 to the AND circuit 21 of the read control circuit 20 is "1" and so the signal S.sub.11 sent from the AND circuit 21 to the OR circuit 22 becomes "1". Accordingly, the read enable signal S.sub.13 which is the output of the read control circuit 20 is in accordance with the output control signal OE that is externally applied. Judging step ST16 is the same as step ST13, so that the external input signal OE is judged whether or not it is in the read. Namely, when the signal OE is not "1", the signal S.sub.13 becomes "1" (step ST6), and it is possible to read the data that stored in the memory (EPROM) not indicated in the figure (step ST7). Moreover, when step ST16is determined to be YES the signal S.sub.13 becomes "0" (step ST7), and it is impossible to read the data after this.
On the other hand, when there is not agreement between the key code and the security code when the two are compared by the comparator circuit 6 (NO for step ST11), the signal S.sub.4 becomes "0", (step ST20), an output signal S.sub.6 of the AND circuit 7 becomes "0" (step ST21). Then, an output signal S.sub.7 of the NOT circuit 9 becomes "1". Also, since the signal S.sub.8 becomes "1", an output signal S.sub.9 of the NAND circuit 10 becomes "0" and is written to the second memory 12. When there is a write to the memory 12, the signal S.sub.10 becomes "0" and so the output signal S.sub.11 of the AND circuit 21 becomes "0". Also, the security code is stored in the first memory 2 and so the signal S.sub.3 also becomes "0" and so the output signal S.sub.12 of the OR circuit 22 also becomes "0". Accordingly, the read enable signal S.sub.13 that is the output of the read control circuit 20 is always "0" and reading of the data that is stored in the memory (EPROM) internal to the microcomputer or the like is not possible for as long as the data in the memory 12 is not erased (step ST18). Moreover, if the data in the memory 12 is erased, then the memory for which reading was prohibited, that is, the data in the memory internal the microcomputer or the like is also erased at the same time and security is ensured.
As has been described above, according to the present embodiment, it is possible for the user who has applied security to read the data that is stored in the memory but it is not possible for this data to be read by other users. Normal reading is also not possible when an erroneous security code has been input.
Accordingly, with the present invention, it is possible for the user who has applied security to read the data that is stored in the memory but it is not possible for this data to be read by other users. Also, normal reading is not possible after an erroneous security code has been input.