Abstract:
An encryption/decryption method and devices for protecting data in a memory device from unauthorized access is provided. First, obtaining a specific code from a memory device and then encrypting the specific code and original data for obtaining encrypted data during a write cycle. Finally, writing the encrypted data to the memory device according to an access address. The access address can be also encrypted to generate the encrypted data. The encryption level increases by this way so that the valuable information is under protection.

Description:
BACKGROUND  
       [0001]     The disclosure relates to encryption/decryption methods, and more particularly to encryption/decryption methods for a memory device.  
         [0002]     For optimizing peripheral add-on cards, control chips of such cards typically require that dedicated drivers or applications run properly under operating systems of host computers. It is also noted that recently integrated circuit (IC) design has a tendency towards multi-function and System-On-Chip (SOC) implementation to fulfill various client requirements.  
         [0003]     Accordingly, the control chips of peripheral add-on cards are generally provided with a non-volatile memory interface to access customized code and information in a non-volatile memory under control of the dedicated drivers or applications. As a result, peripheral add-on card vendors may differentiate their products for a variety of target markets by different programming and definition.  
         [0004]     Nevertheless, traditional ways lack a secure mechanism to read/write non-volatile memories. Because there is no encryption mechanism, critical data and codes in the non-volatile memory are vulnerable to reverse engineering and illegal copy. If unauthorized access to such valuable information has occurred, data stored in the peripheral add-on card is easily available to unauthorized users.  
       SUMMARY  
       [0005]     Encryption/decryption methods and devices for a memory device are provided. An embodiment of an encryption/decryption method comprises obtaining a specific code from a memory device, encrypting the specific code and first data for obtaining encrypted data during a write cycle, and writing the encrypted data to the memory device according to an access address, wherein the memory device comprises the specific code and the encrypted data.  
         [0006]     An embodiment of an encryption/decryption device comprises a memory device comprising a specific code, and a processor coupled to the memory device. The processor encrypts the specific code and first data for obtaining encrypted data and storing the encrypted data to the memory device according to an access address during a write cycle. 
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0007]     The invention can be more fully understood by reading the subsequent detailed description and examples with reference made to the accompanying drawings, wherein:  
         [0008]      FIG. 1  is a flowchart of an encryption method according to an embodiment of the invention;  
         [0009]      FIG. 2  is a flowchart of a decryption method according to an embodiment of the invention;  
         [0010]      FIG. 3  shows an encryption circuit according to an embodiment of the invention; and  
         [0011]      FIG. 4  shows a decryption circuit according to an embodiment of the invention. 
     
    
     DETAILED DESCRIPTION  
       [0012]      FIG. 1  is a flowchart of an encryption method according to an embodiment of the invention. First, to store data in a memory device during a write cycle, a specific code is obtained from the memory device in step  110 . Before the memory device leaves the factory, a manufacturer stores a specific code therein. The specific code can be a serial number of the memory device or the date of production. Memory devices from different manufacturers may have different specific code. Additionally, different memory devices manufactured at the same time also have different serial numbers. The bit length of the specific code can be any length, such as 32 bits, 64 bits, 128 bits, or 256 bits.  
         [0013]     To increase encryption level, the specific code is transformed into a first key value in step  120 . For example, a specific code of 256 bits is transformed into a first key value of 32 bits by a transformation program. The encryption level increases with difference between the specific code and the first key value bit counts.  
         [0014]     Next, original data, the first key value, and an access address are encrypted in step  130 . Embodiments of the invention can utilize any encryption to encrypt the original data, the first key value, and the access address for generating encrypted data. Since different memory devices have different specific code, their encrypted data is different. Thus, different encrypted data is generated for the same original data to be stored in the same address of different memory devices, so the encryption level increases.  
         [0015]     Since the access address and the original data are simultaneously encrypted, different encrypted data related to the same original data is generated by different access addresses after encryption. For example, as original data 00 is respectively stored to access addresses 0000H˜0005H, the original data 00 can be transformed to 00˜05 and stored in the access addresses 0000H˜0005H after the encryption, so the encryption level increases. In another embodiment, the invention can only encrypt the first key value and the original data such that the same encrypted data is generated when the same original data is encrypted.  
         [0016]     The encrypted data is stored in the memory device according to the access address in step  140 . Thus, the specific code and the encrypted data are stored in the memory device. Since the stored data in the memory device is encrypted, the security of the original data is increased.  
         [0017]      FIG. 2  is a flowchart of a decryption method according to an embodiment of the invention. In a read cycle, the encrypted data stored in the memory device is read according to the access address in step  210 . Since the encrypted data stored in the memory device has been encrypted, the encrypted data needs to decrypt to obtain the original data.  
         [0018]     Next, the encrypted data, a second key value, and an access address are decrypted in step  220 . Since the original data, the first key value, and the access address are encrypted in step  130 , the encrypted data, the second key value, and the access address are simultaneously decrypted to obtain the original data. In an embodiment, the first key value equals the second key value.  
         [0019]     A decryption utilized in the decryption method needs to match an encryption utilized in the encryption method, since data operations are complementary. For example, the decryption does not need to decrypt with the access address when the access address is not encrypted during the encryption.  
         [0020]     After the encrypted data stored in the memory device is decrypted, the original data can be obtained in step  230 .  
         [0021]      FIG. 3  shows an encryption circuit according to an embodiment of the invention. In a write cycle, a processor  34  encrypts an original data to obtain encrypted data stored in a memory device  32  to ensure security of the original data. The memory device  32  can be a flash read only memory (Flash ROM) or other ROM. The processor  34  comprises a transformation unit  342 , an operating unit  344 , and a controller  346 . The transformation unit  342  transforms a specific code D I  stored in the memory device  32  to a first key value KEY 1 . In an embodiment, the transformation unit  342  transforms the bit length from 256 bits into 32 bits.  
         [0022]     As difference in bit count between the specific code D I  and the first key value KEY 1  increases, encryption level does commensurately. The transformation unit  342  can be omitted.  
         [0023]     The controller  346  outputs an original data D S  and access address AD to the operating unit  344 . The processor  34 , to store data in the memory device  32 , directs the operating unit  344  to perform encryption. The method for encrypting operation according to the invention is not restricted. The first key value KEY 1 , the original data D S , and the access address AD are encrypted by the operating unit  344  to generate encrypted data D E . The operating unit  344  stores the encrypted data D E  in the memory device  32  according to the access address AD. Thus, the memory device  32  comprises the specific code D I  and the encrypted data D E .  
         [0024]     Additionally, to increase encryption level, the encryption performed by the operating unit  344  encrypts with the access address. In another embodiment, the encryption of access address can be omitted. As an example, encryption with the access address, as the same original-data is to be stored in the memory device  32  at different access addresses, the different encrypted data will be generated after encryption.  
         [0025]      FIG. 4  shows a decryption circuit according to an embodiment of the invention. The circuit in  FIG. 4  is similar to the circuit in  FIG. 3 . The operating unit  344  in  FIG. 4  performs decryption to read the encrypted data stored in the memory device  32  in a read cycle.  
         [0026]     The transformation unit  342  transforms the specific code D I  stored in the memory device  32  to a second key value KEY 2  that equals the first key value KEY 1 . The operating unit  344  reads the encrypted data D E  from the memory device  32  according to the access address AD provided from the controller  346 . The encryption encrypted with the access address AD shown in  FIG. 3 , so the second key value KEY 2 , the access address AD, and encrypted data D E  are decrypted by the operating unit  344  to obtain the original data D S . The controller  346  performs other operations according to the original data D S .  
         [0027]     Advantages of embodiments according to the invention are summarized in the following. Data stored in the memory device is encrypted, so it prevents unauthorized access. If different key values with the same original data are encrypted, the encrypted data is different, such that memory devices with different specific code store different encrypted data. Since the encryption according to the embodiment of the invention encrypts with the access address, when the same original data is stored in different access addresses, the encrypted data stored in different access addresses are different for increased encryption level.  
         [0028]     While the invention has been described by way of example and in terms of preferred embodiment, it is to be understood that the invention is not limited thereto. To the contrary, it is intended to cover various modifications and similar arrangements (as would be apparent to those skilled in the art). Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements.